/* ==========================================================================
   mubeena.tech · v5 scrollytelling prototype — shared tokens + components
   Used by index.html and ai-assurance.html. Mobile-first: base = small screen.
   ========================================================================== */

:root {
  /* white, black, wine — plus neutral surfaces so white things never merge with the page */
  --paper: #ffffff;          /* the page */
  --paper-2: #f2f2f1;        /* tinted bands + mats behind paper documents */
  --sheet: #f7f7f6;          /* card surface — always paired with --line + --shadow */
  --line: #d8d8d6;           /* visible container border */
  --ink: #0b0b0b;
  --body: #232323;
  --muted: #5e5e5e;          /* 6.4:1 on white, 5.7:1 on --paper-2 */
  --dim: #9d9d9d;            /* inactive (scroll-state) text */
  --hair: rgba(0, 0, 0, 0.12);
  --hair-2: rgba(0, 0, 0, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 20px 44px -30px rgba(0, 0, 0, 0.32);
  --wine: #7a2040;
  --wine-ink: #5e1831;
  --wine-wash: rgba(122, 32, 64, 0.08);

  /* status (muted, document-grade) */
  --ok: #3f7a55;
  --warn: #b07a2a;
  --bad: #a23b3b;

  /* night (desk finale, footer) */
  --night: #11151d;
  --night-2: #1a202b;
  --night-ink: #ece6db;
  --night-muted: #a39d93;

  /* type */
  --font: "Josefin Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* motion identity — one ease, one duration scale */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --d-fast: 0.45s;
  --d-base: 0.7s;
  --d-slow: 1.1s;

  /* layout */
  --gutter: clamp(20px, 5vw, 64px);
  --max: 1280px;
  --nav-h: 64px;
  --radius: 14px;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* body only — never html (kills sticky) */
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--wine); color: #fff; }

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

.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 {
  position: fixed; left: 12px; top: -60px; z-index: 3000;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase;
  transition: top var(--d-fast) var(--ease);
}
.skip:focus { top: 12px; }

/* ---------- primitives ---------- */

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.w { color: var(--wine); font-style: normal; }

.eyebrow {
  display: block;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: ""; display: inline-block; vertical-align: 0.3em; width: 26px; height: 1px; margin-right: 12px; background: var(--wine);
}

.display {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.02;
  font-size: clamp(34px, 8.4vw, 96px);
  overflow-wrap: break-word;
  color: var(--ink);
}
.h2 {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  line-height: 1.06;
  font-size: clamp(28px, 5.6vw, 58px);
  color: var(--ink);
}
.h3 {
  font-weight: 600;
  font-size: clamp(19px, 2.1vw, 23px);
  line-height: 1.25;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.lede {
  font-size: clamp(18px, 1.9vw, 22px);
  line-height: 1.55;
  font-weight: 300;
  color: var(--body);
  max-width: 40ch;
}
.meta {
  font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
}
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }

/* headline line masks (CSS-driven so above-the-fold never waits for JS) */
.line { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.line > span { display: block; }
.rise .line > span { animation: rise var(--d-slow) var(--ease) both; }
.rise .line:nth-child(2) > span { animation-delay: 0.08s; }
.rise .line:nth-child(3) > span { animation-delay: 0.16s; }
.rise .line:nth-child(4) > span { animation-delay: 0.24s; }
.fade-in { animation: fadeUp var(--d-slow) var(--ease) 0.35s both; }
.fade-in.d2 { animation-delay: 0.5s; }
.fade-in.d3 { animation-delay: 0.65s; }
@keyframes rise { from { transform: translateY(105%); } to { transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 14px 26px 12px;
  border-radius: 100px; border: 1.5px solid transparent;
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease),
    border-color var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--wine); }
.btn-outline { border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: #fff; }
.btn-light { background: var(--night-ink); color: var(--night); }
.btn-light:hover { background: #fff; color: var(--wine); }
.btn-ghost { color: var(--muted); padding-inline: 8px; }
.muted { color: var(--muted); font-weight: 400; }
.btn-ghost:hover { color: var(--wine); transform: none; }
.btn .arr { transition: transform var(--d-fast) var(--ease); }
.btn:hover .arr { transform: translateX(4px); }

.link {
  color: var(--ink); font-weight: 600;
  background: linear-gradient(var(--wine), var(--wine)) 0 100% / 0 1.5px no-repeat;
  transition: background-size var(--d-base) var(--ease), color var(--d-fast);
  padding-bottom: 2px;
}
.link:hover { background-size: 100% 1.5px; color: var(--wine); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 3px; border-radius: 100px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--paper-2); color: var(--body); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--hair-2);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-top: -2px; }
.pill.ok { color: var(--ok); background: rgba(63, 122, 85, 0.1); }
.pill.warn { color: var(--warn); background: rgba(176, 122, 42, 0.12); }
.pill.hot { color: var(--wine); background: var(--wine-wash); }

.rule { border: 0; border-top: 1px solid var(--hair); margin: 0; }

/* scroll-reveal initial state is set by JS only (no-JS / RM users see everything) */
.js [data-reveal] { will-change: transform, opacity; }

/* ---------- nav ---------- */

.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 900;
  height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex; align-items: center;
  transition: transform var(--d-base) var(--ease), background var(--d-base) var(--ease),
    border-color var(--d-base) var(--ease);
  border-bottom: 1px solid transparent;
}
.nav[data-scrolled="true"] {
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.nav[data-hidden="true"] { transform: translateY(-100%); }
.nav-in {
  width: 100%; max-width: none; margin: 0; padding-inline: var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.wordmark {
  font-weight: 600; font-size: 19px; letter-spacing: 0.02em; color: var(--ink);
  display: inline-flex; align-items: baseline;
}
.wordmark i { font-style: normal; color: var(--wine); }
.nav-links { display: none; align-items: center; gap: 28px; }
.nav-links a:not(.btn) {
  font-size: 11px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  transition: color var(--d-fast);
}
.nav-links a:not(.btn):hover { color: var(--ink); }
.nav .btn { min-height: 40px; padding: 10px 18px 8px; font-size: 11px; }
.nav-cta-sm { display: inline-flex; }

/* chapter progress (mobile: thin bar + label under nav) */
.progress {
  position: fixed; left: 0; right: 0; top: calc(var(--nav-h) + env(safe-area-inset-top, 0px)); z-index: 890;
  height: 2px; background: transparent; pointer-events: none;
  transition: transform var(--d-base) var(--ease);
}
.progress span { display: block; height: 100%; background: var(--wine); transform-origin: 0 50%; transform: scaleX(0); }
.nav[data-hidden="true"] ~ .progress { transform: translateY(calc(-1 * var(--nav-h))); }

/* phase rail (desktop) */
.rail { display: none; }

@media (min-width: 900px) {
  .nav-links { display: flex; }
  .nav-cta-sm { display: none; }
}

@media (min-width: 1180px) {
  .rail {
    display: block; position: fixed; right: 14px; top: 50%; z-index: 880;
    transform: translateY(-50%);
  }
  .rail ol { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; border-radius: 14px; transition: background var(--d-base) var(--ease), box-shadow var(--d-base); }
  .rail a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
    width: 40px; padding: 7px 0 6px; border-radius: 9px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: rgba(0, 0, 0, 0.4);
    transition: color var(--d-fast) var(--ease), background var(--d-fast);
  }
  .rail a .n { font-variant-numeric: tabular-nums; line-height: 1; }
  .rail a::before {
    content: ""; position: absolute; left: 3px; top: 50%; width: 2px; height: 0; border-radius: 1px;
    background: var(--wine); transform: translateY(-50%); transition: height var(--d-base) var(--ease);
  }
  .rail a[aria-current="step"] { color: var(--ink); }
  .rail a[aria-current="step"]::before { height: 60%; }
  .rail a .lbl {
    position: absolute; right: calc(100% + 10px); top: 50%; transform: translate(6px, -50%);
    white-space: nowrap; padding: 6px 10px 4px; border-radius: 8px;
    background: var(--ink); color: var(--paper); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    opacity: 0; pointer-events: none; transition: opacity var(--d-fast) var(--ease), transform var(--d-fast) var(--ease);
  }
  .rail a:hover .lbl, .rail a:focus-visible .lbl { opacity: 1; transform: translate(0, -50%); }
  .rail a:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
  .rail .lock { width: 9px; height: 9px; opacity: 0; transform: scale(0.5); transition: opacity var(--d-fast), transform var(--d-base) var(--ease); }
  .rail a[data-locked="true"] { color: var(--muted); }
  .rail a[data-locked="true"] .lock { opacity: 1; transform: none; color: var(--wine); }
  .rail[data-theme="desk"] ol { background: #fff; box-shadow: 0 0 0 1px var(--line), 0 10px 30px -18px rgba(0, 0, 0, 0.5); }
  .rail[data-theme="night"] a { color: rgba(236, 230, 219, 0.4); }
  .rail[data-theme="night"] a[aria-current="step"], .rail[data-theme="night"] a:hover { color: var(--night-ink); }
  .rail[data-theme="night"] a[data-locked="true"] .lock { color: #d98aa6; }
  .rail[data-theme="night"] a::before { background: #d98aa6; }
}

/* ---------- chapter masthead (the phase gate) ---------- */

.gate {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding-block: 18px;
  border-top: 1px solid var(--hair);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted);
}
.gate .ph { color: var(--ink); }
.gate .ph b { color: var(--wine); font-weight: 600; }
.gate .bar { height: 1px; background: var(--hair); transform-origin: 0 50%; }
.gate .st { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.gate .st svg { width: 12px; height: 12px; }
.gate .st .open { display: inline; }
.gate .st .locked { display: none; color: var(--wine); }
.gate[data-locked="true"] .st .open { display: none; }
.gate[data-locked="true"] .st .locked { display: inline; }
.gate .st .ico-lock { color: var(--wine); }
.gate .desc { display: none; }
@media (min-width: 700px) { .gate .desc { display: inline; } }

.chapter { position: relative; }
.chapter-head { padding-top: clamp(72px, 12vh, 140px); }
.chapter-title { margin-top: clamp(36px, 6vh, 64px); display: grid; gap: 22px; }

/* quote band */
.quote {
  padding-block: clamp(80px, 14vh, 160px);
  text-align: left;
}
.quote blockquote {
  margin: 0; font-weight: 300; color: var(--ink);
  font-size: clamp(28px, 5vw, 60px); line-height: 1.14; letter-spacing: -0.005em;
  max-width: 22ch;
}
.quote blockquote .w { font-weight: 600; }
.quote figcaption { margin-top: 26px; }

/* paper surfaces */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* full-bleed tinted band, usable on an element inside .wrap */
.band {
  background: var(--paper-2);
  box-shadow: 0 0 0 100vmax var(--paper-2);
  clip-path: inset(0 -100vmax);
}

/* dialog */
dialog.modal {
  width: min(760px, calc(100vw - 32px)); max-height: min(86svh, 900px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px; background: #fff; color: var(--body);
  box-shadow: 0 40px 120px -40px rgba(0, 0, 0, 0.5);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: fadeUp var(--d-base) var(--ease); }
.modal-in { padding: clamp(24px, 5vw, 48px); overflow: auto; max-height: inherit; }
.modal-x {
  position: sticky; top: 0; float: right; width: 44px; height: 44px; margin: -10px -10px 0 0;
  border-radius: 50%; border: 1px solid var(--line); background: #fff; display: grid; place-items: center;
}

/* footer */
.foot { background: var(--night); color: var(--night-muted); padding-block: 56px calc(40px + env(safe-area-inset-bottom, 0px)); }
.foot .wordmark { color: var(--night-ink); }
.foot-row { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: baseline; justify-content: space-between; }
.foot .sig { color: var(--night-ink); font-weight: 300; font-size: clamp(18px, 2.2vw, 24px); }
.foot .sig .w { color: #d98aa6; }
.foot a:hover { color: var(--night-ink); }
.foot .meta { color: var(--night-muted); }
.foot-meta { margin-top: 40px; padding-top: 24px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.foot .hover-quote { font-size: 13px; color: var(--night-muted); opacity: 0.8; }

/* ---------- reduced motion: a designed mode ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
  .nav[data-hidden="true"] { transform: none; }
}
