/* ===================================================================
   style.css
   Back-to-School Campaign Microsite — Navy & Gold Theme
   Shared styles for index.php, record.php, watch.php.
   Tablet-first: large touch targets, generous spacing, fast to render.
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --color-bg: #141c33;          /* navy from brand background */
  --color-bg-alt: #0a0f1f;      /* darker navy for gradient fallback */
  --color-card: #ffffff;        /* clean white card, pops against navy bg */
  --color-ink: #141c33;         /* navy text */
  --color-muted: #707a90;
  --color-accent: #f6c90e;      /* gold/yellow from the "BACK TO SCHOOL" logo */
  --color-accent-dark: #d9ae00;
  --color-error: #d94f45;
  --color-success: #2f7d55;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.35);

  /* Playful accent friends, used only for confetti/decoration —
     the brand navy & gold still lead everywhere else. */
  --color-fun-1: #ff8a5c; /* coral */
  --color-fun-2: #5cc8ff; /* sky blue */
  --color-fun-3: #7ee08c; /* mint */
  --color-fun-4: #ff6fb0; /* bubblegum pink */

  /* Lighter gold used only for the shimmer sweep on the title */
  --color-gold-light: #fff3b0;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--color-ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;

  /* Branded background image, with a navy gradient as a fallback/underlay
     in case the image is slow to load or missing on a given page. */
  background-color: var(--color-bg);
  background-image:
    linear-gradient(rgba(10, 15, 31, 0.35), rgba(10, 15, 31, 0.55)),
    url('../images/bg-back-to-school.jpg');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.screen {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 4px rgba(246, 201, 14, 0.35);
  padding: 26px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  z-index: 1;
  animation: cardPopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             cardGlowPulse 3.2s ease-in-out infinite 0.6s;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

/* A gentle playful tilt when kids hover/tap near the card — desktop only,
   media query below disables on touch so it doesn't fight taps. */
.card:hover {
  transform: translateY(-4px) rotate(-0.6deg) scale(1.02);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 0 5px rgba(246, 201, 14, 0.55);
}

/* Idle "glowing ring" heartbeat so the card feels alive even before
   anyone touches it. */
@keyframes cardGlowPulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 4px rgba(246, 201, 14, 0.35); }
  50% { box-shadow: var(--shadow), 0 0 0 8px rgba(246, 201, 14, 0.15); }
}

@keyframes cardPopIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.9) rotate(-2deg);
  }
  60% {
    transform: translateY(-4px) scale(1.02) rotate(1deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.card::before,
.card::after {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  animation: sparkleFloat 2.6s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.card::before {
  content: '✨';
  top: -16px;
  left: -8px;
  animation-delay: 0s;
}

.card::after {
  content: '⭐';
  bottom: -14px;
  right: -6px;
  font-size: 1.3rem;
  animation-delay: 1.1s;
  animation-direction: reverse;
}

/* Extra floating emoji friends around the card for more back-to-school fun */
.card-deco {
  position: absolute;
  pointer-events: none;
  font-size: 1.3rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  animation: sparkleFloat 3s ease-in-out infinite;
}

.card-deco--pencil {
  top: 10%;
  left: -22px;
  animation-delay: 0.4s;
  animation-duration: 3.4s;
}

.card-deco--book {
  bottom: 12%;
  right: -20px;
  font-size: 1.4rem;
  animation-delay: 0.9s;
  animation-direction: reverse;
}

.card-deco--balloon {
  top: -10px;
  right: 14%;
  font-size: 1.2rem;
  animation-delay: 0.2s;
  animation-duration: 3.8s;
}

.card-deco--rainbow {
  bottom: -8px;
  left: 16%;
  font-size: 1.25rem;
  animation-delay: 1.3s;
  animation-duration: 3.1s;
  animation-direction: reverse;
}

@keyframes sparkleFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(18deg);
  }
}

/* Playful entrance keyframes reused across the sheet */
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-6deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}

