/* OrbitLab /orrery: the solar system as a dated instrument.
 *
 * A standalone shell in the workspace's family: a bar that names the tool, a
 * 320px rail of controls divided by hairlines, and an aperture that gives the
 * figure everything that is left. No boxes inside the shell - radius, border
 * and shadow are kept for things that float above it. Labels are sentence
 * case in the body face; the mono face is spent only on measured quantities
 * (the clock, the readings, the table) and the one-line figure caption.
 *
 * Colour follows the house rule: rose marks the chosen world (its rail row,
 * its name on the stage) and the one action; teal carries measured
 * information; the orbit paths are neutral. The stage is a view OF space
 * and paints its own night in both themes. */

.layout {
  --rail-w: 320px;
  --rail-pad: 18px;
  --hair: var(--rule);
  --orrery-space: #07060f;
  --orrery-ink: #eceaff;
  --orrery-dim: #9390b5;
}
.topbar { --hair: var(--rule); }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--app-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- the bar ---------------- */
.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 56px; padding: 0 18px;
  border-block-end: 1px solid var(--hair);
  background: var(--panel);
}
/* Basis 0, not auto: the tagline is nowrap, and with an auto basis its full
   width became the brand's, which on a phone pushed the reading controls onto
   a row of their own. With basis 0 the brand takes what is left and the
   tagline truncates, as the workspace's does. */
.brand { display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0; color: inherit; text-decoration: none; }
.brand .logo { display: inline-flex; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.topbar h1 {
  margin: 0;
  font-family: var(--font-display); font-size: var(--fs-title); font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.1;
}
.topbar h1 b { font-weight: 600; color: var(--accent-2); }
.tagline {
  font-size: 12px; line-height: 1.3; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-nav { display: contents; }
.dest {
  position: relative; color: var(--text-soft); text-decoration: none;
  font-size: 13.5px; padding: 6px 9px; border-radius: var(--r-sm); white-space: nowrap;
  transition: color var(--t-fast) ease;
}
.dest::after {
  content: ""; position: absolute; inset-inline: 9px; bottom: 1px; height: 1.5px;
  background: var(--accent-2); transform: scaleX(0); transform-origin: center;
  transition: transform var(--t-fast) var(--ease-out);
}
.dest:hover { color: var(--text); }
.dest:hover::after { transform: scaleX(1); }
/* A hairline between the destinations and the controls: the two groups do
   different jobs and the gap alone was not saying so. */
.topbar-nav + .music { margin-inline-start: 10px; }
.topbar-nav + .music::before {
  content: ""; position: absolute; inset-inline-start: -10px; height: 20px; width: 1px; background: var(--hair);
}
/* The music toggle: a note and the state in words. On, it takes the
   information colour; it is a reading of what the page is doing. */
.music {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 6px 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: inherit; font-size: 13.5px; color: var(--text-soft); cursor: pointer; white-space: nowrap;
  transition: color var(--t-fast) ease, border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.music:hover { color: var(--text); border-color: var(--hair); background: var(--panel-2); }
.music:focus-visible { outline: 2px solid var(--focus); box-shadow: var(--ring); }
.music[aria-pressed="true"] { color: var(--accent-2); }
.music .svg-icon { width: 18px; height: 18px; }
.topbar .icon-btn {
  position: relative; width: 34px; height: 34px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--text-soft);
}
.topbar .icon-btn:hover { color: var(--text); border-color: var(--hair); background: var(--panel-2); }

/* ---------------- the layout ---------------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------------- the rail ---------------- */
.rail {
  width: var(--rail-w); flex: none;
  display: flex; flex-direction: column; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  border-inline-end: 1px solid var(--hair);
  background: var(--panel);
}
.group { padding: 14px var(--rail-pad) 16px; border-block-end: 1px solid var(--hair); }
.group:last-child { border-block-end: none; }
.group-title { margin: 0 0 10px; font-size: var(--fs-c-h3); font-weight: 600; line-height: 1.3; color: var(--text); }

.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; font-size: 12.5px; color: var(--text-soft); }
.field--inline { flex-direction: row; align-items: center; gap: 10px; }
.field--inline > span { flex: none; }
.field input, .field select {
  box-sizing: border-box; width: 100%; min-height: 36px; padding: 7px 9px;
  background: var(--app-bg); color: var(--text);
  border: 1px solid var(--hair); border-radius: var(--r-xs);
  font-family: inherit; font-size: 13px;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.field input[type="date"] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.field input:hover, .field select:hover { border-color: var(--muted); }
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--focus); box-shadow: var(--ring); outline-offset: 1px; }
.field select { cursor: pointer; }

