/* ============================================
   LETIZIA TOPINA — Graduation Gift Website
   Design System & Animations
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Colors */
  --bg-primary: #0a0e27;
  --bg-secondary: #110d2b;
  --bg-accent: #1a0a2e;
  --gold: #d4a853;
  --gold-light: #f0c675;
  --gold-bright: #ffd700;
  --white: #ffffff;
  --white-soft: rgba(255, 255, 255, 0.85);
  --cyan: #00d4ff;
  --cyan-glow: rgba(0, 212, 255, 0.4);
  --boarding-cream: #f5f0e8;
  --boarding-dark: #2c2c2c;
  --scan-green: #00ff2a;

  /* Typography */
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;

  /* Transitions */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  background: var(--bg-primary);
  background-color: var(--bg-primary);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Starfield Background ---------- */
#starfield-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Phase System ---------- */
.phase {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s var(--ease-out-expo), visibility 0.8s;
}

.phase.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   PHASE 1: CONGRATULATIONS
   ============================================ */
.congrats-content {
  text-align: center;
  position: relative;
  z-index: 2;
  padding: var(--space-lg);
}

.congrats-laurels {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  opacity: 0;
  animation: fadeInDown 1s var(--ease-out-expo) 0.3s forwards;
}

.congrats-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--white) 0%, var(--gold-light) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 30px rgba(212, 168, 83, 0.3));
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  animation: congrats-reveal 1.2s var(--ease-out-expo) 0.5s forwards;
}

.congrats-subtitle {
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 300;
  color: var(--white-soft);
  margin-top: var(--space-md);
  letter-spacing: 0.05em;
  opacity: 0;
  animation: fadeInUp 1s var(--ease-out-expo) 1s forwards;
}

/* Reveal Button */
.reveal-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: var(--space-xl);
  padding: 1rem 2.5rem;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bg-primary);
  background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-bright));
  border: none;
  border-radius: 60px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 1s var(--ease-out-expo) 1.6s forwards;
  transition: transform 0.3s var(--ease-out-back), box-shadow 0.3s ease;
  box-shadow: 0 4px 25px rgba(212, 168, 83, 0.4), 0 0 60px rgba(212, 168, 83, 0.15);
}

.reveal-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 40px rgba(212, 168, 83, 0.6), 0 0 80px rgba(212, 168, 83, 0.25);
}

.reveal-button:active {
  transform: scale(0.97);
}

/* Shimmer effect */
.reveal-button::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  animation: shimmer 3s ease-in-out infinite;
}

.btn-icon {
  font-size: 1.4rem;
  animation: bounce-gift 2s ease-in-out infinite 2s;
}

/* ============================================
   PHASE 2: COUNTDOWN
   ============================================ */
.countdown-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
}

.countdown-number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(8rem, 30vw, 20rem);
  color: var(--white);
  text-shadow: 0 0 60px rgba(0, 212, 255, 0.5), 0 0 120px rgba(0, 212, 255, 0.2);
  opacity: 0;
  transform: scale(0.3);
  position: absolute;
}

.countdown-number.animate {
  animation: countdownZoom 0.85s var(--ease-out-expo) forwards;
}

/* Screen flash on each number */
.countdown-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.15) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.countdown-flash.flash {
  animation: screenFlash 0.4s ease-out forwards;
}

/* ============================================
   PHASE 3: BOARDING PASS
   ============================================ */
.boarding-scene {
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.boarding-pass {
  width: min(90vw, 520px);
  background: var(--boarding-cream);
  border-radius: 16px;
  color: var(--boarding-dark);
  position: relative;
  overflow: hidden;
  transform: translateY(120%) rotateX(25deg);
  opacity: 0;
  transition: transform 1s var(--ease-out-expo), opacity 0.6s ease;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.boarding-pass.visible {
  transform: translateY(0) rotateX(0deg);
  opacity: 1;
}

/* Perforated edge */
.boarding-pass::before {
  content: '';
  position: absolute;
  right: 28%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: repeating-linear-gradient(to bottom,
      transparent 0px,
      transparent 6px,
      rgba(0, 0, 0, 0.15) 6px,
      rgba(0, 0, 0, 0.15) 12px);
}

.pass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: var(--white);
}

.airline {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

.pass-class {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold-light);
}

.pass-body {
  padding: 1.25rem 1.5rem;
}

.passenger-info {
  margin-bottom: 1rem;
}

.passenger-info label,
.route-info label,
.pass-details label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 0.15rem;
}

.passenger-info span {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--boarding-dark);
}

.route-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.route-city {
  text-align: center;
}

