/* Unwrap or Steal: the art's styles. Pairs with art.js; DESIGN.md is the contract.
   Palette, the display face, sticker / halftone / misregistration helpers, the iced look, the effect
   and float layers, the unwrap stage, the wrap ceremony, string lights, and the TV themes.
   Only transform and opacity animate; every loop stops under prefers-reduced-motion (end of file).
   Never put a CSS transform-origin or transform-box on .g-bow or .g-lid inside .gift-svg: those
   groups carry SVG transform attributes that CSS would bend. */

/* Fredoka (OFL 1.1, the Fredoka Project Authors), Latin subset, weight and width axes. */
@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka.woff2) format("woff2"); font-weight: 300 700; font-stretch: 75% 125%; font-display: swap; }

:root {
  --tomato: #ef4a37; --mint: #6fcfae; --butter: #ffd75e; --sky: #7cb7ff; --ink: #1d1b22; --paper: #fbf6ec;
  --tomato-d: #c23523; --tomato-l: #f8a093; --mint-d: #3f9c7f; --mint-l: #c3ecdd; --butter-d: #e0a92a; --butter-l: #fff0b3;
  --sky-d: #3f7fd6; --sky-l: #cfe4ff; --ink-l: #3b3742; --paper-d: #ece2cf; --gold: #f5c445; --gold-d: #c98d14; --ice: #e2efff;
  --display: "Fredoka", "Figtree", ui-rounded, system-ui, sans-serif;
  --dots: radial-gradient(circle, rgba(29, 27, 34, .22) 1.3px, transparent 1.7px) 0 0 / 6px 6px;
}

/* ---------- Helpers ---------- */
/* A sticker: ink outline, a paper-white border around it, a flat offset print shadow. */
.sticker { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 0 0 5px var(--paper), 5px 6px 0 5px rgba(29, 27, 34, .16); }
/* Halftone dots: put it on a shadow shape, or anywhere that needs a printed grey. */
.halftone { background: var(--dots); }
/* The colour plate nudged off the ink: for display type. Set --mis to change the colour. */
.misreg { text-shadow: .055em .05em 0 var(--mis, var(--tomato)); }

