/* =========================================================
   BD2i AI — Studies in applied intelligence
   Design system: cold silver studio with gold, into deep navy.
   ========================================================= */

@font-face {
  font-family: "Manrope";
  src: url("fonts/Manrope-Variable.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/CormorantGaramond-Italic-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

:root {
  /* World 1 — silver studio */
  --bg: #c3c4c0;
  --fog: #cfd0cb;
  --ink: #121c2b;            /* primary text, deep navy-black */
  --ink-2: 36 50 74;         /* #24324a as RGB triplet for alpha use */
  --gold: #b8955a;
  /* World 2 — deep navy */
  --bg-2: #050a18;
  --ink-dark: #e9ebe8;
  --ink-dark-2: 214 220 226;

  --text: var(--ink);
  --text-2: rgb(var(--ink-2) / 0.58);
  --text-3: rgb(var(--ink-2) / 0.42);

  --glass-bg: rgb(255 255 255 / 0.22);
  --glass-border: rgb(255 255 255 / 0.55);
  --glass-hi: rgb(255 255 255 / 0.5);

  --gutter: 3.5vw;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Consolas", "Menlo", monospace;
  --progress: 0;
  color-scheme: light;
}

/* The second world flips the interface to light-on-navy. */
body.world-2 {
  --text: var(--ink-dark);
  --text-2: rgb(var(--ink-dark-2) / 0.62);
  --text-3: rgb(var(--ink-dark-2) / 0.45);
  --glass-bg: rgb(255 255 255 / 0.07);
  --glass-border: rgb(255 255 255 / 0.2);
  --glass-hi: rgb(255 255 255 / 0.16);
}

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

html {
  background: var(--bg);
  scroll-behavior: auto; /* smooth scrolling is driven from JS so it can respect reduced motion */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: color 0.8s ease, background-color 0.8s ease;
}
body.world-2 { background: var(--bg-2); }

a { color: inherit; }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ===== Stage ===== */
#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}
#stage canvas { display: block; width: 100%; height: 100%; }

/* ===== Glass pills ===== */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    inset 0 -8px 18px rgb(255 255 255 / 0.04),
    0 10px 30px rgb(10 20 40 / 0.08);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border-radius: 999px;
  transition: background 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease, opacity 0.5s ease;
}

.eyebrow,
.mark__sub,
.hint,
.hide-ui,
.show-ui,
.pill,
.chapter-nav,
.caption-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ===== Header ===== */
.site-header {
  position: fixed;
  top: 30px;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.site-header > * { pointer-events: auto; }

.mark {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 20px 11px 18px;
  text-decoration: none;
}
.mark__name {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.mark__sub { color: var(--text-2); }

.hide-ui, .show-ui {
  color: inherit;
  cursor: pointer;
  padding: 11px 18px;
}
.show-ui {
  position: fixed;
  top: 30px;
  right: var(--gutter);
  z-index: 11;
  opacity: 0;
  pointer-events: none;
  color: var(--text);
}

/* ===== Chapter nav ===== */
.chapter-nav {
  position: fixed;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}
.chapter-nav ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.chapter-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-3);
  transition: color 0.4s ease;
}
.chapter-nav a::before {
  content: "";
  width: 14px;
  height: 1px;
  background: currentColor;
  transition: width 0.4s ease;
}
.chapter-nav a[aria-current="true"] { color: var(--text); }
.chapter-nav a[aria-current="true"]::before { width: 28px; }
.chapter-nav a:hover { color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 26px;
  z-index: 10;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.hint {
  margin: 0;
  padding: 10px 18px;
  color: var(--text-2);
}
.progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgb(var(--ink-2) / 0.08);
}
.progress span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--progress));
  background: linear-gradient(90deg, var(--text), var(--gold));
}

/* Hide-UI mode: only the scene remains (plus a quiet way back). */
body.ui-hidden .ui,
body.ui-hidden .copy,
body.ui-hidden .axis-caption,
body.ui-hidden .closing { opacity: 0; pointer-events: none; }
body.ui-hidden .show-ui { opacity: 0.8; pointer-events: auto; }
.ui, .copy, .axis-caption, .closing { transition: opacity 0.6s ease; }

/* ===== Chapters ===== */
#track { position: relative; z-index: 1; }

