/* Secret Santa: the setup form, the organizer page and each person's page.
   Built on the site's theme tokens, so it follows light and dark mode. */

.ss { --ss-red: #c8382c; --ss-red-deep: #8f1f1a; }
[data-theme="dark"] .ss { --ss-red: #ef6b5f; }

/* ---- Setup form ---- */
.ss-setup { display: grid; gap: 1rem; }
@media (min-width: 64rem) {
  .ss-setup { grid-template-columns: minmax(0, 1fr) 24rem; align-items: start; }
}
.ss-alert {
  grid-column: 1 / -1;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in oklab, var(--color-error) 40%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--color-error) 10%, var(--color-base-100));
  color: var(--color-error);
  font-size: 0.9375rem;
}
.ss-panel {
  padding: 1.25rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-md);
  background: var(--color-base-100);
}
@media (min-width: 40rem) { .ss-panel { padding: 1.75rem; } }
.ss-field + .ss-field, .ss-pair, .ss-pair + .ss-field { margin-top: 1.4rem; }
.ss-pair .ss-field { margin-top: 0; }
.ss-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 22rem) { .ss-pair { grid-template-columns: minmax(0, 1fr); } }
.ss-label { display: block; margin-bottom: 0.4rem; font-size: 0.9375rem; font-weight: 600; }
.ss-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.ss-label-row .ss-label { margin-bottom: 0; }
.ss-optional { margin-left: 0.25rem; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.ss-help { margin: 0.2rem 0 0.6rem; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.ss-error { margin-top: 0.4rem; font-size: 0.8125rem; color: var(--color-error); }
.ss-count { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ss-count.is-warn { color: var(--color-error); }
.ss textarea { font-size: 1rem; line-height: 1.5; }   /* 16px keeps iOS from zooming in */
.ss-groups { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0 0; padding: 0; list-style: none; }
.ss-groups:empty { display: none; }
.ss-groups li {
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--color-base-content) 7%, transparent);
  font-size: 0.8125rem;
}
.ss-groups li.is-bad { background: color-mix(in oklab, var(--color-error) 14%, transparent); color: var(--color-error); }
.ss-details .btn-primary { gap: 0.5rem; margin-top: 1.6rem; }
.ss-fine { margin-top: 0.75rem; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }

/* ---- Organizer and personal pages ---- */
.ss-page { max-width: 54rem; padding-top: 2.5rem; padding-bottom: 1rem; }
.ss-narrow { max-width: 40rem; }
.ss-page h1 { margin-top: 0.5rem; overflow-wrap: anywhere; }
.ss-kicker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ss-red);
}
.ss-facts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.ss-facts li {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-base-300);
  border-radius: 999px;
  background: var(--color-base-100);
  font-size: 0.875rem;
}
.ss-page .ss-panel { margin-top: 1.25rem; }
.ss-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; }
.ss-progress { font-size: 0.875rem; color: var(--muted); }
.ss-progress strong { color: var(--color-base-content); }
.ss-panel-head + .ss-help { margin-top: 0.5rem; }

.ss-callout {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid color-mix(in oklab, var(--color-success) 40%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--color-success) 11%, var(--color-base-100));
  font-size: 0.9375rem;
  line-height: 1.55;
}
.ss-callout-title { font-weight: 700; }
.ss-linkbox { display: flex; gap: 0.5rem; margin-top: 0.85rem; }
.ss-linkbox .input { min-width: 0; font-size: 0.875rem; }
.ss-linkbox + .ss-copy-label { margin-top: 1.25rem; }
.ss-copy-label { margin-top: 1rem; margin-bottom: 0; font-size: 0.8125rem; color: var(--muted); }
.ss-copy-label + .ss-linkbox { margin-top: 0.4rem; }
/* The ready-made message: shown as it will be sent, with its own copy button. */
.ss-message {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.4rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--color-base-300);
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--color-base-content) 3%, transparent);
}
.ss-message-text { flex: 1 1 18rem; min-width: 0; font-size: 0.9375rem; line-height: 1.5; overflow-wrap: anywhere; }
.ss-message-link { color: var(--muted); font-size: 0.875rem; }
.ss-message .btn { gap: 0.35rem; }

