/* Ambient glow v2 — opt-in only.
   Linked solely from the Goedhuis and Myonghi sample pages.
   Selectors always include [data-ambient-sync] or [data-ambient-tone="bright"],
   so this sheet cannot restyle the other 11 project pages even if it were
   included there by mistake.

   Extracted from the 2026-11-15 comparison draft, with these deliberate
   corrections from the source review:
   - Weaker top (--ambient-top:.5) is used as requested for this sample.
   - Breathe only when a YouTube sample is actually playing
     ([data-ambient-sync][data-ambient-playing="true"]), never on unknown
     or Instagram. Unknown stays at the strong default level, without a
     fabricated playing attribute.
   - Instagram / bright-tone frames stay static (no breathe, no playing attr).
   - Sprite sheets, precomputed film frames, and original-film generation are not included.

   Priority for --ambient-level, later rules win:
   1. v2 default .9, strong 1
   2. [data-ambient-tone="bright"] .72  (Myonghi)
   3. [data-ambient-sync][data-ambient-playing="false"] .45
   4. [data-ambient-sync][data-ambient-playing="true"] 1
   Tone mid/near (mid .45, near .18 / blur 20px / saturate 1.1) override
   v2 ready mid/near on bright frames even if a playing attribute is also set.
*/
@keyframes ambient-breathe{
  0%,100%{opacity:.6}
  50%{opacity:.78}
}

.ambient-frame[data-ambient-sync],
.ambient-frame[data-ambient-tone="bright"]{
  --ambient-pad-x:6.5rem;
  --ambient-pad-y:6rem;
  --ambient-top:.5;      /* top bloom strength relative to bottom */
  --ambient-level:.9;    /* master brightness */
  position:relative;
  isolation:isolate;
  margin:var(--ambient-pad-y) 0;
}
.ambient-frame[data-ambient-sync][data-ambient-state="pending"],
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="pending"]{margin:0}
.ambient-frame[data-ambient-sync][data-ambient-state="pending"] .ambient-glow,
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="pending"] .ambient-glow{display:none}

.ambient-frame[data-ambient-sync]:has(.player-instagram),
.ambient-frame[data-ambient-tone="bright"]:has(.player-instagram){
  --ambient-pad-x:4.5rem;
  --ambient-pad-y:4.25rem;
}

.ambient-frame[data-ambient-sync][data-ambient-strength="strong"],
.ambient-frame[data-ambient-tone="bright"][data-ambient-strength="strong"]{
  --ambient-pad-x:9rem;
  --ambient-pad-y:8rem;
  --ambient-level:1;
}
.ambient-frame[data-ambient-sync][data-ambient-strength="strong"]:has(.player-instagram),
.ambient-frame[data-ambient-tone="bright"][data-ambient-strength="strong"]:has(.player-instagram){
  --ambient-pad-x:6.5rem;
  --ambient-pad-y:6rem;
}

