@import url('./tokens.css');

@font-face {
  font-family: Manrope;
  src: url('./assets/manrope.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

* { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--dim) var(--bg);
}
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
::selection { background: var(--accent); color: var(--bg); }
[hidden] { display: none !important; }
svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
p, h1, h2, h3, figure { margin: 0; }
h1, h2, h3 {
  min-width: 0;
  color: inherit;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.04em;
  overflow-wrap: break-word;
  text-wrap: balance;
}
p { text-wrap: pretty; }
.container { width: min(calc(100% - var(--gutter) * 2), var(--container)); margin-inline: auto; }

.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  transform: translateY(-180%);
  padding: 10px 18px;
  color: var(--bg);
  background: var(--accent);
}
.skip:focus { transform: translateY(0); }
.site-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(14px, 3vw, 48px);
  position: relative;
  z-index: 2;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 750;
  letter-spacing: -.035em;
}
.brand svg { width: 35px; height: 35px; stroke-width: 1.15; }
.brand svg circle { fill: var(--solar); stroke: none; }
.brand svg .brand-moon { fill: var(--accent); }
.desktop-nav { display: flex; gap: clamp(16px, 3vw, 42px); margin-left: auto; font-size: .875rem; color: var(--muted); }
.desktop-nav a { padding-block: 12px; }
.desktop-nav a:hover, .desktop-nav a[aria-current] { color: var(--ink); }
.desktop-nav a[aria-current] { text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--accent); }
.language-switch { display: flex; flex-shrink: 0; gap: 2px; }
.language-switch a {
  display: grid;
  min-width: 42px;
  min-height: 44px;
  place-items: center;
  padding: 4px;
  border-radius: 6px;
  font-size: .8rem;
  color: var(--muted);
}
.language-switch a:hover { color: var(--ink); }
.language-switch a[aria-current] { color: var(--accent); background: var(--surface-raised); }
.mobile-nav .language-switch { margin-top: 8px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.mobile-nav .language-switch a { display: grid; }
.header-cta, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 650;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}
.header-cta svg, .button svg { width: 18px; height: 18px; }
.header-cta:hover, .quiet:hover { background: var(--surface-raised); border-color: var(--accent); }
.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); min-height: 56px; padding-inline: 20px; }
.primary:hover { color: var(--accent-ink); background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-2px); }
.button:active { transform: translateY(1px); }
.menu-button { display: none !important; }
.mobile-nav {
  width: min(calc(100% - var(--gutter) * 2), var(--container));
  margin-inline: auto;
  padding: 12px 18px;
  margin-bottom: 12px;
  background: var(--surface);
  border-radius: 8px;
}
.mobile-nav a { display: flex; align-items: center; min-height: 48px; padding-inline: 8px; }

.hero {
  position: relative;
  overflow: clip;
  isolation: isolate;
  background: radial-gradient(ellipse at 76% 48%, var(--sky-bloom), transparent 58%),
    radial-gradient(ellipse at 98% 12%, var(--sky-violet), transparent 55%), var(--bg);
  border-top: 1px solid var(--line-soft);
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(0, 1.5fr);
  align-items: center;
  min-height: clamp(530px, 76svh, 760px);
}
.hero-copy { position: relative; z-index: 2; padding-block: 48px; }
.hero h1 { font-size: clamp(3.25rem, 6.45vw, 6rem); line-height: .98; }
.hero-copy p { max-width: 28ch; margin: 24px 0 28px; font-size: clamp(1rem, 1.25vw, 1.22rem); color: var(--muted); }
.hero-secondary {
  display: block;
  width: fit-content;
  margin-top: 14px;
  min-height: 38px;
  padding-block: 6px;
  font-size: .875rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 5px;
}
.hero-secondary:hover { color: var(--ink); }
.orbit-stage {
  position: relative;
  min-width: 0;
  align-self: stretch;
  margin-inline: clamp(-78px, -5vw, -28px) calc(var(--gutter) * -.7);
}
.orbit-stage canvas, .orbit-still { width: 100%; height: 100%; position: absolute; inset: 0; display: block; }
.orbit-stage canvas { visibility: hidden; touch-action: pan-y; outline-offset: -6px; }
.orbit-still { object-fit: contain; }
.orbit-stage.has-scene canvas { visibility: visible; }
.orbit-stage.has-scene .orbit-still { visibility: hidden; }
.scene-top {
  display: flex;
  position: absolute;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  top: clamp(22px, 4vw, 56px);
  left: 13%;
  right: 6%;
  color: var(--muted);
  font-size: .82rem;
  pointer-events: none;
}
.scene-top::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 8px);
  height: 1px;
  background: var(--line);
}
.scene-scale { text-align: right; color: var(--dim); }
.planet-info {
  position: absolute;
  left: 13%;
  bottom: 20px;
  max-width: 80%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: .875rem;
  pointer-events: none;
}
.planet-info:empty { display: none; }
.hero-bottom {
  display: flex;
  visibility: hidden;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding-block: 8px;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}
