/* ==========================================================================
   Beanbucks holo card — pairs with /js/holo-card.js (API docs live there).

   Layers inside .holo-card__tilt (the element that rotates in 3D):
     .holo-card__art    the card PNG/WebP (plate left empty in the art)
     .holo-card__shine  per-design foil, masked by <slug>-foil.webp so it never
                        touches the plate; colour-dodge/colour blended
     .holo-card__plate  the amount + "For <name>" line, drawn live
     .holo-card__glare  a soft light that follows the pointer/tilt

   Everything that moves is driven by custom properties the script writes on
   .holo-card every frame:
     --rx --ry   rotation (deg)           --gx --gy   glare centre (0..1)
     --posx/-y   foil background position --sweep     golden-hour ray sweep (deg)
     --o         effect strength (0..1)   --s         lift scale
   Only transform, opacity and background-position change per frame.

   Plate geometry mirrors constants/beanbucks.js ART.plate (fractions of the
   card); BeanbucksHolo.configure({ plate }) overrides the defaults below.
   ========================================================================== */

.holo-card {
  --rx: 0deg; --ry: 0deg; --s: 1;
  --gx: 0.35; --gy: 0.25;
  --posx: 50%; --posy: 50%;
  --sweep: 0deg;
  --o: 0.22;
  --holo-w: 300px;
  --holo-ink: #1C1C1C;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 7;
  perspective: calc(var(--holo-w) * 3.4);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
@supports not (aspect-ratio: 1 / 1) {
  .holo-card { height: 0; padding-bottom: 140%; }
}

.holo-card__tilt {
  position: absolute;
  inset: 0;
  /* circular corners on a 5:7 box: 4.5% of the width = 3.214% of the height */
  border-radius: 4.5% / 3.2143%;
  overflow: hidden;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--s));
  transform-origin: 50% 50%;
  will-change: transform;
  box-shadow:
    0 0 0 1px rgba(28, 20, 14, 0.06),
    0 2px 6px rgba(28, 20, 14, 0.16),
    0 calc(var(--holo-w) * 0.05) calc(var(--holo-w) * 0.1) calc(var(--holo-w) * -0.03) rgba(28, 20, 14, 0.4);
  pointer-events: none;
  /* own stacking context: the blend layers blend with the art, not the page */
  isolation: isolate;
  background: var(--holo-bg, #d9cbb0);   /* shows only while the art loads */
}

.holo-card__art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

/* ---- plate text ---------------------------------------------------------- */

.holo-card__plate {
  --holo-ph: calc(var(--holo-w) * 1.4 * var(--holo-plate-h, 0.19));
  position: absolute;
  left: calc(var(--holo-plate-x, 0.08) * 100%);
  top: calc(var(--holo-plate-y, 0.735) * 100%);
  width: calc(var(--holo-plate-w, 0.84) * 100%);
  height: calc(var(--holo-plate-h, 0.19) * 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--holo-ph) * 0.09);
  color: var(--holo-ink);
  text-align: center;
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1;
}
/* Two-class selectors + explicit font on the spans so page rules such as
   "button span { font: ... }" can't restyle the plate. */
.holo-card .holo-card__amount,
.holo-card .holo-card__to {
  margin: 0;
  padding: 0;
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  color: inherit;
}
.holo-card .holo-card__amount {
  display: inline-block;
  font-size: calc(var(--holo-ph) * 0.52 * var(--holo-fit, 1));
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
  text-box: trim-both cap alphabetic;
}
.holo-card.holo-card--has-to .holo-card__amount { font-size: calc(var(--holo-ph) * 0.44 * var(--holo-fit, 1)); }
.holo-card .holo-card__to {
  display: block;
  max-width: 92%;
  font-size: calc(var(--holo-ph) * 0.12 * var(--holo-fit-to, 1));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-box: trim-both cap alphabetic;
}
.holo-card .holo-card__amount:empty,
.holo-card .holo-card__to:empty { display: none; }

/* ---- shine (foil) -------------------------------------------------------- */

