/*
 * Sun & Moon era: full-art GX / Tag Team / Supporter, Rainbow Rare and gold.
 *
 * Draws sm-fa (Rare Ultra GX and Tag Team full arts), sm-fa + sm-alt (the
 * alternate-art Tag Teams and Cosmic Eclipse's full-colour secret Pokémon:
 * matte Pokémon, foil on the scenery), sm-tfa (full-art Supporter),
 * sm-rainbow (`foil-ir`) and sm-gold (`foil-gold`: gold Trainers, Energy and
 * GX). Classes come from smPattern() in js/sm-foil.js; `era-sm` marks every
 * Sun & Moon print (js/foil-maps.js). The research, the photos and what each
 * finish does are in .claude/skills/card-textures/reference/sun-moon-fullart.md
 * and /mnt/project-files/sun-moon/texture-refs/f3-fullart-rainbow-gold.
 *
 * Same stock as the Sword & Shield and Scarlet & Violet full arts (TCG Live
 * files them as SUN_PILLAR / ETCHED, RAINBOW and gold ETCHED), so this sheet
 * keeps sv-fullart.css's Ultra Rare and gold layers and the tuning swsh.css
 * learned from the poke-holo.simey.me benchmark, and adds what only the
 * Sun & Moon maps say: the etch is a concentric fingerprint over the whole
 * face, the gold's printed stars are cut out of it, and an alternate art is
 * foil on its scenery only.
 *
 * Layer ideas follow pokemon-cards-css by Simon Goellner (@simeydotme),
 * GPL-3.0; see NOTICE.md.
 *
 * Specificity: `era-sm` five times in every selector (ten classes once the
 * rest is counted), one more than sv-fullart.css, so the rule wins whichever
 * order the sheets load in; a resting card paints `.foil` alone.
 * Bump this sheet's ?v= tag in index.html on every change.
 */

body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm {
  --smfa-glitter: url("/assets/foil/glitter.png");
  --smfa-flecks: url("/assets/foil/glitter-flecks.webp");
  --smfa-spectrum: hsl(2, 100%, 73%), hsl(53, 100%, 69%), hsl(93, 100%, 69%),
    hsl(176, 100%, 76%), hsl(228, 100%, 74%), hsl(283, 100%, 73%), hsl(2, 100%, 73%);
  --smfa-seed-pos: calc(var(--seed-x, 0.5) * 100%) calc(var(--seed-y, 0.5) * 100%);
}