.hero:has(.has-scene) .hero-bottom { visibility: visible; }
.cursor-hint, .scene-tools { display: flex; align-items: center; gap: 10px; }
.cursor-hint svg { width: 18px; height: 18px; color: var(--accent); }
.speed-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: color 180ms var(--ease), background-color 180ms var(--ease), border-color 180ms var(--ease);
}
.speed-button { font-family: var(--font-data); font-size: .875rem; }
.icon-button svg { width: 19px; height: 19px; }
.icon-button:hover, .speed-button:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-raised); }
.scene-pause[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.section { padding-block: clamp(68px, 9vw, 144px); }
.experiments-section { background: var(--paper); color: var(--paper-ink); color-scheme: light; }
.section-heading { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); align-items: end; gap: var(--gap); margin-bottom: clamp(28px, 4vw, 56px); }
.section-heading h2, .about-section h2 { font-size: clamp(2.35rem, 4.8vw, 4.4rem); line-height: 1.01; }
.section-heading p { max-width: 36ch; color: var(--muted); }
.experiments-section .section-heading p { color: var(--paper-muted); }
.experiments-section a:focus-visible { outline-color: var(--paper-focus); }
.experiment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 4vw, 56px) var(--gap); }
.experiment {
  min-width: 0;
  position: relative;
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}
.experiments-section .experiment { border-color: var(--paper-line); }
.experiment:first-child { grid-column: 1/-1; grid-template-columns: minmax(0, .58fr) minmax(0, 1fr); align-content: center; column-gap: var(--gap); align-items: center; }
.experiment-preview {
  position: relative;
  aspect-ratio: 1.7;
  background: radial-gradient(ellipse at center, var(--surface-raised), var(--surface));
  border-radius: 12px;
  overflow: clip;
  color: var(--ink);
  color-scheme: dark;
}
.experiment:first-child .experiment-preview { grid-column: 2; grid-row: 1/4; aspect-ratio: 1.65; }
.experiment-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 500ms var(--ease);
}
.preview-tag { position: absolute; top: 16px; left: 16px; font-size: .82rem; color: var(--muted); }
.experiment-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0 8px; }
.experiment-title h3 { font-size: clamp(1.75rem, 3vw, 3rem); }
.experiment-title svg, .row-arrow { width: 22px; height: 22px; color: currentColor; transition: transform 220ms var(--ease); }
.experiment:hover .experiment-title svg, .experiment:focus-visible .experiment-title svg { transform: translate(3px,-3px); }
.experiment:hover .experiment-preview canvas, .experiment:focus-visible .experiment-preview canvas { transform: scale(1.07); }
.experiment > p, .experiment-meta { color: var(--muted); }
.experiments-section .experiment > p, .experiments-section .experiment-meta { color: var(--paper-muted); }
.experiment-meta { display: block; margin-top: 10px; font-size: .82rem; }

.phenomena-section { padding-block: clamp(68px, 9vw, 144px); }
.phenomena-list { border-top: 1px solid var(--line); }
.phenomenon-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1.1fr) minmax(0, .65fr) 24px;
  align-items: center;
  gap: var(--gap);
  min-height: 156px;
  border-bottom: 1px solid var(--line);
  transition: background-color 220ms var(--ease);
}
.phenomenon-row:hover, .phenomenon-row:focus-visible { background: var(--surface); }
.phenomenon-symbol { color: var(--accent); }
.phenomenon-symbol svg { width: 92px; height: 65px; stroke-width: 1; }
.phenomenon-row h3 { font-size: clamp(1.42rem, 2.4vw, 2.2rem); }
.phenomenon-row p { font-size: .9rem; color: var(--muted); }
.phenomenon-row:hover .row-arrow { transform: translateX(3px); color: var(--accent); }
.about-section {
  display: grid;
  grid-template-columns: minmax(0, .65fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: center;
  padding: clamp(28px, 6vw, 86px);
  margin-bottom: clamp(70px, 9vw, 128px);
  background: var(--surface);
  border-radius: 12px;
}
.about-orbit { display: grid; place-items: center; color: var(--accent); }
.about-orbit svg { width: min(100%, 260px); height: auto; stroke-width: .55; }
.about-section p { color: var(--muted); margin-top: 22px; max-width: 54ch; }
.text-link { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); margin-top: 20px; min-height: 44px; font-size: .95rem; }
.text-link:hover { text-decoration: underline; text-underline-offset: 5px; }
.text-link svg { width: 18px; height: 18px; }

