/* ============================================================
   style.css — Gradient Birthday Loader
   Design tokens match the Flask app (base.html).
   No inline styles anywhere — all visual state is driven
   by adding / removing classes from JS.
   ============================================================ */

/* ── Design tokens ── */
:root {
  --bg:             #0B0F14;
  --surface:        #1A2332;
  --border:         #2A3647;
  --accent:         #186275;
  --accent-hover:   #1d7a91;
  --accent-glow:    rgba(24, 98, 117, 0.35);
  --text:           #EDEDED;
  --text-secondary: #5B7797;
  --text-muted:     #8295B0;
  --success-text:   #7ecfdf;
  --error-text:     #e89090;

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body:    'Alegreya Sans', system-ui, sans-serif;

  --radius-card: 24px;
  --radius-sm:   10px;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  /* prevent scrollbar flash during redirect fade-out */
  overflow: hidden;
}

/* ── Whole-page fade-out on redirect ── */
body.is-redirecting {
  animation: page-fade-out 0.6s ease forwards;
}

@keyframes page-fade-out {
  to { opacity: 0; }
}

/* ── Ambient background glow ── */
.bg-glow {
  position: fixed;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(500px, 80vw, 1000px);
  height: clamp(300px, 50vh, 520px);
  background: radial-gradient(
    ellipse at center,
    rgba(24, 98, 117, 0.22) 0%,
    rgba(24, 98, 117, 0.07) 45%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.stage {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 48px); /* leave room for footer */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: clamp(44px, 6vw, 68px) clamp(40px, 7vw, 76px);
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow:
    0 0 0 1px rgba(24, 98, 117, 0.10),
    0 40px 100px rgba(0, 0, 0, 0.55);
  /* Slow glow-breathe so the card feels alive */
  animation: card-breathe 4s ease-in-out infinite;
}

@keyframes card-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(24, 98, 117, 0.10),
      0 40px 100px rgba(0, 0, 0, 0.55);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(24, 98, 117, 0.24),
      0 40px 100px rgba(0, 0, 0, 0.55),
      0 0 70px rgba(24, 98, 117, 0.12);
  }
}

/* ── Logo ── */
.logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  /* prevent ring from clipping */
  padding: 14px;
}

.logo-img {
  height: 52px;
  width: auto;
  display: block;
  position: relative;
  z-index: 1;
  animation: logo-pulse 3s ease-in-out infinite;
}

/* Glow ring behind logo */
.logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(24, 98, 117, 0.28) 0%,
    transparent 68%
  );
  animation: logo-glow 3s ease-in-out infinite;
  z-index: 0;
}

@keyframes logo-pulse {
  0%, 100% { transform: scale(1);    opacity: 1;    }
  50%       { transform: scale(1.07); opacity: 0.88; }
}

@keyframes logo-glow {
  0%, 100% { opacity: 0.45; transform: scale(1);   }
  50%       { opacity: 1;    transform: scale(1.35); }
}

/* ── Title ── */
.title {
  font-family: var(--font-heading);
  font-size: clamp(1.3rem, 2.5vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 36px;
}

/* ── Progress bar ── */
.progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 28px;
}

/* Indeterminate shimmer while polling */
.progress-fill {
  height: 100%;
  width: 45%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--success-text),
    var(--accent)
  );
  background-size: 200% 100%;
  animation: progress-shimmer 2s linear infinite;
  transition: width 0.5s ease;
}

/* Triggered by JS when server is ready */
.progress-fill.is-complete {
  width: 100%;
  animation: none;
  background: linear-gradient(90deg, var(--accent), var(--success-text));
}

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

/* ── Spinner ── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid rgba(24, 98, 117, 0.18);
  border-top-color: var(--accent);
  border-right-color: var(--success-text);
  animation: spin 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transition: border-color 0.3s ease;
}

/* Triggered by JS when server is ready */
.spinner.is-done {
  animation: none;
  border-color: rgba(24, 98, 117, 0.35);
  border-top-color: var(--success-text);
  border-right-color: var(--success-text);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Status message ── */
.status-msg {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.5em;
  margin-bottom: 12px;
  transition: opacity 0.35s ease;
}

/* JS adds this class to fade before swapping text */
.status-msg.is-fading {
  opacity: 0;
}

/* JS adds this class when server responds */
.status-msg.is-ready {
  color: var(--success-text);
}

/* ── Dot indicators ── */
.dots {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.25;
  animation: dot-pop 1.5s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pop {
  0%, 80%, 100% {
    opacity: 0.22;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1.25);
    box-shadow: 0 0 7px rgba(24, 98, 117, 0.65);
  }
}

/* ── Cold-start note ── */
.cold-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.65;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(42, 54, 71, 0.65);
  border-radius: var(--radius-sm);
  width: 100%;
}

.cold-note strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Timeout warning ── */
.timeout-warning {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: rgba(164, 203, 235, 0.06);
  border: 1px solid rgba(164, 203, 235, 0.18);
  color: #a4cbeb;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.65;
  width: 100%;
  animation: fade-up 0.45s ease;
}

/* hidden attribute handled by JS; this just animates the reveal */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* ── Success flash ── */
.success-flash {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--success-text);
  font-size: 0.9rem;
  font-weight: 500;
  animation: fade-up 0.3s ease;
  width: 100%;
}

.success-flash svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Footer ── */
.page-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 520px) {
  .card {
    padding: 36px 24px;
    border-radius: 18px;
  }

  .logo-img {
    height: 44px;
  }
}

@media (max-width: 360px) {
  .card {
    padding: 28px 18px;
  }
}
