/* Secret Santa: festive, but never in the way. Mobile first. */

:root {
  --red: #8e1c24;
  --red-bright: #b3262e;
  --green: #1d5c43;
  --green-soft: #e3efe8;
  --gold: #c9962b;
  --cream: #fbf6ec;
  --paper: #ffffff;
  --ink: #2b2420;
  --ink-soft: #6b5f57;
  --line: #e6dccb;
  --danger: #a3191f;
  --danger-soft: #fbe9e9;

  --radius: 14px;
  --shadow: 0 1px 2px rgb(43 36 32 / 0.06), 0 8px 24px rgb(43 36 32 / 0.08);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

/* Components set display:flex/grid, which would otherwise beat [hidden]. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 1rem/1.55 var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgb(179 38 46 / 0.08), transparent 40%),
    radial-gradient(circle at 110% 10%, rgb(29 92 67 / 0.08), transparent 40%),
    var(--cream);
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.5rem;
}
h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); color: var(--red); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }

a { color: var(--red); }
a:hover { color: var(--red-bright); }

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--paper);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

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

/* --- header -------------------------------------------------------------- */

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--red);
  color: #fff;
  /* a candy-cane edge */
  border-bottom: 6px solid transparent;
  border-image: repeating-linear-gradient(-45deg, #fff 0 10px, var(--red-bright) 10px 20px) 6;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.brand:hover { color: #fff; }
.brand-icon { font-size: 1.4rem; }

#account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}
#account a { color: #fff; }
#account .button { --bg: transparent; border-color: rgb(255 255 255 / 0.6); color: #fff; }

/* --- layout -------------------------------------------------------------- */

main {
  position: relative;
  z-index: 1;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
main:focus { outline: none; }

.loading { color: var(--ink-soft); text-align: center; padding: 3rem 0; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 0 0 1.25rem;
}

.stack > * + * { margin-top: 1rem; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }

.hero {
  text-align: center;
  padding: 2rem 0 1rem;
}
.hero .lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 30rem; margin: 0 auto 1.5rem; }
.hero-art { font-size: 3.5rem; line-height: 1; margin-bottom: 1rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.row.center { justify-content: center; }
.spread { justify-content: space-between; }

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

.button {
  --bg: var(--red);
  --fg: #fff;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem; /* comfortable touch target */
  padding: 0.55rem 1.1rem;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.button:hover { color: var(--fg); background: color-mix(in srgb, var(--bg) 88%, #000); }
.button:active { transform: translateY(1px); }
.button[disabled] { opacity: 0.6; cursor: progress; }

.button.secondary { --bg: var(--paper); --fg: var(--red); border-color: var(--line); }
.button.secondary:hover { background: var(--cream); }
.button.green { --bg: var(--green); }
.button.danger { --bg: var(--danger); }
.button.small { min-height: 2.25rem; padding: 0.3rem 0.8rem; font-size: 0.9rem; }

.link-button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.25rem;
  color: var(--red);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

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

.field { display: grid; gap: 0.3rem; margin-bottom: 1rem; }
.field label { font-weight: 600; }
.field .hint { font-size: 0.9rem; color: var(--ink-soft); }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 7rem; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--gold); }

[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.9rem; font-weight: 600; }
.field-error:empty { display: none; }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}
.form-error:empty { display: none; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end; /* buttons line up with the inputs, wrapped or not */
}
.inline-form .field { flex: 1 1 12rem; margin: 0; }

/* --- lists --------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--line);
}
.list > li:last-child { border-bottom: 0; }
.list .who { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; font-weight: 600; overflow-wrap: anywhere; }
.list .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.game-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.game-link:hover h3 { color: var(--red); }

.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--green-soft);
  color: var(--green);
  vertical-align: middle;
}
.badge.locked { background: #f6e7c8; color: #7a5410; }
.badge.waiting { background: #eee8e1; color: var(--ink-soft); }

.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 1rem 0;
}
.empty .art { font-size: 2.25rem; display: block; margin-bottom: 0.25rem; }

.invite-link {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.invite-link input { font-size: 0.85rem; min-height: 2.25rem; padding: 0.3rem 0.6rem; }

/* --- reveal card --------------------------------------------------------- */

.reveal {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 0.5rem 0 1rem;
}

.flip-card {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: min(100%, 20rem);
  aspect-ratio: 3 / 4;
  perspective: 1200px;
  border-radius: 18px;
}
.flip-card[disabled] { cursor: default; }

.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1.1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border-radius: 18px;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 12px 30px rgb(43 36 32 / 0.25);
}

/* wrapping paper with a ribbon */
.face.front {
  color: #fff;
  background:
    linear-gradient(90deg, transparent 44%, var(--gold) 44% 56%, transparent 56%),
    linear-gradient(0deg, transparent 44%, var(--gold) 44% 56%, transparent 56%),
    repeating-linear-gradient(45deg, var(--red) 0 18px, var(--red-bright) 18px 36px);
}
.face.front .bow { font-size: 3rem; line-height: 1; }
.face.front .tap {
  background: rgb(0 0 0 / 0.35);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
}

.face.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 0, rgb(201 150 43 / 0.25), transparent 60%),
    var(--paper);
  border: 3px solid var(--gold);
}
.face.back .label { color: var(--ink-soft); font-size: 0.95rem; }
.face.back .name {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  color: var(--green);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.flip-card:not(.flipped):hover .flip-inner { transform: rotateY(-8deg) rotateX(3deg); }

.wishes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--green-soft);
  border-radius: 10px;
  padding: 1rem;
  margin: 0;
  font: inherit;
}

/* --- dialog -------------------------------------------------------------- */

dialog {
  width: min(32rem, calc(100vw - 2rem));
  border: 0;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
  color: var(--ink);
}
dialog::backdrop { background: rgb(43 36 32 / 0.55); }
dialog h2 { color: var(--red); }

/* --- toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 20;
  visibility: hidden;
  transform: translate(-50%, calc(100% + 2rem));
  background: var(--green);
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-weight: 600;
  text-align: center;
  width: max-content;
  max-width: calc(100vw - 2rem);
  transition: transform 0.25s ease;
}
.toast.show { visibility: visible; transform: translate(-50%, 0); }

/* --- snow ---------------------------------------------------------------- */

.snow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(3px 3px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 80px 120px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 150px 60px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 210px 170px, #fff 50%, transparent 51%),
    radial-gradient(4px 4px at 260px 20px, #fff 50%, transparent 51%);
  background-size: 300px 220px;
  filter: drop-shadow(0 0 1px rgb(120 140 160 / 0.6));
  opacity: 0.8;
  animation: snowfall 18s linear infinite;
}
@keyframes snowfall {
  to { background-position: 60px 220px; }
}

/* --- small celebratory bounce ------------------------------------------- */

@keyframes pop {
  0% { transform: scale(0.95); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.4s ease-out; }

/* --- wider screens ------------------------------------------------------- */

@media (min-width: 40rem) {
  main { padding-top: 2.5rem; }
  .card { padding: 1.5rem 1.75rem; }
}

/* --- reduced motion: keep the charm, lose the movement ------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .snow { animation: none; }
  /* Cross-fade instead of a 3D flip */
  .flip-inner { transform: none !important; }
  .face { backface-visibility: visible; transition: opacity 0.3s ease !important; }
  .face.back { transform: none; opacity: 0; }
  .flip-card.flipped .face.front { opacity: 0; }
  .flip-card.flipped .face.back { opacity: 1; }
}
