/* ==========================================================
   Christmas at The Fox Box
   Palette: cream paper on festive red, with green / gold / sky accents
   ========================================================== */

:root {
  --bg: #b9372a;          /* page red */
  --bg-deep: #9c2b20;
  --paper: #fbf3e4;       /* card cream */
  --paper-2: #f4e8d2;
  --ink: #2b211c;         /* body text */
  --ink-soft: #6b5a4e;    /* secondary text, 5.9:1 on paper */
  --line: #e2d3b9;

  --red: #c8402f;
  --fox: #d9622b;
  --green: #2f6b45;
  --gold: #e9a23b;

  --tint-red: #f7cfc4;
  --tint-green: #d3e4bd;
  --tint-gold: #fbe3a9;
  --tint-blue: #cfe2f1;

  --radius: 14px;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 10px 30px -12px rgba(60, 10, 0, .45);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* faint paper grain so the red isn't flat */
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 210, 160, .18), transparent 70%),
    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' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Snow ---------- */
#snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- Layout ---------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

.muted { color: var(--ink-soft); }
.placeholder { color: var(--red); font-style: normal; font-size: .9em; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -.01em;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: 600 16px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn--primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn--primary:hover { background: var(--bg-deep); border-color: var(--bg-deep); }
.btn--ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding: 0 8px; }
.btn--ghost:hover { background: transparent; color: var(--red); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.actions { display: flex; gap: 10px; margin-top: 20px; }
.actions .btn { flex: 1; }
.actions--wrap { flex-wrap: wrap; }
.actions--wrap .btn { flex: 1 1 auto; }

/* ---------- Postcard hero ---------- */
.postcard {
  padding: 16px;
}

.postcard__art {
  position: relative;
  background: var(--red);
  border-radius: 2px;
  aspect-ratio: 6 / 4.2;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.postcard__dots {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.75) 1.4px, transparent 1.8px),
    radial-gradient(circle, rgba(255,255,255,.45) 1px, transparent 1.4px);
  background-size: 46px 46px, 31px 31px;
  background-position: 7px 11px, 19px 3px;
  pointer-events: none;
}
.fox-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.postcard__body { padding: 22px 10px 14px; position: relative; }


.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--red);
}
.title { font-size: clamp(34px, 10vw, 52px); }
.title__accent { color: var(--red); }

.facts { margin: 22px 0 0; display: grid; gap: 14px; }
.facts__row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding-top: 14px;
  border-top: 1.5px dashed var(--line);
}
.facts dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 3px;
}
.facts dd { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.4; }
.facts dd .muted { font-weight: 400; font-size: 16px; }

