/* GoStargazing — science page styles.
 *
 * Two-track layout: a layman explanation (`.track-layman`) that anyone
 * can read, and a technically precise track (`.track-technical`) inside
 * collapsible <details> elements that cite revision units, formulas,
 * and primary literature.
 *
 * Consumes tokens from tokens.css. Mirrors the visual idiom of
 * observatory/report (corner frames, top-nav, mono labels, serif body,
 * dark parchment surface).
 *
 * Sections are anchored by stable IDs (`#why-scores`, `#windows`, ...)
 * so the table of contents and external links remain durable.
 *
 * Print stylesheet at the bottom expands all <details>, drops the
 * fixed chrome, and tightens spacing so the page reads cleanly as PDF.
 */

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

html, body { overflow-x: hidden; }
body {
  min-height: 100vh;
  padding: 0;
  font-family: inherit;
}

/* Corner frame — shared with demo/observatory */
.corner { position: fixed; width: 14px; height: 14px; border: 1px solid var(--border-strong); pointer-events: none; z-index: 5; }
.corner.tl { top: 10px; left: 10px;  border-right: none;  border-bottom: none; }
.corner.tr { top: 10px; right: 10px; border-left: none;   border-bottom: none; }
.corner.bl { bottom: 10px; left: 10px;  border-right: none; border-top: none; }
.corner.br { bottom: 10px; right: 10px; border-left: none;  border-top: none; }

.top-nav {
  position: fixed; top: 18px; right: 24px; z-index: 30;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.top-nav-link {
  font-family: inherit; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-dim); text-decoration: none;
  padding: 6px 10px; border: 1px solid var(--border);
  background: var(--panel);
  transition: color 0.15s, border-color 0.15s;
}
.top-nav-link:hover { color: var(--accent); border-color: var(--accent-dim); }
.top-nav-link.active { color: var(--accent); border-color: var(--accent-dim); }

.nav-back {
  position: fixed; top: 18px; left: 24px; z-index: 30;
  font-family: inherit; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-dim); text-decoration: none;
  padding: 6px 10px; border: 1px solid var(--border);
  background: var(--panel);
}
.nav-back:hover { color: var(--accent); border-color: var(--accent-dim); }

/* ----- Page layout ----------------------------------------------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 120px 32px 120px;
}

.hero {
  text-align: center;
  margin-bottom: 72px;
}
.hero-eyebrow {
  font-size: 9px; color: var(--ink-faint);
  letter-spacing: 0.4em; text-transform: uppercase;
  margin-bottom: 14px;
}
.hero-title {
  font-family: 'Instrument Serif', serif;
  font-size: 52px; line-height: 1.05; font-style: italic;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.hero-sub {
  font-family: 'Instrument Serif', serif;
  font-size: 19px; line-height: 1.5;
  color: var(--ink-dim);
  font-style: italic;
  max-width: 620px; margin: 0 auto;
}

.hero-meta {
  margin-top: 26px;
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--ink-faint);
}
.hero-meta .chip {
  padding: 4px 9px; border: 1px solid var(--border);
}
.hero-meta .chip strong { color: var(--accent); font-weight: 500; }

/* ----- Table of contents ----------------------------------------- */

.science-toc {
  margin: 56px auto 72px;
  max-width: 720px;
  padding: 22px 28px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.science-toc-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.35em; text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.science-toc ol {
  list-style: decimal-leading-zero;
  padding-left: 28px;
  margin: 0;
  font-family: 'Instrument Serif', serif;
  font-size: 15px; line-height: 1.6;
  color: var(--ink-dim);
  columns: 2;
  column-gap: 28px;
}
.science-toc li::marker {
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.science-toc a {
  color: var(--ink);
  border-bottom: 1px solid transparent;
}
.science-toc a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

/* ----- Sections -------------------------------------------------- */

section {
  margin: 80px 0;
  padding-top: 56px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 80px;
}
section:first-of-type { border-top: none; padding-top: 0; }

.section-eyebrow {
  font-size: 9px; color: var(--ink-faint);
  letter-spacing: 0.4em; text-transform: uppercase;
  margin-bottom: 12px;
}
.section-title {
  font-family: 'Instrument Serif', serif;
  font-size: 34px; line-height: 1.15; font-style: italic;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin: 0 0 28px;
}

/* ----- Two-track layout: layman + technical --------------------- */

/* Default (mobile, < 900px): single stacked column.
   Above 900px: layman lives on the left, technical block on the right,
   roughly two-thirds / one-third so the explanatory prose dominates. */

.track-layman {
  font-family: 'Instrument Serif', serif;
  font-size: 17px; line-height: 1.65;
  color: rgba(232, 230, 223, 0.85);
}
.track-layman p { margin: 0 0 16px; }
.track-layman p:last-child { margin-bottom: 0; }
.track-layman p.lede { font-size: 19px; color: var(--ink); }
.track-layman em, .track-layman i { color: var(--accent); font-style: italic; }
.track-layman strong { color: var(--ink); font-weight: 500; }

.track-technical {
  margin-top: 24px;
  padding: 18px 22px;
  border-left: 2px solid var(--accent-dim);
  background: color-mix(in oklab, var(--accent), transparent 96%);
}
.track-technical[open] { background: color-mix(in oklab, var(--accent), transparent 93%); }
.track-technical > summary {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-dim);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
  user-select: none;
}
.track-technical > summary::-webkit-details-marker { display: none; }
.track-technical > summary::before {
  content: '◇ ';
  color: var(--accent);
  margin-right: 6px;
}
.track-technical[open] > summary::before { content: '◆ '; }
.track-technical > summary:hover { color: var(--ink); }

.track-technical .tech-body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px; line-height: 1.7;
  color: var(--ink-dim);
  margin-top: 14px;
}
.track-technical .tech-body p { margin: 0 0 14px; }
.track-technical .tech-body p:last-child { margin-bottom: 0; }
.track-technical .tech-body strong { color: var(--ink); font-weight: 500; }
.track-technical .tech-body em { color: var(--accent); font-style: italic; }

