/* 3D gift card, spins like a video game item pickup.
   Markup is built by /assets/js/gift-card-3d.js from a single
   <div class="gc3d" data-code="..."></div>. Card art is 85 x 55mm, the
   finished size of the printed card.
   Intellectual property of Sidedoor Digital. */

.gc3d {
  --gc-w: min(440px, 84vw);
  --gc-radius: 3.8%;
  --gc-gold: #eba721;
  position: relative;
  width: var(--gc-w);
  margin: 0 auto;
  padding: 28px 0 64px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  cursor: grab;
}
.gc3d.is-dragging { cursor: grabbing; }

.gc3d-scene {
  perspective: 1400px;
  perspective-origin: 50% 40%;
}

/* Hover bob. Driven from JS so the floor shadow can move with it. */
.gc3d-float {
  transform: translate3d(0, var(--gc-bob, 0px), 0);
  transform-style: preserve-3d;
}

.gc3d-card {
  position: relative;
  width: 100%;
  aspect-ratio: 85 / 55;
  transform-style: preserve-3d;
  transform: rotateX(var(--gc-tilt, 0deg)) rotateY(var(--gc-spin, 0deg));
  container-type: inline-size;
}

.gc3d-face,
.gc3d-edge {
  position: absolute;
  inset: 0;
  border-radius: var(--gc-radius) / calc(var(--gc-radius) * 85 / 55);
}

.gc3d-face {
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #000;
}
.gc3d-front { transform: translateZ(3px); }
.gc3d-back  { transform: rotateY(180deg) translateZ(3px); }

.gc3d-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Light sweeping across the card as it turns, plus a little shade when
   it's side on. Both positions come from JS as the card rotates. */
.gc3d-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg,
      transparent 30%,
      rgba(255, 236, 190, 0.22) 45%,
      rgba(255, 255, 255, 0.4) 50%,
      rgba(255, 236, 190, 0.22) 55%,
      transparent 70%) var(--gc-shine, 50%) 0 / 300% 100% no-repeat;
  mix-blend-mode: screen;
  opacity: var(--gc-gloss, 0);
  z-index: 3;
}
.gc3d-face::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(0, 0, 0, var(--gc-shade, 0));
}

/* Card thickness: stacked layers between the two faces, only seen when
   the card is side on. */
.gc3d-edge {
  background: #3a2c0c;
  box-shadow: inset 0 0 0 1px var(--gc-gold);
}

/* The code printed into the grey box on the back. Position matches the
   box in card-back.webp. */
.gc3d-code {
  position: absolute;
  z-index: 2;
  left: 4.1%;
  width: 91.9%;
  top: 60.7%;
  height: 19.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Saira Condensed", "Arial Narrow", Arial, sans-serif;
  font-weight: 700;
  font-size: 9cqw;
  letter-spacing: 0.08em;
  color: #111;
  white-space: nowrap;
}
.gc3d-code.is-placeholder { color: rgba(17, 17, 17, 0.28); font-size: 6.5cqw; }

/* Floor under the card: a soft shadow and a gold pickup glow. Both shrink
   as the card floats up. */
.gc3d-floor {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 78%;
  height: 34px;
  transform: translateX(-50%) scale(var(--gc-floor, 1));
  pointer-events: none;
}
.gc3d-floor::before,
.gc3d-floor::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.gc3d-floor::before {
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), transparent);
}
.gc3d-floor::after {
  inset: -30% -8%;
  background: radial-gradient(closest-side, rgba(240, 169, 30, 0.35), rgba(240, 169, 30, 0.08) 60%, transparent);
  opacity: var(--gc-glow, 0.8);
}

.gc3d-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}
.gc3d-btn {
  font-family: "Saira Condensed", "Arial Narrow", Arial, sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--bone, #efe6d8);
  background: rgba(30, 28, 25, 0.7);
  border: 1px solid #4a4238;
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
}
.gc3d-btn:hover { border-color: var(--gc-gold); }
.gc3d-btn:focus-visible { outline: 2px solid var(--gc-gold); outline-offset: 2px; }
.gc3d-btn[aria-pressed="true"] { border-color: var(--gc-gold); color: var(--gc-gold); }

@media (prefers-reduced-motion: reduce) {
  .gc3d { cursor: default; }
}
