/*
 * THE PRESET CARDS' EFFECTS - the look (rp-cardfx, a technical study,
 * 2026-09-26; the engine is card-fx.js). Every value here is Breece's to
 * tune, and a card redesign restyles this file: nothing below assumes the
 * card's layout, only that the card holds the layers card-fx.js adds.
 *
 * Chromium 99 (the After Effects panel): no color-mix, no unprefixed mask,
 * no individual transform properties - hence rgba() everywhere, -webkit-mask,
 * and one `transform` on the card.
 *
 * Stacking: the card is its own stacking context (isolation), so the
 * pattern at z-index -1 paints over the card's fill and under its content;
 * the foil, shimmer and glare are positioned and paint over the content.
 */

.has-fx {
  isolation: isolate;
  /* Before the first pointer: at rest. */
  --fx-px: .5; --fx-py: .5; --fx-rx: 0deg; --fx-ry: 0deg; --fx-hover: 0;
  /* THE GRADIENT OFFSET (his ask, 2026-09-30): a share of one repeat of the
     bands, -.5 to .5, from the card's Gradient Offset slider (card-fx.js).
     Added to every foil's band position below; the metals through the
     metal shift. */
  --fx-offset: 0;
  /* THE METAL SHIFT (his ask, 2026-09-29): every stop of the metallic foils
     moved along by this, so the colors that sat in the top-left corner at
     rest (about 31% along) sit at the center, and the pale band goes out of
     view until the pointer nears an edge. 0% is the first look; he chose 35%.
     HIS VALUE TO TUNE. */
  --fx-metal-shift: calc(35% + var(--fx-offset) * 100%);
  /* THE METAL BLEND (2026-09-29, his pick: Color Dodge, the Rainbow's): how
     the metals and the Crystal meet the card. It treats the art box's lighter
     grey unlike the card's fill, so the bands seem to jump at the art box -
     and with no art fill there is nothing to differ, so the art box's shape
     disappears (his point against drawing a copy). Overlay was the first;
     the foils' opacities were brought down to about the Rainbow's for it. */
  --fx-metal-blend: color-dodge;
}

/* ------------------------------------------------------------ the tilt */

.has-fx[data-fx-tilt="true"] {
  transform: perspective(700px) rotateX(var(--fx-rx)) rotateY(var(--fx-ry)) scale(calc(1 + .035 * var(--fx-hover)));
  /* The lift, and the hover glow (Breece, 2026-09-28) growing with it. */
  box-shadow: 0 calc(10px * var(--fx-hover)) calc(26px * var(--fx-hover)) rgba(0, 0, 0, calc(.38 * var(--fx-hover))),
    0 0 calc(14px * var(--fx-hover)) calc(1px * var(--fx-hover)) var(--card-glow, rgba(255, 255, 255, .24));
  will-change: transform;
}

/* ------------------------------------------------------------ the layers */

.card-fx-pattern, .card-fx-foil, .card-fx-shimmer, .card-fx-glare {
  position: absolute; inset: 0;
  border-radius: inherit;
  /* Clip what a layer holds to the card's rounded corners, not only its
     background - the Crystal's SVG showed square corners (2026-09-29). */
  overflow: hidden;
  pointer-events: none;
}
.card-fx-pattern { z-index: -1; }
/* The art box's own pattern layer (2026-09-28), under its icons; and
   the card's choice of where the pattern goes - the card (its own
   layer), the art box, or both. */
.card-fx-pattern.is-art { z-index: 0; }
/* PATTERN ON (Breece, 2026-09-28): CARD - the card's, with the art box
   masking it out (an opaque base under the art's grey); ART BOX - the art's
   own layer only; BOTH - the card's, showing through the art's grey. */
