/*
 * Full-strength holofoil, closer to pokemon-cards-css by Simon Goellner
 * (@simeydotme), https://github.com/simeydotme/pokemon-cards-css, GPL-3.0.
 * See NOTICE.md. Loaded last so it takes over from the quieter tuning in
 * finishes.css for the full-art rarities.
 *
 * Upstream reads a per-card foil map for each Scarlet & Violet print. Those
 * maps are not available here, so the full arts use upstream's own fallback
 * texture for unmasked cards (illusion.png), which is the textured, etched
 * look a real full art has under a lamp.
 */

body.fx-holo.fx-holo.fx-holo .tcg {
  --holo-illusion: url("/assets/foil/reference/illusion.png");
  --holo-illusion-2: url("/assets/foil/reference/illusion2.png");
}

/* A foil reaches full strength under the pointer, like upstream, instead of
   stopping at a third. The resting glint stays low. */
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra, .foil-sir, .foil-ir, .foil-mega-attack, .foil-gold, .foil-bwr, .foil-future) .foil {
  opacity: calc((0.16 + var(--card-opacity) * 0.84) * var(--foil-strength, 1));
}
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra, .foil-sir, .foil-ir, .foil-mega-attack, .foil-gold, .foil-bwr, .foil-future):not(.lit):not(.settling) .foil {
  opacity: calc(0.16 * var(--foil-strength, 1));
}

/* ---- Double Rare ex and Ultra Rare: textured full art -------------------- */
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra) .foil,
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra) .foil::after {
  --space: 5%;
  --angle: 133deg;
  background-image:
    var(--holo-illusion),
    repeating-linear-gradient(0deg,
      var(--sunpillar-clr-1) calc(var(--space) * 1),
      var(--sunpillar-clr-2) calc(var(--space) * 2),
      var(--sunpillar-clr-3) calc(var(--space) * 3),
      var(--sunpillar-clr-4) calc(var(--space) * 4),
      var(--sunpillar-clr-5) calc(var(--space) * 5),
      var(--sunpillar-clr-6) calc(var(--space) * 6),
      var(--sunpillar-clr-1) calc(var(--space) * 7)),
    repeating-linear-gradient(var(--angle),
      #0e152e 0%, hsl(180, 10%, 60%) 3.8%, hsl(180, 29%, 66%) 4.5%,
      hsl(180, 10%, 60%) 5.2%, #0e152e 10%, #0e152e 12%),
    radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
      hsla(0, 0%, 0%, 0.1) 12%, hsla(0, 0%, 0%, 0.15) 20%, hsla(0, 0%, 0%, 0.25) 120%);
  background-position:
    center center,
    0% var(--background-y),
    calc(var(--background-x) + (var(--background-y) * 0.2)) var(--background-y),
    var(--background-x) var(--background-y);
  background-size: 33%, 200% 700%, 300% 100%, 200% 100%;
  background-repeat: repeat;
  background-blend-mode: exclusion, hue, hard-light;
  mix-blend-mode: color-dodge;
  filter: brightness(calc((var(--pointer-from-center) * 0.3) + 0.35)) contrast(2) saturate(1.5);
  -webkit-mask-image: none;
  mask-image: none;
  clip-path: none;
  border-radius: 4.55% / 3.25%;
}
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra) .foil::after {
  background-position:
    center center,
    0% var(--background-y),
    calc(100% - (var(--background-x) + (var(--background-y) * 0.2))) calc(var(--background-y) * -1),
    var(--background-x) var(--background-y);
  background-size: 33%, 200% 400%, 195% 100%, 200% 100%;
  filter: brightness(calc((var(--pointer-from-center) * 0.4) + 0.8)) contrast(1.5) saturate(1.25);
  mix-blend-mode: exclusion;
  opacity: 1;
}
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra) .foil::before {
  background: none;
  opacity: 0;
}
/* Ultra Rare runs a touch hotter than a Double Rare. */
body.fx-holo.fx-holo.fx-holo .tcg.foil-ultra .foil {
  filter: brightness(calc((var(--pointer-from-center) * 0.35) + 0.4)) contrast(2.1) saturate(1.7);
}