.holo-card__shine {
  position: absolute;
  inset: 0;
  opacity: calc(var(--o) * var(--holo-shine, 0.8));
  mix-blend-mode: color-dodge;
  -webkit-mask-image: var(--holo-foil, none);
  mask-image: var(--holo-foil, none);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  background-image: repeating-linear-gradient(115deg,
    #ff5f6d 0%, #ffc371 5%, #f9f871 10%, #7cf5a6 15%, #5ad1ff 20%, #a98bff 25%, #ff7ad9 30%, #ff5f6d 35%);
  background-size: 300% 300%;
  background-position: var(--posx) var(--posy);
}
.holo-card__shine::before,
.holo-card__shine::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

/* Golden Hour: warm gold glitter that twinkles as the light band passes, and
   a sunburst that sweeps around the bean-sun (the art's sun sits at 50% / 46.86%). */
.holo-card[data-variant="golden-hour"] .holo-card__shine {
  --holo-shine: 0.62;
  background-image:
    var(--holo-glitter, none),
    linear-gradient(115deg, rgba(0, 0, 0, 0) 32%, rgba(255, 226, 150, 0.7) 46%, rgba(255, 244, 210, 0.9) 50%, rgba(255, 206, 110, 0.6) 54%, rgba(0, 0, 0, 0) 68%);
  background-size: calc(var(--holo-w) * 0.5) calc(var(--holo-w) * 0.5), 260% 260%;
  background-position: calc(var(--posx) * -0.6) calc(var(--posy) * -0.6), var(--posx) var(--posy);
  background-blend-mode: multiply, normal;
}
.holo-card[data-variant="golden-hour"] .holo-card__shine::before {
  left: -50%; top: -53.14%; width: 200%; height: 200%;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(255, 232, 160, 0) 0deg, rgba(255, 232, 160, 0.75) 2.4deg, rgba(255, 246, 214, 0.9) 3.2deg,
    rgba(255, 232, 160, 0) 5.6deg, rgba(255, 232, 160, 0) 10deg);
  transform: rotate(var(--sweep));
  opacity: 0.4;
}

/* Jingle Beans: lurex yarn. The mask is the cream and gold stitches; a warm
   light band carries glitter across them as the card tilts. */
.holo-card[data-variant="jingle-beans"] .holo-card__shine {
  --holo-shine: 0.75;
  background-image:
    var(--holo-glitter, none),
    linear-gradient(115deg, rgba(0, 0, 0, 0) 30%, rgba(255, 214, 120, 0.65) 45%, rgba(255, 246, 214, 0.9) 50%, rgba(170, 240, 196, 0.55) 55%, rgba(0, 0, 0, 0) 70%);
  background-size: calc(var(--holo-w) * 0.5) calc(var(--holo-w) * 0.5), 260% 260%;
  background-position: calc(var(--posx) * -0.6) calc(var(--posy) * -0.6), var(--posx) var(--posy);
  background-blend-mode: multiply, normal;
}

/* Contour: oil-slick rainbow that lives on the contour lines (the mask is
   the lines); colour blend keeps the cream paper calm and tints the ink. */
.holo-card[data-variant="contour"] .holo-card__shine {
  --holo-shine: 1;
  mix-blend-mode: color;
  background-image: repeating-linear-gradient(125deg,
    #ff4d6d 0%, #ffb627 4%, #c9f31d 8%, #2ee6a8 12%, #2bb8ff 16%, #8a5cff 20%, #ff4dd2 24%, #ff4d6d 28%);
  background-size: 360% 360%;
}
.holo-card[data-variant="contour"] .holo-card__shine::after {
  inset: 0;
  mix-blend-mode: screen;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 62%);
  background-size: 260% 260%;
  background-position: var(--posx) var(--posy);
}

/* First Crack: prismatic facets. The foil image doubles as a grey facet map:
   "difference" against a moving rainbow gives every shard its own phase. */
.holo-card[data-variant="first-crack"] .holo-card__shine {
  --holo-shine: 0.85;
  mix-blend-mode: color;
  background-image:
    var(--holo-foil, none),
    repeating-linear-gradient(135deg,
      #ff3d77 0%, #ffd23f 6%, #3dffb5 12%, #3dc6ff 18%, #b13dff 24%, #ff3d77 30%);
  background-size: 100% 100%, 300% 300%;
  background-position: 0 0, var(--posx) var(--posy);
  background-blend-mode: difference, normal;
}

/* ---- glare --------------------------------------------------------------- */

.holo-card__glare {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  mix-blend-mode: soft-light;
  opacity: calc(0.25 + var(--o) * 0.75);
}
.holo-card__glare::before {
  content: '';
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.5) 11%, rgba(255, 255, 255, 0) 30%,
    rgba(0, 0, 0, 0.22) 58%, rgba(0, 0, 0, 0.32) 100%);
  transform: translate3d(calc((var(--gx) - 0.5) * 50%), calc((var(--gy) - 0.5) * 50%), 0);
  will-change: transform;
}

