/* Palette: one accent (the Sun), one cool tone for geometry, one alert colour
   reserved for retrograde motion, and three greys. Planet colours only appear
   as swatches. */
:root {
  color-scheme: dark;

  --bg: #0b0d12;
  --bg1: #10131a;
  --bg2: #151923;
  --ink: #edf1f7;
  --ink2: #b9c1cc;
  --ink3: #8e97a6;
  --line: rgb(210 222 245 / 7%);
  --line2: rgb(210 222 245 / 12%);
  --line3: rgb(210 222 245 / 20%);
  --acc: #f0b35a;
  --acc2: #f8d49c;
  --cool: #96b0d6;
  --alert: #ec584a;
  --earth: #8fb4ff;
  --on-acc: #0b0d12;
  --planet-sun: #f2b75b;
  --planet-moon: #b8c4d2;
  --planet-mercury: #a3a3ad;
  --planet-venus: #e8b04a;
  --planet-mars: #d4643c;
  --planet-jupiter: #cfa973;
  --planet-saturn: #bfa062;
  --planet-uranus: #6cc7b8;
  --planet-neptune: #5f86d8;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Courier New", monospace;
  --serif: "EB Garamond", "Georgia", serif;
  --r: 3px;
  --nav-h: 56px;
}

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

html {
  scroll-padding-top: var(--nav-h);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  background: var(--bg);
  color: var(--ink2);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.75;
}

main,
footer {
  position: relative;
}

a {
  color: var(--acc);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, currentcolor 35%, transparent);
}

a:hover {
  border-bottom-color: currentcolor;
}

:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
  border-radius: var(--r);
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 300;
  background: var(--acc);
  color: var(--on-acc);
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.skip-link:focus {
  top: 1rem;
}

.noscript {
  position: relative;
  z-index: 1;
  padding: 1rem;
  text-align: center;
  background: var(--bg2);
  color: var(--ink);
}

/* ══ NAV ══ */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.5rem;
  background: rgb(11 13 18 / 88%);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink2);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  border: 0;
}

.nav-brand::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 10px var(--acc);
}

.nav-brand:hover {
  color: var(--ink);
}

.nav-links {
  display: flex;
  gap: 0.1rem;
  list-style: none;
}

.nav-links a {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--ink2);
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: var(--r);
}

.nav-links a:hover {
  color: var(--ink);
  background: var(--line);
}

.nav-lang {
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
}

#nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  border-radius: var(--r);
  color: var(--ink2);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

#nav-toggle:hover {
  background: var(--line);
}

/* ══ HERO ══ */
#hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: calc(var(--nav-h) + 1rem) 1.5rem 3rem;
  text-align: center;
}

.hero-canvas-wrap {
  position: relative;
  width: min(720px, 94vw, calc(100svh - 17rem));
  min-width: 280px;
  aspect-ratio: 1;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--acc);
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.hero-desc {
  max-width: 38rem;
  font-size: 1rem;
  color: var(--ink2);
}

.hero-today {
  min-height: 1.4em;
  max-width: 38rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--acc2);
}

/* ══ GENERAL LAYOUT ══ */
.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 2.5rem;
}

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-top: 5.5rem;
  padding-bottom: 1rem;
  margin-bottom: 2.4rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--acc), var(--acc)) left bottom / 3.5rem 1px no-repeat;
}

.sec-n {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--acc);
}

.sec-n::before {
  content: "§ ";
  color: var(--ink3);
}

.sec-t {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.15;
}

.prose {
  max-width: 720px;
}

.prose p {
  line-height: 1.8;
  margin-bottom: 1.2rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose strong {
  color: var(--ink);
  font-weight: 500;
}

.prose em {
  color: var(--acc2);
}

.sec-foot {
  margin-top: 1.8rem;
}

.note {
  max-width: 720px;
  margin-top: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--ink3);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--acc2);
}

/* ══ FORMULAS ══ */
.fbox {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--acc);
  border-radius: var(--r);
  padding: 1.4rem 1.8rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.fbox-ttl {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acc);
}

.fbox-ttl::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--acc) 20%, transparent);
}

.fline {
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 2.2;
  white-space: nowrap;
}

.fline .v,
.fdef .v {
  color: var(--acc);
  font-weight: 500;
}

.fline .c {
  margin-left: 1.2rem;
  font-size: 0.75rem;
  color: var(--ink3);
}

.fnote {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--ink3);
  white-space: normal;
  line-height: 1.6;
}

.fdefs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.4rem 1.6rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.fdef {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink2);
}

/* ══ DIAGRAMS ══ */
.diagram {
  padding: 0;
}

.di-svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}

.di-svg text {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--ink2);
}

.di-svg .title {
  font-size: 12px;
  font-weight: 500;
  fill: var(--ink);
}