/* ---- Special Illustration Rare: glitter and a wide rainbow --------------- */
body.fx-holo.fx-holo.fx-holo .tcg.foil-sir .foil {
  --r-clr-1: hsl(0, 57%, 37%);
  --r-clr-2: hsl(40, 53%, 39%);
  --r-clr-3: hsl(90, 60%, 35%);
  --r-clr-4: hsl(180, 60%, 35%);
  --r-clr-5: hsl(180, 60%, 35%);
  --r-clr-6: hsl(210, 57%, 39%);
  --r-clr-7: hsl(280, 55%, 31%);
  --space: 5%;
  --angle: 133deg;
  background-image:
    repeating-linear-gradient(var(--angle),
      hsla(283, 49%, 60%, 0.75) calc(var(--space) * 1),
      hsla(2, 70%, 58%, 0.75) calc(var(--space) * 2),
      hsla(53, 67%, 53%, 0.75) calc(var(--space) * 3),
      hsla(93, 56%, 52%, 0.75) calc(var(--space) * 4),
      hsla(176, 38%, 50%, 0.75) calc(var(--space) * 5),
      hsla(228, 100%, 77%, 0.75) calc(var(--space) * 6),
      hsla(283, 49%, 61%, 0.75) calc(var(--space) * 7)),
    var(--holo-glitter),
    linear-gradient(-30deg,
      var(--r-clr-1), var(--r-clr-2), var(--r-clr-3), var(--r-clr-4), var(--r-clr-5), var(--r-clr-6), var(--r-clr-7),
      var(--r-clr-1), var(--r-clr-2), var(--r-clr-3), var(--r-clr-4), var(--r-clr-5), var(--r-clr-6), var(--r-clr-7),
      var(--r-clr-1));
  background-size: 200% 400%, 25% 25%, 400% 400%;
  background-position: 0% var(--background-y), center center,
    calc(var(--background-x) * 1.5) calc(var(--background-y) * 1.5);
  background-repeat: repeat;
  background-blend-mode: luminosity, overlay;
  mix-blend-mode: color-dodge;
  filter: brightness(calc((var(--pointer-from-center) * 0.3) + 0.3)) contrast(3) saturate(1.8);
  -webkit-mask-image: none;
  mask-image: none;
  clip-path: none;
  border-radius: 4.55% / 3.25%;
}
body.fx-holo.fx-holo.fx-holo .tcg.foil-sir .foil::after {
  background-image: var(--holo-glitter),
    linear-gradient(-60deg,
      var(--r-clr-1), var(--r-clr-2), var(--r-clr-3), var(--r-clr-4), var(--r-clr-5), var(--r-clr-6), var(--r-clr-7),
      var(--r-clr-1), var(--r-clr-2), var(--r-clr-3), var(--r-clr-4), var(--r-clr-5), var(--r-clr-6), var(--r-clr-7),
      var(--r-clr-1));
  background-size: 25% 25%, 400% 400%;
  background-position: center center, calc(var(--background-x) * -1.5) calc(var(--background-y) * -1.5);
  background-blend-mode: overlay;
  mix-blend-mode: color-dodge;
  filter: brightness(calc((var(--pointer-from-center) * 0.5) + 0.6)) contrast(3) saturate(1);
  opacity: calc(1.2 + (var(--pointer-from-center) / 2) * -1);
}
body.fx-holo.fx-holo.fx-holo .tcg.foil-sir .foil::before {
  background-image: var(--holo-illusion-2);
  background-size: cover;
  background-position: center center;
  background-blend-mode: normal;
  mix-blend-mode: color-dodge;
  filter: brightness(1.5) contrast(1.5);
  opacity: calc((var(--pointer-from-center) + 0.6) * 0.4);
}

/* ---- Glare: a real hot spot on every foil --------------------------------- */
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra) .glare {
  background: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    /* 2026-09-28: far end was hsl(320, 40%, 10%); hard-light with a near-black
       end shaded the far half and dotted fine print (Mega Absol/Venusaur ex).
       Glitter never darkens: keep the far end above ~25% lightness. */
    hsl(0, 0%, 75%) 5%, hsl(200, 5%, 38%) 60%, hsl(320, 25%, 24%) 150%);
  background-size: 120% 150%;
  background-position: center center;
  mix-blend-mode: hard-light;
  filter: brightness(1) contrast(1.2) saturate(1);
  opacity: calc(var(--card-opacity) * 0.75);
  -webkit-mask-image: none;
  mask-image: none;
  clip-path: none;
  border-radius: 4.55% / 3.25%;
}
body.fx-holo.fx-holo.fx-holo .tcg.foil-sir .glare {
  background: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsla(50, 20%, 90%, 0.75) 0%, hsla(150, 20%, 30%, 0.65) 45%, hsla(0, 0%, 0%, 1) 100%);
  mix-blend-mode: hard-light;
  filter: brightness(0.9) contrast(2);
  opacity: calc(var(--card-opacity) * 0.75);
  -webkit-mask-image: none;
  mask-image: none;
  clip-path: none;
  border-radius: 4.55% / 3.25%;
}
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-ex, .foil-ultra, .foil-sir) .glare::after { background: none; }

/* The regular window holo and reverse get the upstream glare strength. */
body.fx-holo.fx-holo.fx-holo .tcg:is(.foil-holo, .foil-reverse) .glare {
  opacity: calc(var(--card-opacity) * 0.9);
}

/* ---- The card as an object ----------------------------------------------- */
/* A lifted card throws a shadow that moves against the tilt, which is what
   sells it as a physical card rather than an image leaning. */
body.fx-holo.fx-holo.fx-holo .tcg.lit img,
body.fx-holo.fx-holo.fx-holo .tcg.settling img {
  filter:
    drop-shadow(calc((var(--pointer-from-left) - 0.5) * -24px) calc(14px + (var(--pointer-from-top) - 0.5) * -20px) 22px rgba(0, 0, 0, 0.55))
    drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
}
/* No outline on .tcg itself. The box is square but the printed card is not:
   a 1px rim here stuck out past all four rounded corners as a faint
   rectangle whenever a foil was held. Anything drawn around the card has to
   follow the art's own alpha, like the drop shadows above. */
