/* Stylesheet of the single-page static site. Mobile first: the base rules are for a phone held
   upright (360px wide); the @media block at the end only widens the layout on desktop.
   System fonts, no web fonts and no other stylesheet. */

:root {
  --ink: #1d1f20;
  --muted: #5f6368;
  --line: #c9ccd1;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --tap-height: 44px; /* minimum height of everything that can be tapped */
  /* Side padding that also keeps content out of a phone's notch / rounded corners. */
  --side-left: max(12px, env(safe-area-inset-left));
  --side-right: max(12px, env(safe-area-inset-right));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #fff;
  /* min-width 0 chain: nothing may force a horizontal page scroll at 360px. */
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Header ---- */
.page-header {
  padding: calc(8px + env(safe-area-inset-top)) var(--side-right) 4px var(--side-left);
}
.page-header h1 { margin: 0; font-size: 18px; line-height: 1.3; }
.page-meta {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}

/* ---- Chart: full viewport width, about 55% of the screen height, never tiny or huge ---- */
#chart {
  width: 100%;
  height: clamp(320px, 55vh, 520px);
  /* svh = the height with the mobile address bar shown, so the chart does not resize while scrolling. */
  height: clamp(320px, 55svh, 520px);
}
.load-error { margin: 12px var(--side-right) 12px var(--side-left); color: #b42318; }

/* ---- Controls ---- */
.controls {
  display: grid;
  gap: 16px;
  padding: 12px var(--side-right) 24px var(--side-left);
}
.control-group { min-width: 0; }
.control-title { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.control-row { margin-bottom: 10px; }

button, select, summary {
  font: inherit;
  color: inherit;
}
button, select {
  min-height: var(--tap-height);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
}
button { cursor: pointer; touch-action: manipulation; /* no double-tap zoom delay */ }
select { width: 100%; }

/* Segmented buttons: one row of equal-width buttons that look joined together. */
.segments { display: flex; }
.segments button {
  flex: 1;
  border-radius: 0;
  margin-left: -1px;
  padding: 0 4px;
}
.segments button:first-child { margin-left: 0; border-radius: 6px 0 0 6px; }
.segments button:last-child { border-radius: 0 6px 6px 0; }
.segments button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  position: relative; /* draws its blue border above the neighbours' grey ones */
}

/* Previous / today / next: the middle button is the widest. */
.nav-buttons { display: flex; gap: 8px; }
.nav-buttons button { flex: 1; font-size: 18px; }
.nav-buttons button.nav-today { flex: 2; font-size: 15px; }

/* ---- Model chips ---- */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.chip {
  display: flex; align-items: center; gap: 8px;
  text-align: left;
  padding: 4px 8px;
}
.chip[aria-pressed="false"] { opacity: 0.4; }
.chip-swatch { flex: none; width: 14px; height: 14px; border-radius: 3px; }
.chip-text { min-width: 0; display: flex; flex-direction: column; }
.chip-id { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.chip-label { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.chip-buttons { display: flex; gap: 8px; }
.chip-buttons button { flex: 1; }

.note { margin: 0; font-size: 12px; color: var(--muted); }

/* ---- Compare runs ---- */
.compare { border: 1px solid var(--line); border-radius: 6px; }
.compare summary {
  display: flex; align-items: center;
  min-height: var(--tap-height);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
}
.compare-body { padding: 0 12px 12px; }
.run-check {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap-height);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.run-check input { width: 22px; height: 22px; flex: none; }
.compare-buttons { display: flex; gap: 8px; margin-top: 8px; }
.compare-buttons button { flex: 1; }

/* ---- Desktop: two columns of controls, chart still full width ---- */
@media (min-width: 720px) {
  .page-header h1 { font-size: 22px; }
  .controls {
    max-width: 960px;
    margin: 0 auto;
    grid-template-columns: 1fr 1fr;
    gap: 16px 32px;
  }
  .control-group.wide { grid-column: 1 / -1; }
}
