/* Shell and shared components. Each tab's own layout is in views.css. */
*, *::before, *::after { box-sizing: border-box; }

/* bars run full width, but their content lines up with the centred page */
body {
  --edge: max(var(--gutter), calc((100% - var(--content-max)) / 2 + var(--gutter)));
  margin: 0;
  color: var(--ink);
  font: 400 var(--text-md)/1.55 var(--font);
  background: radial-gradient(1100px 420px at 12% -8%, #dbe8f5 0%, transparent 62%), var(--canvas);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }   /* the hidden attribute wins over any layout class */
h1, h2, h3, p, ol, ul, dl, dd, figure, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { padding: 0; border: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }   /* a real outline also shows in forced-colours mode */
.topbar :focus-visible { outline-color: #ffd9c8; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { display: none; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-2); }
.small { font-size: var(--text-sm); }
.fineprint { font-size: var(--text-xs); color: var(--ink-3); }
.kicker { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--edge);
  background: var(--brand-deep); color: #fff;
}
.brand { display: flex; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -0.01em; font-size: var(--text-lg); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--band-3); color: #fff; }
.brand-mark .icon { width: 22px; height: 22px; }
.place { padding: 3px 10px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 999px; font-size: var(--text-xs); color: #d3e2f1; white-space: nowrap; }
.finder { position: relative; margin-left: auto; width: min(22rem, 100%); }
.finder .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.finder input { width: 100%; height: 40px; padding: 0 var(--space-3) 0 38px; border: 0; border-radius: var(--radius-sm); background: #fff; color: var(--ink); }
.badge { padding: 3px 9px; border-radius: 999px; background: rgba(201, 83, 31, 0.18); color: #ffd9c8; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }

/* ---------- tabs: a bar under the header on wide screens, a bottom bar on phones ---------- */
.tabs {
  position: sticky; top: 0; z-index: 1000;
  display: flex; gap: var(--space-1);
  padding: 0 var(--edge);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs [role="tab"] {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-3); border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--ink-2); font-weight: 600; font-size: var(--text-sm); cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--brand); border-bottom-color: var(--accent); }
.tabs [role="tab"]:focus-visible { border-radius: 0; }

main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-6) var(--gutter) var(--space-10); }
.panel:focus { outline: none; }
.panel:not([hidden]) { animation: enter var(--duration-normal) var(--ease-out) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* ---------- surfaces and headings ---------- */
.surface { padding: var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.surface-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
h2 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em; }
.small-heading { font-size: var(--text-sm); font-weight: 700; margin-bottom: var(--space-2); }
.view-head { margin-bottom: var(--space-5); }
.view-head h1, .view-title { margin: var(--space-1) 0; font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }

.alert { margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--danger-wash); color: #7a2a12; font-weight: 600; font-size: var(--text-sm); }
.alert-inline { margin-bottom: var(--space-3); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 42px; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: var(--text-sm); cursor: pointer; text-decoration: none;
  transition: background-color var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-sunk); border-color: var(--ink-3); }
.btn-link { min-height: 0; padding: 0; background: none; color: var(--brand); font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.field { width: 100%; min-height: 42px; padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.field:hover { border-color: var(--ink-3); }
.field:focus-visible { border-color: var(--accent); }

/* flood size picker: three choices, each with its chance over ten years */
.scenario { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px; gap: 3px; border-radius: var(--radius-md); background: var(--surface-sunk); border: 1px solid var(--line); min-width: min(100%, 26rem); }
.scenario button { padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font-weight: 700; font-size: var(--text-sm); line-height: 1.25; cursor: pointer; color: var(--ink); transition: background-color var(--duration-fast); }
.scenario button:hover { background: var(--surface); }
.scenario button[aria-pressed="true"] { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.scenario .chance { display: block; font-size: var(--text-xs); font-weight: 500; color: var(--ink-3); }
.scenario button[aria-pressed="true"] .chance { color: var(--band-1); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { padding: var(--space-2) var(--space-3); border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: var(--text-sm); text-align: left; cursor: pointer; transition: border-color var(--duration-fast), background-color var(--duration-fast); }
.chip:hover { border-color: var(--brand); background: var(--brand-wash); }

.tags { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.tag { padding: 2px var(--space-2); border-radius: 999px; background: var(--surface-sunk); border: 1px solid var(--line); font-size: var(--text-xs); color: var(--ink-2); }

/* ---------- legend and depth swatches ---------- */
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: var(--space-2) var(--space-4); margin-top: var(--space-4); font-size: var(--text-xs); }
.legend li { display: flex; align-items: center; gap: var(--space-2); }
.legend .muted::before { content: "· "; }
.swatch { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); }
.band-1 { background: var(--band-1); } .band-2 { background: var(--band-2); } .band-3 { background: var(--band-3); }
.band-4 { background: var(--band-4); } .band-5 { background: var(--band-5); }
.swatch-dry { background: var(--surface); }

/* ---------- footer ---------- */
.about { max-width: var(--content-max); margin: 0 auto; padding: var(--space-8) var(--gutter) var(--space-10); display: grid; gap: var(--space-2); font-size: var(--text-xs); color: var(--ink-2); border-top: 1px solid var(--line); }
.about h2 { font-size: var(--text-sm); color: var(--ink); }

/* ---------- phones: compact header, tabs become a bottom bar ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
  .place, .badge { display: none; }
  .finder { order: 3; width: 100%; margin-left: 0; }
  .tabs {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    justify-content: space-around; gap: 0; padding: 0 0 env(safe-area-inset-bottom);
    border-top: 1px solid var(--line); border-bottom: 0;
  }
  .tabs [role="tab"] { flex: 1; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-1); border-bottom: 0; border-top: 2px solid transparent; font-size: 0.6875rem; }
  .tabs [role="tab"][aria-selected="true"] { border-top-color: var(--accent); }
  .tabs .icon { width: 22px; height: 22px; }
  main, .about { padding-bottom: calc(var(--space-10) + 64px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
