/* Coffee vs El Niño. Colors are roles, set once for each theme; the charts read them as variables.
   The two coffees and the two ENSO poles were checked together for people with color blindness. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --arabica: #008300;
  --robusta: #4a3aa7;
  --warm: #e34948;
  --cool: #2a78d6;
  --neutral: #c3c2b7;
  --quiet: #c9c8c1;
  --warm-wash: rgba(227, 73, 72, 0.11);
  --cool-wash: rgba(42, 120, 214, 0.11);
  --warm-wash-key: rgba(227, 73, 72, 0.30);
  --cool-wash-key: rgba(42, 120, 214, 0.30);
  --chance: rgba(137, 135, 129, 0.20);
  --accent: #0b0b0b;
  --on-accent: #ffffff;
  --error: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --arabica: #008300;
    --robusta: #9085e9;
    --warm: #e66767;
    --cool: #3987e5;
    --neutral: #52514e;
    --quiet: #454542;
    --warm-wash: rgba(230, 103, 103, 0.12);
    --cool-wash: rgba(57, 135, 229, 0.13);
    --warm-wash-key: rgba(230, 103, 103, 0.40);
    --cool-wash-key: rgba(57, 135, 229, 0.40);
    --chance: rgba(137, 135, 129, 0.28);
    --accent: #ffffff;
    --on-accent: #0b0b0b;
    --error: #e66767;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.hidden { display: none !important; }

.top, main, .foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.top { padding-top: 28px; }

.top-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: flex-start;
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.tagline { margin: 6px 0 0; color: var(--ink-2); }

.account { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.who { color: var(--ink-2); font-size: 14px; }
.who strong { color: var(--ink); font-weight: 600; }

nav {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  border-bottom: 1px solid var(--grid);
}

nav a {
  padding: 8px 12px;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

main { padding-top: 20px; padding-bottom: 32px; min-height: 60vh; }

.loading { color: var(--ink-2); }
.loading.error { color: var(--error); }

/* -- the pieces of a screen -------------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.tile-label { color: var(--ink-2); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; line-height: 1.25; margin: 2px 0 6px; }
.tile-unit { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.tile-line { color: var(--ink-2); font-size: 13px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.stack { display: grid; gap: 12px; }
.stack.stale { opacity: 0.5; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 12px;
  margin-top: 12px;
}

.section { margin-top: 32px; }
.section:first-child { margin-top: 4px; }
.section h2 { margin: 0; font-size: 20px; font-weight: 650; text-wrap: balance; }
.lede { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
.section > .card { margin-top: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}

.card.wide { margin-top: 12px; }
.stack > .card.wide { margin-top: 0; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 80ch; }
.note { margin: 10px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 80ch; }
.card.ghosted { border-style: dashed; background: transparent; }
.card.lock .primary { margin-top: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 2px; font-size: 13px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.key.box { height: 10px; width: 10px; border-radius: 2px; }

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

.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; max-width: 100%; height: auto; touch-action: pan-y; border-radius: 4px; }
.chart svg:focus-visible { outline: 2px solid var(--cool); outline-offset: 2px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .chance { fill: var(--chance); }
.chart .end { stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--ink-2); font-size: 12px; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }

.tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  min-width: 150px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 12.5px;
  white-space: nowrap;
}

.tip-title { color: var(--ink-2); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-row strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }

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

.table-scroll { max-height: 340px; overflow: auto; margin-top: 10px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 500; white-space: normal; vertical-align: bottom; }
table.data tbody th { font-weight: 500; }

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

button, select, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
}

button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, nav a:focus-visible { outline: 2px solid var(--cool); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.ghost:hover, button.seg:hover { background: var(--grid); }
button.small { padding: 3px 10px; font-size: 13px; color: var(--ink-2); flex: none; }
button.seg { padding: 5px 12px; font-size: 13.5px; color: var(--ink-2); }
button.seg[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.lab-form { display: grid; gap: 12px; }
.lab-form ~ .stack { margin-top: 12px; }
.lab-form ~ .loading { margin: 12px 0 0; }
.fields { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.field select, .field input {
  min-width: 150px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--ink);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lab-form .actions { margin-top: 0; }

.foot { padding-top: 8px; padding-bottom: 32px; color: var(--muted); font-size: 12.5px; }
.foot p { margin: 0; max-width: 90ch; }

@media (max-width: 560px) {
  h1 { font-size: 23px; }
  .card { padding: 12px; }
  .tile-value { font-size: 22px; }
}

@media (prefers-reduced-motion: no-preference) {
  .stack { transition: opacity 0.15s; }
}
