/* Sidereo — see ../DESIGN.md.
 *
 * The page is an instrument, not a document about one. The sky is a fixed canvas behind
 * everything; copy floats over it and gets out of the way. There are no cards, no boxes and no
 * grid of equal tiles -- separation is space, tone and the sky itself. */

/* ---- fonts (self-hosted: no request leaves this origin) ------------------------------------ */

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans-var.woff2') format('woff2');
  font-weight: 100 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/ibm-plex-mono-400-normal.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/ibm-plex-mono-500-normal.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

/* ---- tokens -------------------------------------------------------------------------------- */

:root {
  --canvas: #000000;
  --text-1: #ffffff;
  --text-2: #b6b8bd;
  --text-3: #7b7e86;
  --text-4: #3e424b;
  --accent: #e6b45a;
  --moonlight: #c7ccdb;

  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;

  --s-1: 4px;  --s-2: 10px; --s-3: 16px; --s-4: 26px;
  --s-5: 40px; --s-6: 64px; --s-7: 100px; --s-8: 160px;

  --gutter: clamp(20px, 5vw, 76px);
  --measure: 46ch;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Everything above the sky fades in once the catalog has loaded, so the first frame is never a
   flash of unstyled copy over a black void.
   Gated on `.has-sky`, which only index.html declares: an unscoped `body > *` rule here left the
   privacy and support pages permanently at opacity 0, because nothing on those pages ever adds
   `is-ready`. A page must never depend on JavaScript in order to be visible. */
body.has-sky > *:not(:where(#sky)) { opacity: 0; transition: opacity .9s ease .1s; }
body.has-sky.is-ready > *:not(:where(#sky)) { opacity: 1; }

/* ---- the sky ------------------------------------------------------------------------------- */

#sky {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  z-index: 0;
  cursor: grab;
  touch-action: pan-y;
}
.is-dragging #sky { cursor: grabbing; }

#labels { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

/* Atmospheric grain. The turbulence rect is opaque mid-grey, so painting it straight over the
   canvas lifts every black in the page to charcoal and drowns the stars. `overlay` keeps mid-grey
   neutral and only perturbs what is already there, which is what film grain actually does. */
.grain {
  position: fixed; inset: 0;
  z-index: 3; pointer-events: none;
  opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}

/* A slow vignette so the centre of the frame reads as the aperture. */
.vignette {
  position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(ellipse 88% 78% at 50% 46%, transparent 55%, rgba(0,0,0,.45) 100%);
}

/* ---- chrome -------------------------------------------------------------------------------- */

.masthead {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--gutter);
  mix-blend-mode: difference;
}

.wordmark {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--mono);
  font-size: 12px; letter-spacing: .34em; text-transform: uppercase;
  color: var(--text-1); text-decoration: none;
}
.wordmark img { width: 16px; height: 16px; display: block; }

.masthead nav { display: flex; gap: var(--s-4); }
.masthead nav a {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-1); text-decoration: none; opacity: .55; transition: opacity .16s ease;
}
.masthead nav a:hover, .masthead nav a[aria-current="page"] { opacity: 1; }

/* The instrument readout. Always present, always true. */
.readout {
  position: fixed; left: var(--gutter); bottom: var(--s-4); z-index: 10;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.readout-row { display: flex; gap: var(--s-2); }
.readout-row i { font-style: normal; width: 26px; color: var(--text-4); }
.readout-row b { font-weight: 400; color: var(--moonlight); }
.readout-place { margin-top: var(--s-2); color: var(--text-4); }

/* Retired once the footer arrives: the sky narrative has ended, and a live coordinate readout
   sitting underneath the colophon is just two things fighting for the same corner. */
.readout {
  transition: opacity .45s ease, transform .45s ease;
}
body.has-sky.is-ready > .readout.is-retired {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

/* ---- narrative beats ----------------------------------------------------------------------- */

main { position: relative; z-index: 5; }

.beat {
  position: relative;
  min-height: 118vh;
  display: flex; align-items: center;
  padding: var(--s-8) var(--gutter);
  pointer-events: none;   /* the sky beneath stays draggable everywhere except on real controls */
}
.beat-copy { max-width: var(--measure); pointer-events: auto; }
.beat-hero { min-height: 100vh; }
.beat-devices, .beat-close { min-height: auto; padding-top: var(--s-7); padding-bottom: var(--s-7); }

/* Alternating side keeps the eye moving and stops the page reading as a stack. */
.beat:nth-of-type(even) { justify-content: flex-end; }
.beat:nth-of-type(even) .beat-copy { text-align: right; margin-left: auto; }
.beat-devices, .beat-close { justify-content: center; flex-direction: column; align-items: center; }
.beat-devices .beat-copy, .beat-close .beat-copy { text-align: center; margin: 0 auto; }

h1, h2 {
  font-family: var(--sans);
  font-weight: 300;
  color: var(--text-1);
  margin: 0;
}
/* Tight, deliberate tracking. Plex Sans at 300 loosens optically as it scales, so the negative
   tracking is what keeps a 130px headline reading as one measured object rather than a spread. */
h1 {
  font-size: clamp(44px, 8.2vw, 132px);
  line-height: 0.98;
  letter-spacing: -0.038em;
}
h2 {
  font-size: clamp(30px, 5vw, 68px);
  line-height: 1.06;
  letter-spacing: -0.032em;
}

/* The emphasised word is distinguished by colour and a single step of weight -- never by italic,
   and never by switching to the mono, which is reserved for measured values. */
h1 em, h2 em {
  font-style: normal;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 var(--s-3);
}

.lede {
  margin: var(--s-4) 0 0;
  font-size: clamp(15px, 1.25vw, 18px);
  line-height: 1.66;
  color: var(--text-2);
}

.aside {
  margin: var(--s-4) 0 0;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.62;
  color: var(--text-3);
}
.aside a { color: var(--moonlight); text-decoration: none; border-bottom: 1px solid var(--text-4); }
.aside a:hover { border-bottom-color: var(--accent); }

.hint {
  position: absolute; left: 50%; bottom: var(--s-6); transform: translateX(-50%);
  margin: 0; font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--text-4); white-space: nowrap;
}

.status {
  margin: var(--s-5) 0 0;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em;
  color: var(--accent);
}

/* ---- aperture labels ----------------------------------------------------------------------- */

.sky-label {
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column; gap: 1px;
  padding-left: 13px;
  margin: 0;
  opacity: 0;
  text-transform: none; letter-spacing: normal;
  will-change: transform, opacity;
}
.sky-label.is-visible { opacity: 1; }

/* A hairline tick joining the label to the thing it names, so it never floats free. */
.sky-label::before {
  content: ''; position: absolute; left: 0; top: 6px;
  width: 8px; height: 1px; background: var(--text-3);
}
.label-name {
  font-family: var(--sans); font-size: 12px; font-weight: 400; line-height: 1.1;
  color: var(--text-1); white-space: nowrap;
}
.label-detail {
  font-family: var(--mono); font-size: 9.5px; line-height: 1.2;
  color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.sky-label.is-body .label-name { color: var(--accent); }
.sky-label.is-body::before { background: var(--accent); }

/* ---- the hunt ------------------------------------------------------------------------------ */

.hunt {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 6; pointer-events: none;
  opacity: 0;
  visibility: hidden;   /* not merely transparent: it must never paint over the hero */
  --proximity: 0;
}
body.is-ready .hunt { transition: opacity .5s ease; }
.hunt.is-active { opacity: 1; visibility: visible; }

/* Four corner brackets closing in as you get warmer -- the instrument acquiring a target. */
.hunt-reticle { position: relative; width: 132px; height: 132px; }
.hunt-reticle span {
  position: absolute; width: 20px; height: 20px;
  border: 1px solid var(--moonlight);
  opacity: calc(.28 + var(--proximity) * .6);
  transition: opacity .18s linear;
}
.hunt-reticle span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.hunt-reticle span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.hunt-reticle span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.hunt-reticle span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.hunt.is-locked .hunt-reticle span { border-color: var(--accent); opacity: 1; }

.hunt-meta {
  display: flex; justify-content: center; gap: var(--s-3);
  margin: var(--s-3) 0 0;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.hunt-meta b { font-weight: 400; color: var(--text-3); }
.hunt-meta i { font-style: normal; color: var(--moonlight); }
.hunt.is-locked .hunt-meta b { color: var(--accent); }

.hunt-panel {
  position: absolute; left: 50%; top: calc(100% + var(--s-5)); transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(5, auto); gap: 0 var(--s-5);
  margin: 0; opacity: 0; white-space: nowrap;
}
.hunt-panel div { text-align: center; }
.hunt-panel dt {
  font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-4);
}
.hunt-panel dd {
  margin: 3px 0 0; font-family: var(--mono); font-size: 12px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}

/* ---- devices ------------------------------------------------------------------------------- */

.devices {
  display: flex; gap: clamp(18px, 3vw, 44px); justify-content: center;
  margin-top: var(--s-7); pointer-events: auto;
}
.device { margin: 0; text-align: center; }

.device-shell {
  position: relative;
  width: clamp(168px, 17vw, 226px);
  aspect-ratio: 9 / 19.2;
  border-radius: 34px;
  padding: 7px;
  background: linear-gradient(160deg, #26282d, #0d0e11 40%, #202227);
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.95), inset 0 0 0 1px rgba(255,255,255,.07);
}
.device-island {
  position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
  width: 30%; height: 15px; border-radius: 999px; background: #000; z-index: 2;
}
.device-screen {
  width: 100%; height: 100%; display: block;
  border-radius: 28px; background: #06070b;
  cursor: grab; touch-action: pan-y;
}
.device-screen:active { cursor: grabbing; }

.device figcaption {
  margin-top: var(--s-3);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3);
}

/* ---- facts --------------------------------------------------------------------------------- */

.facts {
  display: flex; justify-content: center; gap: clamp(24px, 5vw, 72px);
  list-style: none; margin: var(--s-6) 0 0; padding: 0;
}
.facts li { display: flex; flex-direction: column; gap: 4px; }
.facts b {
  font-family: var(--sans); font-size: clamp(30px, 3.6vw, 50px); font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--text-1); line-height: 1; font-variant-numeric: tabular-nums;
}
.facts span {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3);
}

