/* Stormbird — base styles, layout, and components. Depends on tokens.css. */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { margin: 0 0 var(--space-2); line-height: 1.25; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-4); }
a { color: var(--color-interactive); }
a:hover { color: var(--color-interactive-hover); }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Accessibility helpers ---------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-interactive);
  color: #FFFFFF;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 1000;
}
.skip-link:focus { top: var(--space-2); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: no-preference) {
  .theme-toggle, .btn, a { transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
}

/* ---------- Layout shell ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 3px solid var(--color-interactive);
  flex-wrap: wrap;
}

.header-title { display: flex; flex-direction: column; gap: 1px; }

.wordmark {
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: 0.08em;
  color: var(--color-text-primary);
}

/* Placeholder mark until a real logo exists — swap the <svg> out, this
   sizing/alignment should still hold. */
.wordmark-icon {
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.3em;
  vertical-align: middle;
  display: inline-block;
}

.header-tagline {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-interactive);
}

.site-nav {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--color-text-primary); border-color: var(--color-border); }
.site-nav a[aria-current="page"] {
  color: #FFFFFF;
  background: var(--color-interactive);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--color-text-primary); border-color: var(--color-text-secondary); }
.icon-btn[aria-current="page"] {
  color: #FFFFFF;
  background: var(--color-interactive);
  border-color: var(--color-interactive);
}

main { flex: 1; }

main#main-content {
  max-width: 72rem;
  margin: 0 auto;
  width: 100%;
  padding: var(--space-6) var(--space-5);
}

.page-heading { margin-bottom: var(--space-5); }

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-6);
}
.footer-inner {
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer .disclaimer-full {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}
.site-footer__meta {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}
.footer-version {
  font-weight: 400;
  letter-spacing: 0.02em;
  opacity: 0.7;
  margin-left: var(--space-1);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: var(--space-2) var(--space-4);
  min-height: 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  background: var(--color-interactive);
  color: #FFFFFF;
}
.btn:hover { background: var(--color-interactive-hover); }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn--primary { min-height: 48px; padding: var(--space-3) var(--space-5); }

.btn--secondary {
  background: transparent;
  color: var(--color-interactive);
  border-color: var(--color-interactive);
}
.btn--secondary:hover { background: var(--color-interactive); color: #FFFFFF; }

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  font-weight: 600;
}
.btn--ghost:hover { color: var(--color-text-primary); border-color: var(--color-text-secondary); }

.btn--danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn--danger:hover { background: var(--color-danger); color: #FFFFFF; }

/* ---------- Theme toggle (pill switch) ---------- */
.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 30px;
  padding: 3px;
  border-radius: 999px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
}
.theme-toggle:hover { border-color: var(--color-interactive); }
.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--color-interactive);
  transition: left 0.2s ease;
  z-index: 0;
}
.theme-toggle[aria-checked="true"] .theme-toggle-thumb { left: calc(50% + 1px); }
.theme-toggle-option {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
}
.theme-toggle[aria-checked="false"] .theme-toggle-option--light,
.theme-toggle[aria-checked="true"]  .theme-toggle-option--dark {
  color: #FFFFFF;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
input, select {
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 40px;
  margin-bottom: var(--space-3);
}
input:focus, select:focus { border-color: var(--color-interactive); }
input:disabled, select:disabled { color: var(--color-text-secondary); }
/* A disabled number input showing spin arrows implies it's still
   adjustable when it isn't (e.g. weight fields filled by a preset) —
   hide the arrows only in the disabled state; editable ones keep them. */
input[type="number"]:disabled::-webkit-inner-spin-button,
input[type="number"]:disabled::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]:disabled { -moz-appearance: textfield; }
/* Coordinates aren't a quantity anyone increments/decrements one at a time —
   the spin arrows are pure visual noise here. Scoped to lat/lon only; other
   number inputs (weight percentages) keep theirs, where nudging by 1 is useful. */
#site-lat::-webkit-inner-spin-button,
#site-lat::-webkit-outer-spin-button,
#site-lon::-webkit-inner-spin-button,
#site-lon::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#site-lat, #site-lon { -moz-appearance: textfield; }
fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
}
legend { font-weight: 600; padding: 0 var(--space-2); }
fieldset label { display: flex; align-items: center; gap: var(--space-2); font-weight: 400; margin-bottom: var(--space-2); }

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.form-row > div { display: flex; flex-direction: column; }
.form-row > div input,
.form-row > div select { margin-bottom: 0; }

