/* Exo 2 for the name, self-hosted under the SIL Open Font License 1.1 (see NOTICE); the interface
   uses the site's faces (assets/css/fonts.css): Geist, Geist Mono for numbers, Geist Serif for the phase. */
@font-face { font-family: "Exo 2"; src: url("fonts/exo-2-latin-200-normal.woff2") format("woff2"); font-weight: 200; font-style: normal; font-display: swap; }
@font-face { font-family: "Exo 2"; src: url("fonts/exo-2-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Exo 2"; src: url("fonts/exo-2-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Exo 2"; src: url("fonts/exo-2-latin-200-italic.woff2") format("woff2"); font-weight: 200; font-style: italic; font-display: swap; }

/* Stellar Explorer. The site's surfaces and meaning colours, light and dark tuned apart; the star
   always stands on a dark plate. Every plot is a canvas drawn at device resolution, its axis titles
   KaTeX placed over it. Type: 13 px floor, 12 px for axis ticks only. */
:root {
  color-scheme: light dark;
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --serif: "Geist Serif", "Source Serif 4", Georgia, serif;
  --font-display: "Exo 2", var(--sans);

  --raised: light-dark(#fbfaf6, #1c1a18);
  --base: light-dark(#f3f0eb, #121110);
  --alt: light-dark(#f0ede7, #191715);
  --line: light-dark(#dcd8d2, #2b2926);
  --line-strong: light-dark(#bbb7b1, #46433f);
  --ink: light-dark(#1c1a18, #ebe8e3);
  --ink-2: light-dark(#4a4743, #bcb8b2);
  --muted: light-dark(#66635e, #9a968f);
  --fig: light-dark(#3f3d3a, #cdc9c3);
  --mark: light-dark(#1b5fd6, #7cb8ff);
  --flow: light-dark(#8a6a1f, #d8b768);
  --mark-soft: color-mix(in oklab, var(--mark) 12%, transparent);
  --plate: #0f0e0d;
  --plate-ink: #e9e5de;
  --plate-ink-2: #b9b3aa;

  --head-h: 46px;
  --stats-h: 44px;
  --strip-h: 70px;
  --r: 6px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

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

html { background: var(--base); }
body {
  min-height: 100vh;
  background: var(--base);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--mark); text-decoration: none; }
a:hover { text-decoration: underline; }
canvas { display: block; width: 100%; height: 100%; }
.katex { font-size: 1em; }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }

/* ---------------------------------------------------------------- loading screen */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: var(--plate); color-scheme: dark;
  transition: opacity .35s ease;
}
#overlay.hidden { opacity: 0; pointer-events: none; }
.ov-logo {
  font-family: var(--font-display); font-size: 40px; font-weight: 200; font-style: italic;
  color: #d8b768; letter-spacing: .15em; text-transform: uppercase;
}
.ov-logo strong { font-weight: 600; font-style: normal; color: #fff; }
.ov-sub { font-family: var(--mono); font-size: 13px; color: var(--plate-ink-2); letter-spacing: .12em; text-transform: uppercase; }
.spin-ring {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid #3a3733; border-top-color: #d8b768;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#ov-msg { font-family: var(--mono); font-size: 13px; color: #d8b768; letter-spacing: .06em; min-height: 18px; text-align: center; }
#ov-bar { width: 220px; height: 2px; background: #2b2926; overflow: hidden; }
#ov-bar i { display: block; height: 100%; width: 0; background: #d8b768; transition: width .2s; }
@media (prefers-reduced-motion: reduce) { .spin-ring { animation-duration: 2s; } }

/* ---------------------------------------------------------------- frame: one screen on a desktop */
#app { display: none; }
#app.visible {
  display: grid; height: 100vh; height: 100dvh; min-height: 640px;
  grid-template-rows: var(--head-h) var(--stats-h) var(--strip-h) minmax(0, 1fr);
}

#header {
  display: flex; align-items: center; gap: 18px; min-width: 0;
  padding: 0 14px 0 16px;
  background: var(--raised); border-bottom: 1px solid var(--line);
}
.logo {
  font-family: var(--font-display); font-weight: 200; font-style: italic; font-size: 21px;
  color: var(--flow); letter-spacing: .15em; text-transform: uppercase; white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo strong { font-weight: 600; font-style: normal; color: var(--ink); margin-right: 6px; }
.header-sub { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.header-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 32px; height: 30px; padding: 0 10px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r); background: var(--raised);
  transition: color .12s, border-color .12s, background .12s;
}
.btn:hover { color: var(--ink); border-color: var(--line-strong); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.on, .btn[aria-pressed="true"] { color: var(--mark); border-color: color-mix(in oklab, var(--mark) 55%, var(--line)); background: var(--mark-soft); }
.btn-s { min-width: 28px; height: 26px; padding: 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; height: 28px; min-width: 30px; padding: 0 10px; }
.seg .btn + .btn { border-left: 1px solid var(--line); }
.seg .btn .katex { font-size: 14px; }
#btn-theme .i-moon { display: none; }
:root[data-theme="light"] #btn-theme .i-sun { display: none; }
:root[data-theme="light"] #btn-theme .i-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) #btn-theme .i-sun { display: none; }
  :root:not([data-theme]) #btn-theme .i-moon { display: block; }
}

/* ---------------------------------------------------------------- stats */
#stats {
  display: flex; align-items: stretch; min-width: 0;
  padding: 0 6px;
  background: var(--raised); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
#stats::-webkit-scrollbar { display: none; }
.stat {
  display: flex; align-items: baseline; align-self: center; gap: 6px;
  padding: 0 13px; border-right: 1px solid var(--line); white-space: nowrap; line-height: 1.2;
}
.stat:last-of-type { border-right: 0; }
.stat-lbl { font-size: 14px; color: var(--muted); }
.stat-lbl .katex { font-size: 15px; color: var(--muted); }
.stat-val { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-unit { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.stat-phase { padding-left: 10px; }
.stat-phase .stat-val { font-family: var(--serif); font-size: 19px; font-weight: 500; letter-spacing: 0; }
.stat-phase::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--phase, var(--ink)); align-self: center; flex: none; }

/* ---------------------------------------------------------------- timeline strip */
#strip { position: relative; background: var(--raised); border-bottom: 1px solid var(--line); cursor: crosshair; touch-action: none; min-width: 0; }
#strip .ax { position: absolute; left: 8px; top: 50%; transform: translateY(-20%); font-size: 13px; color: var(--muted); pointer-events: none; }
#strip .ax .katex { font-size: 13px; }
#strip-readout { position: absolute; right: 10px; top: 3px; font-family: var(--mono); font-size: 13px; color: var(--ink-2); pointer-events: none; }

/* ---------------------------------------------------------------- main grid */
#main {
  min-height: 0; min-width: 0;
  display: grid; gap: 1px; background: var(--line);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.95fr);
  grid-template-rows: minmax(0, 1.14fr) minmax(0, 0.86fr);
  grid-template-areas: "hr int osc" "prof prof osc";
}
#panel-hr { grid-area: hr; }
#panel-int { grid-area: int; }
#panel-prof { grid-area: prof; }
#panel-osc { grid-area: osc; }
.panel { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--raised); }
.phead {
  display: flex; align-items: center; gap: 12px;
  height: 34px; padding: 0 8px 0 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.ptitle { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.readout { font-family: var(--mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.readout .katex { font-size: 14px; }
.rd-sep { margin: 0 8px; color: var(--muted); }
.pctl { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pbody { position: relative; flex: 1; min-height: 0; }
.pbody > canvas { position: absolute; inset: 0; }

/* axis titles over a canvas */
.ax { position: absolute; font-size: 13px; color: var(--ink-2); pointer-events: none; }
.ax .katex { font-size: 14px; color: var(--ink-2); }
.ax-x { right: 10px; bottom: 5px; }
.ax-y { left: 10px; top: 6px; }
#hr-body .ax-x { bottom: 28px; }

/* small multiples */
.grid { display: grid; gap: 1px; background: var(--line); position: absolute; inset: 0; }
.grid-3x2 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.grid-osc { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 0.9fr); }
.grid-osc #sm-prop, .grid-osc #sm-eigen { grid-column: 1 / -1; }
.sm { position: relative; min-width: 0; min-height: 0; background: var(--raised); overflow: hidden; }
.sm > canvas { position: absolute; inset: 0; }
.sm .ax-y { left: 10px; top: 5px; }
.sm .ax-x { right: 8px; bottom: 3px; }
.sm-val { position: absolute; right: 10px; top: 6px; font-family: var(--mono); font-size: 13px; color: var(--ink); pointer-events: none; white-space: nowrap; }
.sm-note { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); text-align: center; padding: 12px; pointer-events: none; }
.sm-zoom {
  position: absolute; right: 6px; bottom: 24px; width: 26px; height: 26px; border-radius: var(--r);
  display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent; opacity: 0; transition: opacity .12s, color .12s;
}
.sm:hover .sm-zoom, .sm-zoom:focus-visible, .sm.is-max .sm-zoom { opacity: 1; }
.sm-zoom:hover { color: var(--ink); border-color: var(--line); background: var(--raised); }
.sm-zoom svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.grid.has-max .sm { display: none; }
.grid.has-max .sm.is-max { display: block; grid-column: 1 / -1; grid-row: 1 / -1; }

/* interior: a dark plate in both themes */
#panel-int .pbody { background: var(--plate); color-scheme: dark; }
#int-gl, #int-canvas { position: absolute; inset: 0; }
#int-legend {
  position: absolute; left: 14px; bottom: 12px; display: grid; gap: 6px;
  font-size: 13px; color: var(--plate-ink-2); pointer-events: none;
}
#int-legend div { display: flex; align-items: center; gap: 8px; }
#int-legend svg { width: 26px; height: 14px; flex: none; }

/* info sheet */
#info {
  position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-start; justify-content: center;
  padding: 60px 16px; background: rgb(12 11 10 / .6); overflow: auto;
}
#info.open { display: flex; }
.sheet {
  width: min(680px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 26px 30px;
  font-size: 16px; color: var(--ink); line-height: 1.55;
}
.sheet h2 { font-family: var(--font-display); font-weight: 400; font-size: 22px; letter-spacing: .06em; margin-bottom: 12px; }
.sheet h3 { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 20px 0 6px; }
.sheet p + p { margin-top: 8px; }
.sheet dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.sheet dt { font-family: var(--mono); font-size: 14px; color: var(--mark); padding-top: 2px; }
.sheet kbd { font-family: var(--mono); font-size: 13px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--alt); }
.sheet .close { float: right; margin: -8px -12px 0 0; }

#mnav { display: none; }

/* ---------------------------------------------------------------- narrower desktops */
@media (max-width: 1500px) {
  .stat { padding: 0 9px; }
}
@media (max-width: 1400px) {
  .header-sub { display: none; }
  .stat { padding: 0 8px; }
}

/* ---------------------------------------------------------------- tablets and phones: one column that scrolls */
@media (max-width: 1100px) {
  #app.visible { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
  #header { position: sticky; top: 0; z-index: 30; height: auto; min-height: var(--head-h); flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .header-nav { margin-left: 0; flex-wrap: wrap; }
  #stats {
    height: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px 6px; gap: 4px 0;
  }
  .stat { border-right: 0; padding: 3px 8px; flex-direction: column; align-items: flex-start; align-self: start; gap: 1px; }
  .stat-phase { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; padding-bottom: 6px; }
  #strip { height: 76px; flex: none; }
  #main { display: flex; flex-direction: column; gap: 1px; }
  .panel { flex: none; }
  .pbody { flex: none; }
  .btn .lbl { display: none; }
  #panel-int { order: -1; }
  .phead { height: auto; min-height: 40px; flex-wrap: wrap; row-gap: 2px; padding: 6px 8px 6px 14px; }
  .phead .readout { order: 3; flex-basis: 100%; white-space: normal; padding-bottom: 2px; }
  #panel-int .pbody { height: min(100vw, 560px); }
  #panel-hr .pbody { height: min(78vw, 460px); }
  #panel-prof .pbody { height: 680px; }
  .grid-3x2 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  #panel-osc .pbody { height: 980px; }
  .grid-osc { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(4, minmax(0, 1fr)); }
  .sm-zoom { opacity: 1; }
  #mnav {
    position: sticky; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--raised); border-top: 1px solid var(--line);
  }
  #mnav a { padding: 12px 4px; text-align: center; font-size: 14px; font-weight: 500; color: var(--ink-2); }
  #mnav a:hover { color: var(--mark); text-decoration: none; }
  .sheet { padding: 20px; font-size: 15px; }
  .sheet dl { grid-template-columns: 1fr; gap: 2px; }
  .sheet dd { margin-bottom: 8px; }
}
@media (max-width: 480px) {
  .logo { font-size: 18px; }
}

/* ---------------------------------------------------------------- phones: every tap target 44 px or more.
   The header's controls join the header's own flex line (display: contents) and break into two rows:
   the name with theme and help, then the radius axis, pulsation and model stepping. */
@media (max-width: 760px) {
  #header { row-gap: 0; padding: 4px 10px 8px; }
  .header-nav { display: contents; }
  .logo { order: 0; display: inline-flex; align-items: center; min-height: 44px; }
  #btn-theme { order: 1; margin-left: auto; }
  #btn-info { order: 1; }
  #header::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .header-nav > :not(#btn-theme, #btn-info) { order: 3; }
  .header-nav > .seg, .header-nav > .btn { margin-top: 2px; }
  .sep { display: none; }
  .btn, .btn-s { min-width: 44px; height: 44px; padding: 0 10px; }
  .seg .btn { height: 44px; min-width: 44px; padding: 0 10px; }
  .pctl { gap: 6px; }
  #app #main .phead .lb-ctl { inline-size: 44px; block-size: 44px; }
  .sm-zoom { width: 44px; height: 44px; right: 0; bottom: 16px; }
  #mnav a { padding: 0 4px; min-height: 48px; display: flex; align-items: center; justify-content: center; }
  .sheet .close { margin: -12px -14px 0 0; }
}