.site-footer { border-top: 1px solid var(--line); padding-block: 24px; }
.footer-top, .footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-top { padding-bottom: 24px; color: var(--muted); }
.footer-top .brand { color: var(--ink); }
.footer-top > a:last-child { font-size: .875rem; }
.footer-bottom { border-top: 1px solid var(--line-soft); padding-top: 18px; font-size: .82rem; color: var(--muted); }
.back-top { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.back-top svg { width: 16px; height: 16px; }
.noscript { padding-block: 18px; color: var(--muted); }

.route-intro { padding-top: clamp(28px, 5vw, 64px); margin-bottom: clamp(24px, 4vw, 52px); }
.breadcrumb { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); margin-bottom: 18px; font-size: .875rem; }
.breadcrumb:hover { color: var(--ink); }
.breadcrumb svg { width: 17px; height: 17px; transform: rotate(180deg); }
.route-intro h1, .not-found h1 { font-size: clamp(2.6rem, 6.2vw, 5.6rem); max-width: 20ch; }
.route-intro > p { color: var(--muted); margin-top: 18px; max-width: 61ch; }
.route-list { padding-bottom: clamp(64px, 8vw, 120px); }
.lab-tabs { display: flex; flex-wrap: wrap; gap: 0 24px; margin-block: 18px 28px; border-bottom: 1px solid var(--line); }
.lab-tabs a { display: inline-flex; align-items: center; min-height: 48px; padding-block: 8px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lab-tabs a[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.lab-tabs a:hover { color: var(--ink); }
.lab-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, 305px); gap: var(--gap); padding-bottom: 24px; }
.lab-view { min-width: 0; }
.lab-canvas-wrap {
  position: relative;
  height: clamp(365px, 47vw, 610px);
  background: radial-gradient(ellipse at center, var(--surface-raised), var(--surface));
  border: 1px solid var(--line);
  border-radius: 12px;
}
.lab-canvas-wrap canvas { display: block; width: 100%; height: 100%; }
.lab-canvas-caption { position: absolute; inset: 15px 18px auto; font-size: .84rem; color: var(--muted); pointer-events: none; }
.lab-toolbar, .toolbar-actions, .lab-play { display: flex; align-items: center; gap: 12px; }
.lab-toolbar { min-height: 68px; justify-content: space-between; font-size: .82rem; color: var(--muted); }
.lab-play { padding: 8px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: .875rem; }
.lab-play:hover { border-color: var(--accent); color: var(--accent); }
.lab-play svg { width: 16px; height: 16px; }
.lab-controls { padding: 24px; background: var(--surface); border-radius: 12px; align-self: start; }
.lab-controls h2 { font-size: 1.35rem; margin-bottom: 24px; }
.range-field { display: block; margin-bottom: 22px; }
.range-label { display: flex; justify-content: space-between; gap: 8px; font-size: .875rem; }
.range-label output { flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--accent); }
input[type="range"] { display: block; width: 100%; min-height: 28px; margin: 4px 0 0; accent-color: var(--accent); cursor: pointer; }
.range-bounds { display: flex; justify-content: space-between; font-size: .82rem; color: var(--dim); }
.preset-label { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { min-height: 44px; padding: 6px 10px; background: transparent; border: 1px solid var(--line); border-radius: 6px; font-size: .82rem; }
.presets button:hover { color: var(--accent); border-color: var(--accent); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.metric { min-width: 0; padding: 14px 12px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.metric-value { font-size: clamp(1.15rem, 2.7vw, 1.65rem); font-variant-numeric: tabular-nums; }
.metric-unit { font-size: .8rem; color: var(--muted); margin-left: 4px; }
.lab-note { display: flex; justify-content: space-between; align-items: start; gap: 24px; padding-bottom: 64px; color: var(--muted); font-size: .9rem; }
.lab-note p { max-width: 68ch; }
.lab-note .text-link { margin-top: 0; flex-shrink: 0; }
.article-top, .explanation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: end; }
.article-top p, .explanation p { max-width: 62ch; color: var(--muted); }
.article-top h1 { font-size: clamp(2.45rem, 5vw, 4.6rem); }
.article-diagram { margin-bottom: 32px; }
.explanation { padding-bottom: 74px; align-items: start; }
.explanation h2 { font-size: clamp(2rem, 4.1vw, 3.65rem); }
.explanation p { margin-bottom: 14px; }
.formula { font-family: var(--font-data); color: var(--accent); font-size: clamp(1.25rem, 4vw, 2.35rem); margin-bottom: 12px; }
.formula-note { font-size: .84rem; }
.not-found { padding-block: 74px; }
.not-found p { margin-top: 20px; color: var(--muted); }
.route-about { padding-top: 24px; }

@media (max-width: 900px) {
  .desktop-nav, .site-header > .language-switch { display: none; }
  .menu-button { display: inline-flex !important; }
  .header-cta { margin-left: auto; }
  .hero-grid { min-height: 0; grid-template-columns: minmax(0, 1fr); }
  .hero-copy { padding: 40px 0 8px; }
  .hero h1 { font-size: clamp(3.25rem, 10vw, 5.5rem); }
  .hero-copy p { margin: 16px 0 20px; }
  .orbit-stage { min-height: clamp(320px, 58vw, 530px); margin: -12px calc(var(--gutter) * -.65) 0; }
  .scene-top { top: 28px; inset-inline: 6%; }
  .planet-info { left: 6%; }
  .lab-layout { grid-template-columns: minmax(0, 1fr) minmax(220px, 265px); }
  .lab-controls { padding: 18px; }
}
@media (max-width: 640px) {
  .site-header { min-height: 72px; gap: 8px; }
  .brand { font-size: 1.3rem; gap: 7px; }
  .brand svg { width: 29px; height: 29px; }
  .header-cta { padding-inline: 10px; font-size: .8rem; }
  .header-cta svg { display: none; }
  .hero-copy { padding-top: 32px; }
  .hero h1 { font-size: clamp(2.7rem, 11vw, 4.1rem); }
  .hero-secondary { margin-top: 8px; }
  .orbit-stage { min-height: clamp(272px, 70vw, 380px); margin-top: 4px; }
  .scene-top { top: 16px; font-size: .76rem; }
  .planet-info { bottom: 8px; }
  .hero-bottom { flex-wrap: wrap; gap: 8px; padding-block: 12px; }
  .scene-tools { margin-left: auto; }
  .section-heading, .experiment-grid, .about-section, .lab-layout, .article-top, .explanation { grid-template-columns: minmax(0, 1fr); }
  .section-heading { gap: 14px; align-items: start; }
  .experiment:first-child { display: block; }
  .experiment:first-child .experiment-preview, .experiment-preview { aspect-ratio: 1.35; }
  .experiment-title { margin-top: 14px; }
  .phenomenon-row { grid-template-columns: 44px minmax(0, 1fr) 18px; min-height: 120px; gap: 5px 12px; padding-block: 20px; }
  .phenomenon-symbol { grid-row: 1/3; }
  .phenomenon-symbol svg { width: 44px; height: 42px; }
  .phenomenon-row h3 { grid-column: 2; grid-row: 1; }
  .phenomenon-row p { grid-column: 2; grid-row: 2; font-size: .84rem; }
  .phenomenon-row .row-arrow { grid-column: 3; grid-row: 1/3; width: 18px; }
  .about-section { gap: 24px; }
  .about-orbit { justify-content: start; }
  .about-orbit svg { width: 100px; }
  .footer-top, .footer-bottom { gap: 10px; }
  .footer-top > span { flex-basis: 100%; order: 3; }
  .lab-canvas-wrap { height: clamp(295px, 90vw, 400px); }
  .lab-toolbar { gap: 6px; }
  .toolbar-actions { gap: 6px; }
  .metric { padding-inline: 8px; }
  .lab-note { display: block; }
  .lab-note .text-link { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .experiment:hover .experiment-preview canvas, .experiment:focus-visible .experiment-preview canvas { transform: none; }
}
