/* Send a Cracker art: every style art.js draws with. Load base.css first; this file imports nothing.
   Prefixes: ck- cracker, cr- crown, slip- slips, mi- minis, tk- trinkets, pl- place, ws- wax seal,
   mk- ceremony, sc- scene and bursts. Custom properties the app may set: --tilt-x, --tilt-y
   (-1..1, set by startTilt on <html>). */

/* ---------- the scene ---------- */
#scene { position: fixed; left: 0; top: 0; width: 100%; height: 100lvh; z-index: -1; display: block; pointer-events: none; background: var(--holly-deep); }
.sc-fx { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.sc-fly { position: fixed; z-index: 55; pointer-events: none; }

/* ---------- foil: the glint follows the phone's tilt; without a gyroscope it sweeps now and then ---------- */
.ck-tilt { transform: translate(calc(var(--tilt-x, 0) * 210px), calc(var(--tilt-y, 0) * 18px)); }
.ck-tilt-sm { transform: translate(calc(var(--tilt-x, 0) * 70px), calc(var(--tilt-y, 0) * 20px)); }
.ck-glint { transform: translateX(-330px); }
.ck-glint-sm { transform: translateX(-120px); }
html:not(.tilt-live) .ck-glint { animation: ck-glint 9s var(--ease-out) infinite; }
html:not(.tilt-live) .ck-glint-sm { animation: ck-glint-sm 8s var(--ease-out) infinite; }
html.tilt-live .ck-glint, html.tilt-live .ck-glint-sm { transform: none; }
@keyframes ck-glint { 0% { transform: translateX(-330px); } 34% { transform: translateX(330px); } 100% { transform: translateX(330px); } }
@keyframes ck-glint-sm { 0% { transform: translateX(-120px); } 38% { transform: translateX(120px); } 100% { transform: translateX(120px); } }

/* ---------- the cracker ---------- */
/* The drawing always stays inside the box (pulled ends stop at its edge); the box clips so the
   moving full-size layers never add sideways scroll. The flying end leaves through a fixed layer. */
.ck { position: relative; width: 100%; aspect-ratio: 384 / 113; overflow: hidden; overflow: clip; overflow-clip-margin: 8px; -webkit-tap-highlight-color: transparent; }
.ck.sc-fly { overflow: visible; }
.ck[data-orient="v"] { width: auto; height: 100%; aspect-ratio: 113 / 384; margin-inline: auto; max-width: 100%; }
.ck-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ck-rot { position: absolute; inset: 0; perspective: 900px; }
.ck[data-orient="v"] .ck-rot { inset: auto; left: 50%; top: 50%; width: 339.823%; height: 29.427%; transform: translate(-50%, -50%) rotate(90deg); }
.ck-whole, .ck-shake, .ck-breath { position: absolute; inset: 0; }
.ck-p { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
.ck-end-far { transform-origin: 16.93% 50%; }
.ck-end-near { transform-origin: 83.07% 50%; }
.ck-crimp-far { transform-origin: 28.65% 50%; }
.ck-crimp-near { transform-origin: 71.35% 50%; }
.ck.is-live .ck-p { will-change: transform; }
.ck-crease { opacity: var(--ck-crease, 0); }
.ck-torn { opacity: 0; transition: opacity .16s var(--ease-out); }
.ck-seal { position: absolute; left: 50%; top: 50%; width: 9.4%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(-8deg); filter: drop-shadow(0 1px 1px rgba(36, 28, 23, .3)); }
.ck[data-orient="v"] .ck-seal { transform: translate(-50%, -50%) rotate(-98deg); }
.ck-seal .ws { display: block; width: 100%; height: 100%; }

/* At rest it breathes, very slightly. */
.ck-breath { animation: ck-breathe 5.2s ease-in-out infinite; transform-origin: 50% 50%; }
@keyframes ck-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.004, 1.02); } }
.ck.is-pulling .ck-breath, .ck[data-won] .ck-breath { animation: none; }

/* After the snap: the losing end and its crimp are gone, the torn edge shows, the half lies tipped. */
.ck[data-won="near"] :is(.ck-end-far, .ck-crimp-far, .ck-tie-far),
.ck[data-won="far"] :is(.ck-end-near, .ck-crimp-near, .ck-tie-near) { visibility: hidden; }
.ck[data-won="near"] .ck-torn-far, .ck[data-won="far"] .ck-torn-near { opacity: 1; }
.ck[data-won="near"] .ck-whole { transform: translateX(-8.85%) rotate(-3deg) rotateY(14deg); }
.ck[data-won="far"] .ck-whole { transform: translateX(8.85%) rotate(3deg) rotateY(-14deg); }

