/*
 * style.css - the instrument case around the chart.
 *
 * The chart replaces a brass planisphere, so the page is built like one: ink
 * enamel, hairline rules, engraved small-caps labels and a single warm brass
 * accent. Everything is one column on a phone and two on a desk; nothing needs a
 * build step or a framework.
 */

:root {
  --ink:        #07080b;
  --ink-raised: #0e1015;
  --ink-sunk:   #05060a;
  --rule:       #23262e;
  --rule-soft:  #171a21;

  --text:       #d9dbe0;
  --text-dim:   #8d919c;
  --text-faint: #63676f;

  --brass:      #b8912f;
  --brass-lit:  #e0bd6a;
  --brass-dim:  #6b551f;

  --focus:      #7fb2d8;

  --serif: "Bodoni Moda", "Didot", "Bodoni MT", "Playfair Display", Georgia, serif;
  --sans:  "Karla", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono:  "IBM Plex Mono", "Consolas", "SF Mono", ui-monospace, monospace;

  --gap: clamp(0.9rem, 2.2vw, 1.5rem);
}

/* Night mode drains every colour on the page down to red, matching what the
   canvas does, so the whole instrument keeps your dark adaptation. */
body.night {
  --text:       #ff6a4d;
  --text-dim:   #b13b28;
  --text-faint: #7c2a1d;
  --rule:       #3a1109;
  --rule-soft:  #220a05;
  --brass:      #d8452a;
  --brass-lit:  #ff7554;
  --brass-dim:  #7a2313;
  --focus:      #ff8a6a;
  --ink-raised: #0d0505;
  --ink-sunk:   #060202;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, #12151d 0%, transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 110%, #0c0e14 0%, transparent 55%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

/* A faint film grain keeps the large dark areas from looking like flat plastic. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: var(--gap);
  padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
}

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

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--gap);
  animation: rise 0.6s ease-out both;
}

.masthead h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 5.5vw, 3rem);
  line-height: 1;
  margin: 0;
  letter-spacing: 0.01em;
  color: #f0eee9;
}

body.night .masthead h1 { color: var(--text); }

.masthead__sub {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

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

.layout {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 940px) {
  .layout { grid-template-columns: 20rem minmax(0, 1fr); align-items: start; }
  .console-toggle { display: none; }
  .console { position: sticky; top: var(--gap); }
}

/* --------------------------------------------------------------- console */

.console {
  display: grid;
  gap: 1.35rem;
  animation: rise 0.7s 0.06s ease-out both;
}

@media (max-width: 939px) {
  .console { display: none; }
  .console.is-open { display: grid; margin-bottom: var(--gap); }
}

.group {
  background: linear-gradient(160deg, var(--ink-raised), var(--ink-sunk));
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1rem 1.1rem;
}

.group__head {
  margin: 0 0 0.9rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

/* A hairline rule trailing off each section heading, as on an engraved plate. */
.group__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--brass-dim), transparent);
}

.field { display: grid; gap: 0.3rem; margin-bottom: 0.75rem; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

label,
.field > label {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--ink-sunk);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent);
}

select { font-family: var(--sans); }

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-faint);
}

.hint.is-warning { color: var(--brass-lit); }

/* ------------------------------------------------------------- combo box */

.combo { position: relative; margin-bottom: 0; }

.combo__list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 15rem;
  overflow-y: auto;
  background: #0c0e13;
  border: 1px solid var(--rule);
  border-radius: 2px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.combo__list li {
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--rule-soft);
}