.di-svg .param {
  font-size: 10px;
  fill: var(--acc);
}

.di-svg .axis {
  stroke: rgb(180 190 210 / 20%);
  stroke-width: 0.6;
}

.di-svg .sep {
  stroke: var(--line2);
}

.di-svg .orbit {
  fill: none;
  stroke: var(--cool);
  stroke-width: 1.2;
}

.di-svg .earth {
  fill: var(--earth);
}

.di-svg .sun {
  fill: var(--planet-sun);
}

.di-svg .arrow {
  stroke: var(--acc);
  stroke-width: 1.2;
  marker-end: url("#arrowhead");
}

.di-svg .arrowhead,
.di-svg .mark {
  fill: var(--acc2);
}

.di-svg .ecliptic {
  stroke: rgb(180 190 210 / 45%);
  stroke-width: 1;
}

.di-svg .equator,
.di-svg .angle {
  fill: none;
  stroke: var(--acc);
  stroke-width: 1;
}

.di-svg .analemma {
  fill: none;
  stroke: var(--acc2);
  stroke-width: 1.6;
}

.di-svg .box rect {
  fill: var(--bg2);
  stroke: var(--line3);
}

.di-svg .box.check rect {
  fill: none;
  stroke: var(--acc);
  stroke-dasharray: 4 3;
}

.di-svg .flow {
  stroke: var(--acc);
  stroke-width: 1.3;
  marker-end: url("#flow");
}

.di-svg .flow.dashed {
  stroke-dasharray: 4 3;
}

/* ══ CARDS ══ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin: 1.6rem 0;
}

.icard {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.4rem;
}

.icard h3 {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

.icard p,
.hbox p {
  font-size: 0.92rem;
  color: var(--ink2);
  line-height: 1.65;
}

.hbox {
  background: color-mix(in srgb, var(--acc) 4%, transparent);
  border: 1px solid color-mix(in srgb, var(--acc) 18%, transparent);
  border-radius: var(--r);
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
}

.hbox h3 {
  margin-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acc);
}

/* ══ SIMULATIONS ══ */
.ccard {
  position: relative;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.ccard canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.ccard canvas:focus-visible {
  outline-offset: -2px;
}

#solar-canvas { aspect-ratio: 1 / 0.93; }
#pl-canvas { aspect-ratio: 2 / 1; }
#ven-canvas { aspect-ratio: 1; }

.ctip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  max-width: 190px;
  padding: 0.45rem 0.65rem;
  background: rgb(11 13 18 / 94%);
  border: 1px solid var(--line3);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--ink2);
  pointer-events: none;
}

.ctip[hidden] {
  display: none;
}

.ctip strong {
  font-weight: 500;
  color: var(--acc);
}

.ctoolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--bg2);
}

.ctoolbar2 {
  justify-content: space-between;
  background: var(--bg1);
}

.ctoolbar label,
.grp label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink3);
}

.grp {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.grp-spd {
  flex: 0 1 220px;
}

.ctoolbar input[type="range"] {
  flex: 1;
  min-width: 70px;
  accent-color: var(--acc);
  cursor: pointer;
}

.ctoolbar input.scrub {
  flex: 1 1 160px;
}

.ctoolbar input[type="number"] {
  width: 5.2em;
  min-height: 32px;
  padding: 0.2rem 0.4rem;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
}

.when {
  min-width: 7.5em;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.slbl {
  min-width: 2.5em;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--acc);
}

.chk {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.chk input {
  accent-color: var(--acc);
  width: 15px;
  height: 15px;
}

.ctoolbar button,
.pbtn,
.evbar button,
.seg button {
  min-height: 34px;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line2);
  border-radius: var(--r);
  background: transparent;
  color: var(--ink2);
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: nowrap;
  cursor: pointer;
}

.ctoolbar button:hover,
.pbtn:hover,
.evbar button:hover,
.seg button:hover {
  border-color: var(--acc);
  color: var(--acc);
}

.ctoolbar .bplay {
  min-width: 6.5em;
  border-color: color-mix(in srgb, var(--acc) 50%, transparent);
  color: var(--acc);
}

.ctoolbar button.on,
.pbtn[aria-pressed="true"],
.seg button[aria-pressed="true"] {
  background: var(--acc);
  border-color: var(--acc);
  color: var(--on-acc);
}

.seg {
  display: inline-flex;
}

.seg button + button {
  margin-left: -1px;
}

.seg-view {
  margin-bottom: 0.7rem;
}

.evbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.evlbl {
  min-width: 12em;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  text-align: center;
}

.howto {
  margin-top: 0.55rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.55;
  color: var(--ink3);
}

.dcard {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1rem 1.2rem;
}

.ly-venus .dcard {
  margin-top: 1rem;
}

.dcard-t {
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--acc);
}