@keyframes bounceIn {
  0% { opacity: 0; transform: translateY(14px) scale(0.85); }
  55% { opacity: 1; transform: translateY(-4px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  70% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  margin: 0 0 4px;
  letter-spacing: 0.3px;
  display: inline-block;
  color: var(--color-accent); /* fallback if background-clip: text isn't supported */
  background: linear-gradient(
    90deg,
    var(--color-accent-dark) 0%,
    var(--color-accent) 22%,
    var(--color-gold-light) 45%,
    var(--color-accent) 68%,
    var(--color-accent-dark) 100%
  );
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 6px rgba(246, 201, 14, 0.4));
  animation: bounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.1s,
             titleFloat 3.4s ease-in-out infinite 0.8s,
             titleShimmer 3.2s linear infinite;
  transition: transform 0.2s ease;
}

.title:hover {
  animation: wiggle 0.5s ease, titleShimmer 0.8s linear infinite;
  cursor: default;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Gold glint sweeping across the title text, like light catching foil */
@keyframes titleShimmer {
  0% { background-position: 0% center; }
  100% { background-position: 220% center; }
}

.subtitle {
  color: var(--color-muted);
  margin: 0 0 20px;
  font-size: 0.9rem;
  animation: bounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.22s;
}

/* ---------- Form fields ---------- */

.field {
  text-align: left;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--color-ink);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
  transform-origin: left center;
}

.field:focus-within label {
  color: var(--color-accent-dark);
  transform: scale(1.06) translateX(1px);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="email"] {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.95rem;
  border: 2px solid #e4e7ee;
  border-radius: 9px;
  background: #fff;
  color: var(--color-ink);
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--color-accent);
  transform: scale(1.015);
  box-shadow: 0 0 0 4px rgba(246, 201, 14, 0.25);
}

.field input.invalid {
  border-color: var(--color-error);
  animation: shake 0.4s ease;
}

.error-msg {
  display: block;
  min-height: 16px;
  color: var(--color-error);
  font-size: 0.76rem;
  margin-top: 3px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  position: relative;
  width: 100%;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Fredoka', sans-serif;
  border: none;
  border-radius: 11px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  overflow: hidden;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-2px) scale(1.03);
}

.btn:active {
  transform: scale(0.96);
}

/* Shiny sweep across the button on hover, like a little glimmer */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
  pointer-events: none;
}

.btn:hover::after {
  left: 125%;
}

.btn-primary {
  background: var(--color-accent);
  color: #241d00;
  box-shadow: 0 4px 0 var(--color-accent-dark), 0 6px 14px rgba(246, 201, 14, 0.35);
  animation: btnInvitePulse 2.2s ease-in-out infinite;
}

.btn-primary:hover {
  background: var(--color-accent-dark);
  box-shadow: 0 4px 0 #b28e00, 0 10px 20px rgba(246, 201, 14, 0.45);
  animation: jellySquish 0.5s ease;
}

/* Soft "come tap me" breathing glow while idle */
@keyframes btnInvitePulse {
  0%, 100% { box-shadow: 0 4px 0 var(--color-accent-dark), 0 6px 14px rgba(246, 201, 14, 0.35); }
  50% { box-shadow: 0 4px 0 var(--color-accent-dark), 0 6px 22px rgba(246, 201, 14, 0.65); }
}

@keyframes jellySquish {
  0% { border-radius: 11px; }
  30% { border-radius: 22px 8px 22px 8px; transform: translateY(-2px) scale(1.05, 0.95); }
  60% { border-radius: 8px 22px 8px 22px; transform: translateY(-2px) scale(0.97, 1.05); }
  100% { border-radius: 11px; transform: translateY(-2px) scale(1.03); }
}