.ambient-frame[data-ambient-sync] .ambient-glow,
.ambient-frame[data-ambient-tone="bright"] .ambient-glow{
  --ax:var(--ambient-pad-x);
  --ay:var(--ambient-pad-y);
  position:absolute;
  inset:calc(-1 * var(--ay)) calc(-1 * var(--ax));
  z-index:0;
  pointer-events:none;
  isolation:isolate;
  opacity:var(--ambient-level);
  transition:opacity 1.4s ease;
  -webkit-mask-image:
    linear-gradient(to right,
      transparent 0,
      rgb(0 0 0 / .104) calc(var(--ax) * .2),
      rgb(0 0 0 / .352) calc(var(--ax) * .4),
      rgb(0 0 0 / .648) calc(var(--ax) * .6),
      rgb(0 0 0 / .896) calc(var(--ax) * .8),
      #000 var(--ax),
      #000 calc(100% - var(--ax)),
      rgb(0 0 0 / .896) calc(100% - var(--ax) * .8),
      rgb(0 0 0 / .648) calc(100% - var(--ax) * .6),
      rgb(0 0 0 / .352) calc(100% - var(--ax) * .4),
      rgb(0 0 0 / .104) calc(100% - var(--ax) * .2),
      transparent 100%),
    linear-gradient(to bottom,
      transparent 0,
      rgb(0 0 0 / calc(.104 * var(--ambient-top))) calc(var(--ay) * .2),
      rgb(0 0 0 / calc(.352 * var(--ambient-top))) calc(var(--ay) * .4),
      rgb(0 0 0 / calc(.648 * var(--ambient-top))) calc(var(--ay) * .6),
      rgb(0 0 0 / calc(.896 * var(--ambient-top))) calc(var(--ay) * .8),
      rgb(0 0 0 / var(--ambient-top)) var(--ay),
      #000 calc(100% - var(--ay)),
      rgb(0 0 0 / .896) calc(100% - var(--ay) * .8),
      rgb(0 0 0 / .648) calc(100% - var(--ay) * .6),
      rgb(0 0 0 / .352) calc(100% - var(--ay) * .4),
      rgb(0 0 0 / .104) calc(100% - var(--ay) * .2),
      transparent 100%);
  mask-image:
    linear-gradient(to right,
      transparent 0,
      rgb(0 0 0 / .104) calc(var(--ax) * .2),
      rgb(0 0 0 / .352) calc(var(--ax) * .4),
      rgb(0 0 0 / .648) calc(var(--ax) * .6),
      rgb(0 0 0 / .896) calc(var(--ax) * .8),
      #000 var(--ax),
      #000 calc(100% - var(--ax)),
      rgb(0 0 0 / .896) calc(100% - var(--ax) * .8),
      rgb(0 0 0 / .648) calc(100% - var(--ax) * .6),
      rgb(0 0 0 / .352) calc(100% - var(--ax) * .4),
      rgb(0 0 0 / .104) calc(100% - var(--ax) * .2),
      transparent 100%),
    linear-gradient(to bottom,
      transparent 0,
      rgb(0 0 0 / calc(.104 * var(--ambient-top))) calc(var(--ay) * .2),
      rgb(0 0 0 / calc(.352 * var(--ambient-top))) calc(var(--ay) * .4),
      rgb(0 0 0 / calc(.648 * var(--ambient-top))) calc(var(--ay) * .6),
      rgb(0 0 0 / calc(.896 * var(--ambient-top))) calc(var(--ay) * .8),
      rgb(0 0 0 / var(--ambient-top)) var(--ay),
      #000 calc(100% - var(--ay)),
      rgb(0 0 0 / .896) calc(100% - var(--ay) * .8),
      rgb(0 0 0 / .648) calc(100% - var(--ay) * .6),
      rgb(0 0 0 / .352) calc(100% - var(--ay) * .4),
      rgb(0 0 0 / .104) calc(100% - var(--ay) * .2),
      transparent 100%);
  -webkit-mask-composite:source-in;
  mask-composite:intersect;
  -webkit-mask-repeat:no-repeat;
  mask-repeat:no-repeat;
  -webkit-mask-size:100% 100%;
  mask-size:100% 100%;
}

.ambient-frame[data-ambient-sync] .ambient-glow-layer,
.ambient-frame[data-ambient-tone="bright"] .ambient-glow-layer{
  position:absolute;
  inset:var(--ay) var(--ax);
  background-image:var(--ambient-cover,none);
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  mix-blend-mode:screen;
  opacity:0;
}

.ambient-frame[data-ambient-sync][data-ambient-state="ready"] .ambient-glow-layer--far,
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="ready"] .ambient-glow-layer--far{
  opacity:.72;
  filter:blur(92px) saturate(1.5);
  transform:scale(1.38);
}
.ambient-frame[data-ambient-sync][data-ambient-state="ready"] .ambient-glow-layer--mid,
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="ready"] .ambient-glow-layer--mid{
  opacity:.55;
  filter:blur(44px) saturate(1.35);
  transform:scale(1.12);
}
.ambient-frame[data-ambient-sync][data-ambient-state="ready"] .ambient-glow-layer--near,
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="ready"] .ambient-glow-layer--near{
  opacity:.36;
  filter:blur(16px) saturate(1.2);
  transform:scale(1.015);
}

