/* ZVN weer — homepage block. Same tokens as style.css (light palette), laid out
   like the old weerblok-zvn.php tiles: 2 columns, 4 from 560px wide. Light by
   default because it sits on the club's white page; ?thema=auto follows the
   visitor's dark mode, ?thema=donker forces dark. */
:root {
  --ground: #E7EEEE;
  --surface: #F6F9F8;
  --ink: #14323C;
  --muted: #557079;
  --line: #C9D6D7;
  --signal: #E8590C;
  --sea: #1C7C8C;
  --warn: #B4231B;
  --ok: #2B8A3E;
  --hw: #E3F0F2;
  --bft-0: #B3DEEC; --bft-1: #86CBE0; --bft-2: #52B4CC; --bft-3: #3FAE92; --bft-4: #6DBE4B;
  --bft-5: #B4CE3A; --bft-6: #F2C744; --bft-7: #F39A45; --bft-8: #E8590C; --bft-9: #D42F1F;
  --bft-10: #B0145A; --bft-11: #861B7C; --bft-12: #561A6C;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-thema="auto"] {
    --ground: #0C1D23; --surface: #12282F; --ink: #E2ECEC; --muted: #8EA6AD; --line: #22414A;
    --signal: #FF7A33; --sea: #4DB3C2; --warn: #FF6B5E; --ok: #51CF66; --hw: #173A43;
    color-scheme: dark;
  }
}
:root[data-thema="donker"] {
  --ground: #0C1D23; --surface: #12282F; --ink: #E2ECEC; --muted: #8EA6AD; --line: #22414A;
  --signal: #FF7A33; --sea: #4DB3C2; --warn: #FF6B5E; --ok: #51CF66; --hw: #173A43;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { background: transparent; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  container-type: inline-size;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 880px;
  margin: 0 auto;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
a.tile { transition: border-color .2s; }
a.tile:hover { border-color: var(--sea); }
a.tile:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }
.wide { grid-column: 1 / -1; }

.label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}
.label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.unit { font-size: 15px; font-weight: 400; color: var(--muted); }
.sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub:empty { display: none; }
.sub.gusty { color: var(--warn); }
.sub.gusty::before { content: "\26A0\FE0E\00A0"; }

/* Sea state icon after the wave height; red when short and steep */
.chop-icon { align-self: center; width: 24px; height: 16px; margin-left: 4px; fill: none; stroke: var(--sea);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chop-icon[hidden] { display: none; }
.chop-icon .cap { stroke-width: 1.2; }
.chop-icon.warn { stroke: var(--warn); }
.sub.rough { color: var(--warn); }

/* Wind: Beaufort colour chip, arrow pointing downwind, red when offshore */
.chip {
  align-self: center;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  margin-right: 2px;
  background: var(--c, var(--line));
  transition: background .6s;
}
.dir {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
}
.dir[hidden] { display: none; }
#b-dir-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.arrow { width: 14px; height: 14px; flex: none; color: var(--signal); transition: transform 1.2s cubic-bezier(.3,.7,.3,1); }
.dir b { color: var(--sea); font-weight: 650; }
.wind.warn .arrow, .wind.warn .dir b { color: var(--warn); }

/* Tides: the next four high and low waters */
.tides {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.tide {
  padding: 7px 4px;
  border-radius: 9px;
  border: 1px solid var(--line);
  text-align: center;
  line-height: 1.3;
}
.tide.HW { background: var(--hw); }
.tide .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.tide.HW .k { color: var(--sea); }
.tide .t { font-size: 18px; font-weight: 600; }
.tide .h { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tide .day::before { content: " · "; }
.tide.next { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.empty { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.empty[hidden] { display: none; }

/* Sun and live status */
.foot {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding-block: 9px;
  font-size: 13px;
  color: var(--muted);
}
.sun b { color: var(--ink); font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.status.live .dot { background: var(--ok); }
.status.stale { color: var(--warn); }
.status.stale .dot { background: var(--warn); }

@container (min-width: 560px) {
  .grid  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tides { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@container (max-width: 359px) {
  .grid { gap: 8px; }
  .tile { padding: 10px 12px; }
  .value { font-size: 22px; }
  .label { font-size: 11px; letter-spacing: .03em; }
  .tide .t { font-size: 16px; }
}
@container (max-width: 299px) {
  .tides { grid-template-columns: minmax(0, 1fr); }
  .tide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: baseline;
    padding: 5px 10px;
    text-align: left;
  }
  .tide .h { text-align: right; }
  .tide .day { display: block; font-weight: 400; letter-spacing: 0; }
  .tide .day::before { content: none; }
  .dir { align-items: flex-start; white-space: normal; }
  .arrow { margin-top: 1px; }
  #b-dir-text, #b-wind-sub { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .arrow, .chip { transition: none; }
}