.ck-swatch { display: block; width: 100%; height: 100%; border-radius: inherit; }
.mark { display: block; width: 100%; height: 100%; }

/* ---------- wax seal ---------- */
.ws { display: block; width: 100%; height: 100%; }
.ws-letter { font-family: var(--display); font-weight: 700; font-size: 38px; font-variation-settings: "SOFT" 100, "WONK" 0; }


/* ---------- the tissue crown ---------- */
.crown { position: relative; width: 100%; aspect-ratio: 240 / 110; }
.crown > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cr-open { transform-origin: 50% 70%; }
.cr-folded { transform-origin: 50% 60%; }
.crown[data-state="folded"] .cr-open { opacity: 0; }
.crown[data-state="open"] .cr-folded { opacity: 0; }
.crown[data-state="opening"] .cr-open { opacity: 1; }

/* ---------- slips ---------- */
.slip { position: relative; transform: rotate(var(--slip-rot, -1deg)); filter: drop-shadow(0 6px 8px rgba(36, 28, 23, .35)) drop-shadow(0 1px 1px rgba(36, 28, 23, .3)); }
.slip-paper { position: relative; padding: 18px 26px 16px; color: var(--ink); font-family: var(--type); font-size: clamp(16px, 4.6vw, 19px); line-height: 1.42;
  background-color: var(--newsprint);
  background-image:
    linear-gradient(180deg, rgba(36, 28, 23, .05), transparent 18%, transparent 47%, rgba(36, 28, 23, .07) 49.5%, rgba(244, 234, 214, .55) 50.5%, transparent 53%, transparent 85%, rgba(36, 28, 23, .06)),
    radial-gradient(circle at 30% 40%, rgba(91, 77, 65, .07) 0 .7px, transparent 1.1px),
    radial-gradient(circle at 70% 20%, rgba(91, 77, 65, .05) 0 .6px, transparent 1px),
    radial-gradient(circle at 50% 60%, rgba(250, 246, 236, .6) 0 .8px, transparent 1.2px);
  background-size: 100% 100%, 13px 11px, 7px 17px, 19px 9px; }
.slip-q { margin: 0; text-shadow: .35px 0 rgba(36, 28, 23, .45); }
.slip-a { position: relative; margin: 12px 0 0; padding-top: 10px; font-weight: 700; color: var(--cranberry-deep); border-top: 1.5px dashed rgba(91, 77, 65, .45); text-shadow: .35px 0 rgba(140, 27, 45, .4); }
.slip-a-ghost { visibility: hidden; }
.slip-a-type { position: absolute; left: 0; right: 0; top: 10px; }
.slip-a[data-revealed="done"] .slip-a-ghost { visibility: visible; }
.slip-caret { display: inline-block; width: .55em; height: 1.05em; margin-left: 1px; vertical-align: -.15em; background: var(--cranberry-deep); animation: slip-blink .7s steps(2, jump-none) infinite; }
@keyframes slip-blink { 50% { opacity: 0; } }
.slip.motto { max-width: 340px; margin-inline: auto; }
.slip-card { position: relative; padding: 26px 24px 20px; text-align: center; color: var(--ink); background-color: var(--cream);
  background-image: radial-gradient(120% 90% at 30% 20%, rgba(255, 250, 238, .7), transparent 60%), linear-gradient(180deg, transparent 70%, rgba(36, 28, 23, .05));
  box-shadow: inset 0 0 0 5px var(--cream), inset 0 0 0 7px var(--cranberry), inset 0 0 0 10px var(--cream), inset 0 0 0 11px var(--cranberry); }
.slip-card::after { content: ""; position: absolute; inset: 6px 5px 4px 7px; border: 1px solid var(--cranberry-deep); opacity: .4; pointer-events: none; }
.slip-orn { display: block; width: 44px; height: 18px; margin: 0 auto 8px; }
.slip-text { margin: 0; font-family: var(--display); font-style: italic; font-weight: 420; font-size: clamp(19px, 5.4vw, 23px); line-height: 1.3; overflow-wrap: anywhere; }
.slip-from { margin: 12px 0 0; font-family: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--cranberry-deep); }

