/* Base styling for the firecalc dashboard.
 *
 * Layout rules that depend on viewport width live in responsive.css, which
 * index.html links straight after this file. This one holds the colour tokens,
 * typography, and the component styling that is the same at every width.
 *
 * Colours are declared once as tokens and reused, so the contrast ratios below hold
 * everywhere (A4, WCAG AA):
 *   light  #16191d on #ffffff  = 15.8:1     muted #4a5157 on #ffffff = 8.0:1
 *          #0b5fa5 on #ffffff  =  6.6:1     #ffffff on #0b5fa5       = 6.6:1
 *   dark   #e8ebee on #14171a  = 14.6:1     muted #a9b2bb on #14171a = 8.7:1
 *          #7cb7ec on #14171a  =  7.9:1
 * Nothing is fetched: the font stack is whatever the system already has (A5).
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-sunken: #f4f6f8;
  --bg-raised: #ffffff;
  --text: #16191d;
  --text-muted: #4a5157;
  --accent: #0b5fa5;
  --accent-text: #ffffff;
  --border: #ccd3da;
  --border-strong: #98a3ad;
  --grid: #dde3e9;
  --focus: #0b5fa5;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-numeric: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 6px;
  --gap: 1rem;
  --gap-lg: 1.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --bg-sunken: #1c2126;
    --bg-raised: #1a1e23;
    --text: #e8ebee;
    --text-muted: #a9b2bb;
    --accent: #7cb7ec;
    --accent-text: #10161c;
    --border: #39424b;
    --border-strong: #5d6874;
    --grid: #2c333a;
    --focus: #7cb7ec;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Anchor jumps from the skip link land below the sticky nothing, but keep a
     little breathing room anyway. */
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  padding: 0 1rem 3rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  /* Nothing on this page may push the body sideways; wide tables scroll inside
     their own wrapper instead (A3). */
  overflow-x: hidden;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  margin-top: var(--gap-lg);
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
}

/* --- Focus, visible on every control (A4) --------------------------------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

/* --- Header, disclaimer, footer ------------------------------------------- */

.page-header,
.page-footer,
.layout {
  max-width: 1180px;
  margin: 0 auto;
}

.page-header {
  padding: 1.5rem 0 0.5rem;
}

.page-header__lead {
  max-width: 62ch;
  color: var(--text-muted);
}

.disclaimer {
  max-width: 78ch;
  margin: 1rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: 0.95rem;
}

.page-footer {
  margin-top: var(--gap-lg);
  padding-top: var(--gap);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 78ch;
}

/* --- Panels ---------------------------------------------------------------- */

.layout {
  display: block;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

/* --- Form ------------------------------------------------------------------ */

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem 0.25rem;
  margin: 0 0 var(--gap);
}

legend {
  padding: 0 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.field input,
.field select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-family: var(--font-numeric);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.field select {
  font-family: var(--font);
}

.hint {
  margin: 0.3rem 0 0;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}

.button:hover {
  filter: brightness(1.08);
}

/* --- Readouts -------------------------------------------------------------- */

.readouts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0;
}

.readout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  padding: 0.7rem 0.85rem;
}

.readout__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.readout__body {
  margin: 0.15rem 0 0;
}

.readout__value {
  display: block;
  font-family: var(--font-numeric);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.readout__note {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* --- Chart ----------------------------------------------------------------- */

.chart-figure {
  margin: 0;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.chart-tick,
.chart-legend,
.chart-axis-name,
.chart-empty {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
}

.chart-axis-name {
  font-weight: 600;
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* The two series differ by dash pattern as well as colour, so the chart still
   reads without colour vision (A4). */
.chart-line--nominal {
  stroke: var(--accent);
}

.chart-line--real {
  stroke: var(--text);
  stroke-dasharray: 7 5;
}

.chart-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Tables ---------------------------------------------------------------- */

/* Wide content scrolls inside its own box; the page body never does (A3). */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table-scroll--tall {
  max-height: 22rem;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table caption {
  caption-side: top;
  text-align: left;
  padding: 0.6rem 0.7rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.data-table th,
.data-table td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-sunken);
  text-align: right;
  border-bottom: 2px solid var(--border-strong);
}

.data-table thead th:first-child {
  text-align: left;
}

.data-table tbody th {
  text-align: left;
  font-weight: 600;
}

.data-table tbody td {
  text-align: right;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* --- Assumptions ----------------------------------------------------------- */

.assumptions {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.assumption {
  border-left: 3px solid var(--border-strong);
  padding-left: 0.7rem;
}

.assumption dt {
  font-weight: 600;
  font-size: 0.9rem;
}

.assumption dd {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
}
