/* Ecliptic — an instrument, not a horoscope. Brass rules on an indigo ground,
   with the four classical elements as the only other pigments. */

:root {
  color-scheme: dark light;

  --ground: #141a2e;
  --ground-sunk: #0f142699;
  --ground-raised: #1b2239;
  --rule: #2b3450;
  --rule-strong: #47537a;
  --brass: #c69749;
  --brass-dim: #8a6b36;
  --text: #e4e7f0;
  --text-dim: #99a2ba;
  --text-faint: #6f7893;

  --fire: #c4553f;
  --earth: #928d47;
  --air: #93abb8;
  --water: #3d8686;

  --font-display: 'Bodoni Moda', Didot, Georgia, serif;
  --font-ui: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-glyph: 'Noto Sans Symbols 2', 'Apple Symbols', 'Segoe UI Symbol', serif;

  --gutter: 16px;
  --measure: 1200px;
}

/* Paper and ink, for anyone whose system asks for a light interface. The brass
   darkens so it still holds contrast against a pale ground. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --ground: #e7e9f0;
    --ground-sunk: #d8dce788;
    --ground-raised: #f1f3f8;
    --rule: #c2c8d9;
    --rule-strong: #9aa3bd;
    --brass: #8a6526;
    --brass-dim: #a8874a;
    --text: #171c2b;
    --text-dim: #4d5570;
    --text-faint: #6f7893;

    --fire: #a33c28;
    --earth: #6c6829;
    --air: #5c7a89;
    --water: #226363;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 var(--gutter) 4rem;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
}

/* ---------- masthead ---------- */

.masthead {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.75rem 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
}

.masthead h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 0.95;
  font-variation-settings: 'opsz' 96;
}

.masthead-name p {
  margin: 0.5rem 0 0;
  max-width: 44ch;
  color: var(--text-dim);
}

.masthead-state {
  display: flex;
  gap: 1.75rem;
  margin: 0;
  padding-bottom: 0.35rem;
}

.masthead-state dt {
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.masthead-state dd {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- the instrument panel ---------- */

.panel {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 0 1.1rem;
  border-top: 1px solid var(--brass-dim);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem 1.25rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 8.5rem; }
.field-narrow { flex: 0 1 6.5rem; }

.field label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

input, select {
  font: inherit;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--ground-raised);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.44rem 0.5rem;
  width: 100%;
  min-width: 0;
}

input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, pre:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.btn {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 0.46rem 0.85rem;
  cursor: pointer;
}

.btn:hover { border-color: var(--brass); color: var(--brass); }

.btn-primary {
  color: var(--ground);
  background: var(--brass);
  border-color: var(--brass);
  font-weight: 600;
}

.btn-primary:hover { color: var(--ground); background: var(--brass); filter: brightness(1.08); }
.btn[disabled] { opacity: 0.5; cursor: progress; }

.save-chart {
  max-width: var(--measure);
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.save-chart input { flex: 1 1 auto; min-width: 0; }

.notice {
  max-width: var(--measure);
  margin: 0.9rem auto 0;
  padding: 0.6rem 0.8rem;
  border-left: 2px solid var(--fire);
  background: var(--ground-sunk);
  color: var(--text);
}

/* ---------- plate: dial + readout ---------- */

.plate {
  max-width: var(--measure);
  margin: 2.25rem auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(19rem, 0.8fr);
  gap: 2.5rem;
  align-items: start;
}

.dial { margin: 0; }
.dial svg { width: 100%; height: auto; display: block; }

.dial figcaption {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-faint);
  max-width: 52ch;
}

.readout section + section { margin-top: 2rem; }

.readout h2, .aspects h2 {
  font-size: 1.3rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--brass-dim);
  margin-bottom: 0.65rem;
}

.section-note {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--text-faint);
  max-width: 60ch;
}

/* ---------- tables ---------- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 0.76rem;
  color: var(--text-faint);
  padding: 0 0.5rem 0.35rem 0;
  border-bottom: 1px solid var(--rule);
}

.tbl td {
  padding: 0.33rem 0.5rem 0.33rem 0;
  border-bottom: 1px solid var(--rule);
}

.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; padding-right: 0; }
.tbl .glyph {
  font-family: var(--font-glyph);
  font-size: 1.05rem;
  width: 1.6em;
  padding-right: 0.15rem;
}
.tbl .name { color: var(--text); }
.tbl .retro { color: var(--brass); font-family: var(--font-glyph); }

.tbl-angles td:first-child { color: var(--text-dim); }

.element-fire, .glyph.element-fire { color: var(--fire); }
.element-earth, .glyph.element-earth { color: var(--earth); }
.element-air, .glyph.element-air { color: var(--air); }
.element-water, .glyph.element-water { color: var(--water); }

/* ---------- aspects ---------- */

.aspects, .raw, .colophon, .chat-panel {
  max-width: var(--measure);
  margin: 3rem auto 0;
}

/* ---------- chat ---------- */

.chat-transcript {
  display: grid;
  gap: 0.75rem;
  max-height: 22rem;
  overflow-y: auto;
  margin-top: 0.5rem;
  padding: 1rem;
  background: var(--ground-sunk);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.chat-message {
  max-width: 70ch;
  padding: 0.5rem 0.8rem;
  border-radius: 3px;
  line-height: 1.5;
}

.chat-message p { margin: 0; }

.chat-user {
  justify-self: end;
  background: var(--ground-raised);
  color: var(--text);
}

.chat-model {
  justify-self: start;
  border-left: 2px solid var(--brass-dim);
}

.chat-activity {
  color: var(--text-faint);
  font-style: italic;
}

.chat-failed { border-left-color: var(--fire); }

.chat-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.chat-form input { flex: 1 1 auto; min-width: 0; }

.aspect-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.1rem 1.75rem;
}

