/* Holiday Cards delight kit: paper, ink, buttons, focus, card, burst, bloom, trail. */

:root {
  --paper: #fbf6ee;
  --paper-deep: #f3ead9;
  --pine: #2f5d50;
  --pine-deep: #24493f;
  --berry: #7a2e2e;
  --midnight: #24324a;
  --gold: #c79a3b;
  --gold-ink: #8a6420; /* gold that passes contrast on paper */
  --ink: #24324a;
  --muted: #5d564c;
  --rule: rgba(36, 50, 74, 0.14);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --body: "Lora", Georgia, serif;
  --ease-out: cubic-bezier(0.2, 0.75, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  background-color: var(--paper);
  /* watercolor paper: two faint washes and a fine grain */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(60vw 50vh at 85% 8%, rgba(199, 154, 59, 0.08), transparent 70%),
    radial-gradient(70vw 60vh at 5% 95%, rgba(47, 93, 80, 0.07), transparent 70%);
  background-attachment: scroll;
}

img, svg { max-width: 100%; }

::selection { background: rgba(199, 154, 59, 0.35); }

/* ---------- links: hand-drawn wavy underline on hover ---------- */
a {
  color: var(--pine);
  text-decoration: underline;
  text-decoration-color: rgba(47, 93, 80, 0.35);
  text-underline-offset: 3px;
  position: relative;
}
a:hover {
  text-decoration: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='6' viewBox='0 0 24 6'%3E%3Cpath d='M0 3.5c3-2.5 6-2.5 9 0s6 2.5 9 0 4.5-2 6-1' fill='none' stroke='%237a2e2e' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x 0 100% / 24px 6px;
  padding-bottom: 4px;
  animation: wave-slide 1.2s linear infinite;
}
@keyframes wave-slide { to { background-position: 24px 100%; } }

/* ---------- brush-circle focus ring ---------- */
:where(a, button, .btn, [role="button"], [contenteditable], [tabindex]):focus { outline: none; }
:where(a, button, .btn, [role="button"], [contenteditable], [tabindex]):focus-visible {
  outline: 2px solid transparent; /* keeps forced-colors users covered */
  position: relative;
}
:where(a, button, .btn, [role="button"], [contenteditable], [tabindex]):focus-visible::after {
  content: "";
  position: absolute;
  inset: -9px -12px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 100' preserveAspectRatio='none'%3E%3Cpath d='M18 52C14 22 70 8 112 10c48 2 80 18 76 42-4 26-50 40-96 38C44 88 10 74 14 46c3-20 40-34 84-35' fill='none' stroke='%23c79a3b' stroke-width='4.5' stroke-linecap='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  animation: brush-in 0.35s var(--ease-out);
  z-index: 3;
}
@keyframes brush-in { from { opacity: 0; transform: scale(0.92) rotate(-2deg); } }

/* ---------- ink pill button ---------- */
.btn {
  --btn-bg: var(--midnight);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0.7em 1.5em 0.75em;
  border: 0;
  border-radius: 999px;
  color: var(--paper);
  background:
    radial-gradient(120% 140% at 20% 0%, rgba(255, 255, 255, 0.16), transparent 50%),
    var(--btn-bg);
  font: 600 1rem/1.1 var(--body);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 6px 16px -6px rgba(36, 50, 74, 0.55);
  transition: transform 0.25s var(--ease-spring), box-shadow 0.25s, background-color 0.2s;
  position: relative;
}
.btn:hover { animation: wobble 0.55s ease-in-out; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 10px 22px -8px rgba(36, 50, 74, 0.6); }
.btn:active { transform: scale(0.96); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.7; cursor: progress; animation: none; }
.btn--berry { --btn-bg: var(--berry); }
.btn--pine { --btn-bg: var(--pine); }
.btn--ghost {
  --btn-bg: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(36, 50, 74, 0.35);
  background: transparent;
}
.btn--small { min-height: 40px; padding: 0.45em 1em 0.5em; font-size: 0.9rem; }
@keyframes wobble {
  0% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-2.2deg) scale(1.03); }
  50% { transform: rotate(1.6deg) scale(1.03); }
  75% { transform: rotate(-0.8deg) scale(1.02); }
  100% { transform: rotate(0) scale(1.02); }
}

/* hand-drawn tick used by copy buttons and the saved stamp */
.tick { width: 1.05em; height: 1.05em; flex: none; }
.tick path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: tick-draw 0.5s 0.05s var(--ease-out) forwards; }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }

/* ---------- snow canvas ---------- */
.snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