.ss-list { margin: 1rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--color-base-300); }
.ss-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--color-base-300);
}
.ss-row-main { flex: 1 1 15rem; min-width: 0; }
.ss-row-name { font-weight: 650; overflow-wrap: anywhere; }
.ss-row-status { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }
.ss-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in oklab, var(--color-base-content) 7%, transparent);
  font-size: 0.75rem;
  color: var(--muted);
}
.ss-icon-sm { width: 0.875rem; height: 0.875rem; }
.ss-tag.is-done {
  background: color-mix(in oklab, var(--color-success) 16%, transparent);
  color: color-mix(in oklab, var(--color-success) 65%, var(--color-base-content));
}
.ss-row-link {
  margin-top: 0.35rem;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}
.ss-row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ss-row-actions .btn, .ss-linkbox .btn { gap: 0.35rem; }
.ss .btn.is-copied { border-color: color-mix(in oklab, var(--color-success) 50%, transparent); color: color-mix(in oklab, var(--color-success) 70%, var(--color-base-content)); }

.ss-note { margin-top: 0.5rem; line-height: 1.6; overflow-wrap: anywhere; }
.ss-note a { text-decoration: underline; text-underline-offset: 2px; }
.ss-confirm { margin-top: 0.85rem; }
.ss-confirm > summary { list-style: none; }
.ss-confirm > summary::-webkit-details-marker { display: none; }
.ss-confirm-body {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--color-error) 8%, var(--color-base-100));
  font-size: 0.9375rem;
}
.ss-btn-danger { margin-top: 0.7rem; border-color: transparent; background: var(--color-error); color: var(--color-error-content); }
.ss-back { margin-top: 1.5rem; font-size: 0.9375rem; }
.ss-center { text-align: center; }

/* ---- Reveal ---- */
.ss-gate { margin-top: 1rem; padding-block: 2.5rem; text-align: center; }
.ss-gate h1 { margin-top: 0; }
.ss-gate-lead { margin: 0.75rem 0 1.5rem; font-size: 1.125rem; color: var(--muted); }
.ss-gate .btn { gap: 0.5rem; }
.ss-gate-hint { margin-top: 0.9rem; font-size: 0.875rem; color: var(--muted); }

/* The reveal button: big, red and glowing, so it's plain it wants a tap. A gold
   ring pulses out of it and a shine sweeps across now and then. */
