/* ==========================================================================
   ocean-art.css -- THE SCENE. Sky, waterline, water, waves, descent, abyss.

   WHY THIS REPLACED A FILE THAT "SOUNDED GOOD". The previous version was a smooth
   colour ramp with a luminance step, and the user's verdict on it was exact and
   correct: "When I say 'sky' I also mean clouds and shit. When I say water I also
   mean the defusion of light in water, which is different than air. Waves are little
   curly lines." All three were missing. A gradient that goes pale-to-navy is a
   gradient, not a medium: the eye reads a medium by its TEXTURE and its LIGHT.
   So this file draws texture, and the pieces are named after what they are:

     SKY      a gradient plus cloud banks and a horizon haze
     WAVES    literal curly line-art on the waterline
     CAUSTICS concentric light rings in the upper water
     DIFFUSION a stack of veils that thicken with depth -- the physical difference
               between air (clear) and water (scattering), which is the one thing a
               single opacity ramp cannot express
     DESCENT  the document-length fall from sunlit to abyss
     ABYSS    near-black at the bottom of the page

   EVERY PIXEL HERE IS A CSS GRADIENT. The CSP is `default-src 'none'` and the page
   must render offline, so there is no image, no font, no SVG asset and no url()
   anywhere: radial-gradient gives cloud puffs, repeating-radial-gradient gives both
   the caustic rings and the wave curls, and layered background-images give the haze.
   Gradients are paint, not requests.

   THE RULE THAT IS NOT NEGOTIABLE: no gradient on an ANCESTOR of the page text.
   sites/audit-render.mjs `bgOf()` returns the sentinel 'unjudged' the moment any
   ancestor of a text element carries a `background-image` gradient, and then SKIPS
   that text while the summary still prints green -- a vacuous pass, the defect this
   repository exists to prevent. So everything here lives on `.ocean` (position:fixed,
   a SIBLING of `.page`, no text element's ancestor) or on its own layers. The text
   that would otherwise sit on bare water is given an opaque `background-color` in
   style.css, which `bgOf` measures correctly.

   THE AIR LAYER IS IN THE MARKUP, NOT A PSEUDO-ELEMENT, and that is deliberate: it
   needs two independently painted surfaces -- cloud banks and the wave line -- with
   different repeats, sizes and positions. `.ocean-layer[data-role="air"]` carries
   them and does not parallax (clouds sliding with the water would read as the sky
   falling).
   ========================================================================== */

:root {
  /* THE WATERLINE, AND WHY IT MOVED UP. At 56vh the line landed at 363px of a 649px
     viewport -- underneath the hero panel, which starts around y=190. The scene was
     correct and invisible: the sky showed above the panel and the water showed below
     it, but the one feature that says "this is air over water" was behind the copy.
     34vh puts the line above the hero, so the first screen reads sky -> waterline ->
     water in order, with the content starting under the surface. */
  --ocean-surface: clamp(28vh, 34vh, 44vh);

  /* Cloud colour, stated once so the dark scheme swaps it in one place. */
  --ocean-cloud: 255, 255, 255;
}

/* ==========================================================================
   1. THE WATER COLUMN
   --------------------------------------------------------------------------
   A 180deg gradient down the VIEWPORT, read top to bottom: the visible water
   immediately under the surface, then the fall to near-black at the bottom of the
   screen. This is the per-screen depth -- visible without scrolling.

   The first stop sits UNDER the air layer (which paints the sky), so the water's
   own top edge is only visible from the moment the reader scrolls the surface past.
   The DOCUMENT-length descent is the separate gradient in section 3. */
