/* Secret Santa: a dark, festive glass look.
   Motion animates only transform and opacity, and hover styles sit behind
   (hover: hover), following the phone and motion rules of root ADR 0018. */

:root {
  --bg: #140b1f;
  --bg-2: #1f1030;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f8f1ff;
  --muted: #b9a9cc;
  --red: #ff4d6d;
  --red-2: #ff8a5c;
  --gold: #ffc94d;
  --green: #34d399;
  --radius: 18px;
  --radius-sm: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg) 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }

a { color: var(--gold); }

[hidden] { display: none !important; }

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

/* --- background effects --------------------------------------------------- */

.fx-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.fx-top { z-index: 50; }

.glow {
  position: fixed;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: drift 22s ease-in-out infinite alternate;
}
.glow-a { background: #7c2d5a; top: -30vmax; left: -20vmax; }
.glow-b { background: #1c4b5c; bottom: -35vmax; right: -25vmax; animation-delay: -11s; }

@keyframes drift {
  to { transform: translate(8vmax, 6vmax) scale(1.1); }
}

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

.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; display: flex; flex-direction: column; }
/* A participant sees no footer, and the receive view fills the screen: the
   present and the answer sit in its middle, and "organise your own" sits at
   the very bottom. */
body.is-receive .footer { display: none; }
.view.receive { flex: 1; display: flex; flex-direction: column; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 20px;
}

.brand {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
/* The gradient sits on the words only. On the whole heading, the tilting
   present showed a corner of it as a white triangle. */
.brand-text {
  background: linear-gradient(90deg, var(--text), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-icon {
  display: inline-block;
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob {
  50% { transform: translateY(-4px) rotate(-6deg); }
}

.lang {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--card-border);
}
.lang button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.lang button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* --- cards and fields ----------------------------------------------------- */

.view { animation: view-in 0.3s var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.card h2 { margin: 0 0 4px; font-size: 1.35rem; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85rem; }

.field-label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 700;
  font-size: 0.9rem;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  font-size: 16px; /* 16px keeps iOS from zooming into the field */
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}
.input:focus { border-color: var(--gold); background: rgba(0, 0, 0, 0.35); }
textarea.input { resize: none; overflow: hidden; line-height: 1.4; }
textarea.input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.add-row, .link-row { display: flex; gap: 8px; align-items: flex-start; }
.add-row .input, .link-row .input { flex: 1; min-width: 0; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s var(--ease-out), background-color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  color: #fff;
  box-shadow: 0 10px 30px rgba(255, 77, 109, 0.35);
}
.btn-big { width: 100%; padding: 16px; font-size: 1.15rem; }

@media (hover: hover) {
  .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }
  .btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
  .lang button:hover { color: var(--text); }
  .link-button:hover, .subtle-link:hover { color: var(--text); }
  .btn-whatsapp:hover { background: #1ebe5b; }
  .chip:hover { border-color: var(--muted); }
  .name-btn:hover { transform: translateY(-2px); border-color: var(--gold); }
  .gift:hover .gift-lid { transform: translateY(-4px) rotate(-2deg); }
}

/* --- the mutual switch ---------------------------------------------------- */

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 0.9rem;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  flex: none;
  width: 42px;
  height: 24px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  transition: background-color 0.25s;
}
.switch-thumb {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s var(--ease-spring);
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- people list ---------------------------------------------------------- */

.people-head { margin: 22px 4px 8px; }
.people-count { font-weight: 700; color: var(--muted); font-size: 0.9rem; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.person {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: person-in 0.3s var(--ease-spring) backwards;
}
@keyframes person-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
}
.person.leaving { animation: person-out 0.2s var(--ease-out) forwards; }
@keyframes person-out {
  to { opacity: 0; transform: scale(0.94); }
}

.person-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
  color: #fff;
  background: hsl(var(--hue, 340) 70% 55%);
}

.person-main { flex: 1; min-width: 0; }
.person-name { font-weight: 700; overflow-wrap: anywhere; }
.person-rules { font-size: 0.8rem; color: var(--muted); }
.person-rules.has-rules { color: var(--red-2); }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), background-color 0.2s;
}
.icon-btn:active { transform: scale(0.9); }
/* An open exclusion list reads as "forbidden": a red ring that matches the 🚫 sign. */
.icon-btn[aria-expanded="true"] { background: rgba(255, 77, 109, 0.22); box-shadow: inset 0 0 0 2px var(--red); }

.rules-panel { padding: 0 12px 12px; border-top: 1px solid var(--card-border); }
.rules-panel p { margin: 10px 0 8px; font-size: 0.85rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease-out), background-color 0.2s, border-color 0.2s;
}
.chip:active { transform: scale(0.94); }
.chip[aria-pressed="true"] {
  background: rgba(255, 77, 109, 0.2);
  border-color: var(--red);
  color: #ffd0d9;
  text-decoration: line-through;
}