/* Lightbox: the card follows a thumb, so it must not scroll the page. */
.holo-card--drag { touch-action: none; cursor: grab; }
.holo-card--drag.is-dragging { cursor: grabbing; }

/* ---- reduced motion: a still, tasteful sheen ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .holo-card {
    --rx: 0deg !important; --ry: 0deg !important; --s: 1 !important;
    --gx: 0.3 !important; --gy: 0.2 !important;
    --posx: 38% !important; --posy: 30% !important;
    --sweep: 0deg !important;
    --o: 0.38 !important;
  }
}

/* ==========================================================================
   Lightbox (native <dialog>)
   ========================================================================== */

html.holo-lock { overflow: hidden; }

.holo-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #FFF8E7;
  overflow: hidden auto;
  overscroll-behavior: contain;
}
.holo-lightbox::backdrop {
  background: rgba(16, 11, 8, 0.74);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
}
.holo-lightbox[open]::backdrop { animation: holo-fade 0.28s ease-out both; }
.holo-lightbox.is-closing::backdrop { animation: holo-fade-out 0.2s ease-in both; }

.holo-lightbox__inner {
  box-sizing: border-box;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 64px 16px 28px;
  font-family: 'Inter', system-ui, sans-serif;
}
.holo-lightbox__title {
  margin: 0;
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.25rem, 2.6vw + 0.6rem, 1.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-align: center;
}
.holo-lightbox__stage {
  width: min(80vw, 360px, calc((100vh - 270px) * 0.714));
  min-width: 200px;
  margin: 6px 0 4px;
}
@supports (height: 100dvh) {
  .holo-lightbox__stage { width: min(80vw, 360px, calc((100dvh - 270px) * 0.714)); }
}
.holo-lightbox[open] .holo-lightbox__stage { animation: holo-card-in 0.62s cubic-bezier(0.2, 0.9, 0.25, 1.12) both; }
.holo-lightbox.is-closing .holo-lightbox__stage { animation: holo-card-out 0.2s ease-in both; }

.holo-lightbox__hint {
  margin: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(255, 248, 231, 0.62);
}
.holo-lightbox__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.holo-lightbox__action,
.holo-lightbox__tilt {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 10px;
  transition: transform 0.12s ease, background-color 0.2s ease, box-shadow 0.12s ease;
}
.holo-lightbox__action {
  min-height: 48px;
  padding: 14px 26px;
  font-size: 0.9375rem;
  color: #1C1C1C;
  background: #FFD600;
  box-shadow: 5px 5px 0 #FFF8E7;
}
.holo-lightbox__action:hover { background: #ffe34d; transform: translate(-1px, -1px); box-shadow: 6px 6px 0 #FFF8E7; }
.holo-lightbox__action:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #FFF8E7; }
.holo-lightbox__tilt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  font-size: 0.75rem;
  color: #FFF8E7;
  background: rgba(255, 248, 231, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 231, 0.32);
}
.holo-lightbox__tilt:hover { background: rgba(255, 248, 231, 0.18); }
.holo-lightbox__tilt svg { width: 16px; height: 16px; flex: none; }

.holo-lightbox__close {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #FFF8E7;
  background: rgba(255, 248, 231, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 231, 0.28);
  transition: background-color 0.2s ease;
}
.holo-lightbox__close:hover { background: rgba(255, 248, 231, 0.22); }
.holo-lightbox__close svg { width: 18px; height: 18px; }

.holo-lightbox :focus-visible {
  outline: 3px solid #FFD600;
  outline-offset: 3px;
}

@keyframes holo-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes holo-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes holo-card-in {
  from { opacity: 0; transform: translateY(28px) scale(0.86) rotate(-4deg); }
  to { opacity: 1; transform: none; }
}
@keyframes holo-card-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(12px) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .holo-lightbox[open] .holo-lightbox__stage { animation: holo-fade 0.2s ease-out both; }
  .holo-lightbox.is-closing .holo-lightbox__stage { animation: holo-fade-out 0.15s ease-in both; }
  .holo-lightbox__action,
  .holo-lightbox__tilt { transition: none; }
}
