/* ==========================================================================
   Secret Santa — shared Material-inspired Christmas theme
   ========================================================================== */

:root {
  /* Brand / festive palette */
  --red-50: #fdecec;
  --red-100: #f9d0d0;
  --red-500: #d32f2f;
  --red-600: #c62828;
  --red-700: #a51d1d;
  --green-50: #e8f5ec;
  --green-100: #c9e8d2;
  --green-500: #2e7d32;
  --green-700: #1b5e20;
  --gold-100: #fff1cc;
  --gold-400: #f6c453;
  --gold-600: #d99a16;
  --night-900: #07112a;
  --night-800: #0c1b3d;
  --night-700: #142a57;
  --ice: #dbeeff;

  /* Material roles */
  --primary: var(--red-600);
  --on-primary: #fff;
  --primary-container: var(--red-50);
  --secondary: var(--green-500);
  --secondary-container: var(--green-50);
  --tertiary: var(--gold-600);
  --surface: #ffffff;
  --surface-dim: #f7f4ef;
  --surface-variant: #f1ece4;
  --outline: #d9d2c7;
  --outline-strong: #b7ad9f;
  --on-surface: #1f1b16;
  --on-surface-muted: #6b625a;
  --error: #b3261e;
  --success: #2e7d32;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 999px;

  --elev-1: 0 1px 2px rgba(31, 27, 22, .08), 0 1px 3px 1px rgba(31, 27, 22, .05);
  --elev-2: 0 2px 6px rgba(31, 27, 22, .08), 0 6px 16px rgba(31, 27, 22, .06);
  --elev-3: 0 8px 24px rgba(31, 27, 22, .12), 0 2px 6px rgba(31, 27, 22, .06);
  --elev-4: 0 20px 48px rgba(7, 17, 42, .28);

  --font-body: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Mountains of Christmas', 'Poppins', cursive;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--surface-dim);
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
}
.icon-fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

.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;
}