.ss-reveal-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.75rem;
  padding: 0.75rem 1.75rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(160deg, #e0503f, #a3241c);
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgb(246 185 59 / .6), 0 12px 28px -10px rgb(163 36 28 / .75), inset 0 1px 0 rgb(255 255 255 / .25);
  animation: ss-glow 1.9s ease-out infinite;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), filter .2s ease;
}
.ss-reveal-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .38) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: ss-shine 3.2s ease-in-out 1s infinite;
  pointer-events: none;
}
.ss-reveal-btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.06); }
.ss-reveal-btn:active { transform: scale(.97); }
.ss-reveal-btn:focus-visible { outline: 3px solid #f6b93b; outline-offset: 3px; }
.ss-reveal-btn:disabled { cursor: progress; animation: none; }
.ss-reveal-btn:disabled::after { animation: none; }
@keyframes ss-glow {
  0% { box-shadow: 0 0 0 0 rgb(246 185 59 / .65), 0 12px 28px -10px rgb(163 36 28 / .75), inset 0 1px 0 rgb(255 255 255 / .25); }
  70%, 100% { box-shadow: 0 0 0 18px rgb(246 185 59 / 0), 0 12px 28px -10px rgb(163 36 28 / .75), inset 0 1px 0 rgb(255 255 255 / .25); }
}
@keyframes ss-shine { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }

/* The present: built from boxes, red with a gold ribbon and bow. It bobs and
   wiggles while it waits; app.js adds .is-shaking (shakes harder and grows
   while the reveal saves) then .is-bursting (the lid flies, the box pops). */
.ss-present {
  position: relative;
  display: block;
  width: 7.5rem;
  height: 7.25rem;
  margin: 0 auto 1.25rem;
  cursor: pointer;
  animation: ss-wait 3.4s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.ss-present-box, .ss-present-lid { position: absolute; display: block; }
.ss-present-box {
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0;
  height: 4.6rem;
  border-radius: 0.45rem;
  background:
    linear-gradient(90deg, transparent 41%, #f6b93b 41% 59%, transparent 59%),
    linear-gradient(165deg, #d9473a, #9a221b);
  box-shadow: inset 0 -0.5rem 0 rgb(0 0 0 / .12), 0 16px 24px -14px rgb(120 20 15 / .7);
}
.ss-present-lid {
  z-index: 1;
  left: 0;
  right: 0;
  top: 1.45rem;
  height: 1.55rem;
  border-radius: 0.4rem;
  background:
    linear-gradient(90deg, transparent 41%, #fbc85a 41% 59%, transparent 59%),
    linear-gradient(165deg, #e8594b, #b02c23);
  box-shadow: 0 4px 0 rgb(0 0 0 / .1);
  transform-origin: 50% 100%;
}
/* The bow: two gold loops on the lid. */
.ss-present-bow { position: absolute; left: 50%; bottom: 100%; width: 0; height: 0; }
.ss-present-bow::before, .ss-present-bow::after {
  content: "";
  position: absolute;
  bottom: -0.2rem;
  width: 1.7rem;
  height: 1.3rem;
  border: 0.42rem solid #f6b93b;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.ss-present-bow::before { right: -0.1rem; transform: rotate(-24deg); transform-origin: 100% 100%; }
.ss-present-bow::after { left: -0.1rem; transform: rotate(24deg); transform-origin: 0 100%; }
.ss-present-glow {
  position: absolute;
  inset: -1.5rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 236 170 / .95), rgb(246 185 59 / .45) 35%, transparent 65%);
  opacity: 0;
  transform: scale(.4);
  pointer-events: none;
}
.ss-present:hover { animation-play-state: paused; }

@keyframes ss-wait {
  0%, 62%, 100% { transform: translateY(0) rotate(0); }
  31% { transform: translateY(-6px) rotate(0); }
  70% { transform: rotate(-6deg); }
  76% { transform: rotate(5deg); }
  82% { transform: rotate(-4deg); }
  88% { transform: rotate(2deg); }
}

/* Shaking: harder and bigger over 1.6s, then a steady rattle if the server's slow. */
.is-shaking .ss-present { animation: ss-build 1.6s ease-in both, ss-rattle .16s linear 1.6s infinite; }
.is-shaking .ss-present-lid { animation: ss-lid .14s ease-in-out infinite alternate; }
.is-shaking .ss-present-glow { opacity: .55; transform: scale(.9); transition: opacity 1.4s ease-in, transform 1.4s ease-in; }
@keyframes ss-build {
  0% { transform: rotate(0) scale(1); }
  10% { transform: rotate(-3deg) scale(1.01); }
  20% { transform: rotate(3deg) scale(1.02); }
  30% { transform: rotate(-5deg) scale(1.04); }
  40% { transform: rotate(6deg) scale(1.05); }
  50% { transform: rotate(-8deg) scale(1.07) translateY(-2px); }
  60% { transform: rotate(9deg) scale(1.09) translateY(-3px); }
  70% { transform: rotate(-11deg) scale(1.11) translateY(-3px); }
  80% { transform: rotate(12deg) scale(1.13) translateY(-4px); }
  90% { transform: rotate(-13deg) scale(1.15) translateY(-4px); }
  100% { transform: rotate(0) scale(1.17) translateY(-4px); }
}
@keyframes ss-rattle {
  0%, 100% { transform: rotate(-9deg) scale(1.17) translateY(-4px); }
  50% { transform: rotate(9deg) scale(1.17) translateY(-4px); }
}
@keyframes ss-lid { from { transform: translateY(0); } to { transform: translateY(-4px) rotate(-2deg); } }

/* Bursting: the lid flies up and spins away, the box swells and pops in a flash. */
.is-bursting .ss-present { animation: none; transform: scale(1.17) translateY(-4px); }
.is-bursting .ss-present-lid { animation: ss-lid-off .6s cubic-bezier(.2, .7, .3, 1) forwards; }
.is-bursting .ss-present-box { animation: ss-pop-box .5s cubic-bezier(.3, 0, .6, 1) .08s forwards; }
.is-bursting .ss-present-glow { animation: ss-flash .6s ease-out forwards; }
@keyframes ss-lid-off { to { transform: translate(2.5rem, -8rem) rotate(40deg); opacity: 0; } }
@keyframes ss-pop-box { 40% { transform: scale(1.25, .9); } to { transform: scale(1.6); opacity: 0; } }
@keyframes ss-flash { 30% { opacity: 1; transform: scale(1.6); } to { opacity: 0; transform: scale(2.4); } }

.ss-confetti { position: fixed; z-index: 60; inset: 0; overflow: hidden; pointer-events: none; }
.ss-confetti i { position: absolute; display: block; width: 0.5rem; height: 0.8rem; border-radius: 2px; }
.ss-confetti i.is-round { width: 0.55rem; height: 0.55rem; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) {
  .ss-present, .ss-reveal-btn, .ss-reveal-btn::after { animation: none; }
  .is-shaking .ss-present, .is-shaking .ss-present-lid { animation: none; }
  .is-bursting .ss-present-lid, .is-bursting .ss-present-box, .is-bursting .ss-present-glow { animation: none; opacity: 0; }
}

/* Anchored jumps (#match, #wishlist) land below the sticky site header. */
.ss-reveal, .ss-page .ss-panel { scroll-margin-top: 5.5rem; }
.ss-reveal {
  margin-top: 1rem;
  padding: 2.25rem 1.25rem 1.75rem;
  border-radius: 1.25rem;
  background:
    radial-gradient(circle at 20% 15%, rgb(255 255 255 / .16) 0 2px, transparent 3px) 0 0 / 46px 46px,
    linear-gradient(160deg, #d2463a, #8f1f1a);
  color: #fff;
  text-align: center;
}
.ss-reveal-lead { font-size: 1.0625rem; opacity: .92; }
.ss-page .ss-reveal-name { margin-top: 0.35rem; font-size: clamp(2.5rem, 10vw, 4.5rem); line-height: 1.05; }
.ss-reveal .ss-facts { justify-content: center; }
.ss-reveal .ss-facts li { border-color: rgb(255 255 255 / .35); background: rgb(255 255 255 / .12); color: #fff; }
.ss-reveal .ss-fine { color: rgb(255 255 255 / .85); }
.ss-reveal.is-fresh .ss-reveal-name { animation: ss-pop .7s cubic-bezier(.2, .9, .3, 1.3) .15s both; }
@keyframes ss-pop { from { opacity: 0; transform: scale(.6) translateY(.5rem); } }
.ss-reveal.is-fresh { animation: ss-card-in .5s cubic-bezier(.2, .9, .3, 1.15) both; }
@keyframes ss-card-in { from { opacity: 0; transform: scale(.92); } }
@media (prefers-reduced-motion: reduce) { .ss-reveal.is-fresh, .ss-reveal.is-fresh .ss-reveal-name { animation: none; } }

.ss-wishlist-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; }
.ss-saved {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.6rem;
  font-size: 0.875rem;
  color: color-mix(in oklab, var(--color-success) 70%, var(--color-base-content));
}

/* ---- How people get their match (setup form) ---- */
.ss-delivery { margin-top: 1.4rem; padding: 0; border: 0; }
.ss-choice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.ss-choice:has(input:checked) {
  border-color: color-mix(in oklab, var(--ss-red) 55%, transparent);
  background: color-mix(in oklab, var(--ss-red) 6%, var(--color-base-100));
}
.ss-choice input { margin-top: 0.2rem; accent-color: var(--ss-red); flex: none; }
.ss-choice-title { display: block; font-size: 0.9375rem; font-weight: 600; }
.ss-choice-help { display: block; margin-top: 0.1rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }

/* ---- Your draws (signed in) ---- */
.ss-yours { margin-bottom: 1rem; }
.ss-yours .ss-list { margin-top: 0.75rem; }

/* ---- Group link: pick your name ---- */
.ss-names {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.ss-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 3.25rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-base-300);
  border-radius: var(--r-sm);
  background: var(--color-base-100);
  font-weight: 650;
  overflow-wrap: anywhere;
  transition: border-color .15s, background-color .15s;
}
.ss-name:hover, .ss-name:focus-visible {
  border-color: color-mix(in oklab, var(--ss-red) 55%, transparent);
  background: color-mix(in oklab, var(--ss-red) 6%, var(--color-base-100));
}
.ss-name.is-taken { color: var(--muted); font-weight: 500; background: var(--color-base-200); }
.ss-name.is-mine { border-color: color-mix(in oklab, var(--color-success) 50%, transparent); }
.ss-mine { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.ss-mine .btn { gap: 0.35rem; }
.ss-gate .ss-mine { justify-content: center; gap: 0.75rem; margin: 1.25rem 0 0.5rem; }
.ss-gate .ss-gate-lead:first-child, .ss-gate .ss-alert + .ss-gate-lead { margin: 0 0 0.25rem; }
a.ss-reveal-btn { text-decoration: none; }
.ss-gate h2 { overflow-wrap: anywhere; }
.ss-gate .ss-alert { margin-bottom: 1.25rem; text-align: left; }
.ss-claim { display: grid; justify-items: center; gap: 1rem; }
.ss-claim .ss-field { text-align: left; max-width: 22rem; }
.ss-pin { width: 9rem; font-size: 1.25rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.ss-claim .ss-field .ss-pin { display: block; margin-inline: auto; }

/* ---- Organizer: put a picked name back ---- */
.ss-confirm-inline { margin-top: 0; }
.ss-confirm-inline[open] { flex-basis: 100%; }
.ss-confirm-inline .ss-confirm-body { max-width: 28rem; font-size: 0.875rem; }

/* ---- Draw Names (kinds.py css="ss-plain"): the same pages in teal, not Christmas red ---- */
.ss.ss-plain { --ss-red: #137577; --ss-red-deep: #0b4f52; }
[data-theme="dark"] .ss.ss-plain { --ss-red: #4cc2c0; }
.ss-plain .ss-reveal-btn {
  background: linear-gradient(160deg, #1d8d8c, #0e5d61);
  box-shadow: 0 0 0 0 rgb(246 185 59 / .6), 0 12px 28px -10px rgb(14 93 97 / .75), inset 0 1px 0 rgb(255 255 255 / .25);
}
.ss-plain .ss-present-box {
  background:
    linear-gradient(90deg, transparent 41%, #f6b93b 41% 59%, transparent 59%),
    linear-gradient(165deg, #22928f, #0d5a5e);
  box-shadow: inset 0 -0.5rem 0 rgb(0 0 0 / .12), 0 16px 24px -14px rgb(10 60 62 / .7);
}
.ss-plain .ss-present-lid {
  background:
    linear-gradient(90deg, transparent 41%, #fbc85a 41% 59%, transparent 59%),
    linear-gradient(165deg, #2aa29e, #11696b);
}
.ss-plain .ss-reveal {
  background:
    radial-gradient(circle at 20% 15%, rgb(255 255 255 / .16) 0 2px, transparent 3px) 0 0 / 46px 46px,
    linear-gradient(160deg, #1b8584, #0b4f52);
}