/* A lone submit button as a form's first direct-child button is inline-block
   by default, so it can ride up next to a preceding input/select that hasn't
   filled its row (visible whenever nothing block-level separates them — e.g.
   Account's password form, or the Sites form when the visibility picker is
   hidden for Viewers). Forcing it block-level pushes it onto its own line
   without stretching its width or displacing a same-row Cancel button. */
form > .btn:first-of-type { display: block; }
/* The block-level submit button above has no default bottom margin, so a
   following Cancel button (still inline-block) sits flush against it on the
   next line — give it breathing room. */
form > .btn:first-of-type + .btn { margin-top: var(--space-3); }

/* Date + time as two separate native inputs (proper calendar/clock pickers
   each) rather than one segmented datetime-local field. */
.datetime-split { display: flex; gap: var(--space-2); }
/* No min-width override here: flex items default to min-width: auto, which
   keeps each control at least as wide as its own native content (text +
   picker icon). Overriding that to 0 let the time field's "hh:mm AA" text
   get squeezed behind the clock icon once its flex-basis lost the fight
   for space against the date field's higher flex-grow. */
.datetime-split input[type="date"] { flex: 1.3; }
.datetime-split input[type="time"] { flex: 1; }
@media (max-width: 30rem) {
  .datetime-split { flex-direction: column; }
  .datetime-split input[type="date"],
  .datetime-split input[type="time"] { width: 100%; }
}

.field-note { font-size: var(--text-sm); color: var(--color-text-secondary); }
.field-note-details { margin-bottom: var(--space-3); }
.field-note-details summary {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-interactive);
  cursor: pointer;
}
.field-note-details .field-note { margin-top: var(--space-2); }
/* Not a risk-status color on purpose — those are reserved exclusively for
   risk indicators — emphasis is weight/color-of-ink only, same as .form-error. */
.field-note--warn { font-weight: 700; color: var(--color-text-primary); }

/* Deliberately not a risk-status color — those are reserved exclusively for
   risk indicators. An auth error is bolded instead of colored. */
.form-error { font-size: var(--text-sm); font-weight: 700; margin: 0 0 var(--space-3); }
.form-error:empty { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}

#alerts-list .card { border-left: 4px solid var(--color-risk-high); }

/* ---------- Dismissible notice banner (e.g. Dashboard's preset-reset notice) ---------- */
.notice-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-interactive);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.notice-banner p { margin: 0; }
.notice-banner__dismiss {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: var(--text-lg);
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
}
.notice-banner__dismiss:hover { color: var(--color-text-primary); }

/* ---------- Site selector ---------- */
.site-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.site-selector > div { display: flex; flex-direction: column; }
.site-selector > div input,
.site-selector > div select { margin-bottom: 0; }

/* ---------- Risk score cards ---------- */
.risk-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.risk-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.risk-card h2 {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}
.risk-card__status {
  /* Bold + >=18.66px qualifies as "large text" under WCAG, meeting the 3:1
     contrast ratio these exact status colors achieve against surface — that
     ratio isn't met at solid-fill badge sizes, which is why this is
     colored text rather than a colored background. */
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0 0 var(--space-1);
  /* Default (no risk-card--x modifier) = data unavailable, muted rather
     than colored — never implies a real Low/Caution/High reading. */
  color: var(--color-text-secondary);
}
.risk-card__status::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}
.risk-card--low   { border-top-color: var(--color-risk-low); }
.risk-card--caution { border-top-color: var(--color-risk-caution); }
.risk-card--high  { border-top-color: var(--color-risk-high); }
.risk-card--low .risk-card__status { color: var(--color-risk-low); }
.risk-card--caution .risk-card__status { color: var(--color-risk-caution); }
.risk-card--high .risk-card__status { color: var(--color-risk-high); }

/* Overall is a combined/weighted readout, not a fourth peer category — set
   it apart with a brand-tinted background and left accent (left, not top,
   so the status-color top border above still shows through normally). */
