/* FULL-ART HOLO v3 — separate textured shine / independent specular glare.
   Reference: Simon Goellner, pokemon-cards-css (notably v-full-art and regular-holo).
   This implementation uses independently written CSS and an original generated texture.
   Keeps the existing card dimensions/DOM/transport logic and avoids a render loop.

   Unlike v2, this has NO vertical scanline overlay and NO full-card rainbow wash.
   The shine is an optical highlight, not a color filter. */

/* The two optical layers span the entire printed card, including its information
   and transport areas. They remain pointer-transparent above the printed UI. */
.song.material-card[data-finish="holo"] .holo-shine,
.song.material-card[data-finish="holo"] .holo-glare {
  position:absolute;
  left:0;right:0;top:0;
  height:100%;
  border-radius:inherit;
  pointer-events:none;
  overflow:hidden;
  display:none;
}
html[data-holo="on"]:not([data-material="off"]) .song.material-card[data-finish="holo"] .holo-shine,
html[data-holo="on"]:not([data-material="off"]) .song.material-card[data-finish="holo"] .holo-glare {display:block;}
.song.material-card[data-finish="holo"] .holo-shine { z-index:13;mix-blend-mode:screen; }
.song.material-card[data-finish="holo"] .holo-glare { z-index:14;mix-blend-mode:screen; }