.city-code {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: #1a1a2e;
  line-height: 1;
}

.city-name {
  display: block;
  font-size: 0.65rem;
  color: #888;
  letter-spacing: 0.05em;
}

.route-arrow {
  font-size: 1.2rem;
  color: var(--gold);
  flex-shrink: 0;
}

.pass-details {
  display: flex;
  gap: 1.5rem;
}

.pass-details>div span {
  font-weight: 700;
  font-size: 1rem;
}

.pass-barcode {
  padding: 0.75rem 1.5rem 1rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.barcode {
  height: 40px;
  background: repeating-linear-gradient(90deg,
      #1a1a2e 0px, #1a1a2e 2px,
      transparent 2px, transparent 4px,
      #1a1a2e 4px, #1a1a2e 5px,
      transparent 5px, transparent 7px,
      #1a1a2e 7px, #1a1a2e 10px,
      transparent 10px, transparent 12px,
      #1a1a2e 12px, #1a1a2e 13px,
      transparent 13px, transparent 16px,
      #1a1a2e 16px, #1a1a2e 18px,
      transparent 18px, transparent 19px,
      #1a1a2e 19px, #1a1a2e 22px,
      transparent 22px, transparent 24px);
  border-radius: 4px;
}

/* Scanner bar */
.scanner-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent 10%, var(--scan-green) 50%, transparent 90%);
  box-shadow: 0 0 15px var(--scan-green), 0 0 30px rgba(0, 255, 136, 0.3);
  opacity: 0;
  z-index: 5;
  pointer-events: none;
}

.scanner-bar.scanning {
  opacity: 1;
  animation: scanDown 1.2s ease-in-out forwards;
}

.scanner-bar.scanning-2 {
  opacity: 1;
  animation: scanDown 1.2s ease-in-out forwards;
}

/* Approved stamp */
.approved-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(3) rotate(-15deg);
  font-family: var(--font-body);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--scan-green);
  border: 5px solid var(--scan-green);
  border-radius: 12px;
  padding: 0.3rem 1.5rem;
  opacity: 0;
  z-index: 6;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
  pointer-events: none;
}

.approved-stamp.show {
  animation: stampAppear 0.5s var(--ease-out-back) forwards;
}

/* ============================================
   PHASE 4: 3D GLOBE
   ============================================ */
#globe-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.final-message {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
  opacity: 0;
  transition: opacity 1.5s ease;
  pointer-events: none;
}

.final-message.visible {
  opacity: 1;
}

.final-message h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.3;
  background: linear-gradient(135deg, var(--white), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(212, 168, 83, 0.4));
}

.final-message .emoji-row {
  font-size: clamp(2rem, 6vw, 3.5rem);
  margin-top: var(--space-sm);
}

/* ============================================
   CITY REVEAL OVERLAY
   ============================================ */
.city-reveal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.city-reveal.visible {
  opacity: 1;
}

.city-reveal.fade-out {
  opacity: 0;
  transition: opacity 1.2s ease;
}

.city-reveal-name {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 7rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
  background: linear-gradient(
    135deg,
    #d4a853 0%,
    #ffd700 20%,
    #fffbe6 40%,
    #ffd700 60%,
    #d4a853 80%,
    #b8860b 100%
  );
  background-size: 200% 200%;
  animation: goldShimmer 3s ease-in-out infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 40px rgba(255, 215, 0, 0.5))
         drop-shadow(0 0 80px rgba(212, 168, 83, 0.3));
  opacity: 0;
  transform: scale(0.5);
  letter-spacing: 0.04em;
}

.city-reveal.visible .city-reveal-name {
  animation: cityNameAppear 1s var(--ease-out-back) forwards, goldShimmer 3s ease-in-out 1s infinite;
}

@keyframes goldShimmer {
  0% {
    background-position: 200% 0%;
  }
  100% {
    background-position: -200% 0%;
  }
}