.btn-primary:active {
  box-shadow: 0 1px 0 var(--color-accent-dark);
  transform: scale(0.96) translateY(2px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-primary:disabled:hover {
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--color-ink);
  border: 2px solid #e4e7ee;
}

.btn-secondary:hover {
  border-color: var(--color-accent);
  background: #fffbea;
}

.btn-white {
  background: #ffffff;
  color: var(--color-ink);
  box-shadow: 0 4px 0 #d8dbe4, 0 6px 14px rgba(20, 28, 51, 0.12);
}

.btn-white:hover {
  background: #fffbea;
  box-shadow: 0 4px 0 #d8dbe4, 0 8px 18px rgba(20, 28, 51, 0.18);
}

.btn-white:active {
  box-shadow: 0 1px 0 #d8dbe4;
  transform: scale(0.96) translateY(2px);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
  box-shadow: 0 4px 0 #a83a32;
}

.btn-danger:hover {
  transform: translateY(-2px) scale(1.03) rotate(-1deg);
}

.btn-danger:active {
  box-shadow: 0 1px 0 #a83a32;
  transform: scale(0.96) translateY(2px);
}

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.btn-row .btn {
  width: auto;
  flex: 1;
}

/* ---------- Success / status panels ---------- */

.hidden {
  display: none !important;
}

.success-panel {
  margin-top: 6px;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-msg {
  color: var(--color-success);
  font-weight: 600;
  margin-bottom: 16px;
  position: relative;
  display: inline-block;
}

/* A little celebration burst next to the success message */
.success-msg::before {
  content: '🎉';
  display: inline-block;
  margin-right: 6px;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.15s, wiggle 1.8s ease-in-out infinite 0.65s;
}

.success-msg::after {
  content: '🎊';
  display: inline-block;
  margin-left: 6px;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.3s, wiggle 1.8s ease-in-out infinite reverse 0.8s;
}

/* Little falling confetti dots raining behind the success panel */
.success-panel {
  position: relative;
  overflow: visible;
}

.success-panel::before,
.success-panel::after {
  content: '';
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiFall 1.6s ease-in both;
}

.success-panel::before {
  left: 18%;
  background: var(--color-fun-2);
  animation-delay: 0.1s;
}

.success-panel::after {
  right: 20%;
  background: var(--color-fun-4);
  animation-delay: 0.35s;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(70px) rotate(220deg); opacity: 0; }
}

/* ---------- Capture screen specific ---------- */

.capture-card {
  max-width: 480px;
}

#video, #recordedPreview {
  width: 100%;
  border-radius: 10px;
  background: #000;
  display: block;
  margin-bottom: 16px;
}

.capture-frame-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}

.status-text {
  color: var(--color-muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #e4e7ee;
  border-radius: 50%;
  animation: spin 0.9s linear infinite, spinnerPulse 1.8s ease-in-out infinite,
             spinnerRainbow 2.4s linear infinite;
  margin: 18px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes spinnerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Cycle the spinner's colored edges through the playful palette so it
   feels more like a spinning toy top than a loading bar. */
@keyframes spinnerRainbow {
  0%   { border-top-color: var(--color-accent); border-right-color: var(--color-fun-1); }
  25%  { border-top-color: var(--color-fun-1);  border-right-color: var(--color-fun-4); }
  50%  { border-top-color: var(--color-fun-4);  border-right-color: var(--color-fun-2); }
  75%  { border-top-color: var(--color-fun-2);  border-right-color: var(--color-fun-3); }
  100% { border-top-color: var(--color-fun-3);  border-right-color: var(--color-accent); }
}

/* ---------- Download screen specific ---------- */

.download-card img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.download-card img:hover {
  transform: scale(1.02) rotate(-0.5deg);
}

.qr-wrap {
  margin-top: 18px;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.15s;
}

.qr-wrap img {
  width: 190px;
  height: 190px;
  margin: 0 auto;
  display: block;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.qr-wrap img:hover {
  transform: scale(1.06) rotate(1.5deg);
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .card {
    padding: 22px 18px;
    max-width: 340px;
  }
  .title {
    font-size: 1.4rem;
  }
}

/* Larger tablets in landscape: keep the card compact, don't stretch */
@media (min-width: 900px) {
  .card {
    max-width: 400px;
  }
  .capture-card {
    max-width: 500px;
  }
}

/* Touch devices (tablets/phones): skip the hover-tilt so it doesn't get
   "stuck" after a tap, but keep everything else playful. */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }
}

/* Respect reduced-motion preferences — kids' delight shouldn't come at
   the cost of accessibility for sensitive users. */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}