/* ---- Full art: Rare Ultra GX, Tag Team and Supporter ---------------------------
   sv-fullart.css's Ultra Rare (SUN_PILLAR / ETCHED) is the same stock, so its
   layers stay. Tuned here, from the photos and TCG Live's maps:
   - GX / Tag Team full art (Umbreon & Darkrai SM241 tilted; sm9 162, 163):
     the whole face catches rainbow bands, frame included, and the Pokémon
     stays readable. The map greys the Pokémon (part strength); the etch is a
     fingerprint of concentric ridges edge to edge, text box included.
   - Full-art Supporter (sm9 172): same stock, flatter light; its etch follows
     the line art in short hatches.
   Dodge-safe: every colour-dodged chain ends in contrast(0.8), or Safari
   draws near-black ink as pure blue blocks (verify.md).
   The native TCG Live etch (-etch-v4, sigma 0.6) is used as is: a blurred or
   400 px copy turned the ridges into camouflage patches. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm:is(.sm-fa, .sm-tfa).foil-ultra.has-foil-map .foil {
  filter: brightness(calc((var(--pointer-from-center) * 0.45) + 0.5)) contrast(2) saturate(0.9) contrast(0.8);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-tfa.foil-ultra.has-foil-map .foil {
  filter: brightness(calc((var(--pointer-from-center) * 0.15) + 0.5)) contrast(1.9) saturate(1) contrast(0.8);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm:is(.sm-fa, .sm-tfa).foil-ultra.has-foil-map:not(.lit):not(.settling) .foil {
  filter: brightness(0.55) contrast(2.5) saturate(0.4) contrast(0.8);
}
/* A full art is foil edge to edge, silver frame included, but TCG Live shades
   the frame and the copyright band dark, so under the light the lit frame
   stopped in a hard line at a corner (swsh.css, Charizard V SWSH260). A floor
   of foil under the map: art AND light AND (map OR floor). Not on an
   alternate art, whose Pokémon is matte ink: there the map is the truth. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm:is(.sm-fa, .sm-tfa).foil-ultra.has-foil-map:not(.sm-alt) .foil {
  --smfa-floor: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));
  -webkit-mask-image: var(--art), var(--fa-light), var(--foil-map), var(--smfa-floor);
  -webkit-mask-composite: source-in, source-in, source-over, source-over;
  mask-image: var(--art), var(--fa-light), var(--foil-map), var(--smfa-floor);
  mask-composite: intersect, intersect, add, add;
  -webkit-mask-size: contain, 100% 100%, 100% 100%, 100% 100%;
  mask-size: contain, 100% 100%, 100% 100%, 100% 100%;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* The glare over the family: about half of sv-fullart.css's hard-light, which
   over a saturated painting is a milky veil at one tilt (swsh.css benchmark). */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-fa.foil-ultra.has-foil-map .glare {
  opacity: calc(var(--card-opacity) * 0.6);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-tfa.foil-ultra.has-foil-map .glare {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsl(0, 0%, 80%) 5%, hsl(200, 5%, 45%) 65%, hsl(320, 20%, 15%) 150%);
  filter: brightness(0.9) contrast(1.1);
  opacity: calc(var(--card-opacity) * 0.4);
}
/* The etched twin held back: with the native etch the lit ridges cover most
   of a painted Pokémon, and at full strength they shifted its colours. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-fa.foil-ultra.has-foil-map:is(.has-etch-map, .has-etch-tile) .foil::before {
  opacity: 0.35;
}

/* ---- Alternate arts: matte Pokémon, foil on the scenery -------------------------
   TCG Live's maps (sm9 161 and 165 and 170, Cosmic Eclipse 237 to 248): the
   Pokémon is black in the foil map (plain ink), the scenery and the frame are
   foil, and the etch, where there is one (the Tag Team alternate arts carry a
   faint one, the Cosmic Eclipse secret Pokémon none), is a fine fingerprint
   in the background only. So: the map alone decides where the foil is (no
   floor, above), the gloss on the varnish stays off the Pokémon, and a print
   with no etch map draws no etch layers at all (the shared tile
   js/foil-maps.js hands every etched rarity is a texture the real card does
   not have). */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-alt.foil-ultra.has-foil-map .glare {
  -webkit-mask-image: var(--art), var(--foil-map);
  -webkit-mask-composite: source-in, source-over;
  mask-image: var(--art), var(--foil-map);
  mask-composite: intersect, add;
  -webkit-mask-size: contain, 100% 100%;
  mask-size: contain, 100% 100%;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-alt.foil-ultra.has-foil-map.has-etch-tile {
  --fa-etch: linear-gradient(transparent, transparent);
  --fa-etch-size: 100% 100%;
  --fa-etch-pos: center;
  --fa-etch-repeat: no-repeat;
}

/* ---- Rainbow Rare: an etched silver foil under a printed rainbow ----------------
   Rebuilt 2026-10-02 (Noah: "really shitty texture", "overuse of the rainbow
   glare"; photos in /mnt/project-files/sun-moon/texture-refs/secrets-v2 and
   f3-fullart-rainbow-gold). The rainbow is PRINTED: the scan already carries
   it, so the foil adds no colour of its own. What the real card does is the
   etch: TCG Live's fingerprint of ridges over the whole face, following the
   drawing, that catches the light as fine bright lines near the lamp, over a
   silver foil whose glitter is a grain you notice second. So:
   - `.foil`: a neutral silver pool around the pointer, overlaid on the print
     (a dodge turned the pastels white) and cut to the etch (art AND map AND (etch OR 22% floor)): the
     printed pastels brighten along the ridges, not as a milky veil.
   - `.foil::before`: the fine glitter, screened, faint.
   - `.foil::after`: nothing (the old 240% spectrum sheen was the rainbow
     glare Noah saw on every tilt).
   - `.glare`: a small white soft-light pool, no hard-light wash.
   - `.glare::after`: the ridges lit white under the light, the texture.
   No colour-dodge anywhere in it, so nothing for Safari to divide by zero. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow {
  --smr-etch: linear-gradient(#000, #000);
  --smr-etch-size: 100% 100%;
  --smr-etch-pos: center;
  --smr-etch-repeat: no-repeat;
  --smr-floor: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3));
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow.has-etch-map {
  --smr-etch: var(--etch-map);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow.has-etch-tile {
  --smr-etch: var(--etch-tile);
  --smr-etch-size: 100% auto;
  --smr-etch-pos: var(--smfa-seed-pos);
  --smr-etch-repeat: repeat;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow .foil {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsl(0, 0%, 84%) 0%, hsl(0, 0%, 64%) 28%, hsl(0, 0%, 46%) 70%, hsl(0, 0%, 41%) 100%);
  background-size: 100% 100%;
  background-position: center;
  background-blend-mode: normal;
  background-repeat: no-repeat;
  filter: brightness(calc(0.96 + var(--pointer-from-center) * 0.08)) saturate(0);
  mix-blend-mode: overlay;
  opacity: calc((0.1 + var(--card-opacity) * 0.9) * var(--foil-strength, 1));
  clip-path: none;
  border-radius: 0;
  -webkit-mask-image: var(--art), var(--foil-map), var(--smr-etch), var(--smr-floor);
  -webkit-mask-composite: source-in, source-in, source-over, source-over;
  mask-image: var(--art), var(--foil-map), var(--smr-etch), var(--smr-floor);
  mask-composite: intersect, intersect, add, add;
  mask-mode: alpha;
  -webkit-mask-size: contain, 100% 100%, var(--smr-etch-size), 100% 100%;
  mask-size: contain, 100% 100%, var(--smr-etch-size), 100% 100%;
  -webkit-mask-position: center, center, var(--smr-etch-pos), center;
  mask-position: center, center, var(--smr-etch-pos), center;
  -webkit-mask-repeat: no-repeat, no-repeat, var(--smr-etch-repeat), no-repeat;
  mask-repeat: no-repeat, no-repeat, var(--smr-etch-repeat), no-repeat;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow:not(.lit):not(.settling) .foil {
  filter: brightness(0.9) saturate(0);
  opacity: calc(0.35 * var(--foil-strength, 1));
}
/* The glitter: one sparse tile, screened, drifting a few pixels with the tilt. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow .foil::before {
  --shift: 4px;
  background-image: url("/assets/foil/glitter-fine.webp");
  background-size: 22% auto;
  background-position:
    calc(var(--seed-x, 0.5) * 100% + (var(--pointer-from-left) - 0.5) * var(--shift))
    calc(var(--seed-y, 0.5) * 100% + (var(--pointer-from-top) - 0.5) * var(--shift));
  background-blend-mode: normal;
  background-repeat: repeat;
  filter: brightness(1.3) saturate(0);
  mix-blend-mode: screen;
  opacity: calc(var(--card-opacity) * (0.12 + var(--pointer-from-center) * 0.18));
  -webkit-mask-image: none;
  mask-image: none;
  clip-path: none;
  border-radius: 0;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow .foil::after {
  background-image: none;
  mix-blend-mode: normal;
  filter: none;
  opacity: 0;
  -webkit-mask-image: none;
  mask-image: none;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow .glare {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsla(0, 0%, 100%, 0.55) 0%, hsla(0, 0%, 100%, 0.18) 30%, hsla(0, 0%, 50%, 0) 60%);
  background-size: 100% 100%;
  background-position: center;
  mix-blend-mode: soft-light;
  filter: none;
  opacity: var(--card-opacity);
  clip-path: none;
  border-radius: 0;
  -webkit-mask-image: none;
  mask-image: none;
}
/* The texture: the etch's ridges lit white near the light, fading with
   distance, cut to the foil map so the text and its black stay ink. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-rainbow .glare::after {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsla(0, 0%, 100%, 0.7) 0%, hsla(0, 0%, 100%, 0.3) 28%, hsla(0, 0%, 100%, 0.08) 65%, hsla(0, 0%, 100%, 0) 100%);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-mask-image: var(--smr-etch), var(--foil-map);
  -webkit-mask-composite: source-in, source-over;
  mask-image: var(--smr-etch), var(--foil-map);
  mask-composite: intersect, add;
  -webkit-mask-size: var(--smr-etch-size), 100% 100%;
  mask-size: var(--smr-etch-size), 100% 100%;
  -webkit-mask-position: var(--smr-etch-pos), center;
  mask-position: var(--smr-etch-pos), center;
  -webkit-mask-repeat: var(--smr-etch-repeat), no-repeat;
  mask-repeat: var(--smr-etch-repeat), no-repeat;
  mix-blend-mode: normal;
  filter: none;
  opacity: calc(0.55 + var(--pointer-from-center) * 0.3);
}

/* ---- Gold: Trainers, Energy and GX --------------------------------------------
   sv-fullart.css's gold (SV_ULTRA / ETCHED: a faint rainbow through two light
   bars under gold ink, glitter, the etch lit over the whole card) is the same
   stock. The Sun & Moon maps add one thing: the printed four-point stars are
   cut out of the etch and bright in the foil map, glossy mirror foil rather
   than etched, and a Energy's type circle likewise. Dodge-safe: the chain
   closes in contrast(0.8) (Eternatus V, Noah 2026-09-29). */
/* Rebuilt 2026-10-02 (Noah: secret rares "overuse the rainbow glare"): a
   gold secret throws gold and white light, not a spectrum. sv-fullart.css's
   15deg spectrum under the dodge is replaced by a warm gold pool around the
   pointer, so the gold brightens to pale gold where the light is and the
   etch (the foil is cut to it below) carries the texture; the glare is warm
   and lower, the glitter a step down. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map .foil {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsl(46, 66%, 62%) 0%, hsl(42, 55%, 48%) 30%, hsl(38, 45%, 34%) 70%, hsl(36, 40%, 28%) 100%);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  filter: brightness(calc(0.82 + var(--pointer-from-center) * 0.14)) contrast(1.2) saturate(0.8) contrast(0.8);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map:not(.lit):not(.settling) .foil {
  filter: brightness(0.75) contrast(1.2) saturate(0.6) contrast(0.8);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map .glare {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsl(44, 40%, 82%) 5%, hsl(40, 12%, 52%) 35%, hsl(35, 10%, 44%) 110%);
  opacity: calc(var(--card-opacity) * 0.34);
}

/* The gold's lit layers, kept off the ink. The native etch runs under the
   title, the header band and the rules text (the real cards' engraving does),
   and its white lines are drawn in a hard-light glare: over dark ink they
   lifted "Dangerous Drill" and the TRAINER / ENERGY headers to grey, and a
   dark Energy to bright teal (review, 2026-09-30). So the lit lines are cut
   to the foil map as well (TCG Live greys the header band and blacks the
   text), and the lines and glitter run a step lower. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map:is(.has-etch-map, .has-etch-tile) .glare::after {
  background-image: radial-gradient(farthest-corner circle at var(--pointer-x) var(--pointer-y),
    hsla(0, 0%, 100%, 0.8) 0%, hsla(0, 0%, 100%, 0.45) 30%, hsla(0, 0%, 100%, 0.25) 80%);
  -webkit-mask-image: var(--fa-etch), var(--foil-map);
  -webkit-mask-composite: source-in, source-over;
  mask-image: var(--fa-etch), var(--foil-map);
  mask-composite: intersect, add;
  -webkit-mask-size: var(--fa-etch-size), 100% 100%;
  mask-size: var(--fa-etch-size), 100% 100%;
  -webkit-mask-position: var(--fa-etch-pos), center;
  mask-position: var(--fa-etch-pos), center;
  -webkit-mask-repeat: var(--fa-etch-repeat), no-repeat;
  mask-repeat: var(--fa-etch-repeat), no-repeat;
  opacity: calc(0.45 + var(--pointer-from-center) * 0.35);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map .foil::after {
  filter: brightness(1.3) contrast(1.9) saturate(0.4) sepia(0.5);
  opacity: calc(0.16 + var(--pointer-from-center) * 0.24);
}

/* The header band (TRAINER / ENERGY, or a GX's name line) is printed silver
   or grey on gold, the faintest ink on the card: under the pointer the foil
   and the lit lines washed it out (review, sm9-192). One more mask layer cuts
   both to 45% across the band, rows 2.5% to 10.5% of the card. */
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map {
  --smg-calm: linear-gradient(180deg, #000 0, #000 2%, rgba(0, 0, 0, 0.45) 3%,
    rgba(0, 0, 0, 0.45) 10%, #000 11.5%, #000 100%);
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map:is(.has-etch-map, .has-etch-tile) .foil {
  -webkit-mask-image: var(--smg-calm), var(--art), var(--foil-map), var(--fa-etch), var(--fa-floor);
  -webkit-mask-composite: source-in, source-in, source-in, source-over, source-over;
  mask-image: var(--smg-calm), var(--art), var(--foil-map), var(--fa-etch), var(--fa-floor);
  mask-composite: intersect, intersect, intersect, add, add;
  -webkit-mask-size: 100% 100%, contain, 100% 100%, var(--fa-etch-size), 100% 100%;
  mask-size: 100% 100%, contain, 100% 100%, var(--fa-etch-size), 100% 100%;
  -webkit-mask-position: center, center, center, var(--fa-etch-pos), center;
  mask-position: center, center, center, var(--fa-etch-pos), center;
  -webkit-mask-repeat: no-repeat, no-repeat, no-repeat, var(--fa-etch-repeat), no-repeat;
  mask-repeat: no-repeat, no-repeat, no-repeat, var(--fa-etch-repeat), no-repeat;
}
body.fx-holo.fx-holo.fx-holo .tcg.era-sm.era-sm.era-sm.era-sm.era-sm.sm-gold.foil-gold.has-foil-map:is(.has-etch-map, .has-etch-tile) .glare::after {
  -webkit-mask-image: var(--smg-calm), var(--fa-etch), var(--foil-map);
  -webkit-mask-composite: source-in, source-in, source-over;
  mask-image: var(--smg-calm), var(--fa-etch), var(--foil-map);
  mask-composite: intersect, intersect, add;
  -webkit-mask-size: 100% 100%, var(--fa-etch-size), 100% 100%;
  mask-size: 100% 100%, var(--fa-etch-size), 100% 100%;
  -webkit-mask-position: center, var(--fa-etch-pos), center;
  mask-position: center, var(--fa-etch-pos), center;
  -webkit-mask-repeat: no-repeat, var(--fa-etch-repeat), no-repeat;
  mask-repeat: no-repeat, var(--fa-etch-repeat), no-repeat;
}