.drow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line);
}

.drow:last-child {
  border: none;
}

.dk {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink3);
}

.dv {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.dv.retro {
  color: var(--alert);
}

.legrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: 0.6rem;
}

.legitem {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink3);
}

.ldot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ldot.ring {
  border: 1.5px solid var(--acc);
}

.lseg {
  width: 16px;
  height: 2px;
}

.lseg.dashed {
  background: repeating-linear-gradient(90deg, var(--cool) 0 4px, transparent 4px 7px);
}

.sw-acc { background: var(--acc); }
.sw-acc2 { background: var(--acc2); }
.sw-cool { background: var(--cool); }
.sw-alert { background: var(--alert); }
.sw-earth { background: var(--earth); }

.sw-sun { color: var(--planet-sun); }
.sw-moon { color: var(--planet-moon); }
.sw-mercury { color: var(--planet-mercury); }
.sw-venus { color: var(--planet-venus); }
.sw-mars { color: var(--planet-mars); }
.sw-jupiter { color: var(--planet-jupiter); }
.sw-saturn { color: var(--planet-saturn); }
.sw-uranus { color: var(--planet-uranus); }
.sw-neptune { color: var(--planet-neptune); }

.planet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.pbtn {
  background: var(--bg1);
  text-transform: uppercase;
}

.pbtn span {
  margin-right: 0.4em;
}

.pbtn[aria-pressed="true"] span {
  color: var(--on-acc) !important;
}

.ly-solar,
.ly-venus {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}

.ly-solar { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

.ly-venus {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
}

.sidecol {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cardrow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.2rem;
  align-items: start;
}

.shapec {
  background: color-mix(in srgb, var(--acc) 4%, var(--bg1));
  border: 1px solid var(--line2);
  border-radius: var(--r);
  padding: 1rem 1.2rem;
}

.shapec .sn {
  margin-bottom: 0.3rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--acc);
}

.shapec .sd {
  font-size: 0.85rem;
  color: var(--ink2);
  line-height: 1.55;
}

/* ══ TABLES ══ */
.dtable-wrap {
  overflow-x: auto;
  margin: 1.5rem 0 0;
}

.dtable {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.dtable caption {
  padding-bottom: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink3);
  text-align: left;
}

.dtable thead tr {
  border-bottom: 1px solid var(--line3);
}

.dtable th {
  padding: 0.6rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--acc);
  text-align: left;
}

.dtable td {
  padding: 0.5rem 0.7rem;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
}

.dtable tr:hover td {
  background: var(--line);
}

.dtable td:first-child {
  color: var(--ink);
  white-space: nowrap;
}

.mn {
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ══ REFERENCES ══ */
.ref-head {
  margin-top: 3rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
}

.ref-list {
  list-style: none;
  counter-reset: r;
}

.ref-list li {
  position: relative;
  counter-increment: r;
  padding: 0.9rem 0 0.9rem 2.8rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--ink2);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.ref-list li::before {
  content: "[" counter(r) "]";
  position: absolute;
  left: 0;
  top: 0.95rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--acc);
}

.ref-list em {
  color: var(--ink);
}

/* ══ FOOTER ══ */
footer {
  margin-top: 5rem;
  padding: 2rem 2.5rem;
  border-top: 1px solid var(--line);
}

.footer-in {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1.2rem;
  max-width: 1140px;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink3);
}

.footer-in a {
  color: inherit;
}

/* ══ RESPONSIVE ══ */
@media (width <= 900px) {
  .ly-solar,
  .ly-venus,
  .two-col,
  .cardrow {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (width <= 820px) {
  nav {
    padding: 0 1.2rem;
  }

  #nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg1);
    border-bottom: 1px solid var(--line);
    display: none;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.8rem 1.5rem;
    font-size: 0.8rem;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-lang {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
}

@media (width <= 600px) {
  .wrap {
    padding: 0 1.2rem;
  }

  #hero {
    padding-inline: 0.5rem;
  }

  .sec-head {
    padding-top: 4rem;
  }

  .fbox {
    padding: 1rem 1.2rem;
  }

  .fline {
    font-size: 0.78rem;
  }

  .planet-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.4rem;
  }

  .pbtn {
    flex-shrink: 0;
  }

  .ctoolbar {
    padding: 0.5rem 0.7rem;
    gap: 0.5rem;
  }

  .seg {
    flex-wrap: wrap;
  }

  .seg button {
    padding: 0.3rem 0.55rem;
    white-space: normal;
  }

  footer {
    padding: 1.8rem 1.2rem;
  }
}

@media print {
  nav,
  canvas,
  .ctoolbar,
  .planet-bar,
  .evbar,
  .seg,
  .legrow,
  .howto {
    display: none !important;
  }

  #hero {
    min-height: auto;
  }
}