/* ---------- Still pictures ---------- */
.gift-svg, .mascot-svg, .hat-svg, .charm-svg, .react-svg, .brand-svg, .gavel-svg { display: block; width: 100%; height: auto; overflow: visible; }
.icon { display: inline-block; vertical-align: middle; flex: none; }
/* One in three wrapped gifts breathes (art.js picks them), all on one shared keyframe, so a board of 100 stays cheap. */
.gift-svg.breathe { animation: g-breathe 3.8s ease-in-out infinite; animation-delay: var(--d, 0s); transform-origin: 50% 96%; }
@keyframes g-breathe { 0%, 100% { transform: none; } 50% { transform: translateY(-1.8%) scale(1.01, .99); } }
/* Paid papers catch the light every few seconds. */
.g-shine { animation: g-shine 5.2s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes g-shine { 0%, 55% { transform: translateX(0); } 85%, 100% { transform: translateX(340px); } }
.g-tw { animation: g-tw 1.7s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
@keyframes g-tw { from { opacity: .15; } to { opacity: 1; } }
/* Put .gift-tile on a gift's box in a grid: under 64 px the fine ink lines and twinkles drop out. */
.gift-tile { container-type: inline-size; }
@container (max-width: 64px) { .gift-svg .g-fine, .gift-svg .g-tw { display: none; } }

.mascot-svg { animation: m-breathe 3.4s ease-in-out infinite; transform-origin: 50% 96%; }
@keyframes m-breathe { 0%, 100% { transform: none; } 50% { transform: scale(1.012, .988); } }
.hat-svg { transform-origin: 50% 92%; }

/* ---------- The draw: a slip from the hat ---------- */
.slip { position: absolute; left: 50%; top: 6%; z-index: 3; pointer-events: none; transform: translate(-50%, -62%) rotate(-4deg); }
.slip-paper { display: grid; place-items: center; aspect-ratio: 1.3; background: var(--paper); border: .05em solid var(--ink); border-radius: .14em;
  box-shadow: 0 0 0 .06em var(--paper), .07em .09em 0 .06em rgba(29, 27, 34, .2); transform-origin: 50% 50%; }
.slip-num { font: 700 1em/1 var(--display); font-stretch: 108%; color: var(--ink); text-shadow: .05em .045em 0 var(--tomato); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ---------- STOLEN ---------- */
.stamp { position: fixed; z-index: 95; pointer-events: none; font-family: var(--display); font-weight: 700; font-stretch: 115%; line-height: 1; letter-spacing: .05em; white-space: nowrap; }
.stamp > span { display: block; border: .1em solid currentColor; border-radius: .16em; padding: .12em .26em .06em;
  -webkit-mask-image: repeating-linear-gradient(112deg, #000 0 11px, rgba(0, 0, 0, .8) 11px 12px, #000 12px 23px, rgba(0, 0, 0, .9) 23px 24px);
  mask-image: repeating-linear-gradient(112deg, #000 0 11px, rgba(0, 0, 0, .8) 11px 12px, #000 12px 23px, rgba(0, 0, 0, .9) 23px 24px); }
.stamp-ink { position: relative; color: var(--tomato); }
.stamp-ghost { position: absolute; inset: 0; color: var(--sky); transform: translate(.06em, .05em); opacity: .85; }

/* ---------- Frozen ---------- */
/* .iced works on any card; it sets position: relative and uses ::before (icicles) and ::after (the ice). */
.iced { position: relative; }
.iced::after { content: ""; position: absolute; inset: 0; z-index: 4; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(circle at 10% 8%, rgba(251, 246, 236, .85), transparent 30%),
    radial-gradient(circle at 92% 94%, rgba(251, 246, 236, .6), transparent 26%),
    repeating-linear-gradient(122deg, rgba(251, 246, 236, .3) 0 5px, transparent 5px 19px),
    rgba(124, 183, 255, .38);
  box-shadow: inset 0 0 0 3px var(--sky-l), inset 0 0 22px rgba(63, 127, 214, .5); }
.iced::before { content: ""; position: absolute; left: 7%; right: 7%; top: 0; height: 20px; z-index: 5; pointer-events: none; transform-origin: 50% 0;
  background:
    conic-gradient(from -22deg at 50% 100%, var(--ice) 44deg, transparent 0) 0 0 / 13px 13px repeat-x,
    conic-gradient(from -16deg at 50% 100%, var(--sky-l) 32deg, transparent 0) 6px 0 / 21px 20px repeat-x;
  filter: drop-shadow(0 1.5px 0 var(--sky-d)); }
.iced.icing::after { animation: ice-in .95s cubic-bezier(.2, .8, .2, 1) both; }
.iced.icing::before { animation: icicles-in .7s .35s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes ice-in { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes icicles-in { from { transform: scaleY(0); } to { transform: none; } }

/* ---------- Effect and float layers ---------- */
.fx-layer, .float-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 90; }
.float-layer { z-index: 70; }
.fx-box { position: absolute; inset: 0; }
.fx-bit { position: absolute; left: 0; top: 0; }
.fx-bit > svg, .fx-wipe > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.fx-wipe { width: 100%; height: 100%; }
.floater { position: absolute; bottom: calc(110px + env(safe-area-inset-bottom)); left: 50%; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: 600 16px/1.15 var(--display); color: var(--ink); white-space: nowrap; }
.floater .react-svg { width: 56px; height: 56px; }
/* A quick line, as a sticker speech bubble; who sent it, as a little ink label. */
.float-line { background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; padding: 7px 14px 6px; box-shadow: 0 0 0 4px var(--paper), 4px 5px 0 4px rgba(29, 27, 34, .16); font-size: 18px; }
.float-by { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 500; }

/* The marching band */
.march { position: absolute; bottom: 0; height: 100%; animation: march .28s ease-in-out infinite alternate; }
.march svg { display: block; width: 100%; height: 100%; overflow: visible; }
@keyframes march { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-12%) rotate(4deg); } }
.band-note { position: absolute; top: 8%; width: 10px; height: 20px; border-left: 3px solid var(--ink); animation: note-rise .95s ease-out infinite; }
.band-note::after { content: ""; position: absolute; left: -10px; bottom: -4px; width: 11px; height: 8px; border-radius: 50%; background: var(--ink); transform: rotate(-20deg); }
.band-note::before { content: ""; position: absolute; left: 0; top: 0; width: 8px; height: 7px; background: var(--butter); border: 2px solid var(--ink); border-radius: 0 6px 6px 0; }
.band-note.n2 { animation-delay: .45s; }
@keyframes note-rise { from { transform: translateY(0) rotate(-8deg); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-70px) rotate(12deg); opacity: 0; } }

/* ---------- String lights (Party Pass) ---------- */
.lights { position: absolute; left: 0; right: 0; top: 0; height: 46px; pointer-events: none; z-index: 6; }
.lights-wire { position: absolute; left: 0; top: 0; width: 100%; height: 40px; overflow: visible; }
.bulb { position: absolute; top: 17px; width: 16px; height: 25px; margin-left: -8px; }
.bulb::before { content: ""; position: absolute; left: 4px; top: 0; width: 8px; height: 7px; background: var(--ink); border-radius: 2px; z-index: 2; }
.bulb .glass { position: absolute; left: 1px; top: 5px; width: 14px; height: 19px; box-sizing: border-box; background: var(--c); border: 2.5px solid var(--ink);
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%; opacity: .45; }
.bulb .glow { position: absolute; left: -16px; top: -4px; width: 48px; height: 48px; border-radius: 50%; background: radial-gradient(circle, var(--c) 0, transparent 64%); opacity: 0; }
.lights.lit .glass { opacity: 1; }
.lights.lit .glow { opacity: .75; animation: glow 2.4s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
@keyframes glow { from { opacity: .45; } to { opacity: .95; } }

/* ---------- The unwrap stage ---------- */
/* Give the element a width (and a height, or it keeps the gift's 200:220 shape). It scales to any size:
   a phone card or a 900 px tall TV stage. */
.ustage { position: relative; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ustage.auto { height: auto; aspect-ratio: 200 / 220; }
.ustage[data-mode="tear"] { cursor: grab; }
.ustage[data-mode="tear"].pulling { cursor: grabbing; }
.ustage[data-mode="tear"].ribbon-off { cursor: crosshair; }
.ustage[data-mode="watch"] { touch-action: auto; }
.ustage-fit { position: absolute; }
.ustage-fit > svg, .ustage-fit > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.ustage-under { z-index: 1; }
.ustage-paper { z-index: 2; }
.ustage-ribbon { z-index: 3; pointer-events: none; }
.ustage-chunk { position: absolute; z-index: 3; pointer-events: none; }
/* The revealed card rises out of the box and may fill the whole stage, bigger than the gift was. */
.ustage-reveal { position: absolute; inset: 0; padding: 2%; z-index: 5; display: grid; place-items: center; opacity: 0; pointer-events: none; }
.ustage-reveal.shown { opacity: 1; pointer-events: auto; }
.ustage-reveal > * { max-width: 100%; max-height: 100%; }
.ustage-scraps { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: visible; }
.scrap { position: absolute; left: 0; top: 0; }
.ustage .g-lid { transform-box: fill-box; transform-origin: 50% 50%; }
/* An untouched ribbon wiggles now and then: pull me. */
.ustage[data-mode="tear"]:not(.ribbon-off) .g-bow-in { animation: bow-wiggle 2s ease-in-out infinite; }
@keyframes bow-wiggle { 0%, 66%, 100% { transform: none; } 74% { transform: rotate(-10deg) scale(1.07); } 82% { transform: rotate(8deg) scale(1.05); } 90% { transform: rotate(-3deg); } }

/* ---------- The wrap ceremony ---------- */
.wrapc { position: relative; width: 100%; aspect-ratio: 200 / 220; }
.wrapc > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ---------- TV themes ---------- */
/* [data-theme] paints the board: --board-bg (the whole background), --board-ink (text on it),
   --board-card and --board-card-ink (cards on it), --board-accent. */
[data-theme] { background: var(--board-bg); color: var(--board-ink); }
[data-theme="classic"] {
  --board-ink: var(--ink); --board-card: var(--paper); --board-card-ink: var(--ink); --board-accent: var(--tomato);
  --board-bg:
    radial-gradient(9px 3.6px at 50% 50%, var(--tomato) 92%, transparent) 14px 22px / 128px 118px,
    radial-gradient(3.6px 9px at 50% 50%, var(--sky) 92%, transparent) 78px 70px / 154px 136px,
    radial-gradient(circle at 50% 50%, var(--mint) 4.6px, transparent 5.2px) 40px 92px / 112px 124px,
    radial-gradient(8px 3.4px at 50% 50%, var(--butter-d) 92%, transparent) 96px 12px / 170px 146px,
    radial-gradient(circle at 50% 50%, var(--tomato) 3.4px, transparent 4px) 120px 100px / 190px 160px,
    radial-gradient(9px 3.6px at 50% 50%, var(--mint) 92%, transparent) 40px 18px / 86px 94px,
    radial-gradient(3.4px 8px at 50% 50%, var(--tomato) 92%, transparent) 10px 60px / 74px 82px,
    radial-gradient(circle at 50% 50%, var(--sky) 3.8px, transparent 4.4px) 58px 44px / 96px 70px,
    radial-gradient(circle, rgba(29, 27, 34, .07) 1.2px, transparent 1.6px) 0 0 / 7px 7px,
    #f5eddc;
}
[data-theme="neon"] {
  --board-ink: var(--paper); --board-card: #2a2731; --board-card-ink: var(--paper); --board-accent: var(--mint);
  --board-bg:
    radial-gradient(60% 50% at 10% 0%, rgba(111, 207, 174, .34), transparent 70%),
    radial-gradient(50% 55% at 94% 100%, rgba(239, 74, 55, .34), transparent 70%),
    radial-gradient(36% 40% at 62% 38%, rgba(255, 215, 94, .12), transparent 70%),
    repeating-linear-gradient(180deg, transparent 0 96px, rgba(111, 207, 174, .6) 96px 98px, rgba(111, 207, 174, .16) 98px 104px, transparent 104px 200px),
    repeating-linear-gradient(90deg, transparent 0 260px, rgba(239, 74, 55, .45) 260px 262px, rgba(239, 74, 55, .12) 262px 268px, transparent 268px 520px),
    radial-gradient(circle, rgba(251, 246, 236, .06) 1px, transparent 1.5px) 0 0 / 9px 9px,
    var(--ink);
}
[data-theme="lodge"] {
  --board-ink: var(--paper); --board-card: var(--paper); --board-card-ink: var(--ink); --board-accent: var(--butter);
  --board-bg:
    radial-gradient(circle, rgba(251, 246, 236, .92) 0 2.2px, transparent 2.8px) 0 0 / 52px 58px,
    radial-gradient(circle, rgba(251, 246, 236, .7) 0 1.5px, transparent 2px) 24px 30px / 52px 58px,
    repeating-linear-gradient(0deg, rgba(29, 27, 34, .3) 0 16px, transparent 16px 48px),
    repeating-linear-gradient(90deg, rgba(29, 27, 34, .3) 0 16px, transparent 16px 48px),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(255, 215, 94, .38) 22px 24px, transparent 24px 48px),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 215, 94, .38) 22px 24px, transparent 24px 48px),
    var(--tomato-d);
}
[data-theme="tinsel"] {
  --board-ink: var(--paper); --board-card: var(--paper); --board-card-ink: var(--ink); --board-accent: var(--butter);
  --board-bg:
    radial-gradient(ellipse 66px 28px at 50% 0, transparent 70%, var(--butter-l) 72%, var(--butter-d) 80%, transparent 84%) 0 34px / 132px 170px,
    radial-gradient(ellipse 66px 28px at 50% 0, transparent 70%, var(--sky-l) 72%, var(--sky) 80%, transparent 84%) 66px 118px / 132px 170px,
    radial-gradient(circle, var(--butter-l) 0 1.7px, transparent 2.2px) 10px 10px / 37px 41px,
    radial-gradient(circle, var(--sky-l) 0 1.3px, transparent 1.8px) 25px 30px / 53px 47px,
    linear-gradient(180deg, #2f5fae, #24477f);
}

@media (prefers-reduced-motion: reduce) {
  .gift-svg.breathe, .g-shine, .g-tw, .mascot-svg, .lights.lit .glow, .march, .band-note,
  .ustage .g-bow-in, .iced.icing::after, .iced.icing::before { animation: none !important; }
}
