/* =============================================
   The Cold Chain Crisis — Custom Styles
   ============================================= */

/* ---- Fixed Aspect Ratio Container ---- */
:root {
  --app-dvh: 100vh;
  --frame-base-width: 1000px;
  --frame-base-height: 625px;
  --frame-scale: 1;
}

@supports (height: 100dvh) {
  :root {
    --app-dvh: 100dvh;
  }
}

body {
  min-height: var(--app-dvh);
  overflow: hidden;
}

html,
body {
  width: 100%;
  height: 100%;
}

#frame-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  padding-inline: clamp(16px, 3vw, 44px);
}

#frame-stage {
  width: min(100%, 1280px);
  height: 100%;
  margin: 0 auto;
}

#articulate-frame {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Main content fills container with internal scroll */
#main-area {
  overflow: hidden;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* ---- Custom Scrollbar ---- */
#main-area::-webkit-scrollbar {
  width: 6px;
}

#main-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

#main-area::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 3px;
}

#main-area::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
}

/* ---- Slide Transitions ---- */
#slide-container {
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.slide-content {
  animation: slideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Hero Animations ---- */
.hero-badge {
  animation: fadeInDown 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.hero-title {
  animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both;
}

.hero-subtitle {
  animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.7s both;
}

.stats-grid {
  animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.9s both;
}

.stat-card-intro:nth-child(1) { animation: fadeInScale 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1.1s both; }
.stat-card-intro:nth-child(2) { animation: fadeInScale 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1.3s both; }
.stat-card-intro:nth-child(3) { animation: fadeInScale 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1.5s both; }

.cta-button {
  animation: fadeInScale 0.9s cubic-bezier(0.22, 1, 0.36, 1) 1.7s both;
}

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---- HUD Value Flash Animations ---- */
.flash-red {
  animation: flashRed 0.7s ease;
}
.flash-green {
  animation: flashGreen 0.7s ease;
}

@keyframes flashRed {
  0%   { color: inherit; transform: scale(1); }
  30%  { color: #ef4444; transform: scale(1.15); text-shadow: 0 0 12px rgba(239, 68, 68, 0.5); }
  100% { color: inherit; transform: scale(1); }
}
@keyframes flashGreen {
  0%   { color: inherit; transform: scale(1); }
  30%  { color: #0d9488; transform: scale(1.15); text-shadow: 0 0 12px rgba(13, 148, 136, 0.5); }
  100% { color: inherit; transform: scale(1); }
}

/* ---- Fuel Bar Critical Pulse ---- */
.fuel-critical {
  animation: fuelPulse 1.2s ease-in-out infinite;
}
@keyframes fuelPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ---- Choice Cards ---- */
.choice-card {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), 
              box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1), 
              border-color 0.25s ease;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.choice-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.choice-card:active {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ---- Speech Bubble Pointer ---- */
@media (min-width: 640px) {
  .speech-bubble {
    position: relative;
  }
  .speech-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 24px;
    border: 7px solid transparent;
    border-right-color: #1e293b;
  }
}

/* ---- Modal Animation ---- */
.modal-enter {
  animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---- Resource FAB Pulse ---- */
.fab-pulse {
  animation: fabPulse 2s ease-in-out infinite;
}
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 64, 175, 0.4); }
  50%      { box-shadow: 0 0 0 10px rgba(30, 64, 175, 0); }
}

/* ---- Grade Badge Entrance ---- */
.grade-pop {
  animation: gradePop 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes gradePop {
  0%   { opacity: 0; transform: scale(0.3); }
  60%  { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- Counter Roll Animation ---- */
.count-up {
  font-variant-numeric: tabular-nums;
}

/* ---- Results Stat Card Stagger ---- */
.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card {
  animation: statIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes statIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- Timeline Connector ---- */
.timeline-dot {
  position: relative;
}
.timeline-dot::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: -20px;
  width: 2px;
  background: #334155;
}
.timeline-dot:last-child::before {
  display: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* ---- Misc ---- */
.text-gradient {
  background: linear-gradient(135deg, #3b82f6, #1e40af, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
