/* retelogic.com — the network as the page. Rationale and tokens: docs/design.md
   Motion is CSS only and switches off under prefers-reduced-motion. */

@font-face { font-family: "Instrument Serif"; src: url("/fonts/InstrumentSerif-normal-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/fonts/InstrumentSerif-italic-400.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("/fonts/HankenGrotesk-normal-400-600.woff2") format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-normal-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/IBMPlexMono-normal-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* Animatable custom properties drive the 3D network. */
@property --spin { syntax: "<angle>"; inherits: true; initial-value: -26deg; }
@property --lift { syntax: "<length>"; inherits: true; initial-value: 44px; }

:root {
  --paper: #f3f1ec;
  --paper-2: #e9e6df;
  --ink: #161616;
  --muted: #5d5952;
  --line: #cdc8bd;
  --grid: rgba(22, 22, 22, 0.06);
  --red: #d52b1e;       /* Swiss red: marks, never body text */
  --red-text: #ad2318;  /* red that passes AA on paper */
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(1rem, 4vw, 3rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111110;
    --paper-2: #1a1918;
    --ink: #ecebe6;
    --muted: #a39f96;
    --line: #3a3834;
    --grid: rgba(236, 235, 230, 0.05);
    --red: #ff4b3b;
    --red-text: #ff7a6d;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--red-text); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--gutter); top: -3rem; background: var(--ink); color: var(--paper); padding: 0.5rem 0.9rem; z-index: 10; }
.skip:focus { top: 0.75rem; }
.num { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.04em; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Header */
.top { display: flex; align-items: center; gap: 1.5rem; padding: 1.1rem var(--gutter); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 500 1rem/1 var(--mono); letter-spacing: 0.02em; }
.knot { width: 1.35rem; height: 1.35rem; flex: none; }
.knot-spark { fill: var(--red); transform-origin: 12px 12px; animation: orbit 9s linear infinite; }
.nav { display: flex; gap: 1.4rem; margin-left: auto; font-size: 0.95rem; }
.nav a, .langs a { text-decoration: none; }
.nav a[aria-current] { text-decoration: underline; }
.langs { display: flex; gap: 0.15rem; font: 500 0.75rem/1 var(--mono); }
.langs a { padding: 0.45rem 0.4rem; color: var(--muted); }
.langs a[aria-current] { color: var(--ink); box-shadow: inset 0 -1px 0 var(--red); }

/* Home: hero */
.hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center;
  gap: 2rem; padding: clamp(2rem, 6vw, 5rem) var(--gutter) clamp(2rem, 4vw, 3.5rem);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px; background-position: -1px -1px;
}
.eyebrow { font: 500 0.78rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.4rem; }
.eyebrow::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--red); margin-right: 0.6rem; vertical-align: 0.05em; }
h1, h2, h3 { font-weight: 400; margin: 0; }
.hero h1 { font: 400 clamp(3.1rem, 7.2vw, 6.4rem)/0.95 var(--serif); letter-spacing: -0.02em; }
.hero h1 span, .hero h1 em { display: block; }
.hero h1 em { font-style: italic; }
.hero h1 .stop { display: inline; color: var(--red); font-style: normal; }
.lead { font-size: clamp(1.05rem, 1.4vw, 1.2rem); color: var(--muted); max-width: 34rem; margin: 1.6rem 0 0; }

.divisions { margin-top: 2.4rem; max-width: 34rem; }
.divisions h2 { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.6rem; }
.divisions ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.divisions li { border-bottom: 1px solid var(--line); }
.divisions a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 1rem; align-items: baseline; padding: 1rem 0; text-decoration: none; }
.divisions .name { font: 400 1.45rem/1.1 var(--serif); }
.divisions .field { color: var(--muted); font-size: 0.92rem; }
.divisions .go { transition: transform 0.35s var(--ease); color: var(--red-text); }
.divisions a:hover .go { transform: translateX(0.35rem); }


/* The network: a tilted plane in 3D, nodes stand on pins and always face the viewer. */
.net { margin: 0; position: relative; overflow: clip; }
.stage { --s: 0.94; position: relative; height: calc(500px * var(--s)); perspective: 1500px; perspective-origin: 50% 20%; }
.plane {
  position: absolute; left: 50%; top: 50%; width: 560px; height: 560px; margin: -280px 0 0 -280px;
  transform-style: preserve-3d;
  transform: scale(var(--s)) translateY(28px) rotateX(58deg) rotateZ(var(--spin));
  animation: drift 28s ease-in-out infinite alternate;
}
.net:hover .plane, .net:focus-within .plane { animation-play-state: paused; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.disc { fill: var(--paper-2); fill-opacity: 0.6; }
.ring { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 7; transform-box: fill-box; transform-origin: center; animation: orbit 140s linear infinite; }
.ring-2 { animation-duration: 200s; animation-direction: reverse; stroke-dasharray: 1 5; }
.ring-3 { stroke: var(--ink); stroke-dasharray: none; opacity: 0.35; animation: none; }
.wire { fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s var(--ease) forwards; animation-delay: calc(0.5s + var(--i) * 0.16s); }
.wire.live { stroke: var(--ink); }
.wire.future { stroke: var(--muted); stroke-width: 1; opacity: 0.7; }
.flow { fill: none; stroke: var(--red); stroke-width: 4.5; stroke-linecap: round; stroke-dasharray: 0.001 0.08; animation: flow 3.2s linear infinite; opacity: 0; animation-delay: 1.6s; }

.node { --delay: calc(0.9s + var(--i, -1) * 0.16s); position: absolute; left: var(--x); top: var(--y); transform-style: preserve-3d; text-decoration: none; color: var(--ink); }
.node.core { --delay: 0.3s; }
/* Fade the leaves, never .node itself: opacity on a 3D parent flattens its children. */
.bill, .pin, .node::before { opacity: 0; animation: appear 0.7s var(--ease) forwards; animation-delay: var(--delay); }
.pin { --o: 0.55; position: absolute; left: -0.5px; top: 0; width: 1px; height: var(--lift); background: currentColor; transform-origin: 0 0; transform: rotateX(90deg); }
.node::before { --o: 0.5; content: ""; position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; border: 1px solid currentColor; }
.bill {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; display: flex; flex-direction: column; align-items: center; gap: 0.45rem; white-space: nowrap;
  transform: translateZ(var(--lift)) rotateZ(calc(var(--spin) * -1)) rotateX(-58deg) translate(-50%, -100%);
  transition: --lift 0.45s var(--ease);
}
.node.live:hover, .node.live:focus-visible { --lift: 70px; outline: none; }
.dot { position: relative; order: 2; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); }
.label { order: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; text-align: center; padding: 0.35rem 0.6rem; background: var(--paper); border: 1px solid var(--line); }
.label .name { font: 400 1.3rem/1.05 var(--serif); }
.label .field { font-size: 0.78rem; color: var(--muted); }
.core .dot { width: 22px; height: 22px; background: var(--ink); box-shadow: 0 0 0 5px var(--paper), 0 0 0 6px var(--ink); }
.core .label { border-color: var(--ink); }
.live .dot { background: var(--red); }
.live .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--red); animation: pulse 2.6s ease-out infinite; }
.live .label { border-color: var(--ink); }
.live:hover .label, .live:focus-visible .label { background: var(--ink); color: var(--paper); }
.live:hover .label .field, .live:focus-visible .label .field, .live:hover .num, .live:focus-visible .num { color: var(--paper); }
.live:focus-visible .label { outline: 2px solid var(--red); outline-offset: 3px; }
.future { color: var(--muted); }
.future .dot { background: transparent; border: 1.5px dashed var(--muted); animation: orbit 16s linear infinite; }
.future .label { background: var(--paper); border-style: dashed; }
.future .label .name { font: 500 0.72rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }


