:root {
  --bg: #04121c;
  --card: #0b2130;
  --card-edge: #14364a;
  --text: #eaf4f8;
  --muted: #8fb0c0;
  --accent: #4fd1e8;
  --warn: #ffb020;
  --danger: #ff4d4f;
  --tide-fill: rgba(79, 209, 232, 0.18);
  /* sizes scale with the screen so it reads from across a room */
  --u: min(1vh, 0.6vw);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: grid;
  grid-template-columns: 68fr 32fr;
  height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Cam stage ---------- */
#stage { position: relative; background: #000; overflow: hidden; }
#yt-wrap, #yt, #yt-wrap iframe, #hls, #still {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
#yt-wrap iframe { pointer-events: none; }
#hls, #still { object-fit: contain; background: #000; }
#touch { position: absolute; inset: 0; z-index: 5; touch-action: pan-y; cursor: pointer; }

#cam-label {
  position: absolute; left: calc(var(--u) * 2.5); bottom: calc(var(--u) * 2.5); z-index: 6;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 2.2);
  background: rgba(0, 0, 0, 0.55); border-radius: calc(var(--u) * 1.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: none; max-width: 75%;
}
#cam-name { font-size: calc(var(--u) * 4.2); font-weight: 700; line-height: 1.1; }
#cam-where { font-size: calc(var(--u) * 2.6); color: var(--muted); margin-top: calc(var(--u) * 0.4); }
#cam-state {
  position: absolute; right: calc(var(--u) * 2.5); top: calc(var(--u) * 2.5); z-index: 6;
  font-size: calc(var(--u) * 2.4); color: var(--muted); pointer-events: none;
  background: rgba(0, 0, 0, 0.45); padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4); border-radius: 999px;
}
#cam-state:empty { display: none; }
#cam-dots {
  position: absolute; right: calc(var(--u) * 2.5); bottom: calc(var(--u) * 3); z-index: 6;
  display: flex; gap: calc(var(--u) * 0.8); pointer-events: none;
}
#cam-dots i { width: calc(var(--u) * 1.1); height: calc(var(--u) * 1.1); border-radius: 50%; background: rgba(255,255,255,0.3); }
#cam-dots i.on { background: #fff; }
#cam-dots i.bad { background: rgba(255, 77, 79, 0.6); }
#toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7;
  font-size: calc(var(--u) * 5); font-weight: 700; padding: calc(var(--u) * 1.5) calc(var(--u) * 3.5);
  background: rgba(0, 0, 0, 0.6); border-radius: calc(var(--u) * 2); pointer-events: none;
  opacity: 0; transition: opacity 0.25s;
}
#toast.show { opacity: 1; }
.still-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: calc(var(--u) * 3); color: var(--muted); text-align: center; padding: 5%;
}

/* ---------- Conditions strip ----------
   Everything in the strip is sized in em from one base size. app.js lowers --k a little
   when a long forecast or advisory would overflow, so nothing is ever cut off. */
#strip {
  --k: 1;
  font-size: calc(var(--u) * 2.45 * var(--k));
  display: flex; flex-direction: column; gap: 0.55em;
  padding: 0.8em; min-height: 0; overflow: hidden; line-height: 1.3;
}
#strip.scrolls { overflow-y: auto; }
#strip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6em; }
#place { font-size: 1.15em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#clock { font-size: 1.45em; font-weight: 300; font-variant-numeric: tabular-nums; white-space: nowrap; }

#advisory {
  background: var(--danger); color: #fff; font-weight: 800; text-transform: uppercase;
  font-size: 1em; line-height: 1.2; letter-spacing: 0.02em;
  padding: 0.5em 0.7em; border-radius: 0.5em;
  animation: pulse 2.5s ease-in-out infinite;
}
#advisory.watch { background: var(--warn); color: #1a1000; }
#advisory small { display: block; font-weight: 500; text-transform: none; opacity: 0.9; font-size: 0.8em; }
@keyframes pulse { 50% { filter: brightness(1.25); } }