.combo__list li:last-child { border-bottom: none; }
.combo__list li:hover,
.combo__list li.is-active { background: #151922; color: var(--brass-lit); }
.combo__list em { font-style: normal; color: var(--text-faint); font-size: 0.78rem; }

/* -------------------------------------------------------------- controls */

button {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

button:hover { border-color: var(--brass-dim); color: var(--brass-lit); }

.ghost-button.wide { width: 100%; margin-top: 0.4rem; }

.stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.stepper button { padding: 0.45rem 0.2rem; font-family: var(--mono); font-size: 0.75rem; }

.stepper__now {
  border-color: var(--brass-dim);
  color: var(--brass-lit);
  font-family: var(--sans) !important;
  letter-spacing: 0.06em;
}

.stepper__now.is-active {
  background: color-mix(in srgb, var(--brass) 18%, transparent);
  border-color: var(--brass);
  color: var(--brass-lit);
}

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.segmented button { font-weight: 600; letter-spacing: 0.08em; }
.segmented button.is-active {
  background: color-mix(in srgb, var(--brass) 18%, transparent);
  border-color: var(--brass);
  color: var(--brass-lit);
}

.switches { display: grid; gap: 0.1rem; }

.switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
  cursor: pointer;
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
}

.switch input { appearance: none; margin: 0; width: 0; height: 0; }

/* A small engraved square that fills with brass when the layer is on. */
.switch span { position: relative; padding-left: 1.5rem; transition: color 0.15s; }

.switch span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 0.95em;
  height: 0.95em;
  border: 1px solid var(--rule);
  background: var(--ink-sunk);
  transition: background 0.15s, border-color 0.15s;
}

.switch span::after {
  content: "";
  position: absolute;
  left: 0.28em;
  top: 0.4em;
  width: 0.4em;
  height: 0.4em;
  background: var(--brass-lit);
  opacity: 0;
  transition: opacity 0.15s;
}

.switch input:checked + span { color: var(--text); }
.switch input:checked + span::before { border-color: var(--brass-dim); }
.switch input:checked + span::after { opacity: 1; }
.switch input:focus-visible + span::before { border-color: var(--focus); }
.switch:hover span { color: var(--text); }

.slider { margin-top: 1rem; }
.slider label { display: flex; justify-content: space-between; align-items: baseline; }
.slider output { font-family: var(--mono); color: var(--brass-lit); letter-spacing: 0; }

input[type="range"] {
  width: 100%;
  appearance: none;
  height: 1px;
  margin: 0.9rem 0 0.2rem;
  background: var(--rule);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--brass-lit);
  border: 2px solid var(--ink);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--brass-lit);
  border: 2px solid var(--ink);
  cursor: pointer;
}

.credits {
  font-size: 0.7rem;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 0;
}

.credits span { color: var(--text-dim); }
.mono { font-family: var(--mono); }

/* ----------------------------------------------------------------- chart */

.chart-area { display: grid; gap: 0.9rem; animation: rise 0.8s 0.12s ease-out both; }

.chart-frame {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-height: calc(100vh - 12rem);
  margin: 0 auto;
  touch-action: none;
}

@media (min-width: 940px) {
  .chart-frame { max-width: min(100%, calc(100vh - 11rem)); }
}

#sky {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  border-radius: 50%;
  /* The disc sits in a shallow well, like a dial set into its case. */
  box-shadow:
    0 0 0 1px rgba(184, 145, 47, 0.18),
    0 18px 55px rgba(0, 0, 0, 0.65),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#sky.is-dragging { cursor: grabbing; }

.chart-hint {
  position: absolute;
  left: 50%;
  bottom: -0.2rem;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.4s;
}

.chart-hint.is-hidden { opacity: 0; }

/* ------------------------------------------------------------- specimen */

.detail {
  position: absolute;
  min-width: 12.5rem;
  max-width: 16rem;
  padding: 0.75rem 0.9rem 0.85rem;
  background: rgba(10, 12, 17, 0.94);
  border: 1px solid var(--brass-dim);
  border-radius: 2px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  z-index: 15;
  animation: pop 0.16s ease-out both;
}

.detail__close {
  position: absolute;
  top: 0.15rem;
  right: 0.25rem;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  color: var(--text-faint);
}

.detail__close:hover { background: transparent; }

.detail__kind {
  margin: 0;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
}

.detail__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.15;
  margin: 0.15rem 0 0.55rem;
  color: #f0eee9;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

body.night .detail__name { color: var(--text); }

.detail__rows { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; }
.detail__rows dt { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.detail__rows dd { margin: 0; font-family: var(--mono); font-size: 0.78rem; text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- summary */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.6rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
}

.summary__item { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.2rem 0; }

.summary__label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.summary__value { font-family: var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.summary__value.is-accent { color: var(--brass-lit); }

/* ------------------------------------------------------------ animations */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