.ocean {
  background-color: #01050c;
  /* THE WATER MUST NOT START BEFORE THE WATERLINE. This gradient used to reach full
     water at 14% of the viewport (~105px) while the air layer's band ran to
     --ocean-surface (56%, ~419px). Everything between 105px and 419px was therefore
     deep water sitting under a band labelled "air", and the sky had almost no room to
     exist. The first three stops now sit ON the waterline, so air occupies the band
     and water begins exactly where the sky ends. */
  background-image: linear-gradient(180deg,
    #4a86bd 0,
    #8fb8d4 calc(var(--ocean-surface) * 0.72),
    #a8cae0 var(--ocean-surface),
    #4aa6d4 calc(var(--ocean-surface) + 4vh),
    #2f88ba calc(var(--ocean-surface) + 12vh),
    #1f6fa1 calc(var(--ocean-surface) + 24vh),
    #155a86 calc(var(--ocean-surface) + 40vh),
    #0f4369 calc(var(--ocean-surface) + 62vh),
    #072039 calc(var(--ocean-surface) + 94vh),
    #01070f 100%);
}

/* ==========================================================================
   2. CAUSTICS AND DIFFUSION
   --------------------------------------------------------------------------
   CAUSTICS are the bright rings sunlight makes on the underside of a rippling
   surface. Repeating radial rings, three centres at different scales, held in the
   upper third and faded out below it -- caustics belong to light that can still
   reach, so they must not appear in the abyss.

   DIFFUSION is the haze that makes water read as a medium rather than as coloured
   air: two soft radial veils, the lower one heavier, so contrast dies as you go
   down. This is the piece the user asked for by name. */
.ocean::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;

  background-image:
    /* caustics: three ring sets, offset so they do not read as a grid */
    repeating-radial-gradient(circle 6.5rem at 22% 30%,
      rgba(214, 246, 255, 0.16) 0 0.085rem, rgba(214, 246, 255, 0) 0.085rem 1.05rem),
    repeating-radial-gradient(circle 9rem at 68% 24%,
      rgba(198, 240, 255, 0.13) 0 0.10rem, rgba(198, 240, 255, 0) 0.10rem 1.35rem),
    repeating-radial-gradient(circle 5rem at 44% 46%,
      rgba(226, 250, 255, 0.10) 0 0.08rem, rgba(226, 250, 255, 0) 0.08rem 0.9rem),
    /* diffusion: the water's own scattering, thickening downward */
    radial-gradient(130% 62% at 50% 32%, rgba(160, 224, 250, 0.20), rgba(160, 224, 250, 0) 72%),
    radial-gradient(150% 74% at 50% 82%, rgba(16, 62, 100, 0.50), rgba(16, 62, 100, 0) 78%),
    /* and a fade so caustics stop before the deep water begins */
    linear-gradient(180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 26%,
      rgba(2, 10, 20, 0.55) 52%,
      rgba(2, 8, 16, 0.85) 74%,
      rgba(1, 6, 12, 0.95) 100%);
}

/* ==========================================================================
   3. THE DESCENT -- the document getting darker as you go deeper
   --------------------------------------------------------------------------
   A viewport-anchored gradient cannot make the BOTTOM OF THE DOCUMENT darker than
   the top: `.ocean` is fixed, so every scroll position paints the same pixels. The
   length of the page is handled here, on a scroll(root) timeline -- the same
   mechanism style.css uses for the parallax, which is why the scene needs no script.

   The veil is a whole-viewport darkening plus an edge vignette. Its base opacity is
   0 and the fill-mode is `both`, so without scroll-timeline support (or under
   prefers-reduced-motion) it is simply absent. The failure mode is "less dark", never
   "flat". */
.ocean::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;

  background-image:
    radial-gradient(125% 92% at 50% 6%,
      rgba(0, 8, 18, 0) 32%,
      rgba(0, 6, 14, 0.50) 100%),
    linear-gradient(180deg,
      rgba(0, 8, 18, 0.05) 0%,
      rgba(0, 6, 14, 0.42) 100%);

  opacity: 0;
  animation: ocean-descent linear both;
  animation-timeline: scroll(root block);
  animation-duration: 1ms;
}

@keyframes ocean-descent {
  from { opacity: 0; }
  to   { opacity: 0.90; }
}