.countdown {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Stamps (perforated edges via mask) ---------- */
.stamp {
  --r: 4px;          /* perforation radius */
  --s: 12px;         /* perforation spacing */
  display: inline-block;
  width: 64px;
  aspect-ratio: 1;
  padding: calc(var(--r) + 3px);
  background: #fffaf0;
  -webkit-mask:
    radial-gradient(var(--r) at var(--r) var(--r), #0000 97%, #000) calc(-1 * var(--r)) calc(-1 * var(--r)) / var(--s) var(--s) round,
    linear-gradient(#000 0 0) content-box;
          mask:
    radial-gradient(var(--r) at var(--r) var(--r), #0000 97%, #000) calc(-1 * var(--r)) calc(-1 * var(--r)) / var(--s) var(--s) round,
    linear-gradient(#000 0 0) content-box;
  filter: drop-shadow(0 2px 2px rgba(60,10,0,.18));
  flex-shrink: 0;
}
.stamp__inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 1px;
}
.stamp__inner svg { width: 78%; height: 78%; }
.stamp__inner--red   { background: var(--tint-red);   color: var(--fox); }
.stamp__inner--green { background: var(--tint-green); color: var(--green); }
.stamp__inner--gold  { background: var(--tint-gold);  color: var(--red); }
.stamp__inner--blue  { background: var(--tint-blue);  color: var(--green); }

.stamp--sm { width: 52px; --r: 3.5px; --s: 10px; }

/* ---------- Stamp sheet nav ---------- */
.sheet {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 22px 0;
}
.sheet__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.sheet__item .stamp { width: 100%; max-width: 92px; --r: 5px; --s: 14px; transition: transform .2s cubic-bezier(.3,1.6,.5,1); }
.sheet__item:nth-child(odd) .stamp { transform: rotate(-2deg); }
.sheet__item:nth-child(even) .stamp { transform: rotate(2deg); }
.sheet__item:hover .stamp, .sheet__item:focus-visible .stamp { transform: rotate(0) translateY(-3px); }

/* ---------- Cards ---------- */
.card {
  padding: 26px 22px 28px;
  margin-bottom: 18px;
  position: relative;
}
.card__head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.card__head h2 { font-size: 30px; }
.lede { margin: 0 0 16px; }

.info { list-style: none; margin: 0; padding: 0; }
.info li {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1.5px dashed var(--line);
}
.info li:first-child { border-top: 0; padding-top: 4px; }
.info strong {
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 3px;
}

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form--tight { margin-top: 22px; padding-top: 20px; border-top: 1.5px dashed var(--line); }
.form__title { font-size: 21px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field__label { font-weight: 600; font-size: 15px; padding: 0; }
.field--inline { grid-template-columns: 1fr auto; align-items: center; }

input[type="text"], input[type="tel"], textarea, select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font: 400 17px/1.3 var(--font-body);   /* >=16px prevents iOS zoom */
  transition: border-color .15s ease;
}
textarea { resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%232b211c' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
input[type="text"]:focus, input[type="tel"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); }
input::placeholder, textarea::placeholder { color: #a8998b; }
.field.is-invalid input { border-color: var(--red); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segmented span {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: all .15s ease;
}
.segmented input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.segmented input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

.stepper { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 999px; }
.stepper button {
  width: 44px; height: 44px;
  border: 0; background: none;
  font: 500 22px/1 var(--font-body);
  color: var(--ink);
  cursor: pointer;
  border-radius: 999px;
}
.stepper button:active { background: var(--paper-2); }
.stepper output { min-width: 28px; text-align: center; font-weight: 600; font-size: 18px; }

.check { display: flex; gap: 12px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--red); margin: 0; flex-shrink: 0; }

[data-when-attending][hidden] { display: none; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form__msg { margin: 0; font-size: 15px; min-height: 1em; }
.form__msg:empty { display: none; }
.form__msg.is-error { color: var(--red); font-weight: 600; }

/* ---------- RSVP confirmation + rubber stamp ---------- */
.rsvp-status {
  position: relative;
  background: var(--paper-2);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  overflow: hidden;
}
.rsvp-status p { margin: 0; }
.rsvp-status__top { position: relative; padding-right: 128px; min-height: 52px; }
.rsvp-status .linklike {
  margin-top: 6px;
  background: none; border: 0; padding: 0;
  color: var(--red); font: 600 15px var(--font-body);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.rubber {
  position: absolute;
  right: 12px;
  top: 50%;
  padding: 4px 10px;
  border: 3px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font: 700 15px/1 var(--font-body);
  letter-spacing: .14em;
  text-transform: uppercase;
  transform: translateY(-50%) rotate(-10deg);
  opacity: .85;
  mix-blend-mode: multiply;
}
.rubber.is-stamping { animation: stampIn .45s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stampIn {
  0%   { transform: translateY(-50%) rotate(-10deg) scale(2.4); opacity: 0; }
  60%  { opacity: .95; }
  100% { transform: translateY(-50%) rotate(-10deg) scale(1); opacity: .85; }
}
.rsvp-status.is-thud { animation: thud .3s .3s ease-out; }
@keyframes thud {
  30% { transform: translateY(2px); }
  100% { transform: none; }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: #fff;
  padding: 18px 0 8px;
  font-size: 15px;
}
.footer p { margin: 0 0 4px; }
.footer .muted { color: rgba(255,255,255,.75); font-size: 13px; }

/* ---------- Envelope intro ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 4; /* below the snow canvas so it keeps snowing */
  background: var(--bg);
  overflow: hidden;
  cursor: pointer;
}
.intro[hidden] { display: none; }
.intro__skip {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(24px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* Envelope pieces are siblings so the card can sit between back and front.
   Position comes from --env-x/y/w/h, set by JS on .intro */
.env {
  position: absolute;
  left: var(--env-x);
  top: var(--env-y);
  width: var(--env-w);
  height: var(--env-h);
}
.env__back {
  background: #e8d6b4;
  border-radius: 6px;
  box-shadow: 0 18px 40px -16px rgba(40, 5, 0, .6);
}
/* clip region: everything above the envelope's bottom edge */
.env__clip {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: calc(var(--env-y) + var(--env-h));
  overflow: hidden;
  pointer-events: none;
}
.env__clip .postcard { position: absolute; margin: 0; transform-origin: 0 0; }

.env__front {
  border-radius: 6px;
  background: #f3e4c6;
  /* V-shaped pocket: side flaps + bottom flap */
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.05);
}
.env__front::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(0,0,0,.06), transparent 40%),
              linear-gradient(200deg, rgba(0,0,0,.06), transparent 40%);
}
.env__to, .env__from {
  position: absolute;
  font-family: var(--font-display);
  color: var(--ink);
}
.env__to { left: 0; right: 0; bottom: 22%; text-align: center; font-size: clamp(18px, 5.4vw, 26px); font-weight: 600; }
.env__from { left: 0; right: 0; bottom: 10%; text-align: center; font-size: 12px; font-family: var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }

.env__flap {
  height: calc(var(--env-h) * .62);
  transform-origin: 50% 0;
  z-index: 4;
}
.env__flap.is-open { z-index: 1; }
.env__flap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #ead8b5;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 6px 6px 0 0;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.15));
}
.env__seal {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 54px; height: 54px;
  margin: 0 0 -27px -27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8503e, #a82a1d 70%);
  box-shadow: 0 0 0 4px #b3301f, 0 3px 6px rgba(0,0,0,.3);
  color: #f6d9c9;
  backface-visibility: hidden;
}
.env__seal svg { width: 32px; height: 32px; --paper: #a82a1d; --ink: #a82a1d; }

/* stacking during intro */
.env__back  { z-index: 1; }
.env__clip  { z-index: 2; }
.env__front { z-index: 3; }

/* before the intro overlay is up: show only the red background and snow */
.intro-pending .page { visibility: hidden; }

/* hero is hidden while the intro clone is flying */
.is-intro .postcard { visibility: hidden; }
.is-intro .intro .postcard { visibility: visible; }

/* ---------- Wider screens ---------- */
@media (min-width: 560px) {
  .page { padding-top: 40px; }
  .card { padding: 32px 34px 34px; }
  .postcard { padding: 20px; }
  .postcard__body { padding: 24px 16px 16px; }
  .sheet { gap: 16px; }
}

/* ---------- Scalloped "ticket" edges ----------
   The paper is a ::before layer with a mask punched out along every edge,
   so the content isn't masked and the drop shadow follows the scallops.
   CSS masks work in all current browsers (Safari via -webkit-mask). */
.ticket {
  --r: 7px;     /* scallop radius */
  --s: 22px;    /* scallop spacing */
  position: relative;
  isolation: isolate;
  filter: drop-shadow(0 10px 14px rgba(70, 12, 0, .32));
}
.ticket::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: var(--r);
  background: var(--paper);
  -webkit-mask:
    radial-gradient(var(--r) at var(--r) var(--r), #0000 97%, #000) calc(-1 * var(--r)) calc(-1 * var(--r)) / var(--s) var(--s) round,
    linear-gradient(#000 0 0) content-box;
          mask:
    radial-gradient(var(--r) at var(--r) var(--r), #0000 97%, #000) calc(-1 * var(--r)) calc(-1 * var(--r)) / var(--s) var(--s) round,
    linear-gradient(#000 0 0) content-box;
}

/* ---------- "More below" cue ---------- */
.scroll-cue {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .45);
  transform: translate(-50%, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
.scroll-cue svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.scroll-cue.is-ready { opacity: 1; pointer-events: auto; }
.scroll-cue.is-ready svg { animation: nudge 1.6s ease-in-out infinite; }
.scroll-cue.is-hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
@keyframes nudge { 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .scroll-cue.is-ready svg { animation: none; } }

/* ---------- Paper grain over everything ---------- */
.paper {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  pointer-events: none;
  background: url("paper.png") repeat;
  background-size: 256px 256px;
  opacity: .6;
}

/* ---------- Inline links (details / potluck / grab bag) ---------- */
.inline-link {
  color: var(--red);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.inline-link:hover { color: var(--bg-deep); }
.field__hint { font-size: 14px; color: var(--ink-soft); }

/* ---------- After-RSVP "before the party" links ---------- */
.next { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1.5px dashed var(--line); }
.next__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.next__item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  line-height: 1.4;
  transition: border-color .15s ease;
}
.next__item:hover { border-color: var(--ink); }
.next__item strong { font-size: 16px; }
.next__icon { flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 6px; }
.next__icon svg { width: 32px; height: 32px; }
.next__icon--gold { background: var(--tint-gold); color: var(--red); }
.next__icon--blue { background: var(--tint-blue); color: var(--green); }
.next__icon--green { background: var(--tint-green); color: var(--red); }
div.next__item:hover { border-color: var(--line); }
.facts__link { display: inline-block; margin-top: 6px; font-size: 16px; }
.info li { grid-template-columns: 96px 1fr; }
