/* ==========================================================================
   Enfield Feedback - Premium Royal Animated Web App
   Theme: Royal Navy Blue (#071126, #0B1B3D), Pure White (#FFFFFF), Imperial Gold (#D4AF37)
   Mobile-First, 60fps Hardware-Accelerated 3D Transforms & Green Checkmark
   ========================================================================== */
:root {
  /* Color Palette */
  --royal-blue-dark: #071126;
  --royal-blue: #0b1b3d;
  --royal-blue-light: #152e63;
  --royal-blue-glow: rgba(21, 46, 99, 0.45);

  --gold-primary: #d4af37;
  --gold-light: #ffdf73;
  --gold-deep: #996515;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --gold-subtle: rgba(212, 175, 55, 0.12);

  --pure-white: #ffffff;
  --off-white: #f8fafc;
  --paper-cream: #fcfbf7;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;

  --success-green: #10b981;
  --success-green-dark: #059669;
  --error-red: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);

  /* Typography */
  --font-serif: 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  /* Elevations & Shadows */
  --shadow-sm: 0 2px 8px rgba(7, 17, 38, 0.08);
  --shadow-md: 0 8px 24px -4px rgba(7, 17, 38, 0.12), 0 4px 12px -2px rgba(7, 17, 38, 0.08);
  --shadow-lg: 0 20px 45px -10px rgba(7, 17, 38, 0.28), 0 10px 20px -5px rgba(212, 175, 55, 0.15);
  --shadow-gold: 0 10px 30px -5px rgba(212, 175, 55, 0.45);
  --shadow-envelope: 0 25px 60px -15px rgba(5, 12, 28, 0.65), 0 0 40px rgba(212, 175, 55, 0.1);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  /* Transition speeds */
  --transition-smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Base Reset & Box Sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--gray-800);
  background-color: var(--royal-blue-dark);
  overflow-x: hidden;
  position: relative;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 12px 56px;
}

/* Background Luxury Ambience */
.luxury-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  background: radial-gradient(circle at 50% 10%, #152e63 0%, #0b1b3d 50%, #071126 100%);
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  will-change: transform;
}

.orb-1 {
  width: 320px;
  height: 320px;
  background: var(--gold-primary);
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  animation: orbPulse 8s infinite alternate ease-in-out;
}

.orb-2 {
  width: 280px;
  height: 280px;
  background: #1e40af;
  bottom: 10%;
  left: -60px;
  animation: orbDrift 14s infinite alternate ease-in-out;
}

.orb-3 {
  width: 240px;
  height: 240px;
  background: #ca8a04;
  top: 40%;
  right: -50px;
  opacity: 0.2;
}

@keyframes orbPulse {
  0% {
    transform: translateX(-50%) scale(0.9);
    opacity: 0.25;
  }

  100% {
    transform: translateX(-50%) scale(1.15);
    opacity: 0.45;
  }
}

@keyframes orbDrift {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(40px, -40px);
  }
}

/* Canvas Confetti */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* Main Container */
.app-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Brand Header */
.brand-header {
  text-align: center;
  margin-bottom: 20px;
  padding-top: 8px;
  animation: fadeInDown 0.8s var(--transition-smooth) both;
}

.brand-crest {
  display: inline-block;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 14px rgba(212, 175, 55, 0.45));
}

.crest-svg {
  width: 46px;
  height: 46px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #ffffff 10%, #ffdf73 50%, #d4af37 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 16px rgba(212, 175, 55, 0.35);
  margin-bottom: 4px;
}

.brand-tagline {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gray-400);
  font-weight: 500;
}

