/*
  style.css
  Purpose: Layout, colour, and responsive behaviour for the dashboard.
  Light and dark themes share one set of rules. Switching the
  data-theme attribute on <html> changes the colour variables below.
  No external fonts or stylesheets are used.
*/

/* Default (light) palette. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #152033;
  --muted: #5c6b7c;
  --line: #e3e8ee;
  --accent: #e507d6;
  --accent-bar: #1d4e89;
  --valid-bar: #05ef66;
  --track: #e7edf3;
  --shadow: 0 1px 2px rgba(21, 32, 51, 0.05), 0 10px 28px rgba(21, 32, 51, 0.05);
  --radius: 16px;
  color-scheme: light;
}

/* Dark palette, applied by script.js when the visitor chooses dark mode. */
html[data-theme="dark"] {
  --bg: #10161d;
  --surface: #1a232e;
  --text: #e8eef5;
  --muted: #9aabbd;
  --line: #2c3a4a;
  --accent: #8eb8ea;
  --accent-bar: #6aa4e0;
  --valid-bar: #5dcec0;
  --track: #243140;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Keep the content readable on wide screens and inset on small ones. */
.site-header,
main,
.site-footer {
  width: min(1040px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 2rem 0 1.25rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  line-height: 1.2;
  font-weight: 680;
}

.lede,
.panel-note,
.chart-caption,
.site-footer p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Theme control. The label is updated in script.js. */
.theme-toggle {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 0.2rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Four summary cards. They stack on narrow screens and sit in a row on wide ones. */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 1.05rem 1.1rem 1.15rem;
}

.metric-card h2,
.rate-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.metric-value {
  margin: 0.45rem 0 0;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.panel {
  margin-top: 0.9rem;
  padding: 1.25rem 1.25rem 1.1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.rate-block {
  margin: 0;
  text-align: right;
}

.rate-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.03em;
}

/* Each chart row is a label, a track, and the count. */
.chart {
  display: grid;
  gap: 0.95rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(8.5rem, 10rem) 1fr auto;
  gap: 0.75rem 1rem;
  align-items: center;
}

.bar-label,
.bar-value {
  font-size: 0.95rem;
  font-weight: 650;
}

.bar-value {
  font-variant-numeric: tabular-nums;
  min-width: 4.2rem;
  text-align: right;
}

.bar-track {
  height: 1.15rem;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transform-origin: left center;
}

.bar-fill.entries {
  background: var(--accent-bar);
}

.bar-fill.valid {
  background: var(--valid-bar);
}

.chart-caption {
  margin-top: 0.85rem;
}

.site-footer {
  padding: 1.25rem 0 2rem;
}

/* Narrow screens: cards become two columns, then one. Header and chart rows wrap. */
@media (max-width: 800px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .site-header,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .rate-block {
    text-align: left;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr auto;
  }

  .bar-label {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill {
    transition: none;
  }
}