/* ==========================================================================
   4. THE SKY, AND THE WAVES -- painted on the air layer
   --------------------------------------------------------------------------
   `.ocean-layer[data-role="air"]` sits above the water art and below the near
   creatures. It paints two things:

     ::before  CLOUDS. Banks of soft puffs, three clusters at different heights and
               scales, plus a warm haze band sitting on the horizon. Drawn as radial
               gradients -- the only way to get a soft irregular edge with no asset.
               It drifts very slowly; that is the one timed animation in this file.
     ::after   WAVES. The literal curly line, drawn as repeating ELLIPTICAL arcs
               masked into a band a couple of rows tall, pinned to the waterline. Two
               offsets so it reads as a swell rather than as a repeating stamp.

   Both are clipped to the sky/waterline region so neither can bleed into the body of
   the water, where text lives. */
.ocean-layer[data-role="air"] {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ocean-layer[data-role="air"]::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--ocean-surface);
  pointer-events: none;

  /* THE SKY GRADIENT BELONGS HERE, AND IT WAS MISSING.
     This element painted the clouds and a warm haze and nothing else, so the sky...
     was whatever showed through from `.ocean` underneath. And `.ocean` reaches full
     water at 14% of the viewport (~105px) while the waterline sits at 56% (~419px) --
     so from 105px to 419px the "sky" was literally deep water, and above that the band
     was ~40px tall under opaque cloud puffs. Read row by row the result was #dae4e9
     then #358dbd: a waterline with essentially nothing above it, which is exactly the
     report "no sky". The sky is now painted by the element that OWNS the air, as the
     last (lowest) of its layers, and every stop is bluer and darker than --bg.

     Layer order, first on top: clouds, then horizon haze, then this sky gradient. */
  background-image:
    radial-gradient(ellipse 6.5rem 1.5rem at 10% 26%, rgba(var(--ocean-cloud), 0.62), rgba(var(--ocean-cloud), 0) 68%),
    radial-gradient(ellipse 4rem 1.1rem at 17% 21%, rgba(var(--ocean-cloud), 0.52), rgba(var(--ocean-cloud), 0) 68%),
    radial-gradient(ellipse 7.5rem 1.7rem at 41% 34%, rgba(var(--ocean-cloud), 0.44), rgba(var(--ocean-cloud), 0) 70%),
    radial-gradient(ellipse 5rem 1.2rem at 63% 15%, rgba(var(--ocean-cloud), 0.50), rgba(var(--ocean-cloud), 0) 68%),
    radial-gradient(ellipse 4.5rem 1.05rem at 71% 24%, rgba(var(--ocean-cloud), 0.40), rgba(var(--ocean-cloud), 0) 70%),
    radial-gradient(ellipse 8rem 1.8rem at 88% 29%, rgba(var(--ocean-cloud), 0.42), rgba(var(--ocean-cloud), 0) 72%),
    linear-gradient(180deg, rgba(255, 246, 220, 0) 74%, rgba(255, 242, 208, 0.42) 100%),
    /* THE SKY ITSELF. Every stop is below --bg (#dae4e9) in luminance, so the band
       reads as air rather than as more page -- but NOT so dark that --text loses AA:
       pytmp/sky_text.py measured the first attempt (#4a86bd at the top) at 4.15, i.e.
       the headline colour would have failed on its own sky. These stops are the
       solver's answer, and --muted/--faint were moved to match. */
    linear-gradient(180deg,
      #6a9cc9 0,
      #7fadcf 38%,
      #93bcd8 72%,
      #a8cae0 100%);

  background-repeat: no-repeat;
  background-size: 100% 100%;
  animation: ocean-cloud-drift 110s linear infinite alternate;
}

@keyframes ocean-cloud-drift {
  from { transform: translateX(-1.5%) scale(1); }
  to   { transform: translateX(1.5%) scale(1.02); }
}