/* Welcome Hero Screen Text (Section 3) */
.welcome-hero {
  text-align: center;
  margin-bottom: 24px;
  max-width: 420px;
  padding: 0 12px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.welcome-heading {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--pure-white);
  line-height: 1.35;
  margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.welcome-subtext {
  font-size: 0.86rem;
  color: var(--gray-400);
  line-height: 1.5;
}

/* Stage Container */
.stage-container {
  width: 100%;
  position: relative;
  perspective: 1400px;
}

/* ==========================================================================
   3D ENVELOPE ANIMATION SYSTEM
   ========================================================================== */

.envelope-scene {
  width: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 380px;
}

.envelope-perspective {
  width: 100%;
  max-width: 460px;
  perspective: 1400px;
  perspective-origin: 50% 30%;
}

.envelope {
  position: relative;
  width: 100%;
  height: 290px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 0.8s var(--transition-smooth), height 0.8s var(--transition-smooth);
  cursor: pointer;
  outline: none;
}

.envelope:focus-visible {
  box-shadow: 0 0 0 3px var(--gold-primary);
}

.envelope.is-open {
  height: auto;
  min-height: 720px;
  cursor: default;
}

/* Envelope Back Wall */
.envelope-back {
  position: absolute;
  inset: 0;
  height: 290px;
  background: linear-gradient(160deg, #12244d 0%, #0a1838 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-envelope);
  z-index: 1;
  transition: opacity 0.7s ease;
}

.envelope.is-open .envelope-back {
  opacity: 0.12;
}

/* Envelope Pocket */
.envelope-pocket {
  position: absolute;
  inset: 0;
  height: 290px;
  pointer-events: none;
  z-index: 10;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.pocket-left {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 290px 0 0 230px;
  border-color: transparent transparent transparent rgba(15, 32, 69, 0.96);
  filter: drop-shadow(4px 0 6px rgba(0, 0, 0, 0.25));
}

.pocket-right {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 290px 230px;
  border-color: transparent transparent rgba(18, 38, 82, 0.96) transparent;
  filter: drop-shadow(-4px 0 6px rgba(0, 0, 0, 0.25));
}

.pocket-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 230px 150px 230px;
  border-color: transparent transparent #0d1e44 transparent;
  filter: drop-shadow(0 -4px 10px rgba(0, 0, 0, 0.3));
}

.envelope.is-open .envelope-pocket {
  opacity: 0.15;
  transform: translateY(20px) scale(0.96);
}

/* Top Flap (Flips open in 3D perspective) */
.envelope-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 155px;
  width: 100%;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.3s;
  z-index: 20;
}

.envelope-top-flap::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-style: solid;
  border-width: 155px 230px 0 230px;
  border-color: #17326b transparent transparent transparent;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
}

.envelope.is-open .envelope-top-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

/* Golden Wax Seal */
.wax-seal {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe38a 0%, #d4af37 40%, #8c5b08 90%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 175, 55, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  transition: transform 0.35s var(--transition-bounce), opacity 0.5s ease;
  outline: none;
}

.wax-seal:hover {
  transform: translateX(-50%) scale(1.1);
}

.wax-seal:focus-visible {
  box-shadow: 0 0 0 3px #ffffff, 0 0 20px var(--gold-light);
}

.seal-inner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.15) 100%);
}

