/* ==========================================================================
   Base Reset, Architectural Patterns, Typography & Motion Primitives
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background-color: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

section[id],
.proj-section[id],
header[id] {
  scroll-margin-top: 88px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--canvas);
  color: var(--ink);
  line-height: 1.65;
  overflow-x: clip;
  max-width: 100%;
  min-height: 100vh;
  transition: background-color 260ms var(--ease-out), color 260ms var(--ease-out);
  /* Subtle architectural dot-grid pattern (Taraznama-inspired) */
  background-image: radial-gradient(var(--pattern-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}

html[dir="rtl"] body {
  line-height: 1.85;
  letter-spacing: 0;
}

/* Scroll Progress Hairline */
.scroll-progress {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 2.5px;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-sky) 100%);
  z-index: 200;
  pointer-events: none;
}

html[dir="rtl"] .scroll-progress {
  transform-origin: right center;
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  inset-inline-start: 16px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--text-sm);
  transition: top var(--dur-btn) var(--ease-out);
}

.skip-link:focus {
  top: 16px;
}

/* Containers */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* Section Rhythm & Organic Tonal Surface Separation (No Harsh Dividers!) */
.section {
  padding-block: var(--section-py);
  position: relative;
}

.section--bordered {
  border-top: none;
}

.section--surface-band {
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--surface-band) 8%,
    var(--surface-band) 92%,
    transparent 100%
  );
}

.section--ambient-band {
  background: radial-gradient(
      ellipse 72% 48% at 50% 0%,
      var(--primary-soft) 0%,
      transparent 72%
    ),
    linear-gradient(
      180deg,
      transparent 0%,
      var(--surface-band) 14%,
      var(--surface-band) 86%,
      transparent 100%
    );
}

.section-header {
  max-width: 720px;
  margin-bottom: clamp(36px, 5vw, 56px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-text-on-soft);
  margin-bottom: 16px;
}

[data-theme="dark"] .eyebrow {
  color: var(--accent-sky);
}

html[dir="rtl"] .eyebrow {
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.875rem;
}

.eyebrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

[data-theme="dark"] .eyebrow__dot {
  background: var(--accent-sky);
  box-shadow: 0 0 0 4px var(--accent-sky-soft);
}

.section-title {
  font-size: var(--text-h2);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 16px;
}

html[dir="rtl"] .section-title {
  line-height: 1.32;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.section-desc {
  font-size: var(--text-lead);
  color: var(--ink-muted);
  line-height: 1.65;
}

html[dir="rtl"] .section-desc {
  line-height: 1.85;
}

/* Staggered Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--dur-reveal) var(--ease-out),
    transform var(--dur-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Hero Stagger Entrance */
.hero-stagger {
  opacity: 0;
  transform: translateY(16px);
  animation: heroEnter 640ms var(--ease-out) forwards;
  animation-delay: var(--stagger-delay, 0ms);
}

@keyframes heroEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth View Transition Circular Reveal for Light <-> Dark Theme */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 9999;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal,
  .hero-stagger {
    opacity: 1;
    transform: none;
  }
}