/* ---------- burst glyphs ---------- */
.burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.burst-flake {
  position: absolute;
  left: 0; top: 0;
  font-family: "Apple Symbols", "Segoe UI Symbol", serif;
  line-height: 1;
  will-change: transform, opacity;
  user-select: none;
}
.burst-flake svg { display: block; width: 1em; height: 1em; }

/* ---------- ink-bloom reveal ---------- */
/* Hide bloom text from the very first paint (no flash-then-vanish). If bloom.js never runs,
   the failsafe fades it in; keep its delay in step with FAILSAFE_MS in bloom.js. */
@media (scripting: enabled) {
  html:not(.js-bloom) [data-bloom] { opacity: 0; animation: bloom-failsafe 0.6s ease 3.5s forwards; }
}
@keyframes bloom-failsafe { to { opacity: 1; } }
.js-bloom [data-bloom] { opacity: 0; }
.js-bloom [data-bloom].bloom-in {
  opacity: 1;
  -webkit-mask-image: var(--bloom-mask);
  mask-image: var(--bloom-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  animation: bloom-grow 0.9s cubic-bezier(0.5, 0.1, 0.4, 1) both;
}
.js-bloom [data-bloom].bloom-done { opacity: 1; -webkit-mask-image: none; mask-image: none; animation: none; }
@keyframes bloom-grow {
  0% { -webkit-mask-size: 0% 0%; mask-size: 0% 0%; filter: saturate(1.6) blur(1.5px); }
  60% { filter: saturate(1.15) blur(0); }
  100% { -webkit-mask-size: 220% 220%; mask-size: 220% 220%; filter: none; }
}
.js-bloom [data-bloom].bloom-fade { opacity: 1; transition: opacity 0.6s ease; }

/* ---------- the folded card ---------- */
.card3d {
  position: relative;
  width: 100%;
  aspect-ratio: 1530 / 2160;
  perspective: 2200px;
  perspective-origin: 50% 40%;
  container-type: inline-size;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  --rx: 0deg;
  --ry: 0deg;
  --s: 1;
  z-index: 1;
}
.card3d.is-open { z-index: 30; }
.card3d__tilt {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateX(0) scale(1) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 1s var(--ease-out);
}
.card3d.is-tilting .card3d__tilt { transition: transform 0.25s ease-out; }
.card3d.is-open .card3d__tilt {
  transform: translateX(calc(50% * var(--s))) scale(var(--s)) rotateX(calc(var(--rx) * 0.5)) rotateY(calc(var(--ry) * 0.5));
}
/* soft shadow on the "table" */
.card3d__shadow {
  position: absolute;
  left: 4%; right: 4%; bottom: -5%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(36, 50, 74, 0.32), transparent);
  filter: blur(6px);
  transform: translateZ(-40px);
  transition: left 1s var(--ease-out), right 1s var(--ease-out);
}
.card3d.is-open .card3d__shadow { left: -96%; }