.empty { text-align: center; color: var(--muted); padding: 16px; }

.error, .notice {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.error { background: rgba(255, 77, 109, 0.15); border: 1px solid rgba(255, 77, 109, 0.5); animation: shake 0.35s; }
.notice { background: rgba(255, 201, 77, 0.12); border: 1px solid rgba(255, 201, 77, 0.45); }
@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.draw-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 18px -16px 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

/* --- result --------------------------------------------------------------- */

.result {
  margin-top: 18px;
  text-align: center;
  animation: pop-in 0.5s var(--ease-spring);
}
.result .link-row { text-align: left; }
.result-burst { font-size: 3rem; line-height: 1; animation: bob 2s ease-in-out infinite; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.9); }
}

/* --- receive: pick a name ------------------------------------------------- */

.event-title {
  text-align: center;
  margin: 8px 0 0;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
}
.big-question {
  text-align: center;
  font-size: clamp(2rem, 9vw, 3rem);
  margin: 4px 0 0;
  letter-spacing: -0.03em;
}

.names {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.name-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--card);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: transform 0.2s var(--ease-out), border-color 0.2s;
  animation: person-in 0.3s var(--ease-spring) backwards;
}
.name-btn:active { transform: scale(0.96); }

.subtle-link { color: var(--muted); font-size: 0.85rem; }

.create-own { margin: auto 0 0; padding-top: 48px; text-align: center; font-size: 0.8rem; opacity: 0.7; }
.create-own .subtle-link { font-size: inherit; }

/* --- the warning dialog --------------------------------------------------- */

.dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  background: #241338;
  color: var(--text);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog[open] { animation: pop-in 0.3s var(--ease-spring); }
.dialog::backdrop { background: rgba(8, 3, 14, 0.7); backdrop-filter: blur(6px); }
.dialog h2 { margin: 6px 0; }
.dialog p { color: var(--muted); }
.dialog-icon { font-size: 2.6rem; }
.dialog-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* --- receive: the present ------------------------------------------------- */

.reveal { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.hello { font-size: clamp(1.6rem, 7vw, 2.3rem); margin: 0; }

.gift {
  position: relative;
  width: 180px;
  height: 190px;
  margin: 28px 0 12px;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  animation: wiggle 2.4s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
  85% { transform: rotate(-3deg); }
  90% { transform: rotate(2deg); }
}
.gift-box, .gift-lid {
  position: absolute;
  left: 50%;
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 42%, var(--gold) 42%, var(--gold) 58%, transparent 58%),
    linear-gradient(160deg, var(--red-2), var(--red));
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.15);
}
.gift-box { bottom: 0; width: 150px; height: 120px; transform: translateX(-50%); }
.gift-lid {
  bottom: 112px;
  width: 172px;
  height: 40px;
  margin-left: -86px;
  z-index: 2;
  transition: transform 0.3s var(--ease-out);
}
.gift-bow {
  position: absolute;
  left: 50%;
  top: -34px;
  width: 70px;
  height: 40px;
  margin-left: -35px;
}
.gift-bow::before, .gift-bow::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 34px;
  height: 34px;
  border: 8px solid var(--gold);
  border-radius: 50% 50% 0 50%;
}
.gift-bow::before { left: 0; transform: rotate(-20deg); }
.gift-bow::after { right: 0; transform: scaleX(-1) rotate(-20deg); }