/* Bright-tone softening (Myonghi). Placed after ready mid/near so it wins those
   two layers. The strong selector is repeated on purpose: the strong rule above
   has specificity (0,3,0), so a bare [data-ambient-tone] rule (0,2,0) would lose
   to it regardless of order. --ambient-level:.72 wins over strong's 1, but loses to a known
   YouTube playing/paused level if both attributes were ever set on one frame. */
.ambient-frame[data-ambient-tone="bright"],
.ambient-frame[data-ambient-tone="bright"][data-ambient-strength="strong"]{--ambient-level:.72}
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="ready"] .ambient-glow-layer--near{
  opacity:.18;
  filter:blur(20px) saturate(1.1);
}
.ambient-frame[data-ambient-tone="bright"][data-ambient-state="ready"] .ambient-glow-layer--mid{
  opacity:.45;
}

.ambient-frame[data-ambient-sync][data-ambient-playing="false"]{--ambient-level:.45}
.ambient-frame[data-ambient-sync][data-ambient-playing="true"]{--ambient-level:1}

@media (prefers-reduced-motion:no-preference){
  .ambient-frame[data-ambient-sync][data-ambient-state="ready"][data-ambient-playing="true"] .ambient-glow-layer--far{
    animation:ambient-breathe 9s ease-in-out infinite;
  }
}

.ambient-frame[data-ambient-sync] .player,
.ambient-frame[data-ambient-tone="bright"] .player{
  position:relative;
  z-index:1;
  background:#000;
}

@media (max-width:767px){
  .ambient-frame[data-ambient-sync],
  .ambient-frame[data-ambient-tone="bright"]{--ambient-pad-x:1rem;--ambient-pad-y:3.5rem}
  .ambient-frame[data-ambient-sync]:has(.player-instagram),
  .ambient-frame[data-ambient-tone="bright"]:has(.player-instagram){--ambient-pad-x:1rem;--ambient-pad-y:3rem}
  .ambient-frame[data-ambient-sync][data-ambient-strength="strong"],
  .ambient-frame[data-ambient-tone="bright"][data-ambient-strength="strong"]{--ambient-pad-x:1rem;--ambient-pad-y:5.5rem}
  .ambient-frame[data-ambient-sync][data-ambient-strength="strong"]:has(.player-instagram),
  .ambient-frame[data-ambient-tone="bright"][data-ambient-strength="strong"]:has(.player-instagram){--ambient-pad-x:1rem;--ambient-pad-y:4.5rem}
}

/* White light. Opt-in with data-ambient-light="white" on a frame that already
   uses v2 (data-ambient-sync or data-ambient-tone="bright"). The cover colours
   are not used: the three layers become one flat fill (--w-color) blurred into
   the same soft halo. The cover path stays on the frame only to keep
   data-ambient-state="ready". Placed last so it wins the equal-specificity
   ready/tone rules above.
   Motion is separate: js/ambient-glow-motion.js, enabled per frame with
   data-ambient-motion. Without it the white halo is static. */
.ambient-frame[data-ambient-light="white"]{
  --w-color:#fff1de;              /* warm white (chosen). #fff neutral, #eaf2ff cool */
  --ambient-motion-gain:2;        /* size swing strength, 0 = still, max 2 */
  --w-far:.34;
  --w-mid:.24;
  --w-near:.12;
}
.ambient-frame[data-ambient-light="white"] .ambient-glow-layer{
  background-image:none;
  background-color:var(--w-color);
}
.ambient-frame[data-ambient-light="white"][data-ambient-state="ready"] .ambient-glow-layer--far{
  opacity:var(--w-far);
  filter:blur(92px);
  transform:scale(1.38);
}
.ambient-frame[data-ambient-light="white"][data-ambient-state="ready"] .ambient-glow-layer--mid{
  opacity:var(--w-mid);
  filter:blur(44px);
  transform:scale(1.12);
}
.ambient-frame[data-ambient-light="white"][data-ambient-state="ready"] .ambient-glow-layer--near{
  opacity:var(--w-near);
  filter:blur(20px);
  transform:scale(1.015);
}
/* The cover-colour breathing above would override the white far opacity. */
.ambient-frame[data-ambient-light="white"][data-ambient-sync][data-ambient-state="ready"][data-ambient-playing="true"] .ambient-glow-layer--far{
  animation:none;
}
