/* generate.css — layout for the T4 screens: Progress, Result, Offline, and the
 * install bar. Same tokens + inline-free posture as base.css / screens.css.
 *
 * The Progress screen layers an AMBIENT holiday scene (drifting sun, clouds,
 * birds, a rolling wave) behind an honest, backend-driven progress bar. The scene
 * is decorative only — it fills the wait but never represents real progress. All
 * of its motion is neutralised by the prefers-reduced-motion rule in base.css.
 */

/* ============================ PROGRESS ============================ */
.screen-progress {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 8%, #ff9a5a 0%, #e86a4a 20%, #6d3f6e 50%, var(--ink) 84%);
  padding: calc(var(--s5) + var(--safe-t))
    calc(var(--s5) + var(--safe-r))
    calc(var(--s5) + var(--safe-b))
    calc(var(--s5) + var(--safe-l));
}

/* --- ambient scene --- */
.progress-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.p-sun {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 140px;
  height: 140px;
  margin-left: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff2cf 0%, var(--gold) 55%, rgba(255, 194, 75, 0) 72%);
  animation: p-sun-breathe 5.5s ease-in-out infinite;
}

.p-cloud {
  position: absolute;
  height: 26px;
  border-radius: var(--r-pill);
  background: rgba(255, 246, 233, 0.72);
  filter: blur(1px);
  opacity: 0.75;
}

.p-cloud::before,
.p-cloud::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: inherit;
}

.p-cloud-a {
  top: 26%;
  left: -30%;
  width: 120px;
  animation: p-drift-r 26s linear infinite;
}

.p-cloud-a::before { width: 44px; height: 44px; left: 18px; bottom: 2px; }
.p-cloud-a::after { width: 60px; height: 60px; right: 16px; bottom: 4px; }

.p-cloud-b {
  top: 40%;
  left: -40%;
  width: 90px;
  height: 20px;
  opacity: 0.55;
  animation: p-drift-r 34s linear infinite;
  animation-delay: -12s;
}

.p-cloud-b::before { width: 34px; height: 34px; left: 14px; bottom: 2px; }
.p-cloud-b::after { width: 46px; height: 46px; right: 12px; bottom: 3px; }

.p-bird {
  position: absolute;
  width: 16px;
  height: 8px;
  border-top: 2px solid rgba(20, 35, 59, 0.6);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.p-bird::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 12px;
  width: 16px;
  height: 8px;
  border-top: 2px solid rgba(20, 35, 59, 0.6);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.p-bird-a { top: 20%; left: -10%; animation: p-fly 18s linear infinite; }
.p-bird-b { top: 24%; left: -10%; transform: scale(0.7); animation: p-fly 22s linear infinite; animation-delay: -8s; }

.p-wave {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -40px;
  height: 140px;
  background:
    radial-gradient(60% 60% at 20% 0%, rgba(47, 191, 166, 0.5), rgba(47, 191, 166, 0) 70%),
    radial-gradient(60% 60% at 60% 10%, rgba(47, 191, 166, 0.4), rgba(47, 191, 166, 0) 70%),
    linear-gradient(rgba(20, 35, 59, 0.2), rgba(20, 35, 59, 0.6));
  border-radius: 50% 50% 0 0;
  animation: p-swell 7s ease-in-out infinite;
}

@keyframes p-sun-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes p-drift-r { from { transform: translateX(0); } to { transform: translateX(160vw); } }
@keyframes p-fly {
  from { transform: translateX(0) translateY(0); }
  50% { transform: translateX(60vw) translateY(-12px); }
  to { transform: translateX(130vw) translateY(6px); }
}
@keyframes p-swell { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

/* --- mini-game (change B): a playful canvas overlay entertaining the wait.
 * Sits above the ambient scene but below the card, so the card's Cancel/Retry
 * taps always land on the card, never the canvas. */
.progress-game {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* --- card --- */
.progress-card {
  position: relative;
  z-index: 2;
  width: min(92%, 440px);
  margin-top: auto;
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s6) var(--s5);
  border-radius: var(--r-lg);
  background: rgba(20, 35, 59, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(10px);
  text-align: center;
}

.progress-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.progress-scene-counter {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.85);
}

.progress-title {
  font-size: clamp(1.4rem, 6vw, 1.8rem);
  color: #fff;
}

.progress-copy {
  max-width: 32ch;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  font-size: 1rem;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 12px;
  margin-top: var(--s3);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.progress-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--gold), var(--coral));
  transition: width 420ms ease;
}