.card-fx-pattern.is-art { display: none; }
.has-fx[data-pattern-on="art"] .card-fx-pattern.is-art { display: block; }
.has-fx[data-pattern-on="art"] > .card-fx-pattern { display: none; }
.has-fx:not([data-pattern-on]) .card-fx-art, .has-fx[data-pattern-on="card"] .card-fx-art {
  background-image: linear-gradient(var(--card-art, transparent), var(--card-art, transparent));
  background-color: var(--card-bg, #1d212b);
}
.card-fx-foil, .card-fx-shimmer, .card-fx-glare { opacity: 0; }

/* ------------------------------------------------------------ the glare
   A light that follows the pointer, brightening where it is and darkening
   the far side a touch - what sells the tilt as a surface. */

.has-fx[data-fx-glare="true"] .card-fx-glare {
  background: radial-gradient(farthest-corner circle at calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%),
    rgba(255, 255, 255, .5) 0%, rgba(255, 255, 255, .14) 32%, rgba(0, 0, 0, .22) 95%);
  mix-blend-mode: overlay;
  opacity: calc(.85 * var(--fx-hover));
}

/* ------------------------------------------------------------ the foils */

/* RAINBOW: a holographic sheen - bands of color sliding with the pointer
   through fine diagonal lines, dodged into the card. */
.has-fx[data-fx-foil="rainbow"] .card-fx-foil {
  background:
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, .28) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(115deg, #ff6b7a 0%, #ffc56e 5%, #f4ff7a 10%, #72ffb6 15%, #66ccff 20%, #a98bff 25%, #ff6bd0 30%, #ff6b7a 35%);
  background-size: 100% 100%, 320% 320%;
  background-position: 0 0, calc((var(--fx-px) + var(--fx-offset)) * 100%) calc(var(--fx-py) * 100%);
  mix-blend-mode: color-dodge;
  filter: saturate(1.15) contrast(1.05);
  opacity: calc(.28 + .42 * var(--fx-hover));
}

/* SILVER: brushed metal - fine grey bands, overlaid. */
.has-fx[data-fx-foil="silver"] .card-fx-foil {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 3px),
    linear-gradient(120deg, #8a919c calc(var(--fx-metal-shift) + -60%), #f6f8fa calc(var(--fx-metal-shift) + -42%), #d7dce3 calc(var(--fx-metal-shift) + -22%), #6d7480 calc(var(--fx-metal-shift) + 0%), #e9edf2 calc(var(--fx-metal-shift) + 22%), #8a919c calc(var(--fx-metal-shift) + 40%), #f6f8fa calc(var(--fx-metal-shift) + 58%), #737a86 calc(var(--fx-metal-shift) + 78%), #d7dce3 calc(var(--fx-metal-shift) + 100%));
  background-size: 100% 100%, 260% 260%;
  background-position: 0 0, calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%);
  mix-blend-mode: var(--fx-metal-blend);
  opacity: calc(.3 + .32 * var(--fx-hover));
}

/* GOLD: warm leaf - the same idea in gold, soft-lit. */
.has-fx[data-fx-foil="gold"] .card-fx-foil {
  /* A touch richer (his note, 2026-09-28: "just a bit more saturated"), and
     a few degrees toward orange (2026-09-29; -6 of hue). */
  /* 2026-09-29, under Color Dodge: yellower (his "more gold"), and the darks
     lifted to saturated amber - dodge passes dark colors by, which left the
     top-left corner (where the dark stop sits at rest) without color. */
  background: linear-gradient(120deg, #cc8100 calc(var(--fx-metal-shift) + -62%), #ffea8f calc(var(--fx-metal-shift) + -45%), #f6b828 calc(var(--fx-metal-shift) + -25%), #a86d00 calc(var(--fx-metal-shift) + 0%), #ffcf3d calc(var(--fx-metal-shift) + 20%), #cc8100 calc(var(--fx-metal-shift) + 38%), #ffea8f calc(var(--fx-metal-shift) + 55%), #bd7800 calc(var(--fx-metal-shift) + 75%), #f6b828 calc(var(--fx-metal-shift) + 100%));
  background-size: 260% 260%;
  background-position: calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%);
  mix-blend-mode: var(--fx-metal-blend);
  opacity: calc(.34 + .34 * var(--fx-hover));
}

/* BRONZE (his ask, 2026-09-29): the Gold's leaf in a browner alloy - made a
   richer brown the same day (more saturated, a touch darker). */
