/* ==========================================================================
   Los Serrano · Intercambio Navideño — Light Mode Festive Apple HIG
   Zero Emojis · Custom Vector Crests · Animated Christmas Reveal
   ========================================================================== */

:root {
  color-scheme: light;

  /* Light Mode Festive Stationery Surfaces */
  --surface-primary: #FAF6EE;       /* Warm Ivory Snow */
  --surface-secondary: #FFFFFF;     /* Pure Cotton Cardstock */
  --surface-tertiary: #F2ECE1;      /* Soft Linen */
  --surface-envelope: #FFFDF9;      /* Embossed Letter Paper */

  /* High-Contrast Text Hierarchy (WCAG AA/AAA verified) */
  --content-primary: #14221A;       /* Deep Pine Ink (16.2:1 on #FFFFFF) */
  --content-secondary: #43544A;     /* Holly Slate (7.8:1 on #FFFFFF) */
  --content-tertiary: #63756B;      /* Muted Spruce (4.8:1 on #FFFFFF) */

  /* Christmas Accents */
  --accent-crimson: #B81D24;        /* Crimson Wax (6.4:1 with #FFFFFF) */
  --accent-crimson-pressed: #94141A;
  --accent-crimson-tint: #FCEBEC;
  --accent-forest: #185836;         /* Noble Fir (8.3:1 with #FFFFFF) */
  --accent-forest-tint: #E5F3EB;
  --accent-gold: #8A5200;
  --gold-line: #D8B76C;
  --gold-bright: #D4AF37;

  /* Separators & Borders */
  --separator-hairline: rgba(20, 34, 26, 0.09);
  --border-card: rgba(20, 34, 26, 0.10);

  /* Functional Layer: Regular Liquid Glass */
  --glass-bg: rgba(250, 246, 238, 0.82);
  --glass-border: rgba(20, 34, 26, 0.11);
  --glass-highlight: rgba(255, 255, 255, 0.78);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  --font-serif: "New York", ui-serif, Georgia, Cambria, "Times New Roman", serif;

  --radius-card: 16px;
  --radius-sheet: 24px;
  --radius-pill: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  :root {
    --glass-bg: #FFFFFF;
    --separator-hairline: rgba(20, 34, 26, 0.30);
    --border-card: rgba(20, 34, 26, 0.30);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  background-color: var(--surface-primary);
  color: var(--content-primary);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--surface-primary);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(184, 29, 36, 0.045) 0%, transparent 38%),
    radial-gradient(circle at 88% 8%, rgba(24, 88, 54, 0.05) 0%, transparent 38%);
  color: var(--content-primary);
  font-size: 1.0625rem; /* 17pt iOS default */
  line-height: 1.47;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(36px + var(--safe-bottom));
  min-height: 100dvh;
}

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

/* Decorative Top Christmas Ribbon */
.christmas-ribbon-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 4px;
  background: repeating-linear-gradient(
    45deg,
    #B81D24 0px,
    #B81D24 14px,
    #FAF6EE 14px,
    #FAF6EE 22px,
    #185836 22px,
    #185836 36px,
    #D4AF37 36px,
    #D4AF37 42px
  );
}

/* Functional Layer: Top Glass Bar */
.glass-bar {
  background-color: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  backdrop-filter: blur(24px) saturate(1.4);
}

.top-toolbar {
  position: fixed;
  top: 4px;
  left: 0;
  right: 0;
  z-index: 30;
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 -1px 0 var(--glass-highlight);
}

.toolbar-inner {
  max-width: 560px;
  margin: 0 auto;
  height: 50px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-emblem {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.toolbar-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--content-primary);
}

.toolbar-season {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-forest);
  background-color: var(--accent-forest-tint);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Main Layout & Festive Crest Hero
   ========================================================================== */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.hero-crest-card {
  background-color: var(--surface-secondary);
  border: 1.5px solid var(--gold-line);
  border-radius: 22px;
  padding: 4px 20px 24px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(20, 34, 26, 0.05);
}

.crest-garland-svg {
  width: 100%;
  max-width: 300px;
  height: 60px;
  margin: 0 auto 2px;
  display: block;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem; /* 12px */
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-crimson);
}

.display-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 7vw, 2.75rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--content-primary);
}

.hero-subtitle {
  margin: 0;
  font-size: 1rem; /* 16px */
  font-weight: 500;
  color: var(--content-secondary);
}

/* ==========================================================================
   Participant List (Clean iOS Inset Grouped List)
   ========================================================================== */