/* ------------------------------------------------------------------ Buttons */
.btn {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .02em;
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
  transition: box-shadow .2s var(--ease), transform .15s var(--ease), background-color .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn::after {               /* state layer */
  content: '';
  position: absolute; inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity .2s;
}
.btn:hover::after { opacity: .08; }
.btn:active::after { opacity: .14; }
.btn:hover { box-shadow: var(--elev-1); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 3px solid var(--gold-400); outline-offset: 2px; }
.btn .material-symbols-rounded { font-size: 20px; }

.btn-lg { height: 56px; padding: 0 32px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-green { --btn-bg: var(--green-500); }
.btn-gold { --btn-bg: linear-gradient(135deg, #f8d06b, #e3a21a); --btn-fg: #3a2600; background: var(--btn-bg); }
.btn-tonal { --btn-bg: var(--primary-container); --btn-fg: var(--red-700); }
.btn-tonal-green { --btn-bg: var(--secondary-container); --btn-fg: var(--green-700); }
.btn-outline {
  --btn-bg: transparent; --btn-fg: var(--on-surface);
  border: 1px solid var(--outline-strong);
}
.btn-text { --btn-bg: transparent; --btn-fg: var(--primary); padding: 0 12px; }
.btn-text:hover { box-shadow: none; }

.btn:disabled, .btn[aria-disabled='true'] {
  cursor: not-allowed;
  background: rgba(31, 27, 22, .1);
  color: rgba(31, 27, 22, .38);
  box-shadow: none;
  transform: none;
}
.btn:disabled::after { display: none; }

.btn .spinner { width: 18px; height: 18px; border-width: 2px; }
.btn.loading { pointer-events: none; }
.btn.loading > :not(.spinner) { opacity: 0; }
.btn.loading .spinner { position: absolute; display: block; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit;
  cursor: pointer;
  transition: background-color .2s;
}
.icon-btn:hover { background: rgba(127, 127, 127, .14); }

.spinner {
  display: none;
  width: 22px; height: 22px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- Outlined fields */
.field { position: relative; margin-bottom: 20px; }

.field-control {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--outline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.field-control:hover { border-color: var(--on-surface); }
.field-control:focus-within {
  border-color: var(--secondary);
  box-shadow: 0 0 0 1px var(--secondary);
}
.field-control > .material-symbols-rounded.lead {
  padding-left: 14px;
  color: var(--on-surface-muted);
}
.field-control input,
.field-control select {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 18px 16px 6px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
}
.field-control select { padding-right: 44px; cursor: pointer; }
.field-control .select-caret {
  position: absolute; right: 14px; pointer-events: none; color: var(--on-surface-muted);
}
.field-control label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--on-surface-muted);
  pointer-events: none;
  transition: all .18s var(--ease);
  font-size: 15px;
  background: transparent;
}
.field-control .lead ~ input,
.field-control .lead ~ select { padding-left: 10px; }
.field-control .lead ~ label { left: 48px; }
.field-control input:focus ~ label,
.field-control input:not(:placeholder-shown) ~ label,
.field-control select ~ label,
.field-control.has-value label {
  top: 14px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
}
.field-control:focus-within label { color: var(--secondary); }
.field-control .trail { padding-right: 8px; display: flex; align-items: center; }

.field.invalid .field-control { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field.invalid .field-control label { color: var(--error); }
.field.valid .field-control { border-color: var(--success); }
.field.disabled .field-control { opacity: .55; background: var(--surface-variant); }
.field.disabled .field-control * { cursor: not-allowed; }

.field-help {
  min-height: 18px;
  margin: 4px 4px 0 16px;
  font-size: 12px;
  color: var(--on-surface-muted);
  display: flex; align-items: center; gap: 4px;
}
.field.invalid .field-help { color: var(--error); }
.field.valid .field-help { color: var(--success); }
.field-help .material-symbols-rounded { font-size: 16px; }

/* ------------------------------------------------------------------- Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-variant);
  color: var(--on-surface-muted);
  white-space: nowrap;
}
.chip .material-symbols-rounded { font-size: 16px; }
.chip-green { background: var(--green-50); color: var(--green-700); }
.chip-red { background: var(--red-50); color: var(--red-700); }
.chip-gold { background: var(--gold-100); color: #7a5200; }
.chip-blue { background: #e3edff; color: #1d4ea8; }

/* ------------------------------------------------------------------- Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-1);
  border: 1px solid rgba(31, 27, 22, .05);
}

/* ------------------------------------------------------------------ Dialog */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 1000;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(7, 17, 42, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in .2s var(--ease);
}
.modal {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-4);
  padding: 28px 24px 20px;
  color: var(--on-surface);
  text-align: center;
  animation: pop-in .28s var(--ease);
}
.modal-icon {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--primary);
}
.modal-icon .material-symbols-rounded { font-size: 34px; }
.modal-icon.green { background: var(--green-50); color: var(--green-500); }
.modal-icon.gold { background: var(--gold-100); color: var(--gold-600); }
.modal-icon.error { background: var(--red-50); color: var(--error); }
.modal h2 { margin: 0 0 8px; font-size: 21px; font-weight: 600; line-height: 1.3; }
.modal p { margin: 0 0 6px; color: var(--on-surface-muted); }
.modal .modal-body { margin: 6px 0 4px; text-align: left; }
.modal .modal-body .field { margin-top: 14px; margin-bottom: 4px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  margin-top: 22px;
}
.modal-actions.center { justify-content: center; }
.modal .modal-body .center { text-align: center; }
.modal .highlight {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  background: var(--gold-100);
  color: #6b4700;
  font-weight: 700;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }

/* ------------------------------------------------------------------ Toasts */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: min(560px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #2b2622;
  color: #fff;
  box-shadow: var(--elev-3);
  font-size: 14px;
  pointer-events: auto;
  animation: toast-in .3s var(--ease);
}
.toast.leaving { animation: toast-out .25s var(--ease) forwards; }
.toast .material-symbols-rounded { flex: none; }
.toast.success .material-symbols-rounded { color: #7ee08a; }
.toast.error .material-symbols-rounded { color: #ff8a80; }
.toast.info .material-symbols-rounded { color: var(--gold-400); }
.toast span.msg { flex: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(16px); } }

/* -------------------------------------------------------------- Snow layer */
.snow-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