.has-fx[data-fx-foil="bronze"] .card-fx-foil {
  /* 2026-09-29, under Color Dodge: the darks lifted so the top-left corner
     keeps its color (dodge passes dark colors by). */
  background: linear-gradient(120deg, #a15621 calc(var(--fx-metal-shift) + -62%), #f5c188 calc(var(--fx-metal-shift) + -45%), #ce7b30 calc(var(--fx-metal-shift) + -25%), #854114 calc(var(--fx-metal-shift) + 0%), #e18c3f calc(var(--fx-metal-shift) + 20%), #a15621 calc(var(--fx-metal-shift) + 38%), #f5c188 calc(var(--fx-metal-shift) + 55%), #934b1b calc(var(--fx-metal-shift) + 75%), #ce7b30 calc(var(--fx-metal-shift) + 100%));
  background-size: 260% 260%;
  background-position: calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%);
  mix-blend-mode: var(--fx-metal-blend);
  opacity: calc(.34 + .34 * var(--fx-hover));
}

/* CUSTOM METAL (his ask, 2026-09-28): Silver's brushed metal in any color -
   the four tones worked out from his pick by card-fx.js metalTones. */
.has-fx[data-fx-foil="metal"] .card-fx-foil {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 3px),
    linear-gradient(120deg, var(--fx-metal-mid) calc(var(--fx-metal-shift) + -60%), var(--fx-metal-hi) calc(var(--fx-metal-shift) + -42%), var(--fx-metal-light) calc(var(--fx-metal-shift) + -22%), var(--fx-metal-dark) calc(var(--fx-metal-shift) + 0%), var(--fx-metal-light) calc(var(--fx-metal-shift) + 22%), var(--fx-metal-mid) calc(var(--fx-metal-shift) + 40%), var(--fx-metal-hi) calc(var(--fx-metal-shift) + 58%), var(--fx-metal-dark) calc(var(--fx-metal-shift) + 78%), var(--fx-metal-light) calc(var(--fx-metal-shift) + 100%));
  background-size: 100% 100%, 260% 260%;
  background-position: 0 0, calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%);
  mix-blend-mode: var(--fx-metal-blend);
  opacity: calc(.34 + .34 * var(--fx-hover));
}

/* CRYSTAL (his ask, 2026-09-28): a metal broken into Voronoi facets, each
   shifting its bands at its own rate and catching the light at its own
   angle (card-fx.js crystalSvg). In the Effect Color's tones, with fewer,
   longer bands than the metals, overlaid like them (2026-09-29: the
   rainbow was "way too much"). */