@media (min-width: 900px) {
  .topic {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    column-gap: 36px;
    align-items: start;
  }
  .topic .track-layman { padding-right: 8px; }
  .topic .track-technical { margin-top: 0; }
}

/* ----- Tags inside topics --------------------------------------- */

.r-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.25em; text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border);
  margin-right: 6px;
  color: var(--ink-faint);
}
.r-tag.phase { color: var(--accent); border-color: var(--accent-dim); }
.r-tag.flag  { color: var(--good); border-color: rgba(120, 180, 80, 0.35); }

/* ----- Code, formulas, tables in technical track ----------------- */

pre, code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
}
pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 14px 0;
  line-height: 1.55;
}
code {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border: 1px solid var(--border);
  font-size: 11.5px;
}
pre code { padding: 0; border: none; background: transparent; font-size: inherit; }

.formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin: 12px 0;
  display: block;
  overflow-x: auto;
}

.tech-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
}
.tech-table th, .tech-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tech-table th {
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 9px;
}
.tech-table td { color: var(--ink-dim); }
.tech-table td.name { color: var(--ink); }

/* ----- References ----------------------------------------------- */

#references ol.refs {
  font-family: 'Instrument Serif', serif;
  font-size: 14px; line-height: 1.6;
  color: var(--ink-dim);
  padding-left: 28px;
  counter-reset: ref;
}
#references ol.refs li {
  margin: 10px 0;
  padding-left: 6px;
}
#references ol.refs li::marker {
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
#references a { color: var(--accent); border-bottom: 1px solid var(--accent-dim); }
#references a:hover { color: var(--ink); border-bottom-color: var(--accent); }

/* ----- Changelog ------------------------------------------------- */

#changelog ul.changelog {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-dim);
  border-top: 1px solid var(--border);
}
#changelog ul.changelog li {
  display: grid;
  grid-template-columns: 140px 1fr;
  column-gap: 22px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
#changelog ul.changelog .ver {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.15em;
}
#changelog ul.changelog .ver.current::after {
  content: ' · CURRENT';
  color: var(--good);
  font-size: 9px;
  letter-spacing: 0.2em;
}

/* ----- Deferred / acknowledged --------------------------------- */

.deferred-list {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  font-family: 'Instrument Serif', serif;
  font-size: 16px;
  line-height: 1.65;
  color: rgba(232, 230, 223, 0.82);
}
.deferred-list li {
  padding: 12px 0 12px 22px;
  border-bottom: 1px dashed var(--border);
  position: relative;
}
.deferred-list li::before {
  content: '○';
  position: absolute;
  left: 0;
  top: 12px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.deferred-list li:last-child { border-bottom: none; }

/* ----- Hero quote outro ----------------------------------------- */

.outro {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  text-align: center;
  padding: 32px 20px;
  margin: 80px 0 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  line-height: 1.45;
}

/* ----- Mobile --------------------------------------------------- */

@media (max-width: 640px) {
  .page { padding: 100px 20px 80px; }
  .hero-title { font-size: 38px; }
  .hero-sub { font-size: 17px; }
  .section-title { font-size: 26px; }
  .top-nav { top: 12px; right: 12px; max-width: calc(100vw - 140px); }
  .nav-back { top: 12px; left: 12px; }
  .science-toc ol { columns: 1; }
  pre, .formula { font-size: 11px; padding: 10px 12px; }
  .track-technical { padding: 14px 16px; }
  #changelog ul.changelog li { grid-template-columns: 1fr; row-gap: 4px; }
}

/* ----- Print stylesheet ----------------------------------------- */

@media print {
  /* Drop fixed chrome and dark background so the page prints
     readably on white paper. */
  .corner, .top-nav, .nav-back { display: none !important; }
  html, body { background: white !important; color: black !important; }
  .page { max-width: none; padding: 24px 32px; }

  .hero-title, .hero-sub, .section-title,
  h1, h2, h3, p, li, td, th {
    color: black !important;
  }
  .hero-eyebrow, .section-eyebrow, .r-tag, .factor-name,
  .track-technical > summary {
    color: #555 !important;
  }

  /* Force every collapsible technical block open for the print
     edition — readers get the complete document offline. */
  details.track-technical { background: transparent !important; border-left: 2px solid #888; }
  details.track-technical[open], details.track-technical:not([open]) {
    background: transparent !important;
  }
  details.track-technical > summary { display: none; }
  details.track-technical .tech-body { display: block !important; color: #333 !important; }

  /* Two-column layout collapses for print to a single column so
     content reads top-to-bottom on the page. */
  .topic { grid-template-columns: 1fr !important; }
  .topic .track-technical { margin-top: 16px !important; }

  pre, code, .formula {
    background: #f5f5f5 !important;
    color: #111 !important;
    border-color: #ccc !important;
  }
  .tech-table th, .tech-table td { border-bottom-color: #ccc !important; }
  a { color: #1a4ea0 !important; text-decoration: underline; border-bottom: none !important; }

  section { page-break-inside: avoid; border-top-color: #ccc !important; }
  .science-toc { display: none; }      /* TOC links are useless in print */
  .hero-meta { display: none; }
  .outro { border-color: #ccc !important; color: #222 !important; }
}