.seal-emblem {
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.35rem;
  color: #3e2600;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

.envelope.is-open .wax-seal {
  transform: translateX(-50%) scale(0.5);
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   THE LETTER CARD (Feedback Form Container)
   ========================================================================== */

.letter-card {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  background: var(--pure-white);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(212, 175, 55, 0.35);
  z-index: 5;
  transform: translateY(20px) scale(0.94);
  opacity: 0.85;
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.6s ease,
    box-shadow 0.8s ease;
  pointer-events: none;
}

.envelope.is-open .letter-card {
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
  z-index: 30;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(212, 175, 55, 0.4);
  animation: letterPop 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes letterPop {
  0% {
    transform: translateY(60px) scale(0.9);
    opacity: 0;
  }

  60% {
    transform: translateY(-8px) scale(1.01);
    opacity: 1;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Welcome Action Wrap (Visible when closed) */
.welcome-action-wrap {
  width: 100%;
  max-width: 340px;
  margin: 28px auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-instruction {
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

.card-header {
  text-align: center;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 16px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-subtle);
  color: var(--gold-deep);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.badge-icon {
  color: var(--gold-primary);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--royal-blue);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.84rem;
  color: var(--gray-600);
  line-height: 1.45;
}

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gray-800);
}

.required-star {
  color: var(--gold-deep);
  font-weight: 700;
}

.optional-tag {
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--gray-400);
}

.label-with-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-counter {
  font-size: 0.72rem;
  color: var(--gray-400);
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--gray-800);
  background-color: var(--pure-white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  min-height: 46px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-subtle);
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.form-select {
  appearance: none;
  cursor: pointer;
  padding-right: 38px;
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--gray-400);
}

.form-textarea {
  resize: vertical;
  min-height: 85px;
  line-height: 1.5;
}

/* ==========================================================================
   Animated Emoji Satisfaction Scale  (replaces the legacy star rating)
   Values — 5 = Very Satisfied · 4 = Satisfied · 3 = Neutral
            2 = Dissatisfied · 1 = Very Dissatisfied
   ========================================================================== */

.rating-group {
  position: relative;
  padding: 16px 12px 12px;
  background: linear-gradient(180deg, #ffffff 0%, var(--paper-cream) 100%);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px -26px rgba(7, 17, 38, 0.5);
  overflow: hidden;
  text-align: center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.rating-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14%;
  right: 14%;
  height: 2px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  opacity: 0.55;
}

.rating-group.has-error {
  border-color: var(--error-red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Question block ---------------------------------------------------------- */
.rating-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.rating-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.rating-question {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--royal-blue);
}

/* Emoji scale grid ------------------------------------------------------- */
.emoji-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 12px 0 2px;
}

.emoji-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  min-width: 0;
  min-height: 92px;
  padding: 14px 3px 10px;
  font-family: inherit;
  background: var(--pure-white);
  border: 1.5px solid var(--gray-200);
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  will-change: transform;
  transition: transform 0.28s var(--transition-bounce),
    border-color 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.3s ease;
}

/* Soft gold glow behind the emoji (visible once selected) */
.emoji-halo {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.4) 0%, rgba(212, 175, 55, 0) 70%);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.35s ease, transform 0.4s var(--transition-smooth);
  pointer-events: none;
}

.emoji-glyph {
  position: relative;
  z-index: 1;
  display: block;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
  font-variant-emoji: emoji;
  font-size: clamp(1.5rem, 8vw, 2.15rem);
  line-height: 1;
  transform-origin: 50% 62%;
  filter: drop-shadow(0 3px 6px rgba(7, 17, 38, 0.14));
  transition: transform 0.28s var(--transition-bounce), opacity 0.28s ease, filter 0.3s ease;
  will-change: transform;
}

.emoji-label {
  position: relative;
  z-index: 1;
  font-size: clamp(0.5rem, 2.3vw, 0.7rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: 0.005em;
  color: var(--gray-600);
  text-align: center;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: anywhere;
  transition: color 0.25s ease, font-weight 0.25s ease;
}

/* Selection badge (small confirmation tick) */
.emoji-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: #3d2a06;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 55%, var(--gold-deep) 100%);
  box-shadow: 0 3px 8px rgba(153, 101, 21, 0.45);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.22s ease, transform 0.32s var(--transition-bounce);
  pointer-events: none;
}

.emoji-badge svg {
  width: 10px;
  height: 10px;
}

/* Expanding gold ring / ripple on tap */
.emoji-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.6) 0%, rgba(212, 175, 55, 0.22) 45%, rgba(212, 175, 55, 0) 72%);
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

/* Gentle sparkle particles (Very Satisfied only) */
.emoji-sparkle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: linear-gradient(135deg, #fff8dd, var(--gold-light) 55%, var(--gold-primary));
  clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
  opacity: 0;
  pointer-events: none;
}

.sparkle-1 {
  top: 16px;
  left: 16%;
}

