/* ============================================================================
   NOCTURNE — BASE
   Reset · typography · layout primitives · accessibility · global texture
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 300;
  line-height: 1.7;
  letter-spacing: 0.01em;
  overflow-x: clip;
  min-height: 100svh;
  transition: background-color var(--t-base) var(--ease-soft),
              color var(--t-base) var(--ease-soft);
}

body.is-locked { overflow: hidden; }

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

img { height: auto; }

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

ul[role="list"],
ol[role="list"] { list-style: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* — Custom scrollbar (cosmetic, never the only signifier) ——————————————— */
@media (pointer: fine) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-deep) transparent;
  }
  ::-webkit-scrollbar { width: 9px; height: 9px; }
  ::-webkit-scrollbar-track { background: var(--bg-sunken); }
  ::-webkit-scrollbar-thumb {
    background: var(--accent-deep);
    border-radius: var(--r-pill);
    border: 2px solid var(--bg-sunken);
  }
}

/* ————————————————————————————————————————————————————————————————————————
   TYPOGRAPHY
   ———————————————————————————————————————————————————————————————————————— */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.display {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-family: var(--font-label);
  font-size: var(--fs-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.42em;
  color: var(--accent);
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}

.eyebrow--line::before {
  content: "";
  inline-size: clamp(1.5rem, 4vw, 3.5rem);
  block-size: 1px;
  background: currentColor;
  opacity: 0.6;
}

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--text-soft);
  font-weight: 300;
  letter-spacing: 0;
}

p { text-wrap: pretty; }

.serif-italic { font-family: var(--font-serif); font-style: italic; }

em, .em { font-family: var(--font-serif); font-style: italic; }

strong { font-weight: 500; color: var(--text); }

.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }

/* RTL Arabic typography tuning */
[lang="ar"] body,
[dir="rtl"] {
  letter-spacing: 0;
}
[dir="rtl"] .eyebrow { letter-spacing: 0.2em; }
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] .display { letter-spacing: 0; line-height: 1.18; }
[dir="rtl"] .display { line-height: 1.2; }

/* ————————————————————————————————————————————————————————————————————————
   LAYOUT PRIMITIVES
   ———————————————————————————————————————————————————————————————————————— */
.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.shell--narrow { max-width: 1200px; }

.section { position: relative; padding-block: var(--section-y); }
.section[id], [data-anchor] { scroll-margin-top: clamp(72px, 10vw, 112px); }
.section--flush { padding-block: 0; }
.section--top { padding-block: var(--section-y) 0; }

.measure { max-width: var(--maxw-text); }

.stack > * + * { margin-block-start: var(--flow, 1.5rem); }

.grid { display: grid; gap: var(--gutter); }

.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
}

.divider {
  inline-size: 100%;
  block-size: 1px;
  background: var(--line);
  border: 0;
}

.divider--gold {
  background: linear-gradient(90deg, transparent, var(--line-gold), transparent);
}

/* ————————————————————————————————————————————————————————————————————————
   ACCESSIBILITY
   ———————————————————————————————————————————————————————————————————————— */
.visually-hidden {
  position: absolute !important;
  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: var(--sp-3);
  left: 50%;
  transform: translate(-50%, -160%);
  z-index: var(--z-preloader);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-label);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.75rem;
  border-radius: var(--r-pill);
  transition: transform var(--t-fast) var(--ease-out);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* ————————————————————————————————————————————————————————————————————————
   GLOBAL TEXTURE — film grain + ambient warmth (purely decorative)
   ———————————————————————————————————————————————————————————————————————— */
.grain {
  position: fixed;
  inset: -50%;
  z-index: var(--z-nav);
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  will-change: transform;
  animation: grain-shift 6s steps(5) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -5%); }
  60% { transform: translate(-2%, 4%); }
  80% { transform: translate(4%, 2%); }
  100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
}

/* — Scroll progress meter ————————————————————————————————————————————— */
.progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  block-size: 2px;
  inline-size: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--accent-deep), var(--accent-bright));
  z-index: var(--z-nav);
  pointer-events: none;
}
[dir="rtl"] .progress { transform-origin: 100% 50%; }

/* — Utility ————————————————————————————————————————————————————————————— */
.no-scroll { overflow: hidden; }
.relative { position: relative; }
.center { text-align: center; }
.mx-auto { margin-inline: auto; }
.full-bleed { width: 100vw; margin-inline: calc(50% - 50vw); }