/* ---------- minis ---------- */
.mi { display: inline-block; width: 100%; height: 100%; line-height: 0; }
.mi-svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---------- trinkets ---------- */
.tk { width: 100%; min-width: 0; display: grid; gap: 10px; justify-items: center; }
.tk-stage { position: relative; width: 100%; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; isolation: isolate; color: var(--ink);
  background: radial-gradient(120% 90% at 30% 18%, #faf3e3, var(--cream) 55%, var(--cream-2));
  box-shadow: inset 0 0 0 7px var(--cream), inset 0 0 0 8.5px rgba(31, 77, 58, .45), inset 0 0 40px rgba(91, 77, 65, .12), 0 16px 30px -16px rgba(36, 28, 23, .75), 0 2px 3px rgba(36, 28, 23, .3); }
.tk-svg, .tk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.tk-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.tk-hit { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; border-radius: inherit; background: transparent; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
.tk[data-kind="top"] .tk-hit, .tk[data-kind="musicbox"] .tk-hit, .tk[data-kind="snowglobe"] .tk-hit { touch-action: none; }
.tk[data-kind="musicbox"] .tk-hit { cursor: grab; }
.tk-hit:focus-visible, .tk-tile:focus-visible { outline: 3px solid var(--candle); outline-offset: -6px; }
.tk-line { margin: 0; font-family: var(--display); font-style: italic; font-size: 19px; line-height: 1.25; text-align: center; text-wrap: balance; }
.tk-status { margin: 0; min-height: 1.35em; font-family: var(--text); font-size: 14px; text-align: center; opacity: .9; }
.tk-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tk-actions[hidden] { display: none; }
.tk-btn { min-height: var(--tap); min-width: var(--tap); padding: 10px 20px; border: 0; border-radius: 999px; font: 650 15px/1.1 var(--text); color: var(--ink); background: var(--cream); cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  box-shadow: 0 1px 0 rgba(255, 250, 238, .6) inset, 0 6px 14px -8px rgba(36, 28, 23, .8); transition: transform .12s var(--ease-out); }
.tk-btn:active { transform: translateY(1px) scale(.98); }
.tk-btn:focus-visible { outline: 3px solid var(--candle); outline-offset: 2px; }
.tk-btn:disabled { opacity: .6; cursor: default; }
.tk-blow { background: var(--cranberry); color: var(--cream); }
.tk-blow[aria-pressed="true"] { background: var(--holly-light); }

/* fish */
.tk-warm { transition: none; }
.tk-card { position: absolute; left: 6%; right: 6%; bottom: 5%; padding: 10px 14px 11px; border-radius: 3px; font-family: var(--type); font-size: 14.5px; line-height: 1.35; color: var(--ink); background: var(--newsprint);
  box-shadow: 0 8px 16px -8px rgba(36, 28, 23, .6); transform: translateY(130%) rotate(-1deg); opacity: 0; transition: transform .45s var(--ease-spring), opacity .2s; pointer-events: none; }
.tk-card.is-on { transform: translateY(0) rotate(-1deg); opacity: 1; }
.tk-card-h { display: block; margin-bottom: 3px; font-weight: 700; color: var(--cranberry-deep); text-transform: uppercase; letter-spacing: .04em; font-size: 12.5px; }

/* puzzle */
.tk-grid { position: absolute; inset: 7%; border-radius: 6px; background: rgba(91, 77, 65, .25); box-shadow: inset 0 1px 3px rgba(36, 28, 23, .4); }
.tk-tile { position: absolute; left: 0; top: 0; width: 33.3334%; height: 33.3334%; margin: 0; padding: 2px; border: 0; background: none; cursor: pointer; touch-action: manipulation; transition: transform .2s var(--ease-out), padding .4s var(--ease-out); -webkit-tap-highlight-color: transparent; }
.tk-tile svg { display: block; width: 100%; height: 100%; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(36, 28, 23, .15), 0 2px 3px rgba(36, 28, 23, .35); }
.tk-tile[data-n="8"] { opacity: 0; pointer-events: none; transition: opacity .5s var(--ease-out), padding .4s var(--ease-out); }
.tk-grid.is-solved .tk-tile { padding: 0; cursor: default; }
.tk-grid.is-solved .tk-tile svg { border-radius: 0; box-shadow: none; }
.tk-grid.is-solved .tk-tile[data-n="8"] { opacity: 1; }
.tk-grid.is-solved { animation: tk-win .7s var(--ease-spring); }
@keyframes tk-win { 30% { transform: scale(1.04) rotate(-1deg); } }

/* whistle, bell, music box */
.tk-wave, .tk-puff { opacity: 0; }
.tk-wave { transform-box: fill-box; transform-origin: 50% 100%; }
.tk-pins, .tk-comb { will-change: transform; }
.tk-globe-front { pointer-events: none; }

/* ---------- a place at the table ---------- */
.place { position: relative; width: 100%; aspect-ratio: 300 / 330; container-type: inline-size; }
.pl-plate { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pl-cracker { position: absolute; left: 0; top: 4%; width: 100%; transform: rotate(-5deg); }
.pl-crown { position: absolute; left: 31%; top: 44%; width: 38%; aspect-ratio: 140 / 72; transform: rotate(9deg); }
.pl-card { position: absolute; left: 50%; bottom: 1%; width: 58%; min-height: 44px; padding: 13px 10px 9px; transform: translateX(-50%) rotate(1.6deg); text-align: center; border-radius: 3px;
  background: linear-gradient(180deg, #d9c8a6 0, #e9dcc2 9px, var(--cream) 10px, var(--cream) 70%, var(--cream-2));
  box-shadow: 0 12px 14px -9px rgba(36, 28, 23, .7), 0 1px 2px rgba(36, 28, 23, .35); }
.pl-card::before { content: ""; position: absolute; left: 8%; right: 8%; top: 15px; border-top: 1px solid var(--cranberry); opacity: .5; }
.pl-name { position: relative; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--display); font-weight: 600; font-size: clamp(14px, 8.4cqw, 28px); line-height: 1.2; color: var(--ink); }

/* ---------- making a cracker ---------- */
.mk { position: relative; width: 100%; aspect-ratio: 1.15; min-height: 300px; max-height: 420px; overflow-x: clip; -webkit-user-select: none; user-select: none; cursor: pointer; }
.mk-sheet { position: absolute; left: 50%; top: 3%; width: min(62%, 340px); aspect-ratio: 2.1; transform: translate(-50%, 0); transform-origin: 50% 100%; border-radius: 3px; overflow: hidden;
  box-shadow: 0 14px 20px -12px rgba(36, 28, 23, .8); }
.mk-sheet .ck-swatch { border-radius: 0; }
.mk-holder { position: absolute; left: 50%; top: 60%; width: min(100%, 560px); aspect-ratio: 384 / 113; transform: translate(-50%, -50%); }
.mk-tube { position: absolute; inset: 0; width: 100%; }
.mk-final { position: absolute; inset: 0; }
.mk-drop { position: absolute; left: 80%; top: -6%; width: 14%; aspect-ratio: 1; opacity: 0; }
.mk-drop-1 { width: 17%; aspect-ratio: 140 / 72; left: 78%; top: 12%; }
.mk-glint { position: absolute; right: -30%; top: -30%; width: 70%; height: 70%; opacity: 0; overflow: visible; }
.mk-shine { position: absolute; top: 15%; bottom: 15%; left: 0; width: 26%; opacity: 0; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(255, 243, 196, .55), transparent); }
.mk.is-playing .mk-final .ck-p, .mk.is-playing .mk-final .ck-seal { opacity: 0; }
.mk.is-quick .mk-sheet, .mk.is-quick .mk-card, .mk.is-quick .mk-mouth { display: none; }
.mk:not(.is-playing):not(.is-done) .mk-tube, .mk:not(.is-playing):not(.is-done) .mk-sheet { visibility: hidden; }
.mk.is-done .mk-sheet, .mk.is-done .mk-tube, .mk.is-done .mk-drop, .mk.is-done .mk-shine { visibility: hidden; }
.mk.is-done .mk-final .ck-p, .mk.is-done .mk-final .ck-seal { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .ck-breath, html:not(.tilt-live) .ck-glint, html:not(.tilt-live) .ck-glint-sm, .slip-caret, .tk-grid.is-solved { animation: none; }
  .tk-tile, .tk-card { transition: none; }
}
