/* Cellstop weather design system. Order: tokens, base, layout, components, page-specific, print, dark. */

/* ---- Tokens (every text/background pair below is >= 4.5:1, WCAG AA) ---- */
:root {
  --bg: #f2f5fa; --surface: #fff; --ink: #14213d; --muted: #44506a; --line: #dde3ee;
  --brand-1: #1b2a6b; --brand-2: #0e5a8a; --heading: #1b2a6b; --link: #1a4fa3; --tint: #eef3fb;
  /* amber is a background only, always with --accent-ink text */
  --accent: #ffb020; --accent-ink: #3a2400;
  --accent-edge: #a86400; /* amber for lines/outlines: >= 3:1 non-text contrast on light backgrounds */
  --hi: #0e5a8a; --lo: #a2461f;
  --best: #1e7a3c; --best-ink: #fff; --good: #e6f6ec; --good-ink: #145c32; --slow: #e5e9f0; --slow-ink: #44506a;
  --radius: 16px; --shadow: 0 6px 18px rgba(20, 33, 61, .10);
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
  /* page-specific: month grid weekend tint and fishing calendar levels */
  --we: #f6f9fc;
  --sf: #dcecf9; --gf: #8fc1ec; --bf: #2b6cb0; --on-bf: #fff;
  /* wind strength bands (Wind::band), always with --ink text */
  --wb0: #e8f6ee; --wb1: #cdeedb; --wb2: #fff1c7; --wb3: #ffd98a; --wb4: #ffb27a; --wb5: #f58a7a;
}

/* ---- Base ---- */
* { box-sizing: border-box; }
body { margin: 0; font: 1rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); overflow-wrap: break-word; }
a { color: var(--link); }
h1 { color: var(--heading); line-height: 1.2; margin: var(--s2) 0; }
h2 { color: var(--heading); margin-top: 1.75rem; }
h3 { margin-bottom: var(--s1); }
img { max-width: 100%; height: auto; }
figure { margin: var(--s4) 0; }
table { border-collapse: collapse; }
th, td { border: 1px solid var(--line); padding: .3rem .5rem; text-align: left; vertical-align: top; }