.gift.open { animation: none; cursor: default; }
.gift.open .gift-lid { animation: lid-off 0.8s var(--ease-out) forwards; }
.gift.open .gift-box { animation: box-down 0.6s 0.2s var(--ease-out) forwards; }
@keyframes lid-off {
  40% { transform: translateY(-60px) rotate(-12deg); }
  to { transform: translate(-140px, -40px) rotate(-60deg); opacity: 0; }
}
@keyframes box-down {
  to { transform: translateX(-50%) translateY(30px) scale(0.85); opacity: 0; }
}

.answer { margin-top: 20px; animation: answer-in 0.6s var(--ease-spring); }
.answer .muted { margin: 0; }
@keyframes answer-in {
  from { opacity: 0; transform: scale(0.5); }
}
.recipient {
  margin: 4px 0 8px;
  font-size: clamp(2.4rem, 12vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  background: linear-gradient(90deg, var(--gold), var(--red-2), var(--gold));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3s linear infinite;
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}
#hide { margin-top: 24px; }
/* Small and far down on purpose: changing who you are should take a moment. */
.not-me { margin: 40px 0 0; max-width: 34ch; font-size: 0.75rem; opacity: 0.6; }
.not-me .subtle-link { font-size: inherit; }

/* --- footer --------------------------------------------------------------- */

.footer {
  margin-top: 48px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer p { margin: 6px 0; }
.about { max-width: 46ch; margin-left: auto !important; margin-right: auto !important; }

/* --- reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- receive: large and plain, so anyone can use it ------------------------ */

.receive { font-size: 1.1rem; }
.lead { color: var(--muted); font-size: 1.1rem; margin: 6px 0; }
.receive .event-title { font-size: 1rem; }
.receive .names { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.receive .name-btn { min-height: 64px; padding: 14px; font-size: 1.2rem; }
.receive .name-btn .avatar { width: 40px; height: 40px; }
.btn-big-ish { padding: 14px 20px; font-size: 1.05rem; }

.note-card {
  margin: 8px auto 14px;
  max-width: 34ch;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: rgba(255, 201, 77, 0.1);
  border: 1px dashed rgba(255, 201, 77, 0.55);
  text-align: left;
}
.note-label { margin: 0 0 4px; font-size: 0.8rem; font-weight: 700; color: var(--gold); }
.note-text { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; white-space: pre-line; }

/* --- create: editor extras ------------------------------------------------ */

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.btn-small { flex: none; padding: 6px 12px; font-size: 0.8rem; font-weight: 600; background: transparent; color: var(--muted); }
.btn-small.armed { background: rgba(255, 77, 109, 0.2); border-color: var(--red); color: #ffd0d9; }
.step { margin: 18px 0 8px; font-size: 1rem; font-weight: 800; }
.card .step:first-of-type { margin-top: 18px; }
.details { margin-top: 18px; }
.details .step { margin-top: 0; }
.note-meta { display: flex; justify-content: space-between; gap: 10px; }
.note-count { flex: none; font-variant-numeric: tabular-nums; }

/* --- create: the share screen --------------------------------------------- */

.share .card { animation: pop-in 0.5s var(--ease-spring); }
.link-box { margin: 16px 0 12px; text-align: center; }
.with-text { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--card-border); }
.with-text .step { margin-top: 0; }
.msg-lang { display: inline-flex; margin-bottom: 10px; }
.message-preview {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  text-align: left;
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-url {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--gold);
  text-decoration: underline;
}
.share-next {
  margin-top: 20px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.5);
}
.share-next p { margin: 0 0 10px; font-weight: 600; }
.share-next.pop { animation: pop-in 0.3s var(--ease-spring); }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn-whatsapp { border-color: transparent; background: #25d366; color: #06301a; }
.share-secondary { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.link-button {
  border: 0;
  background: none;
  padding: 8px;
  margin-top: 10px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
}
