/* =====================================================================
   Secret Santa: Christmas theme.

   Every colour is a token. Light is the default; the dark set (navy night
   sky, evergreen cards, cream text, cranberry and gold accents) applies when
   the device prefers dark. tests/test_contrast.py reads the tokens below and
   enforces WCAG AA, so keep them as plain #rrggbb values.
   ===================================================================== */

@font-face {
  font-family: "Mountains of Christmas";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/mountains-of-christmas-700-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --radius: 14px;
  --font-display: "Mountains of Christmas", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* the night palette: navy sky, evergreen cards, cream text, cranberry and gold */
  --bg: #0b1530;
  --surface: #0e3b2d;
  --surface-alt: #15244a;
  --surface-sunk: #1a2b4f;
  --text: #fff8ee;
  --muted: #d8cfbf;
  --heading: #f3d98b;
  --link: #f3d98b;
  --eyebrow: #ff9aa0;
  --line: #2c5a49;
  --field-bg: #0a2a20;
  --field-border: #9db4aa;
  --primary: #b3202a;
  --on-primary: #ffffff;
  --primary-edge: #f3d98b;
  --primary-glow: #f3d98b;
  --secondary: #f3d98b;
  --on-secondary: #0b1530;
  --ghost: #f3d98b;
  --danger: #c4323c;
  --on-danger: #ffffff;
  --success: #9be3b9;
  --error: #ff9aa0;
  --error-bg: #3a1420;
  --focus: #f3d98b;
  --pick-badge: #b3202a;
  --on-pick-badge: #ffffff;
  --pick-badge-edge: #fff8ee;
  --best: #f3d98b;
  --chosen: #9be3b9;
  --badge-bg: #1d5a43;
  --badge-text: #fff8ee;
  --badge-soon-bg: #4a1620;
  --badge-soon-text: #ffc2c6;
  /* Heat: 0 = nobody free .. 6 = everyone. Even steps in OKLCH lightness,
     at least 1.19:1 apart, so neighbouring levels are easy to tell apart. */
  --heat-0: #0a2a20;
  --heat-1: #1c3d2c;
  --heat-2: #1d4a34;
  --heat-3: #1e573c;
  --heat-4: #1f6444;
  --heat-5: #1e714d;
  --heat-6: #1c7f55;
  --tally: #fff8ee;
  --bar-fill: #9be3b9;
  --bar-track: #06180f;
  --on-best: #0b1530;
  --on-chosen: #0b1530;
  --chip-bg: #0e3b2d;
  --chip-text: #f3d98b;
  --chip-border: #f3d98b;
  --chip-hover: #15553a;
  --notice-border: #f3d98b;
  --night: #070e22;
  --night-text: #fff8ee;
  --night-heading: #f3d98b;
  --night-muted: #d8d3c6;
  --garland: #2e8b5e;
  --garland-dark: #15553a;
  --berry: #e0535c;
  --ornament-red: #e0535c;
  --ornament-gold: #f3d98b;
  --gift: #b3202a;
  --gift-lid: #c9303a;
  --ribbon: #d4a93c;
  --flake: #ffffff; /* pale blue-grey: white would vanish on the cream page */
}


