/* Layout on top of Pico classless, following portfolio-cal.
   Page text lives in content.json; this file is layout + chart tokens only. */

body {
  line-height: 1.25;
}

body > header {
  padding-block: 2rem;
}

header .site-intro {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: center;
  align-items: center;
}

header .site-intro p,
main p,
main li {
  line-height: 1.65;
}

header .site-intro p {
  margin: 0;
  color: var(--pico-muted-color);
}

h1, h2, h3 {
  line-height: 1.5;
}

/* ---------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  justify-content: center; /* Pico's <nav> defaults to space-between */
  gap: 0.25rem;
  border-block-end: 1px solid var(--pico-muted-border-color);
  margin-block-end: 1.5rem;
  overflow-x: auto;
}

/* Pico's classless <button> is a filled primary button; tabs need to be plain. */
.tabs button {
  margin: 0;
  padding: 0.6rem 1rem;
  border: 0;
  border-block-end: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--pico-muted-color);
  font-weight: 500;
  white-space: nowrap;
  width: auto;
  box-shadow: none;
}

.tabs button:hover {
  color: var(--pico-h1-color);
}

.tabs button[aria-selected="true"] {
  color: var(--pico-h1-color);
  border-block-end-color: var(--pico-primary);
}

.tabs button:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: -2px;
}

[role="tabpanel"] > h2 {
  margin-block-end: 0.4rem;
}

.intro {
  color: var(--pico-muted-color);
  margin-block-end: 1.25rem;
}

/* ---------------------------------------------------------------- images tab */

.run-picker {
  max-width: 16rem;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
  justify-content: center;
  gap: 1.25rem;
}

.frame-grid figure {
  margin: 0;
}

.frame-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #000;
  border-radius: var(--pico-border-radius);
}

.frame-grid figcaption {
  margin-block-start: 0.5rem;
  font-weight: 600;
  color: var(--pico-h1-color);
  text-align: left;
}

.frame-grid figcaption small {
  display: block;
  font-weight: 400;
  color: var(--pico-muted-color);
}

/* ---------------------------------------------------------------- timing tab */

.viz-root {
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --grid: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
  }
}

:root[data-theme="dark"] .viz-root {
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --grid: #2c2c2a;
  --baseline: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
}

.viz-root {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: var(--pico-border-radius);
  padding: 1rem;
  color: var(--text-primary);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.legend li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  list-style: none;
}

.legend .swatch {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-block-start: 0.3rem;
  border-radius: 3px;
}

.legend .def {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8rem;
  max-width: 32rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 12px;
  fill: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chart .axis-title {
  fill: var(--text-secondary);
}

.chart .bar {
  cursor: default;
}

.chart .bar.dim {
  opacity: 0.35;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--ring);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 5;
}

.tooltip .muted {
  color: var(--text-secondary);
}

.tooltip .row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tooltip .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* Chart | Table segmented switch; plain buttons like the tabs, not Pico's filled ones. */
.view-switch {
  display: flex;
  width: fit-content;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-block-end: 1rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.view-switch button {
  margin: 0;
  padding: 0.35rem 0.9rem;
  border: 0;
  border-radius: calc(var(--pico-border-radius) - 2px);
  background: transparent;
  color: var(--pico-muted-color);
  font-size: 0.9rem;
  width: auto;
  box-shadow: none;
}

.view-switch button:hover {
  color: var(--pico-h1-color);
}

.view-switch button[aria-pressed="true"] {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.view-switch button:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
}

.data-table {
  overflow-x: auto;
}

.data-table td,
.data-table th {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- methodology */

.method-section + .method-section {
  border-block-start: 1px solid var(--pico-muted-border-color);
  padding-block-start: 1rem;
}

.load-error {
  color: var(--pico-del-color);
}

footer {
  text-align: center;
  padding-block: 2rem;
  color: var(--pico-muted-color);
}

/* ---------------------------------------------------------------- theme toggle (from portfolio-cal) */

.theme-toggle {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 50%;
  background: var(--pico-card-background-color);
  color: var(--pico-h1-color);
  cursor: pointer;
}

.theme-toggle:hover { border-color: var(--pico-primary); }
.theme-toggle:focus-visible { outline: 2px solid var(--pico-primary); outline-offset: 2px; }

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media print {
  .theme-toggle { display: none; }
}