.card3d__inside,
.card3d__face {
  position: absolute;
  inset: 0;
  border-radius: 1.2cqw;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card3d__inside {
  transform: translateZ(-1px);
  background:
    linear-gradient(90deg, rgba(36, 50, 74, 0.14), transparent 7%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .34 0 0 0 0 .26 0 0 0 .5 -.2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"),
    #fdfaf4;
  box-shadow: 0 1px 2px rgba(36, 50, 74, 0.2), 0 18px 40px -18px rgba(36, 50, 74, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12cqw 11cqw;
  color: var(--midnight);
}
.card3d__message {
  font-family: var(--hand);
  font-size: clamp(14px, 8.6cqw, 40px);
  line-height: 1.18;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}
.card3d__message.is-long { font-size: clamp(12px, 6.6cqw, 32px); }
.card3d__message.is-xlong { font-size: clamp(11px, 5.1cqw, 26px); }
.card3d__sender {
  margin: 1.1em 0 0;
  font-family: var(--hand);
  font-size: clamp(13px, 8cqw, 36px);
  color: var(--berry);
  text-align: right;
  overflow-wrap: anywhere;
}
.card3d__sender:not(:empty)::before { content: "— "; }

.card3d__cover {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(0.45, 0.05, 0.2, 1);
}
.card3d.is-open .card3d__cover { transform: rotateY(-178deg); }
.card3d__face--front {
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(36, 50, 74, 0.25), 0 22px 44px -18px rgba(36, 50, 74, 0.55);
}
.card3d__face--front img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* light sweeping across the front as it turns */
.card3d__face--front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.35) 48%, transparent 62%);
  background-size: 250% 100%;
  background-position: 120% 0;
  transition: background-position 1.1s var(--ease-out);
  pointer-events: none;
}
.card3d:hover .card3d__face--front::after,
.card3d.is-open .card3d__face--front::after { background-position: -40% 0; }
.card3d__face--back {
  transform: rotateY(180deg);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 212' preserveAspectRatio='none'%3E%3Cfilter id='w' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.03' numOctaves='3' seed='11'/%3E%3CfeDisplacementMap in='SourceGraphic' scale='22' xChannelSelector='R' yChannelSelector='G'/%3E%3C/filter%3E%3Cg filter='url(%23w)'%3E%3Cellipse cx='40' cy='170' rx='70' ry='34' fill='%232f5d50' fill-opacity='.13'/%3E%3Cellipse cx='112' cy='186' rx='60' ry='30' fill='%23c79a3b' fill-opacity='.16'/%3E%3Cellipse cx='60' cy='40' rx='58' ry='26' fill='%238f86c0' fill-opacity='.12'/%3E%3C/g%3E%3Cg fill='none' stroke='%23c79a3b' stroke-opacity='.55' stroke-width='1.2' stroke-linecap='round' transform='translate(75 104)'%3E%3Cpath d='M0-9V9'/%3E%3Cpath d='M0-9V9' transform='rotate(60)'/%3E%3Cpath d='M0-9V9' transform='rotate(120)'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat,
    #fcf8f1;
  box-shadow: inset -10px 0 24px -14px rgba(36, 50, 74, 0.35);
}
.card3d__face--back::after {
  content: "Painted with Claude";
  position: absolute;
  left: 0; right: 0; bottom: 8cqw;
  text-align: center;
  font: italic 4.4cqw/1 var(--display);
  color: rgba(36, 50, 74, 0.45);
}
.card3d__hint {
  position: absolute;
  bottom: -2.4em;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--muted);
  transition: opacity 0.4s;
  pointer-events: none;
}
.card3d.is-open .card3d__hint { opacity: 0; }

/* ---------- order trail ---------- */
.trail { position: relative; width: 100%; }
.trail svg { display: block; width: 100%; height: auto; overflow: visible; }
.trail__base { fill: none; stroke: rgba(36, 50, 74, 0.16); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 14; }
.trail__ink {
  fill: none;
  stroke: var(--pine);
  stroke-width: 9;
  stroke-linecap: round;
  filter: url(#trail-wet);
  transition: stroke-dashoffset 1.8s var(--ease-out);
}
.trail__stop circle.blob { fill: var(--paper); stroke: rgba(36, 50, 74, 0.25); stroke-width: 3; transition: fill 0.6s, stroke 0.6s; }
.trail__stop.is-done circle.blob { fill: var(--pine); stroke: var(--pine); }
.trail__stop.is-current circle.blob { fill: var(--gold); stroke: var(--gold); }
.trail__stop.is-current .pulse { animation: stop-pulse 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.trail__stop .pulse { fill: none; stroke: var(--gold); stroke-width: 3; opacity: 0; }
.trail.is-attention .trail__stop.is-current circle.blob { fill: var(--berry); stroke: var(--berry); }
.trail.is-attention .trail__stop.is-current .pulse { stroke: var(--berry); }
@keyframes stop-pulse {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.3); }
}
.trail__labels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0.4rem;
  text-align: center;
  list-style: none;
  padding: 0;
}
.trail__labels li { font-family: var(--hand); font-size: clamp(1.05rem, 3.8vw, 1.5rem); line-height: 1.1; color: var(--muted); transition: color 0.5s, transform 0.5s var(--ease-spring); }
.trail__labels li.is-done { color: var(--pine); }
.trail__labels li.is-current { color: var(--midnight); transform: translateY(-2px) scale(1.08); font-weight: 700; }

/* ---------- small utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  a:hover { animation: none; }
  .btn:hover { animation: none; }
  .card3d__tilt, .card3d.is-open .card3d__tilt { transform: none !important; transition: none; }
  .card3d__cover { transition: opacity 0.5s ease; }
  .card3d.is-open .card3d__cover { transform: none; opacity: 0; }
  .card3d.is-open .card3d__shadow { left: 4%; }
  .card3d__inside { transform: none; }
  .card3d__face--front::after { display: none; }
  .js-bloom [data-bloom].bloom-in { animation: none; -webkit-mask-image: none; mask-image: none; }
  .trail__ink { transition: none; }
}