.clock-row { display: flex; gap: 8px; margin: 0 0 12px; }
.field:last-child { margin-bottom: 0; }
.clock-row .btn { flex: 1 1 0; justify-content: center; min-height: 40px; padding: 8px 12px; font-size: 14px; }

.check { display: flex; align-items: center; gap: 9px; margin: 0 0 9px; font-size: 13px; color: var(--text); cursor: pointer; }
.check:last-child { margin-bottom: 0; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check input:focus-visible { outline: 2px solid var(--focus); box-shadow: var(--ring); outline-offset: 2px; }

/* The worlds: one row each, the body's own tint as a dot (data, so a
   literal on purpose), its distance from the Sun live at the end. The chosen
   one carries the house inset rule in rose. */
.worlds { list-style: none; margin: 0 calc(-1 * var(--rail-pad)); padding: 0; }
.world {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 32px; padding: 4px var(--rail-pad);
  background: transparent; border: 0; border-inline-start: 3px solid transparent;
  font-family: inherit; font-size: 13.5px; color: var(--text-soft); text-align: start; cursor: pointer;
  transition: color var(--t-fast) ease, background var(--t-fast) ease;
}
.world:hover { color: var(--text); background: var(--panel-2); }
.world:focus-visible { outline: 2px solid var(--focus); box-shadow: var(--ring); outline-offset: -3px; }
.world[aria-pressed="true"] { color: var(--text); font-weight: 700; border-inline-start-color: var(--accent); }
.world-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex: none; }
.world-dot--none { background: transparent; border: 1px solid var(--border); }
.world-name { flex: 1 1 auto; min-width: 0; }
.world-kind { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.world-r {
  font-family: var(--font-mono); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums;
  color: var(--muted); white-space: nowrap;
}

/* The music credit, shown while the track plays. */
.group--music[hidden] { display: none; }
.note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.note a { color: var(--accent-2); text-decoration: none; border-block-end: 1px solid transparent; }
.note a:hover { border-block-end-color: currentColor; }

/* ---------------- the aperture ---------------- */
.aperture { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px; border-block-end: 1px solid var(--hair); background: var(--panel);
}
.tabs { display: flex; gap: 0; }
.tab {
  position: relative; background: transparent; border: 0; color: var(--muted);
  padding: 15px 0 13px; margin-inline-end: 24px;
  font-family: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: color var(--t-fast) ease;
}
.tab:last-child { margin-inline-end: 0; }
.tab::after {
  content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px;
  background: var(--spectral); opacity: 0; transition: opacity var(--t-fast) ease;
}
.tab:hover { color: var(--text-soft); }
.tab.active { color: var(--text); font-weight: 700; }
.tab.active::after { opacity: 1; }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; box-shadow: var(--ring); }
/* The date the model is drawn for: a measured quantity, so it is set like one. */
.clock { margin: 0; font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.clock b { font-weight: 500; }
.clock span { margin-inline-start: 10px; font-size: 12px; color: var(--muted); }
.clock span[hidden] { display: none; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }
.view:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }

/* ---------------- the stage ---------------- */
.stage {
  position: relative; flex: 1; min-height: 0;
  background: var(--orrery-space); overflow: hidden;
  touch-action: none; cursor: grab;
}
.stage:active { cursor: grabbing; }
.stage:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; box-shadow: var(--ring); }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; margin: 0; color: var(--orrery-dim); font-size: 14px; line-height: 1.6;
}
.stage.is-live .stage-fallback { display: none; }

/* Name labels float over the bodies and are the keyboard route into the
   model: each is a button that selects its world. The tick points at it. */
.stage-labels { position: absolute; inset: 0; pointer-events: none; }
.orrery-label {
  position: absolute; inset-inline-start: 0; inset-block-start: 0;
  transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer;
  margin: 0; padding: 2px 6px 0; background: transparent; border: 0;
  font-family: var(--font-body); font-size: 12px; font-weight: 500; line-height: 1.2;
  color: var(--orrery-dim); white-space: nowrap;
  transition: color var(--t-fast) ease;
}
html[dir="rtl"] .orrery-label { transform: translate(50%, -100%); }
.orrery-label::after { content: ""; display: block; width: 1px; height: 9px; margin: 3px auto 0; background: currentColor; opacity: 0.55; }
.orrery-label.is-below { transform: translate(-50%, 0); padding: 0 6px 2px; }
html[dir="rtl"] .orrery-label.is-below { transform: translate(50%, 0); }
.orrery-label.is-below::after { display: none; }
.orrery-label.is-below::before { content: ""; display: block; width: 1px; height: 9px; margin: 0 auto 3px; background: currentColor; opacity: 0.55; }
.orrery-label.is-end { transform: translate(0, -50%); padding: 0 4px; }
.orrery-label.is-start { transform: translate(-100%, -50%); padding: 0 4px; }
html[dir="rtl"] .orrery-label.is-start { transform: translate(100%, -50%); }
.orrery-label.is-end::after, .orrery-label.is-start::after { display: none; }
.orrery-label:hover { color: var(--orrery-ink); }
.orrery-label:focus-visible { outline: 2px solid var(--focus); box-shadow: var(--ring); border-radius: var(--r-xs); }
.orrery-label.is-selected { color: var(--accent); font-weight: 700; }
.orrery-label[hidden] { display: none; }

/* The reading line under the figure: the chosen world's live quantities,
   set as label-and-value pairs in one wrapping line - a readout, not a row
   of boxes. Values are teal mono; labels are the body face. */
.reading {
  flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 26px;
  padding: 12px 16px 2px; min-height: 24px; font-size: 13px; color: var(--text-soft);
}
.reading:empty { display: none; }
.reading .who { font-weight: 700; color: var(--text); }
.reading .who small { font-weight: 400; color: var(--muted); margin-inline-start: 6px; font-size: 12px; }
/* The pair itself wraps (a next-event note is a sentence); the value never
   breaks from its unit. */