.aspect-list li {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.34rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.aspect-list .glyph { font-family: var(--font-glyph); }
.aspect-list .rel { font-family: var(--font-glyph); font-size: 1rem; }
.aspect-list .orb { margin-left: auto; color: var(--text-faint); font-size: 0.82rem; }

.rel-hard { color: var(--fire); }
.rel-soft { color: var(--water); }
.rel-conjunct { color: var(--brass); }
.rel-minor { color: var(--text-faint); }

/* ---------- text report ---------- */

.raw summary {
  font-family: var(--font-display);
  font-size: 1.3rem;
  cursor: pointer;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--brass-dim);
}

.raw code { font-size: 0.9em; }

.report-tablist {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.9rem;
}

.report-tablist [role="tab"] {
  padding: 0.4rem 0.9rem;
  background: none;
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  color: var(--text-faint);
  font-family: var(--font-ui);
  cursor: pointer;
}

.report-tablist [role="tab"]:hover { color: var(--brass); }

.report-tablist [aria-selected="true"] {
  background: var(--ground-sunk);
  border-color: var(--brass-dim);
  color: var(--brass);
}

.report-panel-head {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.6rem;
}

.copy-report { font-size: 0.82rem; padding: 0.3rem 0.7rem; }

.raw pre {
  margin: 1rem 0 0;
  padding: 1.1rem;
  background: var(--ground-sunk);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
}

.colophon {
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--text-faint);
  font-size: 0.82rem;
}

.colophon p { margin: 0; max-width: 64ch; }

/* ---------- the dial itself ---------- */

#wheel .sign-seg { stroke: currentColor; opacity: 0.13; }

/* The element tints need more weight to register against a pale ground. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) #wheel .sign-seg { opacity: 0.2; }
}
#wheel .rule-outer { stroke: var(--brass-dim); stroke-width: 1.2; }
#wheel .rule-inner { stroke: var(--rule-strong); stroke-width: 1; }
#wheel .rule-aspect { stroke: var(--rule); stroke-width: 1; }
#wheel .rule-hub { stroke: var(--brass-dim); stroke-width: 1; fill: var(--ground); }
#wheel .rule-sign { stroke: var(--brass-dim); stroke-width: 1; opacity: 0.75; }
#wheel .rule-cusp { stroke: var(--rule-strong); stroke-width: 1; }
#wheel .rule-cusp-angular { stroke: var(--brass); stroke-width: 1.6; }

#wheel .sign-glyph { font-family: var(--font-glyph); font-size: 34px; }
#wheel .house-num { fill: var(--text-faint); font-size: 19px; font-family: var(--font-ui); }

#wheel .tick-body { stroke: var(--text-dim); stroke-width: 1.3; }
#wheel .leader { stroke: var(--text-faint); stroke-width: 0.8; stroke-dasharray: 3 3; }
#wheel .body-glyph { fill: var(--text); font-family: var(--font-glyph); font-size: 33px; }
#wheel .body-degree { fill: var(--text-faint); font-family: var(--font-ui); font-size: 17px; }

#wheel .tick-angle { stroke: var(--brass); stroke-width: 2; }
#wheel .angle-label {
  fill: var(--brass);
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 600;
}

#wheel .aspect { stroke-linecap: round; }
#wheel .aspect-hard { stroke: var(--fire); }
#wheel .aspect-soft { stroke: var(--water); }
#wheel .aspect-conjunct { stroke: var(--brass); }
#wheel .aspect-minor { stroke: var(--text-faint); stroke-dasharray: 5 5; }

#wheel .hub-glyph { fill: var(--text-dim); font-family: var(--font-glyph); font-size: 21px; }
#wheel .hub-value { fill: var(--text); font-family: var(--font-glyph); font-size: 20px; }

/* One orchestrated moment: when a chart is drawn, the aspect chords sweep in
   under the glyphs, which settle a beat later. Nothing else on the page moves. */
@media (prefers-reduced-motion: no-preference) {
  #wheel.drawing .layer-aspects line {
    animation: chord 620ms ease-out both;
  }
  #wheel.drawing .body {
    animation: settle 420ms ease-out both;
    animation-delay: calc(260ms + var(--i) * 34ms);
  }
}

@keyframes chord {
  from { stroke-opacity: 0; }
}

@keyframes settle {
  from { opacity: 0; transform: scale(0.94); }
}

#wheel .body { transform-origin: 500px 500px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- narrow screens ---------- */

@media (max-width: 62rem) {
  .plate { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .masthead { padding-top: 2rem; align-items: flex-start; }
  .masthead-state { gap: 1.25rem; }
}

@media (max-width: 34rem) {
  body { font-size: 0.92rem; }
  .field, .field-narrow { flex: 1 1 7rem; }
  .panel-actions { margin-left: 0; width: 100%; }
  .panel-actions .btn { flex: 1 1 auto; }
  .masthead-state { flex-wrap: wrap; }
  #wheel .sign-glyph, #wheel .body-glyph { font-size: 38px; }
  #wheel .body-degree { font-size: 19px; }
}

/* Birthplace typeahead.
   The field is position:relative so the results list can sit over whatever
   follows it rather than pushing the form around as the user types. */
.place-field { position: relative; flex: 1 1 14rem; }

.place-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--ground-raised);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 35%);
}

.place-result {
  padding: 0.42rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}

.place-result:last-child { border-bottom: 0; }

.place-result.highlighted,
.place-result:hover {
  background: var(--ground-sunk);
  color: var(--brass);
}

.place-hint {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}