.has-fx[data-fx-foil="crystal"] .card-fx-foil {
  mix-blend-mode: var(--fx-metal-blend);
  opacity: calc(.3 + .36 * var(--fx-hover));
}
.card-fx-crystal { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ------------------------------------------------------------ the space foils
   (Breece, 2026-09-29: "Could you design some space-themed foils? I'm
   thinking 'Galaxy', 'Nebula', 'Black Hole'...stuff like that.")
   HIS VALUES TO TUNE, all of them. */

/* GALAXY: a spiral seen at an angle, turning a little with the pointer, over
   drifting stars (card-fx.js galaxySvg) - screened on, so it only adds light. */
.has-fx[data-fx-foil="galaxy"] .card-fx-foil {
  mix-blend-mode: screen;
  opacity: calc(.7 + .3 * var(--fx-hover));
}
.card-fx-galaxy { position: absolute; inset: 0; width: 100%; height: 100%; }

/* NEBULA: clouds of magenta, blue, violet and ember, each drifting with the
   pointer at its own rate and direction, over two fields of stars moving at
   two depths. Color-dodged, like the Rainbow: the clouds glow brightest over
   the art box's lighter grey. */
.has-fx[data-fx-foil="nebula"] .card-fx-foil {
  background:
    radial-gradient(circle at 30% 20%, #fff 0 .7px, transparent 1.2px) calc(var(--fx-px) * -5px) calc(var(--fx-py) * -5px) / 29px 31px,
    radial-gradient(circle at 70% 60%, #d8e8ff 0 .6px, transparent 1.1px) calc(var(--fx-px) * -11px) calc(var(--fx-py) * -11px) / 43px 37px,
    radial-gradient(ellipse 62% 42% at calc(22% + var(--fx-px) * 12%) calc(26% + var(--fx-py) * 8%), rgba(255, 70, 180, .95), transparent 72%),
    radial-gradient(ellipse 58% 48% at calc(80% - var(--fx-px) * 10%) calc(62% - var(--fx-py) * 12%), rgba(50, 160, 255, .9), transparent 72%),
    radial-gradient(ellipse 44% 34% at calc(62% + var(--fx-px) * 7%) calc(18% + var(--fx-py) * 5%), rgba(150, 90, 255, .85), transparent 72%),
    radial-gradient(ellipse 46% 30% at calc(28% - var(--fx-px) * 6%) calc(84% - var(--fx-py) * 7%), rgba(255, 150, 70, .7), transparent 72%);
  mix-blend-mode: color-dodge;
  opacity: calc(.4 + .35 * var(--fx-hover));
}

/* BLACK HOLE: a neutral grey layer hard-lit onto the card - the grey leaves
   the card as it was, the event horizon's black darkens it, the light of the
   photon ring and the accretion disk brightens it (card-fx.js blackHoleEl).
   Centered on the art box, under the icons; the whole of it drifts a little
   against the pointer, and the rings' bright side follows it. */
.has-fx[data-fx-foil="blackhole"] .card-fx-foil {
  background: #808080;
  mix-blend-mode: hard-light;
  opacity: calc(.85 + .15 * var(--fx-hover));
}
.card-fx-bh {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 20%, #fff 0 .6px, transparent 1.1px) calc(var(--fx-px) * -4px) calc(var(--fx-py) * -4px) / 31px 29px,
    radial-gradient(circle at 70% 60%, #ffe8cc 0 .5px, transparent 1px) calc(var(--fx-px) * -8px) calc(var(--fx-py) * -8px) / 41px 47px;
  transform: translate(calc((var(--fx-px) - .5) * -6px), calc((var(--fx-py) - .5) * -6px));
}
.card-fx-bh > div { position: absolute; left: 50%; top: 42%; }
.card-fx-bh-core {
  width: 30%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle closest-side, #000 0 78%, rgba(0, 0, 0, .75) 88%, transparent 100%);
}
.card-fx-bh-lens {
  width: 44%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(from calc(160deg + var(--fx-px) * 200deg + var(--fx-offset) * 360deg), #fff6e0, #ffb347 18%, #b8440e 40%, #401206 52%, #b8440e 64%, #ffb347 84%, #fff6e0);
  -webkit-mask-image: radial-gradient(circle closest-side, transparent 0 66%, #000 70% 78%, rgba(0, 0, 0, .4) 86%, transparent 100%);
}
.card-fx-bh-disk-back, .card-fx-bh-disk-front {
  width: 104%; height: 15%;
  transform: translate(-50%, -50%) rotate(calc(-8deg + (var(--fx-px) - .5) * 10deg));
  background: linear-gradient(90deg, #fff4d6, #ffae4a 30%, #d0520f 62%, #5a1a05) calc(var(--fx-px) * 100%) 0 / 200% 100%;
  -webkit-mask-image: radial-gradient(closest-side, transparent 0 30%, #000 42%, rgba(0, 0, 0, .8) 62%, transparent 100%);
}
.card-fx-bh-disk-back { clip-path: inset(0 0 50% 0); }
.card-fx-bh-disk-front { clip-path: inset(50% 0 0 0); }
.card-fx-facet { fill: #fff; stroke: rgba(255, 255, 255, .55); stroke-width: .6; vector-effect: non-scaling-stroke; }

/* GLITTER: points of light, brightest near the pointer (a mask follows it),
   drifting against the card as it tilts; tinted by the card's accent
   (2026-09-29; card-fx.js glitterTones), the old pastels with no accent. */
.has-fx[data-fx-foil="glitter"] .card-fx-foil {
  background:
    radial-gradient(circle at 20% 30%, var(--fx-glint-1, #fff) 0 .8px, transparent 1.4px),
    radial-gradient(circle at 70% 60%, var(--fx-glint-2, #fffbe0) 0 .7px, transparent 1.3px),
    radial-gradient(circle at 45% 85%, var(--fx-glint-3, #e6f3ff) 0 .9px, transparent 1.5px),
    radial-gradient(circle at 85% 15%, var(--fx-glint-4, #ffe6fb) 0 .6px, transparent 1.2px);
  background-size: 23px 19px, 31px 27px, 17px 29px, 37px 23px;
  background-position:
    calc(var(--fx-px) * -6px) calc(var(--fx-py) * -6px),
    calc(var(--fx-px) * 9px) calc(var(--fx-py) * 5px),
    calc(var(--fx-px) * -4px) calc(var(--fx-py) * 8px),
    calc(var(--fx-px) * 7px) calc(var(--fx-py) * -9px);
  mix-blend-mode: color-dodge;
  -webkit-mask-image: radial-gradient(circle at calc(var(--fx-px) * 100%) calc(var(--fx-py) * 100%), #000 0%, rgba(0, 0, 0, .25) 70%);
  opacity: calc(.55 + .45 * var(--fx-hover));
}

/* ------------------------------------------------------------ the shimmer
   A band of light that sweeps across now and then, on its own. */

.has-fx[data-fx-shimmer="true"] .card-fx-shimmer {
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .32) 50%, transparent 62%);
  background-size: 260% 100%;
  mix-blend-mode: overlay;
  opacity: 1;
  animation: card-fx-sweep 3.6s ease-in-out infinite;
}
@keyframes card-fx-sweep {
  0% { background-position: 130% 0; }
  45%, 100% { background-position: -30% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .has-fx .card-fx-shimmer { animation: none; opacity: 0; }
  .has-fx[data-fx-tilt="true"] { transform: none; }
}

/* ------------------------------------------------------------ the patterns
   Beyond the card's own four (dots, grid, diagonal, plain - preview.css),
   drawn on the pattern layer in the card's ink. The SVG ones are masks, so
   one drawing takes any accent. */

/* The tool's own four (preview.css), drawn on the layers too. */
.has-fx[data-bg="dots"] .card-fx-pattern { background: radial-gradient(var(--card-ink) 1.2px, transparent 1.4px) 0 0 / 10px 10px; }
.has-fx[data-bg="grid"] .card-fx-pattern { background: linear-gradient(var(--card-ink) 1px, transparent 1px) 0 0 / 12px 12px, linear-gradient(90deg, var(--card-ink) 1px, transparent 1px) 0 0 / 12px 12px; }
.has-fx[data-bg="diagonal"] .card-fx-pattern { background: repeating-linear-gradient(45deg, var(--card-ink) 0 1px, transparent 1px 8px); }
.has-fx[data-bg="checker"] .card-fx-pattern {
  background: repeating-conic-gradient(var(--card-ink) 0 25%, transparent 0 50%) 0 0 / 14px 14px;
}
.has-fx[data-bg="stripes"] .card-fx-pattern {
  background: repeating-linear-gradient(90deg, var(--card-ink) 0 3px, transparent 3px 10px);
}
.has-fx[data-bg="halftone"] .card-fx-pattern {
  background:
    radial-gradient(var(--card-ink) 2.2px, transparent 2.6px) 0 0 / 9px 9px,
    radial-gradient(var(--card-ink) 1.2px, transparent 1.6px) 4.5px 4.5px / 9px 9px;
  -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 85%);
}
.has-fx[data-bg="waves"] .card-fx-pattern,
.has-fx[data-bg="hex"] .card-fx-pattern,
.has-fx[data-bg="sparkle"] .card-fx-pattern,
.has-fx[data-bg="chevron"] .card-fx-pattern {
  background: var(--card-ink);
  -webkit-mask-repeat: repeat;
}
.has-fx[data-bg="waves"] .card-fx-pattern {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M0 6 Q10 0 20 6 T40 6' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E");
  -webkit-mask-size: 40px 12px;
}
.has-fx[data-bg="hex"] .card-fx-pattern {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17.32' height='30'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.1'%3E%3Cpath d='M8.66 0L17.32 5V15L8.66 20L0 15V5Z'/%3E%3Cpath d='M8.66 20V30'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-size: 17.32px 30px;
}
.has-fx[data-bg="sparkle"] .card-fx-pattern {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36'%3E%3Cpath d='M8 2L9.2 6.8L14 8L9.2 9.2L8 14L6.8 9.2L2 8L6.8 6.8ZM26 19L26.9 23.1L31 24L26.9 24.9L26 29L25.1 24.9L21 24L25.1 23.1Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 36px 36px;
}
.has-fx[data-bg="chevron"] .card-fx-pattern {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12'%3E%3Cpath d='M0 10L10 2L20 10' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E");
  -webkit-mask-size: 20px 12px;
}