.card {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 0.65em;
  padding: 0.55em 0.8em; min-height: 0; flex: none;
  transition: opacity 0.4s;
}
.stale { opacity: 0.45; }
.stale .age, .age.old { color: var(--warn); }
.card-title {
  font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700; display: flex; gap: 0.6em; align-items: baseline;
}
.age { margin-left: auto; font-size: 0.95em; letter-spacing: 0; text-transform: none; font-weight: 500; }
.big { font-size: 2.6em; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.mid { font-size: 1.9em; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.big small, .mid small { font-size: 0.45em; font-weight: 500; color: var(--muted); }
.mid .at { font-size: 0.5em; color: var(--muted); font-weight: 400; }
.sub { font-size: 0.95em; color: var(--muted); }
.sub.inline { font-size: 0.47em; font-weight: 400; margin-left: 0.4em; white-space: nowrap; }
.sub b, .dim b { color: var(--text); font-weight: 600; }
.obs { font-size: 0.8em; color: var(--muted); margin-top: 0.3em; }
.obs:empty { display: none; }
.dim { color: var(--muted); font-size: 0.8em; }
.row { display: flex; align-items: center; gap: 0.8em; }

#wind-arrow { width: 4.2em; height: 4.2em; flex: none; }
#wind-arrow .ring { fill: none; stroke: var(--card-edge); stroke-width: 3; }
#wind-arrow path { fill: var(--accent); }
#wind-arrow-g { transition: transform 1s ease; }

.temps {
  display: grid; gap: 0.15em; margin-top: 0.45em; padding-top: 0.45em;
  border-top: 1px solid var(--card-edge); font-size: 1em; transition: opacity 0.4s;
}
.temps > div { display: grid; grid-template-columns: 3.6em 2.8em minmax(0, 1fr); align-items: baseline; }
.temps b { font-size: 1.3em; font-variant-numeric: tabular-nums; }
.temps .lbl { color: var(--muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.temps .dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* the full NWS wording, never clipped */
.nws { font-size: 0.86em; line-height: 1.32; margin-top: 0.35em; }
.nws b { color: var(--accent); font-weight: 600; }
.nws.bay { color: var(--muted); }
.nws:empty { display: none; }

#card-tide { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 7.5em; }
.tide-next { display: flex; flex-wrap: wrap; column-gap: 1em; font-size: 0.85em; color: var(--muted); margin-top: 0.1em; }
.tide-next > div { white-space: nowrap; }
.tide-next b { color: var(--text); font-size: 1.3em; font-weight: 700; font-variant-numeric: tabular-nums; }
#tide-trend { color: var(--accent); font-weight: 800; letter-spacing: 0; }
.tide-plot { position: relative; flex: 1 1 auto; min-height: 3.2em; margin-top: 0.3em; display: flex; flex-direction: column; }
#tide-svg { width: 100%; flex: 1 1 auto; min-height: 2.2em; overflow: visible; }
#tide-svg .area { fill: var(--tide-fill); }
#tide-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
#tide-svg .now { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#tide-svg .tick { stroke: var(--card-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#tide-hours { position: relative; height: 1.1em; font-size: 0.72em; color: var(--muted); }
#tide-hours span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

#card-fish #fish-head { font-weight: 700; font-size: 0.95em; margin-top: 0.15em; }
#fish-head:empty { display: none; }
#fish-lines { list-style: none; margin: 0.2em 0 0; padding: 0; font-size: 0.86em; line-height: 1.3; }
#fish-lines li { margin-top: 0.12em; }
#fish-lines b { color: var(--accent); font-weight: 600; }
#fish-lines .note { color: var(--warn); }

#updated { font-size: 0.72em; color: var(--muted); text-align: right; margin-top: auto; }
#updated.offline { color: var(--warn); font-weight: 700; }

#night { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 50; transition: opacity 3s; }

/* Portrait (tablet): cams on top, conditions in two columns below */
@media (orientation: portrait) and (min-width: 600px) {
  :root { --u: min(0.62vh, 0.85vw); }
  #app { grid-template-columns: 1fr; grid-template-rows: 44fr 56fr; }
  #strip { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; align-content: start; }
  #strip-head, #advisory, #updated { grid-column: 1 / -1; }
  #card-tide { min-height: 10em; }
}

/* iPhone portrait: a 16:9 cam on top, conditions scroll below in one column */
@media (max-width: 599px) {
  html, body { overflow: auto; height: auto; }
  #app { display: block; height: auto; }
  #stage { position: sticky; top: 0; z-index: 10; width: 100%; aspect-ratio: 16 / 9; }
  #strip { font-size: 16px; overflow: visible; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  #cam-name { font-size: 18px; } #cam-where { font-size: 13px; }
  #cam-label { left: 10px; bottom: 10px; padding: 6px 10px; }
  #cam-state { font-size: 12px; } #cam-dots { bottom: 14px; right: 10px; } #cam-dots i { width: 6px; height: 6px; }
  #toast { font-size: 20px; }
  #card-tide { min-height: 11em; }
}

/* iPhone landscape: side by side, the conditions column scrolls */
@media (max-height: 500px) and (orientation: landscape) {
  #app { grid-template-columns: 62fr 38fr; }
  #strip { font-size: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #cam-name { font-size: 18px; } #cam-where { font-size: 13px; }
  #card-tide { min-height: 10em; }
}
