/* ===================================================================
   Fish WNY — mobile-first stylesheet
   Identity: a cool "river" palette (steel blues + a lower-river orange),
   quiet neutrals biased toward the blue accent, generous touch targets.
   =================================================================== */

/* ===== Design tokens (light) ===== */
:root {
  --surface-1: #ffffff;
  --surface-2: #eef3f8;        /* insets, hover washes */
  --page: #f4f7fa;
  --text-primary: #0c1116;
  --text-secondary: #4a5561;
  --text-muted: #83909d;
  --grid-hairline: #e3e9ef;
  --baseline: #c2ccd6;
  --border: rgba(12, 17, 22, 0.09);
  --series-1: #2a78d6;   /* blue — primary accent / temp chart / upper-river */
  --series-2: #1baf7a;   /* aqua — wind chart */
  --series-8: #eb6834;   /* orange — lower-river markers */
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec;
  --seq-400: #3987e5; --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --shadow-sm: 0 1px 2px rgba(12, 17, 22, 0.05);
  --shadow: 0 1px 2px rgba(12, 17, 22, 0.05), 0 6px 20px rgba(12, 17, 22, 0.06);
  --shadow-lg: 0 2px 6px rgba(12, 17, 22, 0.06), 0 16px 40px rgba(12, 17, 22, 0.10);
  --hero-top: #e7f0fa;
  --hero-bottom: var(--page);
  --header-h: 58px;
  --radius: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --surface-1: #161b21;
  --surface-2: #1e252d;
  --page: #0b0e12;
  --text-primary: #f2f5f8;
  --text-secondary: #b0bac4;
  --text-muted: #7d8894;
  --grid-hairline: #232a31;
  --baseline: #333d47;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #199e70;
  --series-8: #d95926;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.6);
  --hero-top: #121a24;
  --hero-bottom: var(--page);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1: #161b21;
    --surface-2: #1e252d;
    --page: #0b0e12;
    --text-primary: #f2f5f8;
    --text-secondary: #b0bac4;
    --text-muted: #7d8894;
    --grid-hairline: #232a31;
    --baseline: #333d47;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --series-8: #d95926;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.6);
    --hero-top: #121a24;
    --hero-bottom: var(--page);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 10px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 clamp(16px, 5vw, 28px);
}
.fineprint { color: var(--text-muted); font-size: 12px; }
.updated-at { color: var(--text-muted); font-size: 12px; margin-left: 8px; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 1100;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--grid-hairline);
  padding-top: env(safe-area-inset-top, 0);
}
.header-inner {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-primary); margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-size: 20px; line-height: 1;
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(150deg, var(--seq-200), var(--series-1));
  box-shadow: var(--shadow-sm);
}
:root[data-theme="dark"] .brand-mark { background: linear-gradient(150deg, var(--seq-600), var(--series-1)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-text strong { font-size: 15.5px; letter-spacing: -0.01em; }
.brand-text small { color: var(--text-muted); font-size: 10.5px; }

.top-nav { display: flex; gap: 4px; }
.top-nav a {
  color: var(--text-secondary); font-size: 14px;
  padding: 7px 10px; border-radius: 8px;
}
.top-nav a:hover { color: var(--text-primary); background: var(--surface-2); text-decoration: none; }

.header-controls { display: flex; gap: 6px; align-items: center; }
.region-select, .lang-toggle, .theme-toggle {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  min-height: 38px;
}
.theme-toggle { min-width: 38px; }
.lang-toggle:hover, .theme-toggle:hover, .region-select:hover { border-color: var(--baseline); background: var(--surface-2); }

/* hamburger — hidden on desktop */
.nav-toggle {
  display: none;
  width: 40px; height: 40px; padding: 0;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; cursor: pointer;
  color: var(--text-primary);
}
.nav-toggle .bar { display: block; width: 17px; height: 2px; margin: 3px auto; border-radius: 2px; background: currentColor; transition: transform 0.2s ease, opacity 0.2s ease; }
.site-header.nav-open .nav-toggle .bar:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.site-header.nav-open .nav-toggle .bar:nth-child(2) { opacity: 0; }
.site-header.nav-open .nav-toggle .bar:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* ===== Hero ===== */
.hero {
  position: relative;
  background: linear-gradient(180deg, var(--hero-top) 0%, var(--hero-bottom) 100%);
  border-bottom: 1px solid var(--grid-hairline);
  overflow: hidden;
}
.hero::after {
  /* faint contour lines evoking depth/current */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 85% -10%, color-mix(in srgb, var(--series-1) 14%, transparent), transparent 60%);
  opacity: 0.7;
}
.hero-inner { position: relative; z-index: 1; padding: clamp(28px, 6vw, 52px) 0 clamp(24px, 5vw, 40px); }
.hero-eyebrow {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--series-1); font-weight: 600; margin: 0 0 10px;
}
.hero-title {
  margin: 0 0 12px;
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1.12; letter-spacing: -0.02em; font-weight: 800;
  text-wrap: balance; max-width: 18ch;
}
.hero-lede {
  margin: 0 0 20px; color: var(--text-secondary);
  font-size: clamp(14.5px, 2.4vw, 17px); max-width: 52ch;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-chips a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-1); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.hero-chips a:hover { text-decoration: none; border-color: var(--series-1); color: var(--series-1); }