.chapter {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 120px var(--gutter);
}
.chapter--axis {
  height: 700vh;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 var(--gutter);
}
.chapter--closing {
  min-height: 120vh;
  justify-content: center;
  text-align: center;
}

.copy {
  width: min(46vw, 760px);
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
/* A soft, borderless glow behind the copy keeps it legible over the moving liquid. */
.copy, .closing { position: relative; isolation: isolate; }
.copy::before, .closing::before {
  content: "";
  position: absolute;
  inset: -16% -12% -18% -20%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgb(195 196 192 / 0.78), rgb(195 196 192 / 0.45) 55%, rgb(195 196 192 / 0));
  transition: opacity 0.8s ease;
}
body.world-2 .copy::before,
body.world-2 .closing::before {
  background: radial-gradient(closest-side, rgb(5 10 24 / 0.75), rgb(5 10 24 / 0.4) 55%, rgb(5 10 24 / 0));
}

.eyebrow { margin: 0 0 26px; color: var(--text-2); }

.headline {
  margin: 0;
  font-weight: 300;
  font-size: clamp(58px, 6.6vw, 128px);
  letter-spacing: -0.065em;
  line-height: 1.03;
  text-wrap: balance;
}
.headline--closing { font-size: clamp(48px, 6vw, 112px); }

/* The signature detail: every "o" becomes an uppercase italic Cormorant O. */
.script-o {
  display: inline-block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  text-transform: uppercase;
  font-size: 1.04em;
  letter-spacing: -0.02em;
  line-height: 0.8;
  transform: rotate(-10deg);
  margin: 0 0.01em;
}

.lede {
  margin: 28px 0 34px;
  max-width: 34em;
  font-size: clamp(14px, 1.05vw, 17px);
  line-height: 1.6;
  color: var(--text-2);
}

.pill {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 13px 20px;
  text-decoration: none;
}
.pill:hover { background: rgb(255 255 255 / 0.36); }
body.world-2 .pill:hover { background: rgb(255 255 255 / 0.12); }

/* Chapter 05 caption sticks to the bottom-left while the axis orbits. */
.axis-caption {
  position: sticky;
  bottom: 92px;
  margin-top: auto;
  padding-bottom: 92px;
  max-width: 520px;
}
body:not(.world-2) .axis-caption { opacity: 0; }

.caption-title {
  margin: 0 0 12px;
  font-weight: 300;
  font-size: clamp(30px, 3vw, 52px);
  letter-spacing: -0.05em;
  line-height: 1.05;
}
.caption-sub { margin: 0; color: var(--text-2); }

.closing {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1100px;
}

.error {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  padding: 16px 24px;
  border-radius: 18px;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}
.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; z-index: 5; }

/* ===== Mobile ===== */
@media (max-width: 760px) {
  :root { --gutter: 16px; }
  .site-header { top: 16px; }
  .show-ui { top: 16px; }
  .mark { padding: 9px 14px; gap: 10px; }
  .mark__sub { display: none; }
  .chapter-nav { display: none; }
  .site-footer { bottom: 14px; }
  .hint { padding: 8px 14px; font-size: 9px; }

  .chapter {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }
  .copy {
    width: 100%;
    text-align: left;
    align-items: flex-start;
    padding: 90px var(--gutter) 80px;
    /* soft gradient so copy reads over the scene */
    background: linear-gradient(to top, rgb(195 196 192 / 0) 0%, rgb(195 196 192 / 0.85) 20%, rgb(195 196 192 / 0.7) 62%, rgb(195 196 192 / 0) 100%);
  }
  .copy::before { display: none; } /* mobile uses the bottom gradient instead */
  body.world-2 .copy {
    background: linear-gradient(to top, rgb(5 10 24 / 0) 0%, rgb(5 10 24 / 0.8) 20%, rgb(5 10 24 / 0.6) 62%, rgb(5 10 24 / 0) 100%);
  }
  .headline { font-size: clamp(40px, 12vw, 58px); }
  .lede br { display: none; }
  .lede { margin: 18px 0 24px; }
  .chapter--axis { padding: 0 var(--gutter); }
  .axis-caption { bottom: 60px; padding-bottom: 60px; }
  .chapter--closing { align-items: center; padding: 0 var(--gutter); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
