:root {
  --bg-top: #e8f5fb;
  --bg-bot: #f4f9fb;
  --surface: #ffffff;
  --surface-2: #eef5f8;
  --ink: #14323d;
  --ink-soft: #466069;
  --ink-faint: #7f97a0;
  --border: #d8e8ee;
  --accent: #0a7fa3;
  --accent-ink: #075066;
  --good: #149a57;
  --good-bg: #e2f6ea;
  --caution: #c0820a;
  --caution-bg: #fcf2d8;
  --exceeds: #d6443f;
  --exceeds-bg: #fbe2e1;
  --unknown: #6a7e86;
  --unknown-bg: #e9eff2;
  --wave: #0a5d80;
  --shadow: 0 2px 4px rgba(16,60,75,.06), 0 10px 24px rgba(16,60,75,.10);
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #0c1920;
    --bg-bot: #0e171c;
    --surface: #15252d;
    --surface-2: #1b2d36;
    --ink: #e7eef1;
    --ink-soft: #aebcc3;
    --ink-faint: #7e8e96;
    --border: #26393f;
    --accent: #46bdde;
    --accent-ink: #8fd6ee;
    --good: #4fcb89; --good-bg: #0f3325;
    --caution: #e6b452; --caution-bg: #34280d;
    --exceeds: #f3736f; --exceeds-bg: #381a1a;
    --unknown: #93a3ab; --unknown-bg: #1d2b32;
    --shadow: 0 2px 4px rgba(0,0,0,.3), 0 10px 26px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(var(--bg-top), var(--bg-bot)) fixed;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, .value, .chip, .verdict, .ranges button {
  font-family: "Baloo 2", "Quicksand", ui-rounded, "SF Pro Rounded",
               "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); }
.wrap { width: min(1040px, 92vw); margin-inline: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Header with animated waves + mascot ---------- */
.site-header {
  position: relative;
  background: linear-gradient(165deg, #13a7cc 0%, #0a6e8f 55%, var(--wave) 100%);
  color: #fff;
  padding: 2.2rem 0 2.7rem;
  overflow: hidden;
}
.site-header h1 {
  margin: 0; font-size: clamp(1.7rem, 5vw, 2.5rem); font-weight: 700;
  letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem;
}
.drop {
  display: inline-block; width: .95em; height: .95em; flex: none;
  background: currentColor; transform-origin: 50% 80%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2C16 2 6 13 6 20a10 10 0 0 0 20 0C26 13 16 2 16 2z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2C16 2 6 13 6 20a10 10 0 0 0 20 0C26 13 16 2 16 2z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.tagline { margin: .4rem 0 0; opacity: .95; font-size: 1.05rem; }
.waves {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 24px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='24' viewBox='0 0 80 24'%3E%3Cpath fill='%230a5d80' d='M0 0 H80 V12 Q60 24 40 12 T0 12 Z'/%3E%3C/svg%3E") repeat-x;
  background-size: 80px 24px;
}
.mascot {
  position: absolute; right: 8%; bottom: 10px; font-size: 2.3rem;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); z-index: 1; user-select: none;
}

/* ---------- Intro ---------- */
.intro { margin: 1.7rem 0 1rem; }
.lede { margin: 0 0 .9rem; max-width: 62ch; color: var(--ink-soft); }
.lede strong { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.summary { margin: .2rem 0 1rem; font-weight: 600; font-size: 1.05rem; }
.summary .pill { color: var(--exceeds); }
.search input {
  width: 100%; padding: .75rem 1rem; font-size: 1rem;
  color: var(--ink); background: var(--surface);
  border: 2px solid var(--border); border-radius: 999px;
}
.search input:focus-visible { outline: none; border-color: var(--accent); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .7rem; border-radius: 999px;
  font-size: .82rem; font-weight: 600; white-space: nowrap;
  background: var(--unknown-bg); color: var(--unknown);
}
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.caution { background: var(--caution-bg); color: var(--caution); }
.chip.exceeds { background: var(--exceeds-bg); color: var(--exceeds); }
.chip.big { font-size: 1.02rem; padding: .4rem .9rem; }

/* ---------- Beach grid ---------- */
.grid {
  display: grid; gap: .9rem; padding: 0;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.beach {
  position: relative; overflow: hidden; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem 1rem 1.15rem;
  box-shadow: var(--shadow); color: inherit; font: inherit;
  display: flex; flex-direction: column; gap: .35rem;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.beach:hover { transform: translateY(-4px) rotate(-.4deg); border-color: var(--accent);
  box-shadow: 0 8px 10px rgba(16,60,75,.08), 0 18px 34px rgba(16,60,75,.16); }
/* our display:flex would otherwise defeat the hidden attribute — without this,
   the search filter runs but nothing visibly disappears */
.beach[hidden] { display: none; }
.beach:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.beach .mood { position: absolute; top: .55rem; right: .7rem; font-size: 1.6rem; line-height: 1; }
.beach .name { font-weight: 700; font-size: 1.08rem; line-height: 1.2; padding-right: 1.8rem; }
.beach .muni { color: var(--ink-faint); font-size: .82rem; }
.beach .readout { display: flex; align-items: baseline; gap: .4rem; margin-top: .15rem; }
.beach .value { font-size: 2rem; font-weight: 700; line-height: 1; }
.beach .unit { color: var(--ink-faint); font-size: .78rem; }
.beach.good .value { color: var(--good); }
.beach.caution .value { color: var(--caution); }
.beach.exceeds .value { color: var(--exceeds); }
.beach.unknown .value { color: var(--unknown); }
.beach .verdict { font-size: .92rem; font-weight: 600; }
.beach.good .verdict { color: var(--good); }
.beach.caution .verdict { color: var(--caution); }
.beach.exceeds .verdict { color: var(--exceeds); }
.beach.unknown .verdict { color: var(--unknown); }
.beach .when { font-size: .78rem; color: var(--ink-faint); }
.beach .when.stale { color: var(--caution); }
.beach .edge {
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--unknown);
}
.beach.good .edge { background: var(--good); }
.beach.caution .edge { background: var(--caution); }
.beach.exceeds .edge { background: var(--exceeds); }

.status { color: var(--ink-faint); padding: 1.2rem 0; font-size: 1.05rem; }

/* ---------- Detail overlay ---------- */
.detail {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10,40,52,.5); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 1rem;
}
.detail[hidden] { display: none; }
.detail-card {
  position: relative; width: min(820px, 96vw); max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem 1.6rem;
}
.close {
  position: absolute; top: .7rem; right: .8rem;
  width: 2.1rem; height: 2.1rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  font-size: 1.35rem; line-height: 1;
}
.close:hover { border-color: var(--accent); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-right: 2rem; }
.detail-head h2 { margin: 0; font-size: 1.5rem; }
.d-sub { margin: .2rem 0 0; color: var(--ink-faint); font-size: .9rem; }
.stats { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 1rem 0 .5rem; }
.stats div { display: flex; flex-direction: column; }
.stats dt { color: var(--ink-faint); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 700; }
.ranges { display: flex; gap: .4rem; margin: .4rem 0 .2rem; }
.ranges button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-soft);
  border-radius: 999px; padding: .28rem .8rem; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.ranges button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chart { margin: .6rem 0 .4rem; }
.chart svg { width: 100%; height: auto; display: block; touch-action: none; }
.chart-note { margin: .3rem 0 0; color: var(--ink-faint); font-size: .82rem; }
.official { display: inline-block; margin-top: .9rem; font-weight: 600; }
.itch-note {
  background: var(--surface-2); border-radius: 12px;
  padding: .7rem .9rem; margin: .9rem 0 0;
  font-size: .88rem; color: var(--ink-soft);
}
.itch-note strong { color: var(--ink); }

/* SVG chart pieces */
.ax { stroke: var(--border); }
.ax-text { fill: var(--ink-faint); font-size: 12px; }
.grid-line { stroke: var(--border); stroke-dasharray: 2 4; }
.series { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.guide { stroke: var(--exceeds); stroke-width: 1.2; stroke-dasharray: 5 4; opacity: .8; }
.guide-text { fill: var(--exceeds); font-size: 11px; font-weight: 600; }
.dot-good { fill: var(--good); } .dot-caution { fill: var(--caution); } .dot-exceeds { fill: var(--exceeds); }
.crosshair { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.tip-box { fill: var(--ink); opacity: .92; }
.tip-text { fill: var(--surface); font-size: 12px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 2.5rem; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--border); }
.disclaimer { background: var(--surface-2); border-radius: 14px; padding: .85rem 1.1rem; color: var(--ink-soft); margin: 0 0 .9rem; }
.disclaimer strong { color: var(--ink); }
.meta { color: var(--ink-faint); font-size: .85rem; margin: 0; }

/* ---------- Motion (opt-in; calm for reduced-motion users) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .waves { animation: drift 7s linear infinite; }
  .mascot { animation: bob 3.2s ease-in-out infinite; }
  .drop { animation: wiggle 4s ease-in-out infinite; }
  .beach { animation: surface .5s ease both; }
  @keyframes drift { from { background-position-x: 0; } to { background-position-x: -80px; } }
  @keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
  @keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
  @keyframes surface { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .beach { padding: .75rem .8rem .85rem 1rem; }
  .beach .value { font-size: 1.7rem; }
  .mascot { font-size: 1.9rem; right: 6%; }
}