/* ===== Sections ===== */
.section { padding: clamp(32px, 6vw, 52px) 0; }
.section-alt {
  background: var(--surface-1);
  border-top: 1px solid var(--grid-hairline);
  border-bottom: 1px solid var(--grid-hairline);
}
.section-head { margin-bottom: clamp(16px, 3vw, 22px); }
.section-eyebrow {
  font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600; margin: 0 0 6px;
  display: flex; align-items: center; gap: 8px;
}
.section-eyebrow::before {
  content: ""; width: 18px; height: 2px; border-radius: 2px;
  background: var(--series-1); display: inline-block;
}
.section-head h2 { margin: 0 0 5px; font-size: clamp(20px, 4vw, 27px); letter-spacing: -0.015em; text-wrap: balance; }
.section-sub { margin: 0; color: var(--text-secondary); font-size: clamp(13.5px, 2vw, 14.5px); max-width: 60ch; }

/* ===== Stat tiles ===== */
.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: clamp(10px, 2vw, 14px);
  margin-bottom: clamp(16px, 3vw, 22px);
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  min-height: 96px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.section-alt .stat-tile { background: var(--page); }
.stat-tile:hover { box-shadow: var(--shadow); }
.stat-label { color: var(--text-secondary); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: clamp(23px, 5vw, 27px); font-weight: 650; margin-top: 5px; letter-spacing: -0.02em; }
.stat-value small { font-size: 14px; font-weight: 400; color: var(--text-secondary); letter-spacing: 0; }
.stat-detail { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.stat-tile.is-loading .stat-value { color: var(--text-muted); font-weight: 400; font-size: 15px; }
.stat-tile.is-error .stat-value { color: var(--text-muted); font-weight: 400; font-size: 14px; }

/* ===== Charts ===== */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: clamp(10px, 2vw, 14px); }
.chart-card {
  margin: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px 8px;
  box-shadow: var(--shadow-sm);
}
.section-alt .chart-card { background: var(--page); }
.chart-title { color: var(--text-secondary); font-size: 12.5px; margin-bottom: 6px; }
.chart-body { position: relative; }
.chart-body svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-axis-text { fill: var(--text-muted); font-size: 10.5px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart-grid-line { stroke: var(--grid-hairline); stroke-width: 1; }
.chart-tooltip {
  position: fixed; z-index: 2000; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; box-shadow: var(--shadow);
  white-space: nowrap;
}
.chart-tooltip .tt-label { color: var(--text-muted); }
.chart-empty { color: var(--text-muted); font-size: 13px; padding: 24px 0 32px; }

/* ===== Map ===== */
.map-legend { display: flex; gap: 18px; margin-bottom: 12px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface-1); box-shadow: 0 0 0 1px var(--border); }
.leaflet-map {
  height: clamp(340px, 60vh, 540px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 1; /* keep below sticky header */
}
.spot-marker {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fcfcfb;
  box-shadow: 0 0 0 1px rgba(11,11,11,0.25);
}
.spot-popup h3 { margin: 0 0 4px; font-size: 15px; }
.spot-popup .spot-tags { margin: 0 0 6px; }
.spot-popup p { margin: 4px 0; font-size: 12.5px; }
.spot-popup .spot-hazard { color: var(--critical); }
.leaflet-popup-content-wrapper { background: var(--surface-1); color: var(--text-primary); border-radius: 10px; box-shadow: var(--shadow-lg); }
.leaflet-popup-tip { background: var(--surface-1); }
.leaflet-container { font-family: inherit; }
:root[data-theme="dark"] .leaflet-layer,
:root[data-theme="dark"] .leaflet-control-zoom,
:root[data-theme="dark"] .leaflet-control-attribution { filter: none; }

.spot-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.spot-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.section-alt .spot-card { background: var(--page); }
.spot-card:hover { border-color: var(--series-1); transform: translateY(-1px); box-shadow: var(--shadow); }
.spot-card h4 { margin: 0 0 3px; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.spot-card .spot-species { color: var(--text-muted); font-size: 12px; }
.tag {
  display: inline-block; font-size: 11px; border-radius: 999px;
  padding: 2px 9px; border: 1px solid var(--border); color: var(--text-secondary);
  margin-right: 4px;
}

/* ===== Species calendar ===== */
.species-calendar { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.species-table { border-collapse: collapse; width: 100%; min-width: 680px; font-size: 13px; }
.species-table th { text-align: left; color: var(--text-muted); font-weight: 500; font-size: 12px; padding: 6px 8px; }
.species-table th.month-col { text-align: center; padding: 6px 2px; }
.species-table td { padding: 6px 8px; border-top: 1px solid var(--grid-hairline); }
.species-name { white-space: nowrap; cursor: pointer; }
.species-name .sp-en { font-weight: 600; }
.species-name .sp-sub { color: var(--text-muted); font-size: 11.5px; }
.month-cell { padding: 6px 2px !important; }
.month-cell .cell-fill {
  height: 22px; border-radius: 4px; margin: 0 1px; /* 2px surface gap between cells */
  background: var(--grid-hairline);
}
.month-cell[data-level="1"] .cell-fill { background: var(--seq-200); }
.month-cell[data-level="2"] .cell-fill { background: var(--seq-400); }
.month-cell[data-level="3"] .cell-fill { background: var(--seq-600); }
:root[data-theme="dark"] .month-cell[data-level="1"] .cell-fill { background: var(--seq-600); }
:root[data-theme="dark"] .month-cell[data-level="2"] .cell-fill { background: var(--seq-400); }
:root[data-theme="dark"] .month-cell[data-level="3"] .cell-fill { background: var(--seq-200); }
.species-detail-row td {
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.species-detail-row .detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 20px; padding: 4px 0; }
.species-detail-row strong { color: var(--text-primary); font-weight: 600; }
.calendar-scale { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.calendar-scale .scale-cell { width: 22px; height: 12px; border-radius: 3px; background: var(--grid-hairline); }
.scale-cell[data-level="1"] { background: var(--seq-200); }
.scale-cell[data-level="2"] { background: var(--seq-400); }
.scale-cell[data-level="3"] { background: var(--seq-600); }
:root[data-theme="dark"] .scale-cell[data-level="1"] { background: var(--seq-600); }
:root[data-theme="dark"] .scale-cell[data-level="2"] { background: var(--seq-400); }
:root[data-theme="dark"] .scale-cell[data-level="3"] { background: var(--seq-200); }

/* ===== Link cards ===== */
.link-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: clamp(10px, 2vw, 14px); }
.link-card {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  font-size: 13px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.section-alt .link-card { background: var(--surface-1); }
.link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--baseline); }
.link-card h4 { margin: 0 0 5px; font-size: 14.5px; }
.link-card p { margin: 0 0 8px; color: var(--text-secondary); }
.link-card .lc-kind { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* ===== Regulations ===== */
.regs-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: clamp(10px, 2vw, 14px); }
.regs-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}
.section-alt .regs-card { background: var(--page); }
.regs-card h4 { margin: 0 0 7px; font-size: 14.5px; }
.regs-card ul { margin: 0; padding-left: 18px; color: var(--text-secondary); }
.regs-card li { margin: 4px 0; }
.regs-note { border-left: 3px solid var(--warning); }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--grid-hairline);
  padding: 26px 0 calc(34px + env(safe-area-inset-bottom, 0));
  color: var(--text-muted); font-size: 12.5px;
}
.site-footer p { margin: 0 0 8px; max-width: 74ch; }

/* ===================================================================
   Responsive — mobile behaviors below the desktop defaults above
   =================================================================== */
@media (max-width: 760px) {
  :root { --header-h: 54px; }
  .nav-toggle { display: block; }
  .top-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 2px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--grid-hairline);
    box-shadow: var(--shadow-lg);
    padding: 8px clamp(16px, 5vw, 28px) 14px;
    transform: translateY(-8px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  }
  .site-header.nav-open .top-nav { opacity: 1; visibility: visible; transform: translateY(0); }
  .top-nav a { padding: 11px 12px; font-size: 15px; border-radius: 10px; }
  .region-select { display: none; }  /* single region — hidden until multi-region */
  .brand-text small { display: none; }
}

@media (min-width: 761px) {
  .top-nav { margin-left: 8px; margin-right: 8px; }
}