@keyframes cityNameAppear {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
  }
  60% {
    opacity: 1;
    transform: scale(1.08) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* City label styles for Three.js overlay */
.city-label {
  position: absolute;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.city-label.visible {
  opacity: 1;
}

/* ============================================
   POLAROID PHOTOS OVERLAY
   ============================================ */
.polaroid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.polaroid-overlay.visible {
  opacity: 1;
}

.polaroid {
  position: absolute;
  width: clamp(160px, 28vw, 240px);
  background: #fff;
  padding: 10px 10px 36px 10px;
  border-radius: 3px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.06);
  opacity: 0;
  animation: polaroidDrop 0.7s var(--ease-out-back) var(--delay, 0s) forwards;
  transform-origin: center center;
}

.polaroid-image {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  overflow: hidden;
}

.polaroid-caption {
  text-align: center;
  font-family: var(--font-body);
  font-size: clamp(0.65rem, 1.5vw, 0.85rem);
  font-weight: 500;
  color: #444;
  margin-top: 6px;
  letter-spacing: 0.03em;
}

/* ============================================
   TRANSITION TEXT
   ============================================ */
.transition-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.transition-text.visible {
  opacity: 1;
}

.transition-line {
  font-family: var(--font-body);
  font-size: clamp(1.2rem, 3.5vw, 2rem);
  font-weight: 300;
  color: var(--white-soft);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.6s ease, transform 0.6s var(--ease-out-expo);
  line-height: 1.6;
}

.transition-line.show {
  opacity: 1;
  transform: translateY(0);
}

.transition-dest {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--white), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: var(--space-sm);
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  transition: opacity 0.8s ease, transform 0.8s var(--ease-out-back);
}

.transition-dest.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

@keyframes congrats-reveal {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {

  0%,
  100% {
    left: -60%;
  }

  50% {
    left: 120%;
  }
}

@keyframes bounce-gift {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  25% {
    transform: translateY(-5px) rotate(-5deg);
  }

  75% {
    transform: translateY(-3px) rotate(5deg);
  }
}

@keyframes countdownZoom {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }

  40% {
    opacity: 1;
    transform: scale(1.15);
  }

  60% {
    transform: scale(0.95);
  }

  75% {
    transform: scale(1.02);
  }

  100% {
    opacity: 0;
    transform: scale(2.5);
  }
}

@keyframes screenFlash {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes scanDown {
  0% {
    top: 0;
  }

  100% {
    top: calc(100% - 4px);
  }
}

@keyframes stampAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(3) rotate(-15deg);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9) rotate(-15deg);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-15deg);
  }
}

@keyframes polaroidDrop {
  0% {
    opacity: 0;
    transform: translateY(-110vh) rotate(calc(var(--rot) + 25deg)) scale(0.7);
  }

  55% {
    opacity: 1;
    transform: translateY(8px) rotate(calc(var(--rot) - 4deg)) scale(1.03);
  }

  75% {
    transform: translateY(-4px) rotate(calc(var(--rot) + 2deg)) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateY(var(--oy, 0px)) translateX(var(--ox, 0px)) rotate(var(--rot)) scale(1);
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .congrats-laurels {
    font-size: 2rem;
  }

  .reveal-button {
    padding: 0.85rem 2rem;
    font-size: 1rem;
  }

  .boarding-pass {
    width: 92vw;
    border-radius: 12px;
  }

  .pass-header {
    padding: 0.75rem 1rem;
  }

  .pass-body {
    padding: 1rem;
  }

  .city-code {
    font-size: 1.4rem;
  }

  .passenger-info span {
    font-size: 1.1rem;
  }

  .route-info {
    gap: 0.3rem;
  }

  .pass-details {
    gap: 1rem;
  }

  .approved-stamp {
    font-size: 1.6rem;
    border-width: 3px;
    padding: 0.2rem 1rem;
  }

  .final-message {
    bottom: 5%;
    padding: 0 var(--space-sm);
  }
}

@media (max-width: 380px) {
  .congrats-title {
    font-size: 2rem;
  }

  .countdown-number {
    font-size: 7rem;
  }

  .city-code {
    font-size: 1.2rem;
  }
}

/* ============================================
   TRAVEL BOARD MODAL
   ============================================ */
.travel-board {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.travel-board.active {
  opacity: 1;
  visibility: visible;
}

.board-content {
  background: linear-gradient(135deg, #1a1f35, #101423);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: min(90vw, 600px);
  max-height: 85vh;
  padding: 2.5rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.5s var(--ease-out-expo);
  overflow-y: auto;
}

.travel-board.active .board-content {
  transform: translateY(0) scale(1);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 2.5rem;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}

.close-btn:hover {
  color: var(--white);
}

.board-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--white), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1rem;
}

.board-body {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--white-soft);
}

.board-body ul {
  list-style: none;
  margin-top: 1rem;
}

.board-body li {
  margin-bottom: 0.8rem;
  padding-left: 1.8rem;
  position: relative;
}

.board-body li::before {
  content: '✨';
  position: absolute;
  left: 0;
  top: 2px;
  font-size: 0.9rem;
}

.board-body h3 {
  color: var(--gold-light);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.3rem;
  font-weight: 600;
}