.risk-card--overall {
  background: color-mix(in srgb, var(--color-interactive) 6%, var(--color-surface));
  border-left: 3px solid var(--color-interactive);
}
/* A flat 6% tint reads fine mixed into a light surface but is nearly
   invisible against dark mode's already-dark navy surface — needs its own,
   stronger value rather than relying on the same percentage in both themes. */
[data-theme="dark"] .risk-card--overall {
  background: color-mix(in srgb, var(--color-interactive) 16%, var(--color-surface));
}

.risk-card__score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-3xl);
  font-weight: 800;
  margin: 0;
  color: var(--color-text-primary);
}
.risk-card__score-of { font-size: var(--text-base); color: var(--color-text-secondary); font-weight: 400; }
.risk-card__driver {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin: var(--space-2) 0 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

/* ---------- Conditions strip (secondary tier) ---------- */
.conditions-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.condition-item { display: flex; flex-direction: column; gap: var(--space-1); }
.condition-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}
.condition-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-lg);
  font-weight: 600;
}
.condition-value--sub {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; border-radius: var(--radius-md); }
table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  white-space: nowrap;
}
thead th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-bg); }

.comparison-table td.cmp-score--low { color: var(--color-risk-low); font-weight: 600; }
.comparison-table td.cmp-score--caution { color: var(--color-risk-caution); font-weight: 600; }
.comparison-table td.cmp-score--high { color: var(--color-risk-high); font-weight: 600; }

/* ---------- Forecast report cards ---------- */
.forecast-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.forecast-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.forecast-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.forecast-card__header h3 { margin-bottom: 0; }
.forecast-card__window { font-size: var(--text-sm); color: var(--color-text-secondary); }
.forecast-card .risk-scores { margin-bottom: var(--space-4); }

/* Hairline dividers between metrics via the "colored gap" grid trick — the
   grid's own background shows through the 1px gap as a dividing line, so no
   per-cell border juggling (and no edges to special-case) is needed. */
.forecast-card__hazards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: var(--space-4);
}
.forecast-card__hazards .condition-item {
  background: var(--color-surface);
  padding: var(--space-3);
}
@media (max-width: 40rem) {
  .forecast-card__hazards { grid-template-columns: repeat(2, 1fr); }
}
.forecast-card--error .forecast-card__header { margin-bottom: var(--space-3); }

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---------- Settings page ---------- */
.tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.tabs a {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.tabs a:hover { color: var(--color-text-primary); background: var(--color-surface); }

section[id] { margin-bottom: var(--space-7); }

.weight-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  max-width: 24rem;
  margin-bottom: var(--space-4);
}
.weight-grid label { margin-bottom: 0; }
.weight-grid input { width: 5rem; }

.site-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}
.site-list li:last-child { margin-bottom: 0; }
.site-list { margin-bottom: var(--space-3); }
/* Checkbox rows (Forecast's saved-site picker) — full-width clickable label,
   no inherited margin from the generic label/input rules above. */
.site-list li label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  margin-bottom: 0;
  font-weight: 400;
  cursor: pointer;
}
/* Hover/selected feedback on the row itself, scoped to rows that actually
   contain a checkbox (:has) — Settings' plain site-list rows (Edit/Delete
   buttons, no checkbox) share this class but shouldn't look interactive
   the same way. */
.site-list li:has(input[type="checkbox"]):hover { border-color: var(--color-interactive); }
.site-list li:has(input[type="checkbox"]:checked) {
  border-color: var(--color-interactive);
  background: color-mix(in srgb, var(--color-interactive) 6%, var(--color-surface));
}
/* Same reasoning as .risk-card--overall's dark-mode override: a flat 6%
   tint disappears against dark mode's already-dark navy surface. */
[data-theme="dark"] .site-list li:has(input[type="checkbox"]:checked) {
  background: color-mix(in srgb, var(--color-interactive) 16%, var(--color-surface));
}

/* Custom checkbox — the native control looks out of step with the rest of
   the app (a stark white square in dark mode especially). Rebuilt from
   appearance:none rather than left as a browser default next to
   Stormbird-styled text. */