/* ---- footer -------------------------------------------------------------------------------- */

footer {
  position: relative; z-index: 5;
  padding: var(--s-6) var(--gutter) var(--s-5);
  border-top: 1px solid var(--text-4);
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.86) 42%);
}
footer nav { display: flex; gap: var(--s-4); margin-bottom: var(--s-3); }
footer nav a {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); text-decoration: none;
}
footer nav a:hover { color: var(--text-1); }
.fine { margin: 0; max-width: 68ch; font-size: 12px; line-height: 1.6; color: var(--text-4); }

/* ---- focus --------------------------------------------------------------------------------- */

a:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px;
}

/* ---- prose pages (privacy, support) -------------------------------------------------------- */

.wrap { width: 100%; max-width: 940px; margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 5; }
.prose { padding: calc(var(--s-8)) 0 var(--s-7); max-width: 64ch; }
.prose h1 { font-size: clamp(36px, 5vw, 58px); line-height: 1.06; letter-spacing: -0.03em; }
.prose h2 { font-size: clamp(21px, 2.4vw, 28px); margin-top: var(--s-6); letter-spacing: -0.022em; }
.prose h3 { font-family: var(--sans); font-size: 17px; font-weight: 400; color: var(--text-1); margin-top: var(--s-5); }
.prose p, .prose li { margin-top: var(--s-3); font-size: 15px; line-height: 1.68; }
.prose ul { padding-left: 1.1em; margin: 0; }
.prose li::marker { color: var(--text-4); }
.prose a { color: var(--text-1); text-decoration: none; border-bottom: 1px solid var(--text-4); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose strong { font-weight: 500; color: var(--text-1); }

.prose table { width: 100%; border-collapse: collapse; margin-top: var(--s-4); font-size: 13px; }
.prose th, .prose td { text-align: left; padding: var(--s-2) var(--s-3) var(--s-2) 0; vertical-align: top; }
.prose thead th {
  font-family: var(--mono); color: var(--text-3); font-weight: 400;
  text-transform: uppercase; font-size: 10px; letter-spacing: .14em;
}
.prose tbody tr { border-top: 1px solid var(--text-4); }
.prose td:first-child { color: var(--text-1); white-space: nowrap; }
.updated { color: var(--text-3); font-size: 12px; margin-top: var(--s-2); font-family: var(--mono); }

/* ---- responsive ---------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .devices { flex-direction: column; align-items: center; gap: var(--s-6); }
  .device-shell { width: min(72vw, 260px); }
  .hunt-panel { grid-template-columns: repeat(2, auto); gap: var(--s-3) var(--s-5); }
}

/* There is no cursor on a touch device, so half the hint is a lie there -- and centred at the
   bottom it lands straight on top of the readout column. */
@media (pointer: coarse), (max-width: 640px) {
  .hint-pointer { display: none; }
  /* The hint is absolutely positioned inside a section taller than the viewport, so "bottom of
     section" sits below the fold and lands on the fixed readout. Pin it to the opposite corner
     instead: readout bottom-left, hint bottom-right, neither on top of the other. */
  .hint {
    position: fixed;
    left: auto; right: var(--gutter); bottom: var(--s-3);
    transform: none; text-align: right;
    max-width: 52vw; white-space: normal; line-height: 1.5;
  }
}

@media (max-width: 640px) {
  /* Optical sizing by hand: negative tracking has to relax as the type gets smaller, or the
     letterforms start colliding instead of reading as one tight object. */
  h1 { font-size: clamp(40px, 12.4vw, 62px); line-height: 1.02; letter-spacing: -0.028em; }
  h2 { font-size: clamp(27px, 8vw, 40px); line-height: 1.12; letter-spacing: -0.022em; }
  .facts b { letter-spacing: -0.022em; }
  .beat { min-height: 104vh; padding: var(--s-7) var(--gutter); }
  .beat:nth-of-type(even) { justify-content: flex-start; }
  .beat:nth-of-type(even) .beat-copy { text-align: left; margin-left: 0; }
  .readout { font-size: 9.5px; bottom: var(--s-3); }
  .facts { flex-wrap: wrap; gap: var(--s-4) var(--s-5); }
  .hint { font-size: 9.5px; }
  .vignette { background: radial-gradient(ellipse 98% 84% at 50% 44%, transparent 58%, rgba(0,0,0,.42) 100%); }
}

/* ---- reduced motion ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  body.has-sky > *:not(:where(#sky)) { transition: none; }
  .hunt, .hunt-reticle span { transition: none; }
}

/* ---- no WebGL: the page must still read ---------------------------------------------------- */

body.no-webgl #sky, body.no-webgl #labels, body.no-webgl .hunt, body.no-webgl .hint { display: none; }
body.no-webgl { background: #06070b; }
body.no-webgl .beat { min-height: auto; padding-top: var(--s-6); padding-bottom: var(--s-6); }
body.no-webgl .vignette { display: none; }


/* On a reading page the masthead scrolls away with the document. Fixed-over-content works when
   what is behind it is the sky; over prose it just makes the top two lines unreadable. */
body:not(.has-sky) .masthead { position: static; padding-left: 0; padding-right: 0; }

/* Anchor links must not land a heading underneath anything. */
.prose section, .prose h2, .prose h3 { scroll-margin-top: var(--s-4); }

/* ---- field guide ---------------------------------------------------------------------------
   A reading page, not an instrument: no sky canvas behind it, wider measure than the policy
   pages, and a contents rail that stays put on desktop so a long guide stays navigable. */

.learn { max-width: 1080px; }

.learn-head { padding: var(--s-8) 0 var(--s-5); max-width: 30ch; }
.learn-head h1 { font-size: clamp(34px, 4.6vw, 62px); line-height: 1.04; letter-spacing: -0.034em; }
.learn-head .lede { max-width: 54ch; }

/* Contents rail. Sticky only where there is room for it to be sticky. */
.toc { margin: var(--s-6) 0 var(--s-5); }
.toc-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--text-3); margin: 0 0 var(--s-3);
}
.toc ol {
  list-style: none; margin: 0; padding: 0;
  columns: 2; column-gap: var(--s-5);
  font-family: var(--mono); font-size: 12px; line-height: 2.1;
}
.toc a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid transparent; }
.toc a:hover { color: var(--text-1); border-bottom-color: var(--accent); }