/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* No double-tap zoom delay on things people tap. */
a, button, label, input, select, textarea, .day { touch-action: manipulation; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem; /* 17px: inputs inherit it, so iOS never zooms on focus */
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 { color: var(--heading); line-height: 1.2; }
h1 { font-family: var(--font-display); font-size: 2.3rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
h3 { margin: 0.75rem 0 0.25rem; font-size: 1.05rem; }
a { color: var(--link); text-underline-offset: 0.15em; }
p { overflow-wrap: break-word; }

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

.page { max-width: 40rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; position: relative; z-index: 1; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- header + string lights */

.site-header {
  position: relative;
  background: var(--night);
  color: var(--night-text);
  padding: 30px 1rem 0.7rem;
  overflow: hidden;
  z-index: 2;
}
.site-name {
  display: block;
  max-width: 40rem;
  margin: 0 auto;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--night-heading);
}
.site-header::after { /* candy-cane trim under the header */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: repeating-linear-gradient(135deg, var(--primary) 0 7px, var(--night-text) 7px 14px);
  pointer-events: none;
}

/* Each <i> is one 40px swag of wire with a bulb hanging from its low point. */
.lights {
  position: absolute; top: 0; left: 0; right: 0; height: 30px;
  display: flex; overflow: hidden; pointer-events: none;
}
.lights i { position: relative; flex: 0 0 40px; height: 30px; }
.lights i::before { /* the wire */
  content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 20px;
  border-bottom: 2px solid #3b3f4a; border-radius: 0 0 50% 50%;
}
.lights i::after { /* the bulb */
  content: ""; position: absolute; left: 50%; top: 9px;
  width: 10px; height: 14px; margin-left: -5px;
  border-radius: 50% 50% 50% 50% / 60% 60% 45% 45%;
  background: var(--bulb, #e63946);
  box-shadow: 0 0 10px 2px var(--bulb, #e63946);
  animation: twinkle 2.8s ease-in-out infinite;
}
.lights i:nth-child(4n+1) { --bulb: #e63946; }
.lights i:nth-child(4n+2) { --bulb: #f4c542; }
.lights i:nth-child(4n+3) { --bulb: #3fb37f; }
.lights i:nth-child(4n+4) { --bulb: #5aa9e6; }
.lights i:nth-child(3n+1)::after { animation-delay: -0.9s; }
.lights i:nth-child(3n+2)::after { animation-delay: -1.8s; }
.lights i:nth-child(5n)::after { animation-duration: 3.6s; }
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; box-shadow: 0 0 3px 0 var(--bulb, #e63946); }
}

/* ---------------------------------------------------------------- the village along the bottom (_village.html) */

body { display: flex; flex-direction: column; }
.page { width: 100%; flex: 1 0 auto; }
.village { flex: none; margin-top: 1.5rem; line-height: 0; position: relative; z-index: 1; pointer-events: none; }
.village svg { display: block; width: 100%; height: 8.5rem; }
/* Plain hex on purpose: the village is scenery, not text, so it isn't part of the contrast tokens. */
.village .v-ground { fill: #dbe6fb; stroke: #9fb4d8; stroke-width: 1.5; }
.village .v-red { fill: #8f1a22; }
.village .v-green { fill: #174f34; }
.village .v-gold { fill: #9c7a1f; }
.village .v-stone { fill: #6e655c; }
.village .v-roof { fill: #3a2619; stroke: #e9f1ff; stroke-width: 4; stroke-linejoin: round; }
.village .v-door, .village .v-trunk { fill: #2a1a12; }
.village .v-tree { fill: #15563a; stroke: #e9f1ff; stroke-width: 1.5; stroke-linejoin: round; }
.village .v-pole { fill: none; stroke: #9aa0b4; stroke-width: 3; stroke-linecap: round; }
.village .v-window { fill: #ffe08a; filter: drop-shadow(0 0 5px #ffc247); animation: window-glow 3.4s ease-in-out infinite alternate; }
.village .v-window:nth-of-type(2n) { animation-delay: -1.1s; }
.village .v-window:nth-of-type(3n) { animation-delay: -2.2s; animation-duration: 4.1s; }
.village .v-cross { fill: none; stroke: #ffffff; stroke-width: 2.4; stroke-linecap: round; }
.village .v-lamp { fill: #ffe9a8; filter: drop-shadow(0 0 5px #ffd36b); }
@keyframes window-glow { from { opacity: 0.8; } to { opacity: 1; } }

/* ---------------------------------------------------------------- snow (app.js adds the flakes) */

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

/* Easter egg: scroll past the bottom for a blizzard and a snowman (app.js) */
.snow.storm { z-index: 50; }
.snow.live { pointer-events: auto; cursor: pointer; touch-action: none; }
html.blizzard-on { overflow: hidden; }
.snowman-panel {
  position: fixed; z-index: 60; top: 0.75rem; left: 50%; transform: translateX(-50%);
  width: min(30rem, calc(100vw - 1.5rem)); padding: 0.8rem 1rem 0.9rem;
  background: var(--night); color: var(--night-text);
  border: 2px solid var(--night-heading); border-radius: var(--radius);
  text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.snowman-title { margin: 0; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--night-heading); }
.snowman-status { margin: 0.2rem 0 0.7rem; min-height: 1.5em; }
.snowman-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.snowman-panel .btn { min-height: 44px; padding: 0.35rem 1rem; }
.snowman-panel .btn-ghost { color: var(--night-heading); border-color: var(--night-heading); }
.snowman-panel :focus-visible { outline-color: var(--night-heading); }

/* ---------------------------------------------------------------- cards with a garland */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.card::before, .datepop::before { /* evergreen garland with berries along the top edge */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  background:
    radial-gradient(circle at 9px 6px, var(--berry) 2.4px, transparent 3px) 0 0 / 54px 12px repeat-x,
    linear-gradient(135deg, var(--garland) 30%, transparent 31%) 0 0 / 12px 12px repeat-x,
    linear-gradient(225deg, var(--garland) 30%, transparent 31%) 0 0 / 12px 12px repeat-x,
    linear-gradient(var(--garland-dark), var(--garland-dark)) 0 0 / 100% 4px no-repeat;
  pointer-events: none;
}

/* Night-sky hero (home and invite) */
.hero {
  background:
    radial-gradient(1.5px 1.5px at 12% 22%, #ffffffcc 99%, transparent),
    radial-gradient(1px 1px at 28% 68%, #ffffffaa 99%, transparent),
    radial-gradient(1.5px 1.5px at 47% 18%, #ffffffbb 99%, transparent),
    radial-gradient(1px 1px at 63% 52%, #ffffff99 99%, transparent),
    radial-gradient(2px 2px at 82% 26%, #fff3c4dd 99%, transparent),
    radial-gradient(1px 1px at 91% 74%, #ffffffaa 99%, transparent),
    linear-gradient(160deg, var(--night) 0%, #13265a 100%);
  color: var(--night-text);
  border-color: transparent;
}
.hero h1 { color: var(--night-heading); font-size: 2.6rem; }
.hero .eyebrow { color: #ffb3b8; }
.hero .hint, .hero .muted { color: var(--night-muted); }
.hero a { color: var(--night-heading); }

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--eyebrow);
}
.lead { font-size: 1.15rem; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.15rem 0 0.4rem; }
.optional, .muted { color: var(--muted); font-weight: 400; }
.optional { font-size: 0.9rem; }

/* ---------------------------------------------------------------- notices */

.notice { border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; color: var(--text); }
.notice h2 { margin-bottom: 0.25rem; }
.notice p { margin: 0; }
.notice .link-row { margin: 0.75rem 0 0; }
.notice-important { background: var(--surface-alt); border: 2px solid var(--notice-border); }
.notice-closed { background: var(--surface-sunk); border: 2px solid var(--field-border); }
.notice-error { background: var(--error-bg); border: 2px solid var(--error); }
.notice-title { font-weight: 800; color: var(--heading); margin: 0 0 0.15rem !important; }
.notice-error .notice-title { color: var(--error); }
.notice-inline { background: var(--surface-alt); border-radius: 10px; padding: 0.6rem 0.8rem; }

.success { color: var(--success); font-weight: 600; }
.error, .error-summary { color: var(--error); font-weight: 600; }
.error { margin: 0.25rem 0 0; font-size: 0.95rem; }
.status-ok { color: var(--success); }

/* ---------------------------------------------------------------- forms */

fieldset { border: 0; padding: 0; margin: 0 0 0.5rem; min-width: 0; }
legend { font-weight: 700; margin-bottom: 0.25rem; padding: 0; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.field-pair > .field { min-width: 0; }
@media (max-width: 400px) { /* date pickers have a wide intrinsic size */
  .field-pair-dates { grid-template-columns: 1fr; gap: 0; }
}

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: 10px;
}
textarea { resize: vertical; }
input[type="date"], input[type="time"] { accent-color: var(--primary); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { cursor: pointer; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--error); border-width: 2px; }

.check {
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 44px; margin-top: 0.4rem;
  font-weight: 600; cursor: pointer;
}
.check input { flex: none; width: 1.4rem; height: 1.4rem; accent-color: var(--primary); margin: 0; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0.6rem 1.25rem;
  border: 2px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 700; text-decoration: none; text-align: center;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary-edge); }
.btn-secondary { background: var(--secondary); color: var(--on-secondary); }
.btn-ghost { background: transparent; color: var(--ghost); border-color: var(--ghost); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-small { min-height: 44px; padding: 0.4rem 1rem; font-size: 0.95rem; background: var(--secondary); color: var(--on-secondary); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) {
  .btn-primary:hover { box-shadow: 0 0 0 3px var(--primary-glow), 0 0 14px 2px var(--primary-glow); }
  .btn-secondary:hover, .btn-small:hover, .btn-ghost:hover { box-shadow: 0 0 0 3px var(--primary-glow); }
  .chip:hover { background: var(--chip-hover); }
}

.link-button {
  min-height: 44px; padding: 0 0.25rem;
  border: 0; background: none;
  color: var(--error); font: inherit; font-weight: 600; text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- chips + pickers */

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.6rem; }
.chip {
  min-height: 44px; padding: 0.4rem 0.9rem;
  border: 2px solid var(--chip-border); border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-text);
  font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--primary); border-color: var(--primary-edge); color: var(--on-primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.deadline-input { display: flex; align-items: center; gap: 0.75rem; }
.deadline-input input { flex: 1; }
.deadline-preview { margin: 0.5rem 0 0; font-size: 0.95rem; }
.deadline-preview strong { color: var(--heading); }
.event-preview { margin-bottom: 1rem; }
.deadline-input .date-wrap { flex: 1; }

/* ---------------------------------------------------------------- holiday date picker (app.js) */

.date-wrap { position: relative; min-width: 0; }
.date-wrap input[type="date"] { padding-right: 3.4rem; }
.date-wrap input[type="date"]::-webkit-calendar-picker-indicator { display: none; }
.date-trigger {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: var(--field-bg); cursor: pointer;
}
.date-trigger:disabled { opacity: 0.4; cursor: not-allowed; }
.date-trigger-icon { /* a tiny desk calendar: red header, two binder rings, a gold dot */
  position: relative; width: 22px; height: 20px;
  border: 2px solid var(--heading); border-radius: 4px;
  background: linear-gradient(var(--primary) 0 6px, transparent 6px);
}
.date-trigger-icon::before {
  content: ""; position: absolute; top: -6px; left: 3px; right: 3px; height: 6px;
  background:
    linear-gradient(var(--heading), var(--heading)) 0 0 / 2px 100% no-repeat,
    linear-gradient(var(--heading), var(--heading)) 100% 0 / 2px 100% no-repeat;
}
.date-trigger-icon::after {
  content: ""; position: absolute; left: 3px; bottom: 2px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--ornament-gold);
}
@media (hover: hover) { .date-trigger:not(:disabled):hover { background: var(--chip-hover); } }

.datepop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0;
  width: 19.5rem; max-width: calc(100vw - 1.5rem);
  padding: 1.35rem 0.6rem 0.4rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: pop-in 0.16s ease-out both;
}
.datepop.end { left: auto; right: 0; }
.datepop::after { /* candy-cane trim along the bottom */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: repeating-linear-gradient(135deg, var(--primary) 0 7px, var(--surface) 7px 14px);
}
.datepop-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.datepop-title {
  flex: 1; text-align: center;
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; line-height: 1.1;
  color: var(--heading);
}
.datepop.december .datepop-title::before,
.datepop.december .datepop-title::after { /* a little snowflake either side of December */
  content: "\2744\FE0E"; font-family: var(--font-body); font-size: 0.8rem;
  color: var(--ornament-gold); margin: 0 0.4rem; vertical-align: 0.15em;
}
.datepop-nav {
  position: relative; flex: none; width: 40px; height: 40px;
  border: 2px solid var(--chip-border); border-radius: 50%;
  background: var(--chip-bg); cursor: pointer;
}
.datepop-nav::before { /* chevron */
  content: ""; position: absolute; top: 50%; left: 50%; width: 9px; height: 9px;
  border-left: 3px solid var(--chip-text); border-bottom: 3px solid var(--chip-text);
}
.datepop-prev::before { transform: translate(-30%, -50%) rotate(45deg); }
.datepop-next::before { transform: translate(-70%, -50%) rotate(-135deg); }
@media (hover: hover) { .datepop-nav:hover { background: var(--chip-hover); } }

.datepop-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.datepop-grid th {
  padding: 0.2rem 0 0.35rem; font-size: 0.8rem; font-weight: 700; color: var(--muted);
}
.datepop-grid td { padding: 1px 0; text-align: center; }
.datepop-day {
  position: relative; display: block; width: 2.4rem; height: 2.4rem; margin: 0 auto;
  border: 2px solid transparent; border-radius: 50%;
  background: none; color: var(--text);
  font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.datepop-day.outside { font-weight: 400; opacity: 0.8; }
.datepop-day.today { border-color: var(--heading); }
.datepop-day.selected {
  background: var(--primary); color: var(--on-primary); border-color: var(--primary-edge);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.datepop-day.off { color: var(--muted); text-decoration: line-through; opacity: 0.55; cursor: not-allowed; }
.datepop-day.eve::after, .datepop-day.xmas::after { /* gold bauble on the 24th, green on the 25th */
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 6px; height: 6px;
  margin-left: -3px; border-radius: 50%;
}
.datepop-day.eve::after { background: var(--ornament-gold); }
.datepop-day.xmas::after { background: var(--garland); }
@media (hover: hover) {
  .datepop-day:not(.selected):not(.off):hover { background: var(--chip-hover); }
}
.datepop-foot { display: flex; justify-content: space-between; padding: 0.2rem 0.4rem 0.7rem; }
.datepop-link {
  min-height: 36px; padding: 0 0.25rem; border: 0; background: none;
  color: var(--link); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer;
}
.datepop-link:disabled { opacity: 0.45; cursor: not-allowed; text-decoration: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: none; } }

/* "73 sleeps until Christmas" on the home page */
.countdown {
  display: inline-block; margin: 0 0 0.6rem; padding: 0.25rem 0.85rem;
  border: 2px solid var(--night-heading); border-radius: 999px;
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--night-heading);
}
/* "12 sleeps until the party" on participant pages, once the date is locked */
.party-countdown { margin: 0.4rem 0 0.8rem; }

.deadline-badge {
  display: inline-block; margin: 0.25rem 0 0.5rem; padding: 0.3rem 0.8rem;
  border-radius: 999px; background: var(--badge-bg); color: var(--badge-text);
  font-weight: 700; font-size: 0.95rem;
}
.deadline-badge.soon { background: var(--badge-soon-bg); color: var(--badge-soon-text); }

/* ---------------------------------------------------------------- copyable links */

.link-row { margin-bottom: 1.1rem; }
.link-row label { display: block; font-weight: 700; }
.link-copy { display: flex; gap: 0.5rem; }
.link-copy input { flex: 1; min-width: 0; font-size: 1rem; text-overflow: ellipsis; }
.copy-fallback { color: var(--error); font-weight: 600; }
.plink { border-top: 1px solid var(--line); padding-top: 0.6rem; margin-top: 0.6rem; }
.plink .link-row { margin-bottom: 0.25rem; }

/* ---------------------------------------------------------------- event details */

.event-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1rem 0 0; }
.event-details dt { font-size: 0.85rem; color: var(--muted); }
.event-details dd { margin: 0; font-weight: 600; }
.event-details .event-location { grid-column: 1 / -1; }
.map-link {
  display: inline-flex; align-items: center; min-height: 44px;
  margin-left: 0.35rem; font-weight: 600; color: var(--link);
}
.last-updated { margin: 0.75rem 0 0; }
.calendar-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.calendar-actions + .hint { margin-top: 0.5rem; }
.event-date-line { margin: 0 0 1rem; }
.people { padding-left: 1.25rem; columns: 2; }
.people-editable { columns: 1; list-style: none; padding: 0; margin: 0 0 0.5rem; }
.people-editable li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  border-bottom: 1px solid var(--line); min-height: 44px;
}
.rotate-invite { margin: -0.5rem 0 1.1rem; }
.reviewer-box { margin-bottom: 1.1rem; }
.reviewer-status { margin: 0.25rem 0; }
.claim-steps { padding-left: 1.25rem; margin: 0.75rem 0 1rem; }
.claim-steps li { margin-bottom: 0.35rem; }
[data-details-changed] p { margin: 0 0 0.6rem; font-weight: 600; }

/* ---------------------------------------------------------------- availability calendar */

.calendar { border: 0; padding: 0; margin: 0.75rem 0 0; min-width: 0; }
/* Extra row gap: the badges sit on the tile's top edge. */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); gap: 1rem 0.5rem; }
.day {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  min-height: 7.6rem; padding: 0.8rem 0.2rem 0.5rem;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--heat-0); color: var(--text);
  cursor: pointer; user-select: none; line-height: 1.15; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.day input {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.day .dow { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.day .date { font-size: 0.95rem; font-weight: 700; }
.day .count { margin-top: 0.35rem; font-size: 1.75rem; font-weight: 800; line-height: 1; }
.day .of { font-size: 0.875rem; font-weight: 600; color: var(--tally); text-wrap: balance; }
/* Fill bar: free / total. An SVG so its width needs no inline style. */
.day .bar {
  display: block; width: calc(100% - 0.6rem); height: 0.45rem; margin-top: auto;
  border: 1px solid var(--bar-fill); border-radius: 3px; background: var(--bar-track);
  box-sizing: content-box; overflow: hidden;
}
.day .of { margin-bottom: 0.4rem; }
.bar-fill { fill: var(--bar-fill); }

/* Heat: how many people are free (tiles, legend and the ranking list). */
.heat-0 { background: var(--heat-0); }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--heat-4); }
.heat-5 { background: var(--heat-5); }
.heat-6 { background: var(--heat-6); }
.best { box-shadow: 0 0 0 3px var(--best); }

/* Badges: the check (your pick) in the top-right corner, "Best" or "The day"
   on the top-left edge. Never frames, so the two signals can't overlap.
   Siblings of the checkbox, not :has(), so older iPhones show them too. */
.pick-badge, .best-badge, .chosen-badge { position: absolute; display: none; pointer-events: none; }
.pick-badge {
  top: -0.6rem; right: -0.5rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 2px solid var(--pick-badge-edge); box-sizing: border-box;
  background: var(--pick-badge); color: var(--on-pick-badge);
  font-size: 0.85rem; font-weight: 800; line-height: calc(1.5rem - 4px); text-align: center;
}
.day input:checked ~ .pick-badge { display: block; }
.best-badge, .chosen-badge {
  top: -0.7rem; left: 0.2rem;
  padding: 0.05rem 0.35rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 800; line-height: 1.2rem; white-space: nowrap;
}
.best-badge { background: var(--best); color: var(--on-best); }
.day.best .best-badge { display: block; }
.chosen-badge { display: block; background: var(--chosen); color: var(--on-chosen); }
.day.chosen { box-shadow: 0 0 0 3px var(--chosen); }
.day .focus-ring {
  position: absolute; top: -2px; right: -2px; bottom: -2px; left: -2px;
  border-radius: 12px; pointer-events: none;
}
.day input:focus-visible ~ .focus-ring { outline: 3px solid var(--focus); outline-offset: 5px; }
.calendar:disabled .day { cursor: default; }
.calendar:disabled .day input { cursor: default; }

/* Christmas Eve and Day get a bauble next to the weekday. */
.ornament { display: inline-block; width: 0.7rem; height: 0.9rem; margin-left: 0.2rem; vertical-align: -0.1rem; }
.ornament .bauble { fill: var(--ornament-red); }
.ornament.gold .bauble { fill: var(--ornament-gold); }
.ornament .cap { fill: #8a8f99; }
.ornament .shine { fill: #ffffff; opacity: 0.55; }

/* Legend: swatches use the same heat classes, so it's right in both themes. */
.heat-legend { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-size: 0.875rem; font-weight: 600; }
.swatches { display: flex; flex: 1; max-width: 14rem; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.swatch { flex: 1; height: 1rem; }
.legend-key { margin-top: 0.4rem; }

/* "Best days so far" card. */
.best-days {
  margin: 0.75rem 0 1rem; padding: 0.75rem 0.9rem;
  border: 2px solid var(--best); border-radius: 12px; background: var(--surface-alt);
}
.best-days h3 { margin: 0 0 0.5rem; font-size: 1.05rem; color: var(--heading); }
.best-empty { margin: 0; }
.best-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.best-entry { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.best-entry summary {
  display: block; min-height: 44px; padding: 0.55rem 2rem 0.55rem 0.75rem;
  position: relative; cursor: pointer; list-style: none;
}
.best-entry summary::-webkit-details-marker { display: none; }
.best-entry summary::after {
  content: "▸"; position: absolute; right: 0.75rem; top: 0.55rem; color: var(--link);
}
.best-entry[open] summary::after { content: "▾"; }
.best-entry-top { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; font-weight: 700; }
.best-entry-missing { display: block; margin-top: 0.15rem; font-size: 0.9rem; color: var(--muted); }
.day-detail { padding: 0 0.75rem 0.75rem; }
.day-detail p { margin: 0 0 0.5rem; }

.save-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.75rem; }
.save-status { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--success); }
.save-status.is-error { color: var(--error); }
.stale-notice { margin: 0 0 0.75rem; }
/* A form on its way (app.js stops repeat taps); no fading, so labels keep their contrast. */
.btn.is-busy { cursor: progress; }

/* ---------------------------------------------------------------- organizer / host */

.verdict { margin-bottom: 1rem; }
.verdict ul { padding-left: 1.25rem; margin: 0.25rem 0; }
.locked-box {
  background: var(--surface-alt); border: 2px solid var(--notice-border);
  border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 1rem;
}
.locked-box p { margin-top: 0; }
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.rank-row { border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem; }
.rank-row.chosen { border: 3px solid var(--chosen); }
.rank-main { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.rank-day, .rank-count { font-weight: 700; }
.rank-missing { margin: 0.2rem 0 0.4rem; font-size: 0.9rem; }
/* Shaded rows: full-strength text, the grey hint colour is too faint on busy days. */
.rank-row .muted { color: var(--tally); font-style: italic; }
.unpicked, .danger-zone, .participant-links { margin-top: 0.75rem; }
details > summary {
  cursor: pointer; font-weight: 600; min-height: 44px;
  display: flex; align-items: center;
}
.danger-zone { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.danger-zone summary { color: var(--error); }
.unpicked .ranking { margin-top: 0.5rem; }

.exclusions { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.25rem; }
.exclusions li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  border-bottom: 1px solid var(--line); padding: 0.25rem 0; min-height: 44px;
}
.exclusion-form { margin-top: 0.5rem; }
/* Last year's exclusions, by name, waiting for both people to join */
.exclusions-ready { margin: 0 0 1rem; padding: 0.75rem 0.9rem; border: 1px dashed var(--line); border-radius: 12px; }
.exclusions-ready p { margin: 0 0 0.4rem; }
/* Reviewer: a pair that repeats last year's draw */
.repeat-flag {
  display: inline-block; margin-left: 0.35rem; padding: 0 0.5rem; border-radius: 999px;
  background: var(--badge-bg); color: var(--badge-text); font-size: 0.85rem; font-weight: 700;
}
.opened-count { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.25rem; }
.discard-form { margin-top: 0.75rem; }

/* In-page confirm (replaces window.confirm, which in-app browsers can swallow) */
.confirm-box, .release-form {
  margin-top: 0.5rem; padding: 0.9rem;
  border: 2px solid var(--notice-border); border-radius: 12px; background: var(--surface-alt);
}
.confirm-box p { margin: 0 0 0.6rem; font-weight: 600; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.release { margin-top: 0.5rem; }
.release-question { margin-top: 0; }

/* ---------------------------------------------------------------- reviewer */

.matches { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.matches th { text-align: left; font-size: 0.85rem; color: var(--muted); padding: 0.25rem 0.4rem; }
.matches td { padding: 0.55rem 0.4rem; border-top: 1px solid var(--line); font-weight: 600; }
.matches .arrow { color: var(--eyebrow); text-align: center; width: 2rem; }
.adjust-form + .adjust-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.summary-line { font-weight: 700; }

/* ---------------------------------------------------------------- the match + reveal */

.match-name {
  font-family: var(--font-display);
  font-size: 2.8rem; line-height: 1.05; font-weight: 700;
  color: var(--eyebrow); margin: 0 0 0.75rem;
}
.wishlist { white-space: pre-line; overflow-wrap: anywhere; }
.match-detail { margin: 0.75rem 0 0; }
.about-list { margin: 0.25rem 0 0.75rem; padding-left: 1.25rem; overflow-wrap: anywhere; }
.about-list li { margin-bottom: 0.25rem; }
.about-fields { margin-bottom: 1rem; }
.about-fields .field { margin-bottom: 0.6rem; }
.santa-help { margin: 0 0 1rem; border: 1px solid var(--line); border-radius: 10px; padding: 0 0.85rem; }
.santa-help summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--link); }
.santa-help[open] summary { margin-bottom: 0.5rem; }
.wishlist a { overflow-wrap: anywhere; }
.replay { margin-top: 1rem; }
.recover-link { text-align: center; margin-top: 1.5rem; }

/* A present drawn in CSS. Closed before the reveal POST; after it the page
   lands with .play: unties the bow, lifts the lid, bursts a little confetti
   and fades in the name. Reduced motion: a plain fade. */
.gift-stage { display: flex; justify-content: center; padding: 0.5rem 0 1rem; }
.gift { position: relative; width: 132px; height: 128px; }
.gift-box {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 84px;
  background: var(--gift); border-radius: 6px;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12);
}
.gift-box::before, .gift-lid::before { /* ribbon */
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 18px; margin-left: -9px;
  background: var(--ribbon);
}
.gift-lid {
  position: absolute; left: 0; right: 0; top: 26px; height: 24px; z-index: 2;
  background: var(--gift-lid); border-radius: 6px; transform-origin: 15% 100%;
}
.bow { position: absolute; left: 50%; top: -24px; width: 0; height: 0; transform-origin: 0 24px; }
.bow::before, .bow::after {
  content: ""; position: absolute; top: 0; width: 34px; height: 24px;
  border: 7px solid var(--ribbon); border-radius: 50% 50% 40% 40%;
}
.bow::before { right: 0; transform: rotate(-18deg); transform-origin: 100% 100%; }
.bow::after { left: 0; transform: rotate(18deg); transform-origin: 0 100%; }
.gift-stage.closed .gift { animation: gift-idle 2.4s ease-in-out infinite; }

.reveal { position: relative; }
.reveal.play { min-height: 190px; }
.reveal .gift-stage { display: none; }
.reveal.play .gift-stage { display: flex; position: absolute; top: 0; left: 0; right: 0; pointer-events: none; z-index: 3; }
.reveal.play .gift { animation: gift-shake 0.5s ease-in-out 0s 1, gift-away 0.5s ease-in 1.25s both; }
.reveal.play .bow { animation: bow-untie 0.45s ease-in 0.45s both; }
.reveal.play .gift-lid { animation: lid-off 0.6s cubic-bezier(.3, .6, .4, 1) 0.8s both; }
.reveal.play .match-content { animation: content-in 0.7s ease-out 1.45s both; }

.confetti { position: absolute; left: 50%; top: 70px; width: 0; height: 0; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0; background: var(--ribbon); }
.confetti i:nth-child(3n+1) { background: var(--gift); }
.confetti i:nth-child(3n+2) { background: #2f8f5b; width: 7px; height: 7px; border-radius: 50%; }
.reveal.play .confetti i { animation: confetti 1.1s cubic-bezier(.2, .7, .3, 1) 1.1s both; }
.confetti i:nth-child(1)  { --x: -120px; --y: -70px;  --r: 220deg; }
.confetti i:nth-child(2)  { --x: -90px;  --y: -120px; --r: -160deg; }
.confetti i:nth-child(3)  { --x: -50px;  --y: -140px; --r: 300deg; }
.confetti i:nth-child(4)  { --x: -10px;  --y: -150px; --r: -240deg; }
.confetti i:nth-child(5)  { --x: 30px;   --y: -145px; --r: 180deg; }
.confetti i:nth-child(6)  { --x: 70px;   --y: -125px; --r: -320deg; }
.confetti i:nth-child(7)  { --x: 110px;  --y: -90px;  --r: 260deg; }
.confetti i:nth-child(8)  { --x: 130px;  --y: -40px;  --r: -200deg; }
.confetti i:nth-child(9)  { --x: -135px; --y: -20px;  --r: 140deg; }
.confetti i:nth-child(10) { --x: -70px;  --y: -95px;  --r: -280deg; }
.confetti i:nth-child(11) { --x: 50px;   --y: -100px; --r: 340deg; }
.confetti i:nth-child(12) { --x: 95px;   --y: -150px; --r: -120deg; }
.confetti i:nth-child(13) { --x: -105px; --y: -150px; --r: 200deg; }
.confetti i:nth-child(14) { --x: 10px;   --y: -110px; --r: -300deg; }

@keyframes gift-idle { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-2deg) translateY(-2px); } }
@keyframes gift-shake {
  0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg); }
  40% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(3deg); }
}
@keyframes bow-untie { to { transform: scale(0.2) rotate(40deg); opacity: 0; } }
@keyframes lid-off { to { transform: translate(-30px, -70px) rotate(-28deg); opacity: 0; } }
@keyframes gift-away { to { transform: scale(0.6) translateY(30px); opacity: 0; } }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; }
}
@keyframes content-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------- small phones */

@media (max-width: 400px) {
  .page { padding-left: 0.75rem; padding-right: 0.75rem; }
  .card { padding: 1.5rem 0.9rem 1rem; }
  .notice { padding: 0.9rem; }
  h1 { font-size: 2.05rem; }
  .hero h1 { font-size: 2.3rem; }
  .match-name { font-size: 2.4rem; }
  .days { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem 0.4rem; }
}

/* ---------------------------------------------------------------- reduced motion:
   no snow, no twinkle, no confetti or unwrapping (a plain fade instead). */
@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
  .lights i::after { animation: none; }
  .datepop { animation: none; }
  .village .v-window { animation: none; }
  .gift-stage.closed .gift { animation: none; }
  .reveal.play .gift-stage { display: none; }
  .reveal.play .confetti i { animation: none; }
  .reveal.play .match-content { animation: fade-in 0.4s ease-out both; }
}

/* "Save your link" card on participant pages */
.save-link > summary { list-style: none; }
.save-link > summary::-webkit-details-marker { display: none; }
.save-link > summary h2 { margin: 0; }
.save-link > summary h2::after { content: " \25BE"; font: 700 0.8em system-ui, sans-serif; }
.save-link:not([open]) > summary h2::after { content: " \25B8"; }
.save-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1rem; }
.save-actions .btn { min-height: 44px; display: inline-flex; align-items: center; }
.in-app-hint { margin: 0.75rem 0; }
.in-app-hint p { margin: 0; }
.home-screen { margin-top: 0.75rem; }
.home-screen > summary::after { content: " \25BE"; font: 700 0.8em system-ui, sans-serif; margin-left: 0.3em; }
.home-screen:not([open]) > summary::after { content: " \25B8"; }
.home-screen ol { margin: 0.25rem 0 0.75rem; padding-left: 1.4rem; }
.home-screen-os { margin: 0.5rem 0 0; }
.saved-it { margin-top: 0.75rem; min-height: 44px; }
.save-link-again { text-align: center; margin: 0.5rem 0 1rem; }

/* Lost-link page: three plain steps */
.recover-steps { padding-left: 1.4rem; margin: 0.75rem 0 0; }
.recover-steps > li { margin-bottom: 1.25rem; }
.recover-steps h2 { font-size: 1.15rem; margin: 0 0 0.35rem; }
.recover-steps p { margin: 0 0 0.6rem; }

/* Reviewer: ready-to-send message after "Issue new link" */
.reissued { margin: 0.5rem 0 1rem; padding: 0.9rem; border: 2px solid var(--notice-border); border-radius: 12px; background: var(--surface-alt); }
.reissued label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.reissued textarea { width: 100%; font-size: 1rem; }
.reissued .save-actions { margin-bottom: 0; }

/* Secret emoji grid: radio buttons drawn as big tiles (works without JS) */
.emoji-field { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.emoji-field legend { font-weight: 700; padding: 0; margin-bottom: 0.35rem; }
.emoji-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; max-width: 22rem; }
.emoji-tile { position: relative; display: block; cursor: pointer; }
.emoji-tile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.emoji-tile span {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface-alt);
  font: 1.9rem/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-tile input:checked + span { border-color: var(--notice-border); box-shadow: 0 0 0 3px var(--notice-border); }
.emoji-tile input:focus-visible + span { outline: 3px solid var(--link); outline-offset: 2px; }
.emoji-field.has-error .emoji-tile span { border-color: var(--error); }
.old-pin { margin: 0 0 1rem; }