.inset-group-card {
  background-color: var(--surface-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(20, 34, 26, 0.04);
}

.participant-row {
  width: 100%;
  min-height: 58px; /* Exceeds 44pt minimum */
  padding: 11px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--separator-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--content-primary);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.participant-row:last-child {
  border-bottom: none;
}

.participant-row:hover {
  background-color: rgba(184, 29, 36, 0.03);
}

.participant-row:active {
  background-color: rgba(184, 29, 36, 0.08);
}

.participant-row:focus-visible {
  outline: 2px solid var(--accent-crimson);
  outline-offset: -2px;
}

.participant-leading {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.participant-monogram {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--accent-crimson-tint);
  color: var(--accent-crimson);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(184, 29, 36, 0.16);
}

.participant-row:nth-child(even) .participant-monogram {
  background-color: var(--accent-forest-tint);
  color: var(--accent-forest);
  border-color: rgba(24, 88, 54, 0.16);
}

.participant-name {
  font-size: 1.0625rem; /* 17px */
  font-weight: 600;
  color: var(--content-primary);
}

.participant-trailing {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.row-prompt {
  font-size: 0.8125rem; /* 13px */
  font-weight: 500;
  color: var(--content-secondary);
}

.row-prompt.is-opened {
  color: var(--accent-forest);
  font-weight: 600;
}

.row-chevron-svg {
  width: 16px;
  height: 16px;
  color: var(--content-tertiary);
}

/* Discreet Footer */
.app-footer {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.admin-footer-link {
  min-height: 44px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--content-tertiary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.admin-footer-link:hover {
  color: var(--content-primary);
}

.footer-lock-icon {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Modal Sheets & Animated Christmas Reveal
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: rgba(20, 34, 26, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.18s ease-out;
}

.sheet-backdrop[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  background-color: var(--surface-primary);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: 0 -12px 40px rgba(20, 34, 26, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpSheet 0.24s cubic-bezier(0.2, 0.85, 0.3, 1);
}

@media (min-width: 600px) {
  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }
  .modal-sheet {
    border-radius: var(--radius-sheet);
  }
}

.sheet-grabber-area {
  padding: 8px 0 2px;
  display: flex;
  justify-content: center;
  background-color: var(--glass-bg);
}

.sheet-grabber {
  width: 36px;
  height: 5px;
  border-radius: var(--radius-pill);
  background-color: var(--content-tertiary);
  opacity: 0.4;
}

.sheet-toolbar {
  min-height: 48px;
  padding: 2px 12px 6px;
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
}

.sheet-toolbar-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 700;
  text-align: center;
}

.sheet-nav-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--content-secondary);
  cursor: pointer;
  justify-self: start;
}

.sheet-content {
  padding: 20px 18px calc(26px + var(--safe-bottom));
  overflow-y: auto;
}

/* Stage A: Wax-Sealed Envelope */
.wax-envelope {
  position: relative;
  background-color: var(--surface-envelope);
  border: 1.5px solid var(--gold-line);
  border-radius: 20px;
  padding: 32px 20px 28px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(20, 34, 26, 0.06);
  overflow: hidden;
}

.envelope-flap-lines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(180deg, rgba(184, 29, 36, 0.05), transparent);
  pointer-events: none;
}

.envelope-eyebrow {
  position: relative;
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-forest);
}

.envelope-owner-name {
  position: relative;
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--content-primary);
}

.envelope-instruction {
  position: relative;
  margin: 0 auto 20px;
  max-width: 32ch;
  font-size: 0.9375rem;
  color: var(--content-secondary);
}

.pass-form {
  position: relative;
  max-width: 280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.pass-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 1.0625rem; /* 17px avoids iOS auto-zoom */
  font-weight: 500;
  text-align: left;
  color: var(--content-primary);
  background-color: var(--surface-secondary);
  border: 1.5px solid var(--gold-line);
  border-radius: 12px;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(20, 34, 26, 0.04);
}

.pass-input:focus {
  border-color: var(--accent-crimson);
  box-shadow: 0 0 0 3px rgba(184, 29, 36, 0.12);
}