.learn .prose { max-width: 68ch; padding-top: var(--s-5); }
.learn .prose section { padding: 0; margin-top: var(--s-7); scroll-margin-top: var(--s-6); }
.learn .prose section:first-of-type { margin-top: 0; }
.learn .prose h2 {
  font-size: clamp(26px, 3.2vw, 40px); margin: 0 0 var(--s-3);
  padding-top: var(--s-4); border-top: 1px solid var(--text-4);
}
.learn .prose h3 { margin-top: var(--s-5); color: var(--text-1); font-size: 18px; }
.learn .prose em { font-style: normal; color: var(--moonlight); }

/* A worked formula. Set in the mono, because it is a measured thing. */
.formula {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  color: var(--accent);
  padding: var(--s-3) 0 var(--s-3) var(--s-3);
  border-left: 1px solid var(--accent);
  margin-top: var(--s-4) !important;
}

/* An aside worth stopping for -- the thing that catches people out. */
.note {
  padding: var(--s-3) 0 var(--s-3) var(--s-3);
  border-left: 1px solid var(--text-4);
  color: var(--text-3);
  font-size: 14px !important;
}
.note strong { color: var(--text-2); font-weight: 400; }

.glossary { margin: var(--s-4) 0 0; }
.glossary dt {
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  color: var(--accent); margin-top: var(--s-4);
}
.glossary dd { margin: var(--s-1) 0 0; font-size: 14.5px; line-height: 1.62; color: var(--text-2); }

@media (min-width: 1000px) {
  /* Two columns: the guide reads on the left, the contents stay in view on the right. */
  .learn main { max-width: none; }
  .learn { display: grid; grid-template-columns: minmax(0, 1fr) 210px; column-gap: var(--s-7); }
  .learn-head { grid-column: 1 / -1; }
  .toc {
    grid-column: 2; grid-row: 3;
    position: sticky; top: var(--s-7); align-self: start;
    margin: var(--s-5) 0 0;
  }
  .toc ol { columns: 1; }
  .learn .prose { grid-column: 1; grid-row: 3; }
  .learn footer { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .toc ol { columns: 1; }
  .learn-head { padding-top: var(--s-6); }
}