/* Inner pages */
.inner { display: grid; grid-template-columns: minmax(0, 44rem) minmax(0, 1fr); gap: 3rem; padding: clamp(2.5rem, 6vw, 5rem) var(--gutter); }
.inner h1 { font: 400 clamp(2.6rem, 6vw, 4.6rem)/1 var(--serif); letter-spacing: -0.015em; max-width: 16ch; margin-bottom: 2.4rem; }
.inner-art { display: flex; justify-content: center; align-items: flex-start; padding-top: 1rem; }
.inner-art .gyro { position: sticky; top: 3rem; width: clamp(9rem, 18vw, 16rem); height: clamp(9rem, 18vw, 16rem); }
.prose { max-width: 40rem; }
.prose section { padding: 1.3rem 0; border-top: 1px solid var(--line); }
.prose h2 { font: 500 0.78rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem; }
.prose p { margin: 0 0 0.8rem; }
.prose em { font-family: var(--serif); font-size: 1.15em; }
.prose .lead { margin: 0 0 2rem; }
.facts { margin: 0 0 2rem; border-top: 1px solid var(--line); }
.facts + section { border-top: 0; padding-top: 0; }
.facts div { display: grid; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr); gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.facts dt { font: 500 0.78rem/1.6 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; }
.note a { color: var(--red-text); }

/* Gyroscope: three rings turning in 3D around the knot */
.gyro { position: relative; width: 6.5rem; height: 6.5rem; flex: none; perspective: 600px; transform-style: preserve-3d; }
.gyro span { position: absolute; inset: 0; border: 1px solid var(--ink); border-radius: 50%; transform-style: preserve-3d; }
.gyro span:nth-child(1) { animation: gyro-a 14s linear infinite; }
.gyro span:nth-child(2) { inset: 12%; border-color: var(--muted); animation: gyro-b 10s linear infinite; }
.gyro span:nth-child(3) { inset: 25%; border-style: dashed; animation: gyro-c 18s linear infinite; }
.gyro i { position: absolute; left: 50%; top: 50%; width: 0.8rem; height: 0.8rem; margin: -0.4rem; border-radius: 50%; background: var(--red); }