.site-list li input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  min-height: 0; /* override the generic input/select rule's 40px min-height */
  padding: 0; /* override the generic input/select rule's padding */
  margin: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
}
.site-list li input[type="checkbox"]:hover { border-color: var(--color-interactive); }
.site-list li input[type="checkbox"]::before {
  content: "";
  width: 11px;
  height: 11px;
  transform: scale(0);
  transition: transform 120ms ease;
  box-shadow: inset 1em 1em #FFFFFF;
  clip-path: polygon(13% 45%, 0% 65%, 50% 100%, 100% 15%, 80% 0%, 43% 62%);
}
.site-list li input[type="checkbox"]:checked {
  background: var(--color-interactive);
  border-color: var(--color-interactive);
}
.site-list li input[type="checkbox"]:checked::before { transform: scale(1); }

input[type="checkbox"] { margin-bottom: 0; }
.text-secondary { color: var(--color-text-secondary); font-size: var(--text-sm); margin-left: var(--space-2); }

.badge {
  display: inline-flex;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  margin-left: var(--space-2);
  vertical-align: middle;
}

.site-selector-card { margin-bottom: var(--space-5); }
.site-selector-card .site-selector { margin-bottom: 0; }
.active-source-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}
/* Same specificity trap as the site-list checkbox (see CLAUDE.md): a class
   selector and [hidden] tie in specificity, so display:flex above would win
   over display:none without this override. */
.active-source-label[hidden] { display: none; }
.active-source-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-interactive);
}

/* ---------- Auth page ---------- */
.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 3px solid var(--color-interactive);
  background: var(--color-surface);
}
.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-5);
}
.auth-card {
  width: 100%;
  max-width: 24rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-interactive);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  text-align: center;
}
.auth-card .wordmark { display: block; margin-bottom: var(--space-2); }
.auth-tagline { color: var(--color-text-secondary); margin-bottom: var(--space-5); }
.auth-card form { text-align: left; }
.auth-card .btn { width: 100%; margin-top: var(--space-2); }
.auth-note {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: var(--space-4) 0 0;
}

/* ---------- Spacing & layout utilities ---------- */
/* Small, generic one-property overrides — for anything more than spacing/
   alignment, use a real component class instead of stacking these. */
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-5 { margin-bottom: var(--space-5); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.align-end { align-items: flex-end; }
/* Visual separator above a form's destructive/secondary action, set off
   from the rest of the card (e.g. Account's "Sign out" below the password
   form). */
.section-divider { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--color-border); }

/* ---------- Responsive ---------- */
@media (max-width: 40rem) {
  .site-header { padding: var(--space-3) var(--space-4); }
  main#main-content { padding: var(--space-5) var(--space-4); }
  .risk-scores { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 26rem) {
  .risk-scores { grid-template-columns: 1fr; }
}

/* ---------- Link-styled buttons (for JS-triggered actions, not navigation) ---------- */
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-interactive);
  cursor: pointer;
  text-decoration: underline;
}
.link-button:hover { color: var(--color-interactive-hover); }

/* ---------- How This Works modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }

.modal-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  max-width: 40rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-6);
}
.modal-panel h2 { margin-bottom: var(--space-4); }
.modal-panel h3 { font-size: var(--text-base); margin-bottom: var(--space-1); }
.modal-panel section { margin-bottom: var(--space-5); }
.modal-panel__close {
  float: right;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-lg);
  line-height: 1;
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
}
.modal-panel__close:hover { color: var(--color-text-primary); border-color: var(--color-text-secondary); }

@media (prefers-reduced-motion: no-preference) {
  .modal-backdrop { animation: modal-fade-in 120ms ease; }
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Print (PDF export) ---------- */
.print-header { display: none; }

@media print {
  .skip-link, .site-header, #forecast-form, #show-adhoc-form-btn,
  #export-pdf-btn, #sort-toggle-btn, #compare-toggle-btn,
  [data-how-it-works-trigger], .theme-toggle {
    display: none !important;
  }
  body { background: #fff; color: #000; }
  main#main-content { padding: 0; max-width: 100%; }
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2px solid #000;
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-4);
  }
  .print-header .wordmark { color: #000; }
  .card, table, .forecast-card, .risk-card { box-shadow: none; border-color: #000; }
  table { font-size: 0.65rem; }
  th, td { padding: var(--space-1) var(--space-2); white-space: normal; border-color: #999; }
  .site-footer { border-top: 1px solid #000; margin-top: var(--space-4); }
  .site-footer .disclaimer-full, .site-footer__meta { color: #000; }
  a { color: #000; text-decoration: none; }
}