.ocean-layer[data-role="air"]::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;

  /* THE SURFACE SHEEN, AND WHY THE CURLS ARE GONE.
     The previous version drew the surface as repeating thin bright arcs -- literal
     line art. On screen that reads as VECTOR GRAPHIC, not as water: the user's words
     were "now there are wave vectors?", and they were right. A drawn outline is a
     diagram of a wave; water is LIGHT.
     So the surface is now light: a soft specular band with no outline, made of two
     wide, very diffuse horizontal gradients that slide at different speeds. The
     breaks in it come from the caustic rings on `.ocean::before`, which are soft and
     carry no stroke either. Nothing at the waterline has a hard edge. */
  background-image:
    /* the sheen directly under the surface */
    linear-gradient(180deg,
      rgba(0, 0, 0, 0) calc(var(--ocean-surface) - 1.4rem),
      rgba(236, 250, 255, 0.30) calc(var(--ocean-surface) - 0.3rem),
      rgba(210, 240, 255, 0.16) calc(var(--ocean-surface) + 0.6rem),
      rgba(0, 0, 0, 0) calc(var(--ocean-surface) + 2.4rem)),
    /* a second, wider and dimmer one, so the band has internal structure */
    linear-gradient(180deg,
      rgba(0, 0, 0, 0) calc(var(--ocean-surface) + 0.4rem),
      rgba(222, 245, 255, 0.14) calc(var(--ocean-surface) + 1.6rem),
      rgba(0, 0, 0, 0) calc(var(--ocean-surface) + 4.2rem));

  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 100% 100%;
  background-position: 0 0, 0 0;

  /* A soft break in the sheen so it does not read as a single printed bar. */
  -webkit-mask-image: linear-gradient(180deg,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) calc(var(--ocean-surface) - 1.6rem),
    rgba(0, 0, 0, 1) calc(var(--ocean-surface) - 0.2rem),
    rgba(0, 0, 0, 1) calc(var(--ocean-surface) + 2.2rem),
    rgba(0, 0, 0, 0) calc(var(--ocean-surface) + 4.6rem));
  mask-image: linear-gradient(180deg,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) calc(var(--ocean-surface) - 1.6rem),
    rgba(0, 0, 0, 1) calc(var(--ocean-surface) - 0.2rem),
    rgba(0, 0, 0, 1) calc(var(--ocean-surface) + 2.2rem),
    rgba(0, 0, 0, 0) calc(var(--ocean-surface) + 4.6rem));
}

/* ==========================================================================
   5. THE DARK SCHEME -- the same scene at night
   --------------------------------------------------------------------------
   Sky to deep slate, clouds to faint moonlit grey, water to near-black, and the same
   caustics and wave line at lower intensity. The waterline is carried by the wave
   line and the moon haze rather than by a large luminance step, because in this
   scheme every pixel is also a backdrop for light text. */
@media (prefers-color-scheme: dark) {
  :root {
    --ocean-cloud: 206, 222, 235;
  }

  .ocean {
    background-color: #010409;
    background-image: linear-gradient(180deg,
      #123049 0,
      #0f2c42 8%,
      #0c2740 18%,
      #0a2138 30%,
      #081b2f 44%,
      #061527 60%,
      #041021 78%,
      #010912 92%,
      #010409 100%);
  }

  .ocean::before {
    background-image:
      repeating-radial-gradient(circle 6.5rem at 22% 30%,
        rgba(150, 214, 250, 0.10) 0 0.085rem, rgba(150, 214, 250, 0) 0.085rem 1.05rem),
      repeating-radial-gradient(circle 9rem at 68% 24%,
        rgba(140, 205, 245, 0.08) 0 0.10rem, rgba(140, 205, 245, 0) 0.10rem 1.35rem),
      radial-gradient(130% 62% at 50% 32%, rgba(60, 140, 195, 0.14), rgba(60, 140, 195, 0) 72%),
      linear-gradient(180deg,
        rgba(0, 0, 0, 0) 0,
        rgba(0, 0, 0, 0) 30%,
        rgba(1, 5, 11, 0.55) 58%,
        rgba(1, 4, 9, 0.9) 100%);
  }

  .ocean-layer[data-role="air"]::before {
    opacity: 0.5;
    animation-duration: 160s;
  }

  .ocean-layer[data-role="air"]::after {
    filter: brightness(0.9);
  }
}

/* ==========================================================================
   6. REDUCED MOTION
   --------------------------------------------------------------------------
   The cloud drift is the only timed animation here. The descent is scroll-linked and
   does not move on its own, so it is not what this query is about; the drift stops. */
@media (prefers-reduced-motion: reduce) {
  .ocean::after,
  .ocean-layer[data-role="air"]::before {
    animation: none;
  }
}