/* Footer */
.foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem 2rem; align-items: center; padding: 1.6rem var(--gutter); border-top: 1px solid var(--line); font-size: 0.9rem; color: var(--muted); }
.foot-id { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.foot-id strong { color: var(--ink); font-weight: 500; }
.foot nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.foot nav a { text-decoration: none; }
.foot nav a:hover { text-decoration: underline; }
.foot-note { grid-column: 1 / -1; margin: 0; font: 400 0.75rem/1.4 var(--mono); }

/* Entrances */
.rise { opacity: 0; transform: translateY(14px); animation: rise 0.9s var(--ease) forwards; animation-delay: calc(0.08s + var(--d, 0) * 0.11s); }
.hero h1 .rise { display: block; }

@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes appear { to { opacity: var(--o, 1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes flow { from { stroke-dashoffset: 0; opacity: 1; } to { stroke-dashoffset: -0.81; opacity: 1; } }
@keyframes drift { from { --spin: -34deg; } to { --spin: -16deg; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes pulse { from { transform: scale(1); opacity: 0.8; } to { transform: scale(2.6); opacity: 0; } }
@keyframes gyro-a { from { transform: rotateX(70deg) rotateZ(0); } to { transform: rotateX(70deg) rotateZ(360deg); } }
@keyframes gyro-b { from { transform: rotateY(65deg) rotateX(0); } to { transform: rotateY(65deg) rotateX(360deg); } }
@keyframes gyro-c { from { transform: rotateX(20deg) rotateY(0); } to { transform: rotateX(20deg) rotateY(360deg); } }

/* Responsive */
@media (max-width: 64rem) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .net { order: 2; }
  .stage { --s: 0.8; }
}
@media (max-width: 44rem) {
  .top { flex-wrap: wrap; gap: 0.6rem 1rem; }
  .nav { margin-left: auto; gap: 1rem; }
  .langs { width: 100%; justify-content: flex-end; margin-top: -0.2rem; }
  .stage { --s: 0.66; }
    .facts div { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .inner { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .inner-art { order: -1; justify-content: flex-end; padding: 0; margin-bottom: -3.5rem; }
  .inner-art .gyro { position: relative; top: 0; width: 4.5rem; height: 4.5rem; }
  .foot { grid-template-columns: minmax(0, 1fr); }
  .label .name { font-size: 1.15rem; }
  .future .label .name { font-size: 0.9rem; }
  .live .label .field { display: none; }
  .label .name { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rise { opacity: 1; transform: none; }
  .bill, .flow { opacity: 1; }
  .pin, .node::before { opacity: var(--o); }
  .wire { stroke-dashoffset: 0; }
}

/* Home: dossier sections */
.doc { padding: clamp(2.5rem, 6vw, 5rem) var(--gutter); border-top: 1px solid var(--line); }
.doc > h2 { font: 400 clamp(2rem, 4vw, 3rem)/1.05 var(--serif); max-width: 24ch; margin-bottom: 1.2rem; }
.doc-lead { max-width: 46rem; font-size: 1.08rem; line-height: 1.65; margin: 0 0 2.4rem; }
.group { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1rem 3.5rem; padding: 2rem 0; border-top: 1px solid var(--line); }
.group-head h3 { font: 400 1.6rem/1.15 var(--serif); margin: 0.7rem 0 0.8rem; }
.group-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.items { margin: 0; }
.items div { padding: 0.9rem 0; border-top: 1px solid var(--line); }
.items div:first-child { border-top: 0; padding-top: 0; }
.items dt { font-weight: 600; margin-bottom: 0.25rem; }
.items dd { margin: 0; color: var(--muted); line-height: 1.6; max-width: 44rem; }
.doc > .items { max-width: 52rem; }
.table-wrap { overflow-x: auto; }
.doc table { width: 100%; border-collapse: collapse; min-width: 36rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 0.9rem 1.2rem 0.9rem 0; border-top: 1px solid var(--line); line-height: 1.5; }
.doc thead th { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-top: 0; }
.doc tbody th { font-weight: 600; }
.doc td:last-child { color: var(--muted); }
.units { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 3rem; }
.units li { padding: 1.4rem 0; border-top: 1px solid var(--line); }
.units a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1rem; text-decoration: none; }
.units .name { font: 400 1.6rem/1.1 var(--serif); }
.units a:hover .name { color: var(--red-text); }
.units .field { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.units p { margin: 0.7rem 0 0; color: var(--muted); line-height: 1.6; }
.labs { margin: 0; padding-left: 1.2rem; max-width: 46rem; }
.labs li { padding: 0.4rem 0; line-height: 1.6; }
.notice { padding: 0 var(--gutter) clamp(2.5rem, 6vw, 4rem); margin: 0; color: var(--muted); font-size: 0.92rem; max-width: 46rem; }
@media (max-width: 860px) {
  .group, .units { grid-template-columns: minmax(0, 1fr); }
}
