/* ============================================================
   AMEFAR · Egipto 2026 — base.css  (Core lane · FINAL.md §4 typography, §5.4 utilities, §11 net)
   Mobile-first. Only tokens from tokens.css.
   ============================================================ */

/* ---- Document ---- */
html {
  background: var(--c-night);
  color: var(--c-cream);
  font-family: var(--ff-body);
  font-size: 100%;
  line-height: var(--lh-body);
  scroll-behavior: auto;                 /* Lenis / ctx.scrollTo drive the scroll when JS is alive */
  /* no overflow on html: it must stay `visible` so body's overflow propagates to the viewport
     (body.is-loading / menu-open locks). The horizontal clip lives on body only. */
}
html.no-js { scroll-behavior: smooth; }  /* resilience: native smooth hash links without the runtime */
body {
  min-height: 100svh;
  background: var(--c-night);            /* a transparent body must never borrow the host's ground */
  color: var(--c-cream);
  font-size: var(--fs-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
body.is-loading, html:has(body.is-loading) { overflow: hidden; }   /* while the preloader is up (§7.2): lock the viewport, keyboard included */
html.menu-open, html.menu-open body { overflow: hidden; }

main, footer { position: relative; z-index: var(--z-main); }

::selection { background: var(--c-gold); color: var(--c-navy); }

/* ---- Sections ---- */
.section { position: relative; }
/* Pre-entrance GSAP transforms (rotated/shifted sheets) must not widen the scrollable overflow on load:
   clip is not a scroll container, so sticky children and the vertical .torn edges are unaffected. */
.section:not(.hero) { overflow-x: clip; }
.section:focus { outline: none; }        /* programmatic focus after ctx.scrollTo (tabindex=-1) */
.onsky { background: transparent; }
.paper {
  position: relative;
  isolation: isolate;
  background: var(--c-cream);
  color: var(--c-navy);
}
.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("../assets/egipto/art/papyrus-900.webp") center / 900px auto repeat;
  mix-blend-mode: multiply;
  opacity: .35;
  pointer-events: none;
}
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Typography ---- */
h1, h2, h3, h4, .display {
  font-family: var(--ff-display);
  font-optical-sizing: auto;
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: 0;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); font-weight: 900; letter-spacing: -.02em; line-height: var(--lh-display); }
h2 { font-size: var(--fs-h1); }
h3 { font-size: var(--fs-h3); font-weight: 500; }
h4 { font-size: var(--fs-lead); font-weight: 700; }
.display { font-size: var(--fs-display); font-weight: 900; letter-spacing: -.02em; line-height: var(--lh-tight); }
.italic, .tagline, blockquote { font-family: var(--ff-display); font-style: italic; font-weight: 400; }
p { max-width: var(--measure); text-wrap: pretty; }
.lead { font-size: var(--fs-lead); line-height: 1.5; }
.small { font-size: var(--fs-small); }
.num, time, .count, .tabular { font-variant-numeric: tabular-nums; }
a { text-decoration-thickness: 1px; text-underline-offset: .18em; }
.paper a, .sheet a, .plaque a { color: var(--c-terracotta-text); }
.paper, .sheet, .plaque { color: var(--c-navy); }
.muted { color: var(--c-paper-soft); }
.paper .muted, .sheet .muted { color: var(--c-ink-soft); }

/* ---- Utilities ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: calc(var(--z-pre) + 1);
  padding: var(--sp-3) var(--sp-5);
  background: var(--c-cream);
  color: var(--c-navy);
  font: 600 var(--fs-small) / 1 var(--ff-body);
  letter-spacing: var(--track-nav);
  text-transform: uppercase;
  text-decoration: none;
  border-radius: var(--r-sm);
  transform: translateY(-200%);
  transition: transform var(--t-ui) var(--ease-out);
}
.skip:focus-visible { transform: translateY(0); outline: 2px solid var(--c-gold); outline-offset: 4px; }

/* hidden only between first paint and main.js finishing section init */
html.js:not(.js-ready) .will-reveal { opacity: 0; }

/* split text (fx.splitLines) */
.split { position: relative; }
.split .l { display: block; overflow: hidden; padding-bottom: .1em; margin-bottom: -.1em; }
.split .li { display: inline-block; will-change: transform; }
.split--words .l, .split--chars .l { display: inline-block; vertical-align: bottom; }
.split--chars .l { padding: 0; margin: 0; }
.split .w { display: inline-block; white-space: nowrap; }
html.no-js .split .li, html.reduce .split .li { will-change: auto; }

/* ---- Focus ---- */
:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 4px; }
.paper :focus-visible, .sheet :focus-visible, .plaque :focus-visible, .dialog :focus-visible { outline-color: var(--c-terracotta-deep); }
:focus:not(:focus-visible) { outline: none; }

/* ---- Icons ---- */
.ico {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -.25em;
}
.symbols { display: none; }

/* ---- Reduced motion safety net (§11) — the only !important in the project, mandated by the spec ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
html.reduce *, html.reduce *::before, html.reduce *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}
