/* Read outdoors, one-handed, before leaving the house. Big numbers, dark by
   default, everything above the fold on a phone. */
:root {
  color-scheme: dark light;
  --bg: #06131c;
  --panel: #0d2231;
  --line: #16384c;
  --ink: #e8f4fa;
  --dim: #8fb3c7;
  --sea: #2bb3c9;
  --sun: #ffc14d;
  --low: #7fd1a8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bar {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.bar h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
.bar .where { color: var(--sea); font-size: 14px; }
.bar .when { margin-left: auto; color: var(--dim); font-size: 13px; }

main { padding: 16px; max-width: 900px; margin: 0 auto; }

/* The swell, which is the whole reason for looking. */
.swell {
  display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px;
}
.big { display: flex; align-items: baseline; gap: 6px; }
.big .n {
  font-size: 44px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--sea);
}
.big .u { color: var(--dim); font-size: 13px; }
.src { width: 100%; margin: 4px 0 0; color: var(--dim); font-size: 12px; }
.src code { color: var(--sun); }

.spots { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 620px) { .spots { grid-template-columns: 1fr 1fr; } }

.spot {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px;
}
.spot h2 { margin: 0 0 8px; font-size: 17px; }
.wind { margin: 0; font-size: 18px; }
.wind strong { color: var(--sun); }
.sky { margin: 2px 0 10px; color: var(--dim); font-size: 13px; }

.tides { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.tides li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 3px 0; border-top: 1px solid var(--line);
}
.tides li:first-child { border-top: 0; }
.kind { width: 3.4em; font-weight: 600; }
.kind.high { color: var(--sea); }
.kind.low { color: var(--low); }
.at { font-variant-numeric: tabular-nums; }
.ht { margin-left: auto; color: var(--dim); font-variant-numeric: tabular-nums; }

.cams { margin-top: 18px; }
.pick { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pick label { color: var(--dim); font-size: 13px; }
.pick select {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 15px;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
}

/* 16:9 without a wrapper hack, and never wider than the screen. */
.screen {
  aspect-ratio: 16 / 9; width: 100%; max-width: 100%;
  background: #000; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.screen iframe { width: 100%; height: 100%; border: 0; display: block; }

footer { padding: 20px 16px 40px; text-align: center; }
footer p { margin: 0; color: var(--dim); font-size: 12px; }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f7fa; --panel: #ffffff; --line: #d3e2eb;
    --ink: #0d2231; --dim: #55707f; --sea: #0d7c94;
    --sun: #9a6100; --low: #1c7a52;
  }
}

/* The verse, above everything. Quiet: it is the first thing on the page and
   it is not the reason anybody opened it. */
.verse {
  margin: 0; padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.verse blockquote {
  margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--ink);
  max-width: 68ch;
}
.verse figcaption {
  margin-top: 5px; font-size: 12px; color: var(--dim);
  letter-spacing: .02em;
}
.src a { color: var(--sea); }

/* --------------------------------------------------------------- verse --- */
/*
 * The pop-up, and the flight back to the banner above.
 *
 * The dialog fills the viewport and centres the card, so the dim area is part
 * of the dialog's own box and a click there reliably reports the dialog as
 * its target. That is what makes click-outside-to-close work without a
 * separate backdrop element to keep in sync.
 */
.verse-modal {
  width: 100%; max-width: none;
  height: 100%; max-height: none;
  border: 0; padding: 0; margin: 0;
  background: transparent;
  overflow: hidden;
  display: none;            /* the UA default, restated for the [open] pair */
  /* Perspective belongs to the container, not the card: the fold reads as a
     page laying flat only if the vanishing point is the viewport. */
  perspective: 1400px;
}
.verse-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  /* The 16px gutter, at every width, on the smallest screens too. */
  padding: 16px;
}
.verse-modal::backdrop { background: rgba(3, 10, 15, .74); }

.verse-card {
  width: 100%;
  max-width: 34rem;
  max-height: 100%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  /* The top edge is the hinge. */
  transform-origin: 50% 0;
}
.verse-body { margin: 0; padding: 22px 22px 6px; }
.verse-body blockquote {
  margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink);
}
.verse-body figcaption {
  margin-top: 10px; font-size: 12.5px; color: var(--dim);
  letter-spacing: .02em;
}
.verse-actions { display: flex; justify-content: flex-end; padding: 14px 18px 18px; }
.verse-close {
  font: inherit; font-size: 14px;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 10px;
  /* 44px is a thumb, not a mouse pointer. This page is read one-handed on a
     phone before leaving the house and the close button is the only control
     on it that has to be hit first time. */
  min-height: 44px; padding: 0 22px;
  cursor: pointer;
}
.verse-close:hover { border-color: var(--sea); color: var(--sea); }
.verse-close:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }

/* The flight itself. Script measures the banner, writes the transform that
   lands the card on it, and adds .verse-shutting; these two rules are what
   turn that into a movement rather than a jump. The fold comes from the
   rotateX script adds to the same transform. */
.verse-card.verse-shutting {
  transition: transform .52s cubic-bezier(.32, .02, .18, 1),
              opacity .52s cubic-bezier(.6, 0, .9, .6);
  opacity: 0;
}
.verse-modal.verse-shutting::backdrop {
  animation: verse-dim .52s ease-out forwards;
}
@keyframes verse-dim { to { background: rgba(3, 10, 15, 0); } }

/* Arriving: it opens by rising slightly, and the banner it lands in fades up
   under the departing card so the two read as one object changing places. */
@keyframes verse-rise {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
}
.verse.verse-landing { opacity: 0; }
.verse.verse-landed {
  opacity: 1;
  transition: opacity .3s ease-out .2s;
}

@media (prefers-reduced-motion: no-preference) {
  .verse-modal[open] .verse-card { animation: verse-rise .3s ease-out; }
}
/* With motion turned down there is no flight: script closes the dialog and
   the banner is simply there. Nothing below needs to animate for that, and
   the transition properties are dropped so a half-second of nothing does not
   stand in for the movement. */
@media (prefers-reduced-motion: reduce) {
  .verse-card.verse-shutting { transition: none; }
  .verse.verse-landed { transition: none; }
}