/* Indeterminate: sweep a highlight; the fill width is left at 0. */
.progress-bar.is-indeterminate::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, rgba(255, 194, 75, 0), var(--gold), rgba(255, 122, 77, 0));
  animation: p-indeterminate 1.5s ease-in-out infinite;
}

@keyframes p-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.progress-meta {
  min-height: 1.2em;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.progress-cancel {
  margin-top: var(--s3);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.4);
  background: transparent;
}

.progress-cancel:active { background: rgba(255, 255, 255, 0.08); }

/* failure block inside the card */
.progress-fail {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  width: 100%;
  margin-top: var(--s3);
}

.progress-fail-copy {
  color: #fff;
  line-height: 1.5;
}

.progress-fail-actions {
  display: flex;
  gap: var(--s3);
  justify-content: center;
}

.progress-fail-actions .btn { flex: 1 1 auto; }
.progress-fail .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.4); background: transparent; }

/* ============================ RESULT ============================ */
.screen-result { background: var(--ink); }

.result-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s4)
    calc(var(--s5) + var(--safe-r)) var(--s4)
    calc(var(--s5) + var(--safe-l));
}

.result-stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  border-radius: var(--r);
  background: #000;
  box-shadow: var(--shadow-lift);
}

.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  padding: var(--s7) 0;
  color: var(--on-ink-dim);
}

.result-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--gold);
  animation: r-spin 0.9s linear infinite;
}

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

.result-loading-copy { font-size: 0.95rem; }

.result-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  padding: var(--s6) var(--s4);
  text-align: center;
}

.result-error-copy { color: var(--on-ink); line-height: 1.5; }
.result-error .btn-ghost { color: var(--on-ink); border-color: var(--ink-3); }

.result-caption {
  color: var(--on-ink-dim);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.result-hint {
  color: var(--on-ink-dim);
  font-size: 0.85rem;
  text-align: center;
  max-width: 34ch;
}

.result-actions { flex-wrap: wrap; }
.result-actions .btn,
.result-actions .btn:link {
  flex: 1 1 40%;
  text-decoration: none;
}
.result-actions .btn-ghost { color: var(--on-ink); border-color: var(--ink-3); }

/* ============================ OFFLINE ============================ */
.screen-offline { background: var(--ink); }

.offline-page {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--on-ink);
}

.screen-offline,
.offline-page {
  padding: calc(var(--s6) + var(--safe-t)) var(--s5) calc(var(--s6) + var(--safe-b));
}

.screen-offline {
  align-items: center;
  justify-content: center;
}

.offline-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s4);
  max-width: 34ch;
  text-align: center;
}

.offline-glyph { color: var(--gold); }
.offline-title { font-size: 1.6rem; color: #fff; }
.offline-copy { color: var(--on-ink-dim); line-height: 1.5; }
.offline-inner .btn { margin-top: var(--s2); text-decoration: none; }

/* ============================ INSTALL BAR ============================ */
.install-bar {
  position: fixed;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--s4) + var(--safe-b));
  width: min(92%, 460px);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--on-paper);
  box-shadow: var(--shadow-lift);
  animation: install-rise 320ms ease;
}

@keyframes install-rise {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.install-ico {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--coral);
}

.install-copy {
  flex: 1 1 auto;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.install-add {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 var(--s4);
}

.install-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--on-paper-dim);
  cursor: pointer;
  touch-action: manipulation;
}

.install-close:active { background: rgba(0, 0, 0, 0.06); }

@media (min-width: 640px) {
  .result-body { max-width: 560px; margin-left: auto; margin-right: auto; }
}
