/* 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 v8 — prismatic film, not a clear plastic sleeve.
   Preserve v7's seamless overscan, pointer handling and idle animations.
   Saturated spectrum exists only within a moving, feathered reflective band;
   printed ink remains unchanged outside the reflection. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::before {
  background-image:
    url("./holo-etch.png"),
    linear-gradient(112deg,
      transparent 18%,rgba(0,205,255,0) 30%,
      rgba(8,218,255,.85) 36%,rgba(31,244,148,.80) 42%,
      rgba(250,225,52,.76) 48%,rgba(255,66,151,.82) 54%,
      rgba(145,67,255,.86) 60%,rgba(35,185,255,.68) 65%,
      rgba(36,142,242,0) 73%,transparent 82%);
  background-size:166px 166px,155% 100%;
  background-position:center,var(--holo-bg-x,50%) center;
  background-blend-mode:soft-light,normal;
  filter:saturate(1.48) contrast(1.05);
  opacity:var(--holo-shine-opacity,.63);
  -webkit-mask-image:linear-gradient(112deg,
    transparent 24%,rgba(0,0,0,.05) 32%,rgba(0,0,0,.68) 42%,
    #000 49%,rgba(0,0,0,.72) 58%,rgba(0,0,0,.07) 67%,transparent 76%);
  mask-image:linear-gradient(112deg,
    transparent 24%,rgba(0,0,0,.05) 32%,rgba(0,0,0,.68) 42%,
    #000 49%,rgba(0,0,0,.72) 58%,rgba(0,0,0,.07) 67%,transparent 76%);
  -webkit-mask-size:195% 100%;mask-size:195% 100%;
}
/* Retain subtle interference microtexture, without broad neutral haze. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine::after {
  opacity:.10;
}
/* Glare is now an accent, not the dominant plastic-looking highlight. */
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::before {
  opacity:var(--holo-glare-opacity,.16);
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare::after {
  opacity:var(--holo-sweep-opacity,.10);
}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-shine {opacity:.98;}
html[data-holo="on"] .song.material-card[data-finish="holo"] .holo-glare {opacity:.42;}