.ready-seal-badge {
  position: relative;
  z-index: 2;
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background-color: var(--accent-forest-tint);
  color: var(--accent-forest);
  border: 2px solid rgba(24, 88, 54, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ready-check-svg {
  width: 28px;
  height: 28px;
}

/* Interactive Crimson Wax Seal Button */
.wax-seal-btn {
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wax-seal-btn:hover {
  transform: scale(1.05);
}

.wax-seal-btn:active {
  transform: scale(0.95);
}

.wax-seal-ring {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #E02F36, #B81D24 58%, #7C0E13 100%);
  border: 3px solid #D4AF37;
  box-shadow:
    0 10px 24px rgba(184, 29, 36, 0.35),
    0 0 0 5px rgba(184, 29, 36, 0.12),
    inset 0 2px 6px rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulseSeal 2.4s infinite ease-in-out;
}

.seal-star-svg {
  width: 48px;
  height: 48px;
}

.wax-seal-caption {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-crimson);
}

/* Seal Breaking Animation Class */
.wax-seal-btn.is-breaking .wax-seal-ring {
  animation: breakWaxSeal 0.65s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

/* Stage B: Ornate Animated Christmas Reveal Card */
.ornate-christmas-card {
  position: relative;
  background-color: var(--surface-secondary);
  border: 2px solid var(--gold-bright);
  border-radius: 22px;
  padding: 22px 20px 24px;
  text-align: center;
  box-shadow:
    0 14px 36px rgba(184, 29, 36, 0.14),
    inset 0 0 0 4px var(--surface-primary),
    inset 0 0 0 5px rgba(212, 175, 55, 0.45);
  overflow: hidden;
  animation: cardRevealUnfold 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.sparkles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.reveal-wreath-svg {
  position: relative;
  z-index: 2;
  width: 210px;
  height: 50px;
  margin: 0 auto 4px;
  display: block;
}

.reveal-eyebrow {
  position: relative;
  z-index: 2;
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-crimson);
}

.reveal-pretext {
  position: relative;
  z-index: 2;
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--content-secondary);
}

.reveal-name-frame {
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, #FFFDF8 0%, #FAF3E3 100%);
  border: 1.5px solid var(--gold-line);
  border-radius: 16px;
  padding: 22px 16px;
  margin: 0 auto 14px;
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.15);
  animation: popRecipientName 0.6s 0.12s cubic-bezier(0.18, 1.25, 0.4, 1) both;
}

.reveal-recipient-name {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 7.5vw, 2.65rem);
  font-weight: 700;
  line-height: 1.12;
  color: var(--accent-forest);
  letter-spacing: -0.01em;
}

.reveal-bottom-flourish {
  position: relative;
  z-index: 2;
  width: 160px;
  height: 20px;
  margin: 4px auto 18px;
  display: block;
}

/* ==========================================================================
   Buttons & Admin Controls
   ========================================================================== */
.btn {
  position: relative;
  z-index: 2;
  min-height: 46px;
  min-width: 44px;
  padding: 11px 18px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background-color: var(--accent-crimson);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--accent-crimson-pressed);
}

.btn-secondary {
  background-color: var(--surface-tertiary);
  color: var(--content-primary);
  border-color: var(--border-card);
}

.btn-destructive {
  background-color: transparent;
  color: var(--accent-crimson);
  border-color: var(--accent-crimson);
  margin-top: 10px;
}

.btn-small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: 10px;
}

.inset-group-block {
  margin-bottom: 18px;
}

.group-header-label {
  margin: 0 0 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--content-secondary);
}

.stacked-form {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inline-form-row {
  display: flex;
  gap: 8px;
}

.inline-form-row .text-input {
  flex: 1;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--content-primary);
}

.text-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  color: var(--content-primary);
  background-color: var(--surface-primary);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  outline: none;
}

.text-input:focus {
  background-color: var(--surface-secondary);
  border-color: var(--accent-crimson);
}

.form-error {
  margin: 10px 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-crimson);
}

.draw-action-area {
  padding: 16px;
}

.draw-helper-text {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--content-secondary);
}

.admin-member-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-member-row:last-child {
  border-bottom: none;
}

.toast-pill {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background-color: var(--content-primary);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Keyframes & Motion
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes pulseSeal {
  0%, 100% {
    box-shadow:
      0 10px 24px rgba(184, 29, 36, 0.32),
      0 0 0 5px rgba(184, 29, 36, 0.10),
      inset 0 2px 6px rgba(255, 255, 255, 0.35);
  }
  50% {
    box-shadow:
      0 12px 28px rgba(184, 29, 36, 0.45),
      0 0 0 10px rgba(212, 175, 55, 0.22),
      inset 0 2px 6px rgba(255, 255, 255, 0.45);
  }
}

@keyframes breakWaxSeal {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  45% {
    transform: scale(1.18) rotate(-12deg);
    box-shadow: 0 0 36px rgba(212, 175, 55, 0.85);
    opacity: 1;
  }
  100% {
    transform: scale(0.2) rotate(28deg);
    opacity: 0;
  }
}

@keyframes cardRevealUnfold {
  0% {
    opacity: 0;
    transform: perspective(600px) rotateX(-14deg) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: perspective(600px) rotateX(0deg) scale(1);
  }
}

@keyframes popRecipientName {
  0% {
    opacity: 0;
    transform: scale(0.84) translateY(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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