.sparkle-2 {
  top: 11px;
  right: 20%;
}

.sparkle-3 {
  top: 34px;
  right: 9%;
}

/* Hover — desktop / pointer devices only (no sticky hover on touch) ------ */
@media (hover: hover) and (pointer: fine) {
  .emoji-option:hover {
    transform: translateY(-4px);
    border-color: rgba(212, 175, 55, 0.55);
    background: linear-gradient(180deg, #ffffff 0%, rgba(212, 175, 55, 0.09) 100%);
    box-shadow: 0 14px 24px -16px rgba(7, 17, 38, 0.45), 0 0 0 3px var(--gold-subtle);
  }

  .emoji-option:hover .emoji-glyph {
    transform: scale(1.14);
    animation: emojiHoverFloat 1.7s ease-in-out infinite;
  }

  .emoji-option:hover .emoji-label {
    color: var(--gray-800);
  }

  .emoji-option:active {
    transform: translateY(-1px) scale(0.985);
  }
}

/* Selected state — refined border, soft gold wash, gentle glow ----------- */
.emoji-option[aria-checked="true"] {
  border-color: var(--gold-primary);
  background: linear-gradient(180deg, #fffdf6 0%, rgba(212, 175, 55, 0.17) 100%);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.28),
    0 12px 26px -14px rgba(153, 101, 21, 0.55),
    0 0 22px rgba(212, 175, 55, 0.24);
  transform: translateY(-3px);
}

.emoji-option[aria-checked="true"] .emoji-halo {
  opacity: 1;
  transform: scale(1);
}

.emoji-option[aria-checked="true"] .emoji-glyph {
  filter: drop-shadow(0 5px 12px rgba(212, 175, 55, 0.55));
}

.emoji-option[aria-checked="true"] .emoji-label {
  color: var(--gold-deep);
  font-weight: 700;
}

.emoji-option[aria-checked="true"] .emoji-badge {
  opacity: 1;
  transform: scale(1);
}

/* Keep the chosen option dominant, calm the rest back down */
.emoji-scale.has-selection .emoji-option:not([aria-checked="true"]) .emoji-glyph {
  opacity: 0.68;
  transform: scale(0.93);
  filter: saturate(0.8);
}

.emoji-scale.has-selection .emoji-option:not([aria-checked="true"]) .emoji-label {
  color: var(--gray-400);
}

/* Visible keyboard focus ------------------------------------------------- */
.emoji-option:focus {
  outline: none;
}

.emoji-option:focus-visible {
  outline: 3px solid rgba(212, 175, 55, 0.9);
  outline-offset: 2px;
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 5px rgba(212, 175, 55, 0.18);
}

/* Burst (click / tap) animations ---------------------------------------- */
.emoji-option.is-burst .emoji-ripple {
  animation: emojiRipple 0.66s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.emoji-option.is-burst .emoji-badge {
  animation: emojiBadgePop 0.5s var(--transition-bounce) 0.08s both;
}

.emoji-option.is-burst .emoji-label {
  animation: emojiLabelRise 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.emoji-option.is-burst .emoji-glyph {
  animation: emojiHappyPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* 😍 Very Satisfied — cheerful bounce + sparkle */
.emoji-option[data-mood="loved"].is-burst .emoji-glyph {
  animation: emojiLovedBounce 0.72s cubic-bezier(0.28, 0.84, 0.42, 1) both;
}

.emoji-option[data-mood="loved"].is-burst .emoji-sparkle {
  animation: emojiSparkle 0.78s ease-out both;
}

.emoji-option[data-mood="loved"].is-burst .sparkle-2 {
  animation-delay: 0.09s;
}

.emoji-option[data-mood="loved"].is-burst .sparkle-3 {
  animation-delay: 0.17s;
}

/* 😃 Satisfied — happy pop */
.emoji-option[data-mood="happy"].is-burst .emoji-glyph {
  animation: emojiHappyPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* 😐 Neutral — subtle tilt */
.emoji-option[data-mood="neutral"].is-burst .emoji-glyph {
  animation: emojiNeutralTilt 0.62s ease-in-out both;
}

/* 🙁 Dissatisfied — soft downward dip then return */
.emoji-option[data-mood="sad"].is-burst .emoji-glyph {
  animation: emojiSadDip 0.68s ease-in-out both;
}

/* 😡 Very Dissatisfied — brief, controlled shake */
.emoji-option[data-mood="angry"].is-burst .emoji-glyph {
  animation: emojiAngryShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Response line --------------------------------------------------------- */
.rating-response {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--gray-600);
  transition: color 0.3s ease;
}

.rating-response-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
}

.rating-response-inner.is-animating {
  animation: emojiResponseRise 0.48s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.rating-response[data-mood="loved"],
.rating-response[data-mood="happy"] {
  color: var(--success-green-dark);
}

.rating-response[data-mood="neutral"] {
  color: var(--gold-deep);
}

.rating-response[data-mood="sad"],
.rating-response[data-mood="angry"] {
  color: #b82837;
}

/* Keyframes ------------------------------------------------------------- */
@keyframes emojiHoverFloat {

  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1.14);
  }

  50% {
    transform: translateY(-5px) rotate(var(--emoji-hover-tilt, 0deg)) scale(1.16);
  }
}

@keyframes emojiRipple {
  0% {
    transform: scale(0.25);
    opacity: 0.9;
  }

  65% {
    opacity: 0.32;
  }

  100% {
    transform: scale(7.5);
    opacity: 0;
  }
}

@keyframes emojiBadgePop {
  0% {
    transform: scale(0.35);
    opacity: 0;
  }

  60% {
    transform: scale(1.18);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes emojiLabelRise {
  0% {
    opacity: 0.35;
    transform: translateY(6px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes emojiHappyPop {
  0% {
    transform: scale(1);
  }

  42% {
    transform: scale(1.26);
  }

  70% {
    transform: scale(0.94);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes emojiLovedBounce {
  0% {
    transform: translateY(0) scale(1);
  }

  30% {
    transform: translateY(-8px) scale(1.2);
  }

  55% {
    transform: translateY(0) scale(0.98);
  }

  75% {
    transform: translateY(-4px) scale(1.08);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes emojiSparkle {
  0% {
    opacity: 0;
    transform: translateY(3px) scale(0.4) rotate(0deg);
  }

  35% {
    opacity: 1;
    transform: translateY(-2px) scale(1) rotate(40deg);
  }

  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.55) rotate(90deg);
  }
}

@keyframes emojiNeutralTilt {
  0% {
    transform: rotate(0deg) scale(1);
  }

  30% {
    transform: rotate(-8deg) scale(1.08);
  }

  60% {
    transform: rotate(7deg) scale(1.06);
  }

  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes emojiSadDip {
  0% {
    transform: translateY(0) scale(1);
  }

  40% {
    transform: translateY(6px) scale(0.94);
  }

  70% {
    transform: translateY(1px) scale(0.99);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes emojiAngryShake {

  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  15% {
    transform: translateX(-3px) rotate(-2deg);
  }

  35% {
    transform: translateX(3px) rotate(2deg);
  }

  55% {
    transform: translateX(-2px) rotate(-1.4deg);
  }

  80% {
    transform: translateX(2px) rotate(1deg);
  }
}

@keyframes emojiResponseRise {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Per-mood hover tilt so each emoji keeps its own personality ------------ */
.emoji-option[data-mood="neutral"] {
  --emoji-hover-tilt: 5deg;
}

.emoji-option[data-mood="sad"] {
  --emoji-hover-tilt: -3deg;
}

.emoji-option[data-mood="angry"] {
  --emoji-hover-tilt: 0deg;
}

/* Responsive tuning ----------------------------------------------------- */
@media (min-width: 520px) {
  .emoji-scale {
    gap: 9px;
  }

  .emoji-option {
    min-height: 104px;
    padding: 16px 6px 12px;
    gap: 9px;
    border-radius: 18px;
  }

  .emoji-label {
    font-size: 0.72rem;
  }

  .emoji-glyph {
    font-size: 2.2rem;
  }
}

@media (max-width: 430px) {
  .rating-group {
    padding: 14px 8px 10px;
  }

  .emoji-scale {
    gap: 4px;
    margin-top: 10px;
  }

  .emoji-option {
    min-height: 86px;
    padding: 12px 2px 9px;
    gap: 6px;
    border-radius: 13px;
  }

  .emoji-halo {
    width: 48px;
    height: 48px;
    margin-left: -24px;
  }
}

@media (max-width: 360px) {
  .rating-question {
    font-size: 0.95rem;
  }

  .emoji-option {
    min-height: 80px;
    padding: 11px 1px 8px;
  }

  .emoji-glyph {
    font-size: 1.5rem;
  }

  .emoji-label {
    font-size: 0.5rem;
    letter-spacing: 0;
  }
}

/* Custom Consent Checkbox */
.consent-group {
  margin-top: 2px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.custom-checkbox {
  position: absolute;
  opacity: 0;
}

.checkbox-custom {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid var(--gray-400);
  background: var(--pure-white);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-checkbox:checked+.checkbox-custom {
  background: var(--royal-blue);
  border-color: var(--gold-primary);
}

.custom-checkbox:checked+.checkbox-custom::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid var(--gold-light);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox-text {
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.45;
}

/* Field Errors */
.field-error {
  font-size: 0.74rem;
  color: var(--error-red);
  font-weight: 500;
  display: none;
}

.has-error .form-input,
.has-error .form-select,
.has-error .form-textarea {
  border-color: var(--error-red) !important;
  background-color: var(--error-bg);
}

.has-error .field-error {
  display: block;
}

/* Submit Button & Loading */
.submit-btn {
  width: 100%;
  min-height: 48px;
  padding: 13px 24px;
  background: linear-gradient(135deg, #112550 0%, #0b1b3d 60%, #071126 100%);
  color: var(--pure-white);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px -6px rgba(11, 27, 61, 0.5), 0 0 16px var(--gold-glow);
  transition: transform 0.25s var(--transition-smooth), box-shadow 0.25s ease;
  margin-top: 6px;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(11, 27, 61, 0.65), 0 0 24px var(--gold-glow);
}

.submit-btn:active {
  transform: translateY(0);
}

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-spinner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--gold-light);
}

.spinner-svg {
  width: 20px;
  height: 20px;
  animation: spin 0.9s linear infinite;
}

.spinner-track {
  stroke: rgba(255, 255, 255, 0.2);
  fill: none;
}

.spinner-head {
  stroke: var(--gold-light);
  fill: none;
  stroke-dasharray: 45;
  stroke-dashoffset: 20;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.submit-btn.is-loading {
  pointer-events: none;
  opacity: 0.9;
}

.submit-btn.is-loading .btn-content {
  display: none;
}

.submit-btn.is-loading .btn-spinner {
  display: flex;
}

/* Action Gold Button */
.action-btn-gold {
  width: 100%;
  min-height: 48px;
  padding: 13px 24px;
  background: linear-gradient(135deg, #ffdf73 0%, #d4af37 60%, #b8860b 100%);
  color: #2b1800;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.45);
  transition: transform 0.25s var(--transition-bounce), box-shadow 0.25s ease;
}

.action-btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.65);
}

.action-btn-close {
  width: 100%;
  min-height: 42px;
  padding: 10px 20px;
  background: transparent;
  color: var(--gray-600);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn-close:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

/* ==========================================================================
   MODALS (Welcome & Success)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--transition-smooth);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Section 4: Welcome Popup Card */
.popup-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(170deg, #12244d 0%, #0b1b3d 60%, #08142c 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: var(--radius-lg);
  padding: 30px 22px;
  text-align: center;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(212, 175, 55, 0.3);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.45s var(--transition-bounce);
  overflow: hidden;
}

.modal-backdrop.active .popup-card {
  transform: translateY(0) scale(1);
}

.popup-sparkle-halo {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 120px;
  background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.4) 0%, transparent 70%);
  pointer-events: none;
}

.popup-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-light);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.badge-dot {
  width: 6px;
  height: 6px;
  background: var(--gold-light);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--gold-light);
}

.popup-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1e3a7a 0%, #0d1e44 100%);
  border: 1.5px solid rgba(212, 175, 55, 0.6);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px var(--gold-glow);
}

.popup-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--pure-white);
  line-height: 1.35;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.popup-desc {
  font-size: 0.85rem;
  color: var(--gray-400);
  line-height: 1.5;
  margin-bottom: 22px;
}

.popup-action {
  margin-bottom: 10px;
}

.popup-footer-note {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
}

/* ==========================================================================
   Section 9: Thank-You Experience & Green Checkmark Animation
   ========================================================================== */

.success-card {
  width: 100%;
  max-width: 420px;
  background: var(--pure-white);
  border-radius: var(--radius-lg);
  padding: 34px 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45), 0 0 0 1.5px var(--gold-primary);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.45s var(--transition-bounce);
  overflow: hidden;
}

.modal-backdrop.active .success-card {
  transform: translateY(0) scale(1);
}

.success-seal-halo {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  height: 150px;
  background: radial-gradient(ellipse at center, rgba(16, 185, 129, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

/* Animated Green Checkmark Outline & Tick */
.success-icon-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkmark-svg {
  width: 70px;
  height: 70px;
  stroke: var(--success-green);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke: var(--success-green);
  animation: circleDraw 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkDraw 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.55s forwards;
}

@keyframes circleDraw {
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes checkDraw {
  100% {
    stroke-dashoffset: 0;
  }
}

.success-pill {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--success-green-dark);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Sequential Thank You Messages */
.sequential-thankyou-wrap {
  margin-bottom: 18px;
}

.success-msg-primary {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--royal-blue);
  margin-bottom: 6px;
  line-height: 1.35;
  animation: fadeInUp 0.6s ease 0.2s both;
}

.success-msg-secondary {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold-deep);
  animation: fadeInUp 0.6s ease 0.5s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success-ref-box {
  background: var(--off-white);
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.ref-label {
  color: var(--gray-600);
}

.ref-value {
  font-weight: 700;
  font-family: monospace;
  color: var(--gray-800);
}

.text-green {
  color: var(--success-green-dark);
}

.success-gratitude {
  font-size: 0.82rem;
  color: var(--gray-600);
  line-height: 1.5;
  margin-bottom: 22px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   REDUCED MOTION & ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .envelope.is-open .envelope-top-flap {
    transform: none;
    display: none;
  }

  .envelope.is-open .letter-card {
    animation: none;
    transform: none;
  }

  /* Emoji satisfaction scale: keep the states, drop the movement */
  .emoji-option:hover,
  .emoji-option:active,
  .emoji-option[aria-checked="true"] {
    transform: none;
  }

  .emoji-option:hover .emoji-glyph,
  .emoji-option.is-burst .emoji-glyph,
  .emoji-option.is-burst .emoji-label,
  .emoji-option.is-burst .emoji-badge,
  .rating-response-inner.is-animating {
    animation: none;
  }

  .emoji-option.is-burst .emoji-ripple {
    animation: none;
    opacity: 0.5;
    transform: scale(2.4);
  }

  .emoji-option.is-burst .emoji-sparkle {
    animation: none;
    opacity: 0.8;
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  body {
    padding: 12px 10px 48px;
  }

  .brand-title {
    font-size: 1.4rem;
  }

  .welcome-heading {
    font-size: 1.3rem;
  }

  .letter-card {
    padding: 22px 16px;
  }
}