/* ==========================================================================
   ocean-text.css -- THE SURFACES THAT MAKE TEXT READABLE OVER THE SCENE.

   LOADED LAST, AND THAT IS THE ENTIRE POINT. These rules were put in style.css twice
   and were overridden both times: `.picker__group` and `.picker__legend` are declared
   again further down that sheet at equal specificity, so the later rule won and the
   opaque panel never painted. The measured consequence was the dangerous one -- the
   repo audit still reported CLEAN while four elements sat at 1.52 to 3.83 contrast
   against the water behind them, because sites/audit-render.mjs `bgOf()` walks the
   ANCESTOR chain, finds some other painted box, and never sees `.ocean` at all. A
   green check that measured nothing.

   Anything that exists to make text survive the water belongs in this file, so it can
   never be out-ordered by a rule added lower down style.css. Keep it last in the head.

   WHY THESE ELEMENTS AND NOT OTHERS. These are the text boxes that have no panel of
   their own and no painted ancestor: the section heads, the cover headings, the picker
   legend and group labels, and the footer. Everything else on the page already sits on
   a `.card`, `.panel` or `.surface`. The light colour is `--bg`, which in the light
   scheme is a near-white and in the dark scheme a near-black, so the same rule keeps
   dark ink readable in one and light ink readable in the other.

   WHY NOT A TRANSLUCENT SURFACE: a translucent white over near-black deep water
   composites to a grey around luma 130, which fails AA for `--faint`. Opaque is the
   honest choice over the WATER.

   BUT OPAQUE OVER THE SKY IS WHAT HID THE SKY. The header and the first panels sit in
   the top half of screen one, which is exactly where the sky band is. An opaque `--bg`
   there does not "sit on" the sky, it REPLACES it: the rendered column read
   #dae4e9 from y=0 to y=112 and water from y=126 down, so the page had a waterline
   with nothing above it. Text still needs a surface, but it does not need an OPAQUE
   one over air -- air is light already. So these use a near-opaque `--bg` (0.82) that
   lets the sky gradient tint through, which is what makes the sky legible while the
   ink keeps its contrast. Over the DARK water the same panel must stay close to
   opaque, which is why the value is high rather than low. */
/* ONE ALPHA FOR THE WHOLE PAGE WAS WRONG, AND IT WAS WRONG IN BOTH DIRECTIONS.
     Too opaque at the top: 0.82 of --bg over the pale sky flattens the sky to
     #dae4e9, so the rendered column is one flat band from y=0 to y=112 and the reader
     sees "no sky". Too transparent at the bottom: 0.82 over the abyss (luma ~5) lands
     the panel near luma 180, where --faint measures about 2:1 and fails AA badly.
     The sky is the TOP of the page and the abyss is the BOTTOM, so the panel does not
     need one value: it needs a light one over air and a near-opaque one over water.
     `:first-child` scoping is deliberate -- only the first band of the page is over
     the sky, and every later section is over water. */
.section__head,
.picker__group,
.picker__legend {
  /* over WATER: near-opaque, or the text loses its surface */
  background-color: rgba(218, 228, 233, 0.97) !important;
  /* THE PANEL IS THE TEXT MEASURE, NOT THE PAGE WIDTH. These boxes are full-width by
     default; capping to the prose measure and centring keeps water in the margins,
     between sections, and above the waterline. */
  max-width: var(--measure);
  margin-inline: auto;
  border-radius: var(--radius);
  padding-inline: var(--pad);
  padding-block: 0.5rem;
}

/* ...and the FIRST one is over the SKY, where the surface can be light enough to let
   the sky tint through and actually be seen. */
.shell > .section:first-child .section__head {
  background-color: rgba(218, 228, 233, 0.65) !important;
}

/* The cover grid is wider than prose, so its heading uses the wider measure. */
.covers__head {
  background-color: rgba(218, 228, 233, 0.97);
  max-width: var(--measure-wide);
  margin-inline: auto;
  border-radius: var(--radius);
  padding-inline: var(--pad);
  padding-block: 0.5rem;
}

/* ---------- the header brand ----------
   `.brand-sub` sits beside the brand mark, and the header spans the full width across
   the SKY BAND. An opaque bar here is what kept the sky from being seen: the rendered
   column read #dae4e9 from y=60 to y=120 (exactly the header's box) with the sky only
   appearing below it at y=140. So the header keeps a surface for its text but lets the
   sky through it -- 0.42 alpha, then a blur so the cloud edges do not run under the
   letterforms and read as dirt. */
.site-header {
  background-color: rgba(218, 228, 233, 0.65);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  padding-bottom: 1rem;
}

/* ---------- the footer ----------
   Its `--faint` copy runs the full shell width over the deepest water on the page. */
.site-footer {
  background-color: var(--bg);
  padding-block: 1.25rem;
}

/* ==========================================================================
   THE DARK SCHEME -- the panels must invert with it.

   The light-scheme alphas above are hard-coded rgb(218,228,233) because they are tuned
   against a sky, which makes them LIGHT COLOURS. A light panel in the dark scheme puts
   near-white behind near-white text: measured at 320px, `.brand-sub` fell to 1.12 and
   `.eyebrow` to 1.32 -- unreadable, and the repo audit caught it because these are real
   surfaces with measurable backgrounds. So the dark scheme overrides them with the
   themeable near-black `--bg`, at alphas that keep the panel dark enough for light ink
   while still letting the night sky show through at the top.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  /* THE `.page` PREFIX IS THE FIX, AND IT IS NOT DECORATION. Every rule here needs
     `!important` to beat `.picker__group`/`.picker__legend` as they are declared further
     down style.css -- but between TWO `!important` declarations the cascade falls back to
     SPECIFICITY, and plain `.section__head` (0,1,0) loses to the light block's
     `.shell > .section:first-child .section__head` (0,2,1). Measured before this change:
     in the dark scheme `.section__head` still computed `rgba(218, 228, 233, 0.65)` -- a
     LIGHT panel -- which is what put near-white behind near-white ink at 1.32. The extra
     class raises the specificity so the dark values actually win. */
  .page .site-header {
    background-color: rgba(23, 27, 32, 0.66);
  }

  .page .section__head,
  .page .picker__group,
  .page .picker__legend {
    background-color: rgba(18, 22, 27, 0.97) !important;
  }

  /* The first panel as well, and opaquely. A translucent dark panel over the night sky
     still left the hero text short of AA at 320 and 390px, because the night sky is dark
     and this scheme's ink is light: transparency moves both toward the middle. The sky
     stays visible in the header, the margins and above the first panel; the reading
     column is not worth the words. */
  .page .shell > .section:first-child .section__head,
  .page .covers__head {
    background-color: rgba(18, 22, 27, 0.97) !important;
  }
}
