/* Explore: the DNA journey. Built on the shared tokens and components
   (packages/shared/src/design). One face (Archivo), graphite glass, violet
   for selection; every saturated colour on the page is LED light. */
@font-face { font-family: Archivo; src: url("../styles/fonts/archivo-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root { color-scheme: dark; --bar: 64px; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: #3a4156 var(--dm-ground); }
body { margin: 0; background: var(--dm-ground); color: var(--dm-ink); font: 400 16px/1.55 var(--dm-font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; }
em { font-style: normal; color: var(--dm-violet-ink); }

/* Site header */
header.site {
  position: fixed; inset: 0 0 auto; z-index: var(--dm-z-chrome);
  display: flex; align-items: center; justify-content: space-between; gap: var(--dm-s4);
  height: var(--bar); padding: 0 var(--dm-gutter);
  background: linear-gradient(var(--dm-ground) 10%, rgba(9, 11, 18, 0));
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.3rem; letter-spacing: -0.03em; text-decoration: none; }
header.site nav { display: flex; gap: var(--dm-s6); font-size: 0.92rem; }
header.site nav a { color: var(--dm-muted); text-decoration: none; padding: 8px 0; }
header.site nav a:hover, header.site nav [aria-current] { color: var(--dm-ink); }
header.site nav [aria-current] { box-shadow: inset 0 -2px 0 var(--dm-violet); }

/* The scene sits behind everything */
#scene, .fallback-sculpture { position: fixed; inset: 0; z-index: var(--dm-z-canvas); width: 100%; height: 100%; display: block; }
.fallback-sculpture { pointer-events: none; }

/* Chapters */
.journey { position: relative; z-index: var(--dm-z-content); }
.journey section { position: relative; min-height: 132svh; padding: 0 var(--dm-gutter); }
.journey section:first-child { min-height: 150svh; }
.copy {
  position: sticky; top: max(calc(var(--bar) + 32px), 22svh);
  width: min(31rem, 100%);
  padding: var(--dm-s6) 28px;
  border: 1px solid var(--dm-edge); border-radius: var(--dm-r-lg);
  background: var(--dm-glass); -webkit-backdrop-filter: var(--dm-blur); backdrop-filter: var(--dm-blur);
  box-shadow: var(--dm-sheen), var(--dm-lift);
}
#origin .copy { background: none; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding-left: 0; }
h1, h2 { margin: 0 0 var(--dm-s4); font-weight: var(--dm-weight-display); letter-spacing: var(--dm-track-display); text-wrap: balance; }
/* Scales with height too, so short laptop screens keep the intro above the controls */
h1 { font-size: min(var(--dm-display-xl), 10.5vh); line-height: 1.0; max-width: 12ch; }
#origin .copy { top: max(calc(var(--bar) + 24px), 16svh); }
h2 { font-size: clamp(2rem, 4.2vw, 3.3rem); line-height: 1.04; }
.copy p { margin: 0 0 var(--dm-s4); color: var(--dm-prose-muted); max-width: 44ch; }
.copy .intro { font-size: 1.12rem; color: var(--dm-ink); max-width: 36ch; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--dm-s3) var(--dm-s5); margin-top: var(--dm-s5); }
.text-link { color: var(--dm-violet-ink); text-decoration: underline; text-decoration-color: rgba(185, 162, 255, 0.45); text-underline-offset: 0.28em; }
.text-link:hover { color: var(--dm-ink); }
details { margin-top: var(--dm-s4); border-top: 1px solid var(--dm-line); padding-top: var(--dm-s3); }
summary { cursor: pointer; color: var(--dm-ink); font-weight: 550; }
summary:hover { color: var(--dm-violet-ink); }
details p { margin-top: var(--dm-s3); }
#sound { margin-top: var(--dm-s2); }
.level { display: flex; justify-content: space-between; max-width: 22rem; margin-top: var(--dm-s2); color: var(--dm-ink); font-weight: 550; }
.level output { font-variant-numeric: tabular-nums; color: var(--dm-muted); }
input[type="range"] { width: 100%; max-width: 22rem; accent-color: var(--dm-violet); }

/* Sections whose content is long scroll normally instead of sticking */
.journey section.tall { min-height: auto; padding-top: 28svh; padding-bottom: 30svh; }
.journey section.tall .copy { position: relative; top: auto; }

/* Finale: centred */
#final { display: grid; justify-items: center; align-items: start; min-height: 150svh; }
#final .copy { align-self: start; margin-top: 64svh; text-align: center; width: min(40rem, 100%); top: auto; bottom: calc(var(--bar) + 40px); }
#final .copy p { margin-inline: auto; }
#final .actions { justify-content: center; }

/* Journey controls */
.chrome {
  position: fixed; left: var(--dm-gutter); right: var(--dm-gutter); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: var(--dm-z-chrome);
  display: grid; grid-template-columns: auto 1fr auto minmax(8rem, auto); align-items: center; gap: var(--dm-s4);
  padding: 8px 16px 8px 8px; border-radius: var(--dm-r-pill);
}
.chrome #motion { border-radius: var(--dm-r-pill); }
.track { display: grid; gap: 6px; min-width: 0; }
.chrome nav { display: flex; justify-content: space-between; gap: 2px; }
.chrome nav a { flex: 1; display: grid; place-items: center; height: 18px; border-radius: var(--dm-r-pill); }
.chrome nav a::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dm-edge-strong); transition: background var(--dm-fast) var(--dm-ease), transform var(--dm-fast) var(--dm-ease); }
.chrome nav a:hover::before { background: var(--dm-muted); }
.chrome nav a[aria-current]::before { background: var(--dm-ink); transform: scale(1.4); }
.counter { font-variant-numeric: tabular-nums; color: var(--dm-muted); font-size: 0.875rem; }
#readout { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notice { position: relative; z-index: var(--dm-z-content); margin: var(--dm-s6) var(--dm-gutter); color: var(--dm-prose-muted); }
.fallback-link { position: fixed; z-index: var(--dm-z-chrome); right: var(--dm-gutter); top: calc(var(--bar) + 8px); }

/* Tablets and phones */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  :root { --bar: 56px; }
  header.site nav { display: none; }
  .journey section { min-height: 118svh; padding: 0 16px; }
  .copy { top: 46svh; width: 100%; padding: 20px; }
  /* The close-up fills a phone screen, so the intro gets the same glass card as the other chapters */
  #origin .copy {
    top: 46svh; padding: 20px;
    background: var(--dm-glass-strong); border-color: var(--dm-edge); box-shadow: var(--dm-sheen), var(--dm-lift);
    -webkit-backdrop-filter: var(--dm-blur); backdrop-filter: var(--dm-blur);
  }
  h1 { font-size: clamp(2.2rem, 11vw, 3.2rem); }
  h2 { font-size: clamp(1.75rem, 8vw, 2.4rem); }
  .chrome { left: 12px; right: 12px; grid-template-columns: auto 1fr auto; gap: var(--dm-s3); }
  .chrome nav a { height: 24px; } /* chapter navigation stays available on phones, with touch-sized targets */
  #readout { display: none; }
}
@media (max-width: 420px) {
  .sim { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
@media (prefers-reduced-transparency: reduce) {
  .copy { background: var(--dm-rail); }
}