/* ---- Layout: header, nav, hero, page, footer ---- */
.site-header { background: linear-gradient(160deg, var(--brand-1) 0%, var(--brand-2) 100%); color: #fff; padding: var(--s3) var(--s4); }
.site-header.has-hero { padding-bottom: 3.5rem; }
.site-bar { max-width: 72rem; margin: 0 auto; display: flex; align-items: center; gap: var(--s2); }
/* the logo GIF has a white background, so the card stays white in dark mode too */
.brand-card { flex: none; display: flex; background: #fff; border-radius: 12px; padding: 6px 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.brand-card img { display: block; height: 34px; width: auto; }
.brand-name { color: #fff; font-weight: 800; text-decoration: none; margin-right: auto; }
/* Phones get the <details> menu, 700px+ the inline nav: same links, exactly one shown, no JS. */
.site-nav { display: none; }
.site-menu { position: relative; flex: none; }
.site-menu > summary { white-space: nowrap; list-style: none; cursor: pointer; color: #fff; font-weight: 600; padding: var(--s1) var(--s3); border-radius: 8px; background: rgba(255, 255, 255, .16); }
.site-menu > summary::-webkit-details-marker { display: none; }
.site-menu > summary::before { content: "\2630  "; content: "\2630  " / ""; }
.menu-links { position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 10; min-width: 13rem; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: var(--s2); }
.menu-links a { color: var(--ink); text-decoration: none; padding: var(--s2) var(--s3); border-radius: 8px; }
.menu-links a:hover { background: var(--tint); }
/* Theme toggle: shown by theme.js only, so no-JS visitors never see a dead button. In the bar from 700px, in the menu on phones. */
.theme-toggle { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 8px; padding: var(--s1) var(--s3); white-space: nowrap; }
.theme-toggle[hidden] { display: none; }
.theme-toggle-bar { display: none; color: #fff; background: rgba(255, 255, 255, .16); }
.menu-links .theme-toggle { text-align: left; color: var(--ink); background: var(--tint); margin-top: var(--s2); padding: var(--s2) var(--s3); }
@media (min-width: 700px) {
  .site-menu { display: none; }
  .theme-toggle-bar:not([hidden]) { display: inline-block; }
  .site-nav { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
  .site-nav a { color: #dfe8ff; text-decoration: none; padding: var(--s1) 0; font-size: .95rem; }
  .site-nav a:hover { color: #fff; text-decoration: underline; }
}
.hero { max-width: 72rem; margin: 0 auto; }
.hero h1 { color: #fff; font-size: clamp(1.4rem, 5vw, 1.75rem); margin: var(--s5) 0 var(--s1); }
.hero-sub { color: #cfdcf7; margin: 0; }
/* the header pads outside its 72rem bar, the page pads inside: add both gutters so card edges line up with the logo */
.page { max-width: calc(72rem + 2 * var(--s4)); margin: 0 auto; padding: var(--s4); }
.has-hero + .page { margin-top: -2.25rem; padding-top: 0; }
.site-footer { margin-top: var(--s6); padding: var(--s5) var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer nav, .site-footer p { max-width: 72rem; margin: 0 auto; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.site-footer p { margin-top: var(--s3); }

/* ---- Components ---- */
.card { display: flow-root; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s4); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: var(--s3); }
ul.card-grid { list-style: none; padding: 0; }
.chip { display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--slow); color: var(--slow-ink); }
.chip-accent { background: var(--accent); color: var(--accent-ink); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rating-best { background: var(--best); color: var(--best-ink); }
.rating-good { background: var(--good); color: var(--good-ink); }
.rating-slow { background: var(--slow); color: var(--slow-ink); }
.pill-links { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; padding: 0; margin: var(--s3) 0 0; }
.pill-links a { display: inline-block; background: var(--tint); color: var(--heading); border-radius: 8px; padding: .35rem .7rem; font-size: .875rem; font-weight: 600; text-decoration: none; }
.pill-links a:hover { text-decoration: underline; }
.data-table { width: 100%; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { border: 0; border-bottom: 1px solid var(--line); padding: var(--s2); }
.data-table thead th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.notice { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--ink); border-radius: 12px; padding: var(--s3) var(--s4); margin: var(--s3) 0; }
.stack { display: grid; gap: var(--s4); }
.showcase { margin: var(--s5) 0; }
.showcase a { display: block; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.showcase img { display: block; width: 100%; height: auto; aspect-ratio: 15 / 13; }
@media (min-width: 700px) { .showcase img { aspect-ratio: 6 / 1; } }

/* ---- Page-specific: static pages ---- */
.lede { color: var(--muted); margin-top: 0; }
img.right { float: right; margin: var(--s1) 0 var(--s2) var(--s4); }
dl.facts { margin: 0; }
dl.facts dt { font-weight: 700; color: var(--heading); margin-top: var(--s4); }
dl.facts dd { margin: .15rem 0 0; }
dl.facts dl dt { color: var(--heading); margin-top: var(--s2); }
.table-scroll { overflow-x: auto; }
.towns { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--s2) var(--s5); }
.towns h3 { margin: var(--s2) 0 0; font-size: 1rem; }
.towns ul { margin: var(--s1) 0; padding-left: 1.2rem; }

/* ---- Page-specific: fishing calendar ---- */
.calendar td, .calendar th { text-align: center; padding: .2rem .35rem; font-size: .9rem; }
.calendar th[scope=row] { text-align: left; white-space: nowrap; }
.nf { background: var(--surface); } .sf { background: var(--sf); } .gf { background: var(--gf); } .bf { background: var(--bf); color: var(--on-bf); }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.legend span { display: inline-block; min-width: 3rem; text-align: center; border: 1px solid var(--line); }

/* ---- Page-specific: tide month and moon month (grid from 700px, one row per day below; same markup) ---- */
.card-label { margin: 0; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.chip-lg { font-size: 1rem; padding: .35rem .9rem; }
/* Month nav sits on the gradient: white text on 14% white stays >= 5:1 against both gradient stops. */
.hero-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-top: var(--s2); color: #fff; }
.hero-nav a:not(.town-pick a), .town-pick > summary { background: rgba(255, 255, 255, .14); color: #fff; border-radius: 10px; padding: .3rem .75rem; font-size: .875rem; font-weight: 600; text-decoration: none; }
.hero-nav a:not(.town-pick a):hover, .town-pick > summary:hover { text-decoration: underline; }
/* prev | month | next on one row, month centred even when prev or next is missing */
.month-step { flex: 1 0 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s2); }
.month-step [rel=prev] { grid-column: 1; justify-self: start; }
.month-step strong { grid-column: 2; font-size: 1.6rem; text-align: center; }
.month-step [rel=next] { grid-column: 3; justify-self: end; }
/* the nav repeats the month on screen; the sub stays for print */
@media screen { .hero-sub:has(+ .hero-nav) { display: none; } }
@media (max-width: 699.98px) {
  .nav-rest { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.town-pick { margin-left: auto; position: relative; }
.town-pick > summary { cursor: pointer; list-style: none; }
.town-pick > summary::-webkit-details-marker { display: none; }
.town-pick > summary::after { content: " \25BE"; content: " \25BE" / ""; }
.town-pick ul { position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 10; width: min(24rem, 80vw); columns: 2; margin: 0; list-style: none;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: var(--s2) var(--s3); font-size: .9rem; }
.town-pick ul a { color: var(--link); }
.town-pick [aria-current] { font-weight: 700; }
table.month { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 5px; font-size: .8rem; line-height: 1.35; }
.month th { border: 0; color: var(--muted); text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: .1rem; }
.month td { border: 0; border-radius: 12px; background: var(--we); padding: .4rem .45rem; height: 7.5rem; }
.month td.we { background: var(--tint); }
.month td.pad { background: none; vertical-align: middle; }
.month td.today { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); outline: 3px solid var(--accent-edge); outline-offset: -3px; }
.month .top { display: flex; justify-content: space-between; }
.month .top b { font-size: .95rem; }
/* the whole of today's cell opens the today page */
.month td.today { position: relative; }
.today-link { color: inherit; }
.today-link::after { content: ""; position: absolute; inset: 0; }
.month .wd, .summary-phone { display: none; }
.month .tides { display: grid; grid-template-columns: auto auto 1fr; gap: 0 .3rem; margin: .15rem 0 .25rem; font-variant-numeric: tabular-nums; }
.month .tides abbr { font-weight: 800; text-decoration: none; }
.H { color: var(--hi); } .L { color: var(--lo); }
.month .tides .t { font-weight: 800; font-size: .9rem; }
.month .tides .ht { color: var(--muted); }
.month .chip { font-size: .7rem; padding: .05rem .45rem; border-radius: 8px; white-space: normal; }
.month .astro { color: var(--muted); font-size: .7rem; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.summary { margin: 0; font-size: .85rem; }
.summary dt { font-weight: 700; color: var(--heading); }
.summary dd { margin: 0 0 .35rem; font-variant-numeric: tabular-nums; }
.summary-below { display: flex; gap: var(--s6); margin-top: var(--s2); }
.month-notes { font-size: .875rem; color: var(--muted); margin-top: var(--s3); }
.month-notes .chip { font-size: .75rem; }
@media screen and (max-width: 699.98px) {
  table.month, .month tbody, .month tr { display: block; }
  .month thead, .month td.pad, .summary-below { display: none; }
  .summary-phone { display: flex; gap: var(--s5); margin-bottom: var(--s2); }
  .month td { display: grid; grid-template-columns: 3.25rem 1fr; gap: 0 var(--s2); height: auto; border-radius: 0; background: none; border-bottom: 1px solid var(--line); padding: .6rem var(--s1); }
  .month td.we { background: none; }
  .month td .top { grid-row: span 3; flex-direction: column; justify-content: flex-start; }
  .month td > :not(.top) { grid-column: 2; }
  .month .wd { display: inline; font-weight: 400; color: var(--muted); }
  .month .tides { grid-template-columns: repeat(2, auto auto 1fr); }
}

/* ---- Page-specific: tides today ---- */
.today-grid, .today-col { display: grid; gap: var(--s4); align-content: start; }
@media (min-width: 900px) { .today-grid { grid-template-columns: 1.4fr 1fr; } }
.next-big { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: var(--s1) 0; font-size: clamp(1.6rem, 6vw, 2.5rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.next-big .chip { font-size: .85rem; padding: .25rem .75rem; }
.today-grid .meta { color: var(--muted); font-size: .85rem; }
.today-grid .meta .H, .today-grid .meta .L, .today-tides td.H, .today-tides td.L { font-weight: 800; }
.curve { width: 100%; height: auto; display: block; }
.curve .night { fill: var(--line); opacity: .6; } .curve .fishband { fill: var(--best); opacity: .25; }
.curve .line { fill: none; stroke: var(--hi); stroke-width: 3; }
.curve .now { stroke: var(--accent-edge); stroke-width: 2.5; } .curve .mid { stroke: var(--line); }
.curve text { fill: var(--muted); font-size: 10px; } .curve text.nowlabel { fill: var(--ink); font-weight: 700; }

/* ---- Page-specific: wind ---- */
.wind-now { margin-bottom: var(--s4); }
.wind-now .meta, .met-credit { color: var(--muted); font-size: .85rem; }
/* relative: keeps the absolutely positioned visually-hidden labels inside the scroller, not widening the page */
.wind-grid-wrap { position: relative; overflow-x: auto; }
.wind-grid { font-size: .85rem; text-align: center; font-variant-numeric: tabular-nums; }
.wind-grid th, .wind-grid td { border: 0; border-top: 1px solid var(--line); padding: .3rem .5rem; text-align: center; white-space: nowrap; }
.wind-grid th[scope="colgroup"] { background: var(--tint); color: var(--heading); text-align: left; }
.wind-grid th[scope="row"], .wind-grid thead td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); color: var(--muted); text-align: left; }
.wind-grid .step-6h { border-left: 1px dashed var(--line); }
.wind-grid .arrow { display: inline-block; font-size: 1rem; transform: rotate(var(--deg)); }
.band-0, .band-1, .band-2, .band-3, .band-4, .band-5 { color: var(--ink); font-weight: 700; }
.band-0 { background: var(--wb0); } .band-1 { background: var(--wb1); } .band-2 { background: var(--wb2); }
.band-3 { background: var(--wb3); } .band-4 { background: var(--wb4); } .band-5 { background: var(--wb5); }

/* ---- Page-specific: forecast ---- */
.forecast { display: grid; gap: var(--s4); margin-bottom: var(--s4); }
.forecast .meta, .stale { color: var(--muted); font-size: .85rem; }
.now-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.now-row p { margin: 0; }
.days, .tide-strip { list-style: none; padding: 0; margin: var(--s2) 0 0; }
.days li { display: grid; grid-template-columns: 3rem 2rem 1fr auto; grid-template-areas: "day icon temp pill" "day icon wind pill"; gap: 0 var(--s2); align-items: center; padding: var(--s2) 0; border-top: 1px solid var(--line); }
.days li > :nth-child(1) { grid-area: day; } .days li > :nth-child(2) { grid-area: icon; } .days li > :nth-child(3) { grid-area: temp; }
.days li > :nth-child(4) { grid-area: wind; } .days li > :nth-child(5) { grid-area: pill; }
.day-icon img { display: block; }
.tide-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); gap: var(--s2); }
.tide-strip li { background: var(--tint); border-radius: 8px; padding: var(--s2); text-align: center; }
.tide-strip .meta { display: block; }

/* ---- Page-specific: home town cards ---- */
.find-town { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.find-town label { font-weight: 700; }
.find-town input { flex: 1 1 12rem; min-width: 0; font: inherit; padding: .45rem .7rem; border: 1px solid var(--muted); border-radius: 8px; background: var(--bg); color: var(--ink); }
.find-town button { font: inherit; font-weight: 700; padding: .45rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.town-name { margin: 0; font-size: 1.05rem; display: flex; justify-content: space-between; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.town-card .big { font-size: 1.4rem; font-weight: 800; margin: var(--s1) 0; }
.town-card .meta { color: var(--muted); font-size: .85rem; margin: var(--s1) 0; }
.card-weather { margin: var(--s3) 0 var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.card-weather dl { margin: 0; display: grid; gap: var(--s2); }
.card-weather dt { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.card-weather dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); font-weight: 700; color: var(--ink); }
.card-weather .sky { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 500; }

/* ---- Print: one landscape A4 month; no header, nav, footer or showcase ---- */
.print-credit { display: none; }
@media print {
  .print-credit { display: block; text-align: center; font-size: 9pt; margin-top: 3mm; }
  @page { size: A4 landscape; margin: 8mm; }
  /* the header itself stays so a hero <h1> (the page title) prints, in dark ink on white */
  .site-bar, .site-footer, .showcase, .noprint, .summary-phone { display: none; }
  body { font-size: 11pt; background: #fff; }
  .site-header, .site-header.has-hero { background: none; padding: 0; }
  .hero h1 { color: var(--ink); font-size: 14pt; margin: 0; }
  .hero-sub { color: var(--muted); font-size: 9pt; margin: 0 0 2mm; }
  .card { box-shadow: none; border-radius: 0; padding: 0; }
  .has-hero + .page { margin-top: 0; }
  a { color: inherit; text-decoration: none; }
  .page { max-width: none; padding: 0; }
  table.month { border-collapse: collapse; font-size: 7.5pt; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .month th, .month td { border: 1px solid var(--line); border-radius: 0; }
  .month th { background: var(--brand-1); color: #fff; letter-spacing: 0; }
  /* six week rows must fit one page: tides two per line, sun/moon on one line */
  table.month { line-height: 1.2; }
  .month td { height: auto; padding: 1mm; }
  .month .top { line-height: 1.1; }
  .month .top b { font-size: 8.5pt; }
  .month .tides { grid-template-columns: repeat(2, auto auto 1fr); gap: 0 .7mm; margin: .5mm 0; }
  .month .chip { font-size: 7pt; padding: 0 1mm; }
  .month .tides .t { font-size: 8pt; }
  .month .astro { font-size: 6.5pt; white-space: nowrap; margin-top: .5mm; }
  .month-notes, .month-notes .chip { font-size: 7pt; }
  .month-notes p { margin: 1mm 0; }
  /* wind page prints the grid only */
  .wind-now { display: none; }
  .wind-grid-wrap { overflow: visible; }
  .wind-grid { font-size: 8pt; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---- Dark variant (never the default; screen only so print stays light) ---- */
/* Auto follows the device; theme.js sets data-theme="light"|"dark" when the visitor picks one. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1530; --surface: #17213f; --ink: #e6ebf5; --muted: #a9b4c9; --line: #2c3a5e;
    --heading: #b9c8f5; --link: #8db8ff; --tint: #22305a;
    --hi: #8db8ff; --lo: #e2a84c; --accent-edge: #ffb020;
    --good: #16301f; --good-ink: #9fdcb0; --slow: #2c3a5e; --slow-ink: #c9d2e3;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35);
    --we: #1b2747;
    --sf: #1d3247; --gf: #2a5d8c; --bf: #8fc1ec; --on-bf: #11151c;
    --wb0: #17332a; --wb1: #1f4a36; --wb2: #4a4318; --wb3: #6b4c12; --wb4: #7a3a14; --wb5: #8a2a22;
  }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1530; --surface: #17213f; --ink: #e6ebf5; --muted: #a9b4c9; --line: #2c3a5e;
    --heading: #b9c8f5; --link: #8db8ff; --tint: #22305a;
    --hi: #8db8ff; --lo: #e2a84c; --accent-edge: #ffb020;
    --good: #16301f; --good-ink: #9fdcb0; --slow: #2c3a5e; --slow-ink: #c9d2e3;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35);
    --we: #1b2747;
    --sf: #1d3247; --gf: #2a5d8c; --bf: #8fc1ec; --on-bf: #11151c;
    --wb0: #17332a; --wb1: #1f4a36; --wb2: #4a4318; --wb3: #6b4c12; --wb4: #7a3a14; --wb5: #8a2a22;
  }
}
:root[data-theme="light"] { color-scheme: light; }