/* 1. Printed diffraction film: shifting pearlescent pigment, tiny etched texture,
   and dark/bright optical grating as SEPARATE gradients. Background registration
   follows the card pointer exactly like the reference's --background-x/y flow. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::before {
  content:"";
  position:absolute;inset:0;
  background-image:
    url("./holo-etch.png"),
    repeating-linear-gradient(0deg,
      #dcb8d3 0%,#8fc9df 5%,#9dddba 11%,#e2dba3 16%,
      #c9b7e2 22%,#a5cce9 27%,#eac1cd 33%),
    repeating-linear-gradient(137deg,
      #151c31 0%,#a1a8b4 3%,#e3edf2 4%,#a0a7b1 5%,
      #10182b 10%,#10182b 14%);
  background-size:166px 166px, 245% 660%, 370% 230%;
  background-position:
    center,
    50% var(--holo-bg-y,50%),
    var(--holo-bg-x,50%) var(--holo-bg-y,50%);
  background-blend-mode:soft-light, hue, hard-light;
  /* Like the reference, light reflection depends on the viewer/angle.
     Neutral card angle remains mostly ink instead of rainbow recoloring. */
  mix-blend-mode:normal;
  filter:brightness(.78) contrast(1.8) saturate(1.5);
  opacity:var(--holo-shine-opacity,.28);
  -webkit-mask-image:linear-gradient(122deg,
    transparent 19%,rgba(0,0,0,.10) 35%,rgba(0,0,0,.78) 44%,
    #000 49%,rgba(0,0,0,.80) 56%,rgba(0,0,0,.08) 69%,transparent 83%);
  mask-image:linear-gradient(122deg,
    transparent 19%,rgba(0,0,0,.10) 35%,rgba(0,0,0,.78) 44%,
    #000 49%,rgba(0,0,0,.80) 56%,rgba(0,0,0,.08) 69%,transparent 83%);
  -webkit-mask-size:215% 100%;mask-size:215% 100%;
  -webkit-mask-position:var(--holo-band-x,50%) center;
  mask-position:var(--holo-band-x,50%) center;
  -webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;
}
/* 2. Separate opposing interference layer: the oscillating foil print does not
   travel in perfect lockstep with the base spectrum, like actual multilayer film. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::after {
  content:"";position:absolute;inset:0;
  background:
    radial-gradient(farthest-corner circle at var(--holo-pointer-x,50%) var(--holo-pointer-y,45%),
      rgba(255,255,255,.66),rgba(186,208,221,.10) 24%,transparent 63%),
    repeating-linear-gradient(112deg,
      rgba(2,4,12,.92) 0%,rgba(168,182,203,.55) 3%,
      rgba(227,235,245,.9) 4%,rgba(177,186,197,.51) 5%,rgba(7,14,29,.87) 11%);
  background-size:100% 100%,280% 260%;
  background-position:center,var(--holo-counter-x,50%) var(--holo-counter-y,50%);
  background-blend-mode:soft-light;
  mix-blend-mode:hard-light;
  filter:brightness(.8) contrast(1.8);
  opacity:var(--holo-interference-opacity,.18);
  -webkit-mask-image:radial-gradient(ellipse 47% 76% at var(--holo-pointer-x,50%) var(--holo-pointer-y,45%),#000 0%,rgba(0,0,0,.45) 48%,transparent 100%);
  mask-image:radial-gradient(ellipse 47% 76% at var(--holo-pointer-x,50%) var(--holo-pointer-y,45%),#000 0%,rgba(0,0,0,.45) 48%,transparent 100%);
}
/* 3. The glare is NOT another rainbow layer. The source's glare is a separate
   pointer-positioned radial reflection, combining white light and darker falloff. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::before {
  content:"";position:absolute;inset:0;
  background:radial-gradient(farthest-corner circle at var(--holo-pointer-x,50%) var(--holo-pointer-y,40%),
    rgba(255,255,255,.86) 0%,rgba(242,251,255,.48) 12%,
    rgba(166,195,209,.13) 28%,transparent 58%);
  filter:brightness(.9) contrast(1.4);
  mix-blend-mode:screen;
  opacity:var(--holo-glare-opacity,.22);
}
/* 4. Narrow, direction-specific camera/lamp reflection. Independent of foil. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::after {
  content:"";position:absolute;inset:0;
  background:linear-gradient(112deg,
    transparent 28%,rgba(255,255,255,.025) 43%,
    rgba(255,255,255,.21) 48%,rgba(255,255,255,.52) 50%,
    rgba(251,252,255,.16) 52%,transparent 65%);
  background-size:230% 100%;
  background-position:var(--holo-glare-x,50%) center;
  opacity:var(--holo-sweep-opacity,.16);
  mix-blend-mode:screen;
}
/* The existing lacquer and edge continue to simulate paper/bow. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .mat-lacquer {
  z-index:2;
  opacity:.32;
  mix-blend-mode:screen;
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .mat-lacquer::before,
html[data-holo="on"] .song.material-card[data-finish="holo"] .mat-lacquer::after {content:none!important;}
html[data-holo="on"] .song.material-card[data-finish="holo"] .mat-cut::after {
  content:"";position:absolute;inset:0;border-radius:inherit;padding:1.1px;
  background:linear-gradient(135deg,#f7fafb,#9eabbd,#dbb7dc,#fbf3da,#b5ced9,#f7fafb);
  background-size:260% 260%;
  background-position:var(--holo-bg-x,50%) var(--holo-bg-y,50%);
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
  -webkit-mask-composite:xor;
  mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
  mask-composite:exclude;
  opacity:.27;mix-blend-mode:screen;
}
html[data-holo="off"] .song[data-finish="holo"] .mat-cut::after,
html[data-material="off"] .song[data-finish="holo"] .mat-cut::after {content:none!important;}
/* No extra effects on standard and silver cards. No idle animation timer. */

/* Preserve the working compact touch settings row on small iPhones. */
card-settings{display:flex;position:absolute;z-index:90;
  top:calc(8px + env(safe-area-inset-top,0px));left:8px;right:8px;
  justify-content:flex-end;gap:5px;align-items:center;pointer-events:none;}
card-settings .backdrop-toggle{position:relative;top:auto;left:auto;right:auto;
  flex:0 1 auto;min-width:0;padding:0 7px;white-space:nowrap;pointer-events:auto;}
card-settings .holo-toggle{min-width:66px}
@media(max-width:360px){card-settings{gap:4px;left:6px;right:6px}
  card-settings .backdrop-toggle{font-size:9px;padding:0 5px;gap:3px}
  card-settings .holo-toggle{min-width:58px}
  card-settings .backdrop-toggle svg{width:14px;height:14px}}

/* FOIL v5 — visible, restrained idle movement.
   The card never floats or tilts on its own. Three existing optical layers
   travel independently, giving the print a noticeable reflectance shift even
   when untouched. Everything is transform/opacity on existing pseudo-elements,
   not background-position or a JS animation loop. */
@keyframes holo-idle-diffraction {
  0%   { transform:translate3d(-15%, -3%, 0); }
  24%  { transform:translate3d(  2%,  3%, 0); }
  53%  { transform:translate3d( 15%, -2%, 0); }
  77%  { transform:translate3d(  3%,  3%, 0); }
  100% { transform:translate3d(-15%, -3%, 0); }
}
@keyframes holo-idle-specular {
  0%   { transform:translate3d( 20%, -3%, 0); opacity:.22; }
  34%  { transform:translate3d( -5%,  2%, 0); opacity:1; }
  65%  { transform:translate3d(-20%,  0%, 0); opacity:.65; }
  100% { transform:translate3d( 20%, -3%, 0); opacity:.22; }
}
@keyframes holo-idle-light {
  0%   { transform:translate3d(-18%, 3%, 0); opacity:.30; }
  40%  { transform:translate3d(  7%,-3%, 0); opacity:.9; }
  72%  { transform:translate3d( 18%, 2%, 0); opacity:.65; }
  100% { transform:translate3d(-18%, 3%, 0); opacity:.30; }
}

@media (prefers-reduced-motion: no-preference) {
  html[data-holo="on"]:not([data-material="off"]) .app:is([data-mode="hand"],[data-mode="player"])
  .song.material-card[data-finish="holo"] .holo-shine::before {
    animation:holo-idle-diffraction 6.8s ease-in-out infinite;
    will-change:transform;
  }
  html[data-holo="on"]:not([data-material="off"]) .app:is([data-mode="hand"],[data-mode="player"])
  .song.material-card[data-finish="holo"] .holo-glare::after {
    animation:holo-idle-specular 5.4s ease-in-out infinite;
    will-change:transform,opacity;
  }
  html[data-holo="on"]:not([data-material="off"]) .app:is([data-mode="hand"],[data-mode="player"])
  .song.material-card[data-finish="holo"] .holo-glare::before {
    animation:holo-idle-light 7.6s ease-in-out infinite;
    will-change:transform,opacity;
  }
}

/* Finger-driven holography always takes over while touched. */
html[data-holo-idle="paused"] .song[data-finish="holo"] :is(.holo-shine,.holo-glare)::before,
html[data-holo-idle="paused"] .song[data-finish="holo"] .holo-glare::after,
.song.holo-interacting[data-finish="holo"] :is(.holo-shine,.holo-glare)::before,
.song.holo-interacting[data-finish="holo"] .holo-glare::after {
  animation-play-state:paused!important;
}

/* FOIL v6: one continuous reflective surface across the entire printed card.
   Both optical layers are above the ink/panels, but their low-strength screen
   compositing preserves the dark type and controls. No new DOM or animation.
   The foil is clipped to the card's original rounded rectangular boundary. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine,
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {
  inset:0;
  width:100%;
  height:100%;
  border-radius:2px;
  pointer-events:none;
}
/* Reduce the foil's ink wash while keeping the same large traveling reflections.
   No masks or hard stops at the metadata / playback panel boundaries. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine {
  opacity:.70;
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {
  opacity:.62;
}

/* FOIL v7: seam-free overscan.  The v5/v6 idle keyframes translated
   card-sized pseudo-elements far enough to expose their vertical/horizontal
   clipping edges (clearly visible in iPhone Safari screenshots).
   All three moving surfaces now extend *past* every card edge, and their
   translations are bounded within that overscan, including at keyframes.

   Horizontal dimensions: 188% of card width, 44% overhang per side.
   Max horizontal travel: 20% * 188% = 37.6% card width, leaving 6.4%
   spare coverage on BOTH sides even at the extreme.  Vertical dimensions:
   118% height, 9% overhang per side; max travel 3% * 118% = 3.54%.
   The parent holo layers still clip to the original full-card boundary.
   No new elements, canvas, animation loops, or new material layers. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::before,
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::before,
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::after {
  inset:-9% -44%;
}


/* FOIL v9: v7's seamless optical geometry, with a restrained chromatic
   diffraction reflection. The colored region is a narrow feathered moving
   highlight, NOT an all-over rainbow tint. Original ink remains visible. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::before {
  background-image:
    url("./holo-etch.png"),
    linear-gradient(112deg,
      transparent 0%,transparent 30%,
      rgba(15,195,245,0) 36%,
      rgba(20,190,235,.75) 42%,
      rgba(61,224,155,.85) 46%,
      rgba(240,207,65,.86) 50%,
      rgba(239,83,150,.84) 54%,
      rgba(145,91,234,.80) 58%,
      rgba(52,140,220,0) 65%,transparent 72%),
    repeating-linear-gradient(137deg,
      #121b2b 0%,#b2b5c0 3%,#e6e6f0 4%,#a6a8b8 5%,#151a29 11%);
  background-size:166px 166px,100% 100%,370% 230%;
  background-position:center,center,var(--holo-bg-x,50%) var(--holo-bg-y,50%);
  background-blend-mode:soft-light,normal,soft-light;
  filter:saturate(1.20) contrast(1.05);
  opacity:var(--holo-shine-opacity,.40);
  -webkit-mask-image:linear-gradient(112deg,
    transparent 30%,rgba(0,0,0,.08) 36%,rgba(0,0,0,.55) 43%,
    #000 49%,rgba(0,0,0,.62) 56%,rgba(0,0,0,.08) 64%,transparent 71%);
  mask-image:linear-gradient(112deg,
    transparent 30%,rgba(0,0,0,.08) 36%,rgba(0,0,0,.55) 43%,
    #000 49%,rgba(0,0,0,.62) 56%,rgba(0,0,0,.08) 64%,transparent 71%);
  -webkit-mask-size:100% 100%;mask-size:100% 100%;
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::after {opacity:.13;}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::before {opacity:var(--holo-glare-opacity,.13);}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::after {opacity:var(--holo-sweep-opacity,.11);}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine {opacity:.82;}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {opacity:.48;}

/* FOIL v10: ink-reactive reflection. The previous v9 spectrum was screened
   onto the ink, producing a transparent-sleeve appearance. Keep its seamless
   overscan and motion, but combine a co-moving shadow, contrast modulation,
   and spectral reflected light against the actual card pixels. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine,
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {
  mix-blend-mode:normal;
  isolation:auto;
}
/* The foil's first pass modifies local ink contrast and hue rather than simply
   lightening every underlying pixel. Soft-light preserves bright and dark detail. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine {
  mix-blend-mode:soft-light;
  opacity:.88;
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::before {
  mix-blend-mode:normal;
  filter:saturate(1.5) contrast(1.32) brightness(.88);
  opacity:var(--holo-shine-opacity,.64);
}
/* Counter-phase grating locally deepens dark regions as the spectral highlight
   moves, creating the missing contrast response to the foil. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::after {
  mix-blend-mode:multiply;
  opacity:var(--holo-interference-opacity,.24);
  background:
    radial-gradient(ellipse 65% 80% at var(--holo-pointer-x,50%) var(--holo-pointer-y,45%),
      rgba(20,20,42,.10),rgba(9,12,27,.50) 46%,transparent 85%),
    linear-gradient(112deg,transparent 29%,rgba(18,13,42,.14) 40%,
      rgba(11,12,28,.68) 48%,rgba(26,15,44,.48) 54%,transparent 69%);
  -webkit-mask-image:none;mask-image:none;
}
/* A limited specular reflection still screens light, but the soft-light foil
   beneath it changes the ink's luminance instead of leaving it untouched. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {
  mix-blend-mode:screen;
  opacity:.35;
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::before {
  opacity:var(--holo-glare-opacity,.09);
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::after {
  opacity:var(--holo-sweep-opacity,.075);
}

/* FOIL v11: song-derived micro-etched waveform, mock amplitude bins.
   The SVG is generated once per holo card and remains stationary on the print.
   Only the illumination mask travels, so the waveform reads as etched foil,
   not a floating animated waveform overlay. */
.song.material-card[data-finish="holo"] .holo-wave {
  position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  z-index:13;display:none;overflow:hidden;mix-blend-mode:soft-light;
  background-image:var(--foil-waveform);
  background-repeat:repeat;
  background-size:100% 76px;
  opacity:.64;
  -webkit-mask-image:linear-gradient(122deg,transparent 19%,rgba(0,0,0,.18) 37%,#000 49%,rgba(0,0,0,.24) 64%,transparent 83%);
  mask-image:linear-gradient(122deg,transparent 19%,rgba(0,0,0,.18) 37%,#000 49%,rgba(0,0,0,.24) 64%,transparent 83%);
  -webkit-mask-size:215% 100%;mask-size:215% 100%;
  -webkit-mask-position:var(--holo-band-x,50%) center;mask-position:var(--holo-band-x,50%) center;
  -webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;
}
html[data-holo="on"]:not([data-material="off"]) .song.material-card[data-finish="holo"] .holo-wave {display:block;}
