/* Card shine (js/holo.js) - the foil effect on a card picture.
   --mx/--my pointer position on the card (0-100), --rx/--ry tilt in degrees,
   --o how lit up it is (0 at rest), --d distance from the middle (0-1), --s
   scale. Set by script, smoothed with a spring. --art is the artwork window
   (inset) and --around-art the card with that window cut out. */
.cs { --mx: 50; --my: 50; --rx: 0; --ry: 0; --o: 0; --d: 0; --s: 1;
  position: relative; width: 100%; aspect-ratio: 63 / 88; perspective: 900px; touch-action: pan-y; }
.cs-card { position: relative; width: 100%; height: 100%; border-radius: 4.6% / 3.3%; overflow: hidden; isolation: isolate;
  transform: rotateY(calc(var(--ry) * 1deg)) rotateX(calc(var(--rx) * 1deg)) scale(var(--s));
  box-shadow: 0 2px 4px rgba(0,0,0,.35), calc(var(--ry) * -0.6px) calc(12px + var(--rx) * 0.6px) calc(24px + var(--o) * 20px) calc(-10px + var(--o) * 2px) rgba(0,0,0,calc(.45 + var(--o) * .2));
  background: #1B1F25; }
.cs-card img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.cs-card > div { position: absolute; inset: 0; pointer-events: none; }

/* the light that follows the pointer - every card has it */
.cs-glare { opacity: calc(var(--o) * .9); mix-blend-mode: overlay;
  background: radial-gradient(farthest-corner circle at calc(var(--mx) * 1%) calc(var(--my) * 1%),
    rgba(255,255,255,.85) 0%, rgba(255,255,255,.45) 18%, rgba(255,255,255,0) 45%, rgba(0,0,0,.35) 100%); }
.cs-glare2 { opacity: calc(var(--o) * .35); mix-blend-mode: soft-light;
  background: linear-gradient(calc(110deg + var(--ry) * 2deg), rgba(255,255,255,0) 30%, rgba(255,255,255,.7) 50%, rgba(255,255,255,0) 70%);
  background-size: 260% 260%; background-position: calc(100% - var(--mx) * 1%) calc(100% - var(--my) * 1%); }

/* the rainbow foil - where it shows depends on the finish */
.cs-foil { opacity: calc(var(--o) * var(--foil-strength, .8)); mix-blend-mode: color-dodge;
  background-image:
    repeating-linear-gradient(var(--rainbow-angle, 118deg), hsl(0 95% 62%) 0%, hsl(45 100% 60%) 3.5%, hsl(110 85% 58%) 7%, hsl(185 95% 58%) 10.5%, hsl(240 90% 66%) 14%, hsl(300 90% 64%) 17.5%, hsl(360 95% 62%) 21%),
    repeating-linear-gradient(var(--lines-angle, 62deg), #0d1222 0%, #71808e 1.6%, #0d1222 3.2%),
    radial-gradient(farthest-corner circle at calc(var(--mx) * 1%) calc(var(--my) * 1%), rgba(255,255,255,.35) 0%, rgba(0,0,0,.6) 80%);
  background-size: 260% 260%, 180% 180%, 100% 100%;
  background-position: calc(var(--mx) * 1%) calc(var(--my) * 1%), calc(100% - var(--mx) * .6%) calc(var(--my) * .6%), center;
  background-blend-mode: overlay, hard-light, normal;
  filter: brightness(.62) contrast(1.75) saturate(1.35); }
.cs-tex { opacity: calc(var(--o) * var(--tex-strength, 0)); mix-blend-mode: color-dodge; }
.cs-sparkle { opacity: calc(var(--o) * var(--sparkle-strength, 0)); mix-blend-mode: color-dodge;
  background-image: var(--cs-sparkle); background-size: 140px 140px;
  background-position: calc(var(--mx) * -0.6px) calc(var(--my) * -0.6px);
  filter: brightness(calc(.6 + var(--d) * .9)); }
.cs-mark { display: none; }

/* A member's own photo: it tilts, but nothing is laid over it (no foil, no
   light) and nothing is cut off - its corners and edges stay as photographed */
.cs[data-finish="photo"] { aspect-ratio: auto; }
.cs[data-finish="photo"] .cs-card { height: auto; border-radius: 0; background: none; }
.cs[data-finish="photo"] .cs-card img { height: auto; max-height: calc(90vh - 200px); object-fit: contain; }
.cs[data-finish="photo"] .cs-card > div { display: none; }

/* Standard: no foil - just the gloss of light across the card */
.cs[data-finish="plain"] .cs-foil { display: none; }
.cs[data-finish="plain"] .cs-glare { opacity: calc(var(--o) * .6); }
/* Holo: the artwork window only */
.cs[data-finish="holo"] .cs-foil { clip-path: inset(var(--art)); --foil-strength: .95; }
/* Reverse Holo: everything except the artwork window */
.cs[data-finish="reverse"] .cs-foil { clip-path: var(--around-art); --foil-strength: .75; }
/* Whole-card foils run in vertical bands, like the real cards */
.cs:is([data-finish="alt"], [data-finish="sir"], [data-finish="mtg"], [data-finish="etched"], [data-finish="rainbow"], [data-finish="gold"], [data-finish="textured"]) .cs-foil {
  --rainbow-angle: 90deg; --lines-angle: 90deg; }
/* Alternate Art, Illustration Rare, ex / V: the whole card, softer, with fine glitter */
.cs[data-finish="alt"] .cs-foil { --foil-strength: .55; }
.cs[data-finish="alt"] .cs-sparkle { --sparkle-strength: .35; }
/* Special Illustration Rare, Shiny: whole card plus glitter */
.cs[data-finish="sir"] .cs-foil { --foil-strength: .5; }
.cs[data-finish="sir"] .cs-sparkle { --sparkle-strength: .85; }
/* Magic foil: whole card, a light rainbow sweep; etched is duller and metallic */
.cs[data-finish="mtg"] .cs-foil { --foil-strength: .6; filter: brightness(.7) contrast(1.4) saturate(1.1); }
.cs[data-finish="etched"] .cs-foil { --foil-strength: .45; filter: brightness(.75) contrast(1.3) saturate(.55); }

/* Poké Ball / Master Ball reverse: only the balls around the artwork are foil */
.cs:is([data-finish="pokeball"], [data-finish="masterball"]) .cs-foil {
  clip-path: var(--around-art); --foil-strength: 1;
  -webkit-mask-image: var(--ball-mask); mask-image: var(--ball-mask);
  -webkit-mask-size: 20% auto; mask-size: 20% auto;
  -webkit-mask-position: 50% 0; mask-position: 50% 0; }
.cs[data-finish="pokeball"] { --ball-mask: var(--cs-pb); }
.cs[data-finish="pokeball"] .cs-foil { filter: brightness(1.05) contrast(1.35) saturate(1.7); }
.cs[data-finish="masterball"] { --ball-mask: var(--cs-mb); }
.cs[data-finish="masterball"] .cs-foil { filter: brightness(1) contrast(1.4) saturate(1.8) hue-rotate(calc(220deg + var(--mx) * 1.2deg)); }
/* Poké Ball / Master Ball mirror (Prismatic Evolutions, Terastal Festival): a
   silvery mosaic of foil shards around the artwork, one big ball on the text box */
.cs[data-finish="bigball"] .cs-foil { clip-path: var(--around-art); --foil-strength: .45; }
.cs[data-finish="bigball"] .cs-tex { clip-path: var(--around-art); --tex-strength: .5;
  background-image: var(--cs-mosaic); background-size: 100% 100%;
  filter: hue-rotate(calc(var(--mx) * 3deg - var(--my) * 1.5deg)) brightness(calc(.7 + var(--d) * .5)); }
.cs[data-finish="bigball"] .cs-mark { display: block; mix-blend-mode: multiply; opacity: calc(.42 + var(--o) * .22);
  background-image: var(--cs-mark-poke); background-size: 100% 100%; }
.cs[data-finish="bigball"][data-ball="master"] .cs-mark { background-image: var(--cs-mark-master); }
/* Cosmos: shimmering circles in the artwork window */
.cs[data-finish="cosmos"] .cs-foil { clip-path: inset(var(--art)); --foil-strength: .35; }
.cs[data-finish="cosmos"] .cs-tex { clip-path: inset(var(--art)); --tex-strength: .85;
  background-image: var(--cs-cosmos); background-size: 100% 100%;
  filter: hue-rotate(calc(var(--mx) * 3.6deg + var(--my) * 1.8deg)) brightness(calc(.7 + var(--d) * .6)); }
/* Cracked Ice, Shattered Glass: shards that each catch the light differently */
.cs[data-finish="ice"] .cs-foil { clip-path: inset(var(--art)); --foil-strength: .35; }
.cs[data-finish="ice"] .cs-tex { clip-path: inset(var(--art)); --tex-strength: .55;
  background-image: var(--cs-ice); background-size: 100% 100%;
  filter: hue-rotate(calc(var(--mx) * 4deg - var(--my) * 2deg)) brightness(calc(.55 + var(--d) * .7)) contrast(1.15); }
/* Starlight, Tinsel: the artwork window with glitter */
.cs[data-finish="starlight"] .cs-foil { clip-path: inset(var(--art)); --foil-strength: .8; }
.cs[data-finish="starlight"] .cs-sparkle { clip-path: inset(var(--art)); --sparkle-strength: .9; }
/* Crosshatch, Radiant: fine diagonal lines over the whole card */
.cs[data-finish="crosshatch"] .cs-foil { --foil-strength: 1;
  -webkit-mask-image: repeating-linear-gradient(45deg, #000 0 1.2px, transparent 1.2px 5px), repeating-linear-gradient(-45deg, #000 0 1.2px, transparent 1.2px 5px);
  mask-image: repeating-linear-gradient(45deg, #000 0 1.2px, transparent 1.2px 5px), repeating-linear-gradient(-45deg, #000 0 1.2px, transparent 1.2px 5px); }
/* Rainbow, Secret Rare, Amazing Rare: a pastel rainbow wash plus glitter */
.cs[data-finish="rainbow"] .cs-foil { --foil-strength: .75; filter: brightness(.82) contrast(1.25) saturate(.85); }
.cs[data-finish="rainbow"] .cs-sparkle { --sparkle-strength: .7; }
/* Gold, Hyper Rare: gold metal shine plus glitter */
.cs[data-finish="gold"] .cs-foil { --foil-strength: .9; filter: brightness(.8) contrast(1.5);
  background-image:
    repeating-linear-gradient(var(--rainbow-angle, 118deg), #6b4a0c 0%, #f6dd86 3%, #a8771f 6.5%, #fff3bf 9.5%, #7c5712 13%),
    radial-gradient(farthest-corner circle at calc(var(--mx) * 1%) calc(var(--my) * 1%), rgba(255,240,190,.5) 0%, rgba(0,0,0,.6) 75%);
  background-size: 300% 300%, 100% 100%;
  background-position: calc(var(--mx) * 1%) calc(var(--my) * 1%), center;
  background-blend-mode: overlay, normal; }
.cs[data-finish="gold"] .cs-sparkle { --sparkle-strength: .55; }
/* Textured full art, Ultra Rare: raised ridges that catch the light */
.cs[data-finish="textured"] .cs-foil { --foil-strength: .5; }
.cs[data-finish="textured"] .cs-tex { --tex-strength: .45; mix-blend-mode: overlay;
  background-image: repeating-radial-gradient(circle at 38% 34%, rgba(255,255,255,0) 0 1.4px, rgba(255,255,255,.55) 1.7px 2.1px, rgba(255,255,255,0) 2.4px 3.6px);
  background-position: calc((var(--mx) - 50) * -0.25px) calc((var(--my) - 50) * -0.25px); }

@media (forced-colors: active) {
  .cs-card > div { display: none; }
}