.rd { display: inline; }
.rd-k { margin-inline-end: 7px; }
.rd-v { font-family: var(--font-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--accent-2); white-space: nowrap; margin-inline-end: 7px; }
.rd-s { font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.reading .lesson { color: var(--accent-2); text-decoration: none; border-block-end: 1px solid transparent; }
.reading .lesson:hover { border-block-end-color: currentColor; }
.reading .pick { color: var(--muted); }

/* The caption a figure in a paper carries: frame, source, what is and is not
   to scale, and how to drive it. Mono, on the hairline, one or two lines. */
.caption {
  flex: none; margin: 10px 16px 12px; padding-block-start: 7px;
  border-block-start: 1px solid var(--hair);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6; letter-spacing: 0.01em; color: var(--muted);
}
html[lang="ar"] .caption { letter-spacing: 0; word-spacing: 0.06em; line-height: 1.8; }

/* ---------------- positions ---------------- */
.table-wrap { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 16px; }
.positions { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.positions caption {
  text-align: start; caption-side: top; padding: 14px 0 10px;
  font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.positions th, .positions td { padding: 9px 12px; border-block-end: 1px solid var(--hair); text-align: start; }
.positions th { position: sticky; top: 0; background: var(--app-bg); font-size: 12.5px; font-weight: 600; color: var(--text-soft); border-block-end: 1px solid var(--border); }
.positions th.num, .positions td.num { text-align: end; }
.positions td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--accent-2); }
.positions td:first-child { display: flex; align-items: center; gap: 8px; }
.positions tr.is-selected td:first-child { color: var(--accent); font-weight: 700; }
.positions .world-kind { font-weight: 400; }

/* ---------------- your age there ---------------- */
.ages { flex: 1; min-height: 0; overflow: auto; padding: 18px 16px; }
.ages-lead { margin: 0 0 16px; max-width: 60ch; line-height: 1.6; color: var(--text-soft); }
.ages .field--inline input { width: auto; min-width: 170px; }
.privacy { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.ages-empty { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.ages-empty[hidden] { display: none; }
.ages-list { list-style: none; margin: 18px 0 0; padding: 0; max-width: 640px; }
.age-row {
  display: grid; grid-template-columns: minmax(96px, 1fr) auto auto; gap: 8px 20px; align-items: baseline;
  padding: 9px 0; border-block-end: 1px solid var(--hair); font-size: 13.5px;
}
.age-row .world-dot { display: inline-block; margin-inline-end: 8px; vertical-align: middle; }
.age-years { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--accent-2); text-align: end; }
.age-next { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); text-align: end; }

/* ---------------- phones and touch ---------------- */
@media (max-width: 768px) {
  /* Release the viewport lock: the page scrolls, the model comes first. */
  body { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    flex-wrap: wrap; gap: 8px 10px; padding: 8px 14px; justify-content: flex-start;
  }
  .topbar h1 { font-size: 18px; } /* a responsive step-down, not a change of rank */
  .topbar-right { display: contents; }
  .brand { order: 1; flex: 1 1 0; min-width: 0; }
  .topbar .icon-btn, .topbar .lang-switcher, .topbar .music { order: 2; flex: none; }
  .topbar-nav + .music { margin-inline-start: 0; }
  .topbar-nav + .music::before { display: none; }
  .topbar-nav {
    display: flex; order: 3; flex: 1 1 100%; gap: 4px; align-items: center;
    overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav > * { flex: none; }

  .layout { flex-direction: column; }
  .aperture { order: 1; min-height: 0; }
  .rail { order: 2; width: 100%; overflow: visible; border-inline-end: 0; border-block-start: 1px solid var(--hair); }
  .view { flex: none; }
  .stage { aspect-ratio: 16 / 10; min-height: 280px; max-height: 70vh; }
  .positions th { position: static; }
}
@media (max-width: 560px) {
  /* Truncated to "The solar system..." the tagline said nothing; the bar
     keeps the wordmark alone and gets a row back. */
  .tagline { display: none; }
  .stage { aspect-ratio: 1 / 1; }
  .stage-head { flex-wrap: wrap; row-gap: 0; padding-bottom: 8px; }
  .clock { flex: 1 1 100%; }
  .tab { padding: 13px 0 11px; margin-inline-end: 18px; }
  .age-row { grid-template-columns: minmax(0, 1fr) auto; }
  .age-next { grid-column: 1 / -1; text-align: start; }
}
@media (pointer: coarse) {
  .field input, .field select { min-height: 44px; font-size: 16px; }
  .clock-row .btn { min-height: 44px; }
  .check { min-height: 44px; margin-bottom: 0; }
  .world { min-height: 44px; }
  .tab { min-height: 44px; }
  .orrery-label { padding: 6px 8px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .orrery-label, .tab, .dest, .world, .music { transition: none; }
}
@media print {
  .topbar, .rail, .stage, .caption .hint, .tab { display: none; }
  .view, .view.active { display: block; }
  .positions td.num { color: inherit; }
}
