/* ── GiggleGrid — Main Styles ─────────────────────────────── */

:root {
  --color-primary: #ffbf3a;
  --color-primary-light: #ffd36e;
  --color-accent: #ffbf3a;
  --color-bg: #000748;
  --color-text: #ffbf3a;
  --color-overlay: rgba(0, 0, 0, 0.6);
  --font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  --transition-speed: 0.3s;
}

/* ── Reset ──────────────────────────────────────────────────── */

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
}

/* ── App container ──────────────────────────────────────────── */

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Video feed ─────────────────────────────────────────────── */

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror for selfie feel */
}

/* ── Overlay canvas (same size as video) ────────────────────── */

.overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 15;
}

/* ── Processing overlay ─────────────────────────────────────── */

.processing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 50;
  pointer-events: none;
}

.processing-card {
  width: 75vw;
  max-width: 960px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1030;
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  transform: rotate(-2deg);
  overflow: hidden;
  border: 2px solid rgba(255, 191, 58, 0.3);
}

#processing-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.processing-status {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1rem;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.35);
}

.processing-dots::after {
  content: "";
  display: inline-block;
  width: 1.5ch;
  text-align: left;
  animation: dots 1s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

/* ── Prompt ──────────────────────────────────────────────────── */

.prompt {
  position: absolute;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.55);
  padding: 1.25rem 2.5rem;
  border-radius: 1.25rem;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
  z-index: 10;
  max-width: 70vw;
}

.prompt-sub {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.9;
}

.shoot-btn {
  position: absolute;
  bottom: 6vh;
  right: 6vw;
  transform: translateX(0);
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  color: #0d0d1a;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.9rem 2.4rem;
  border: none;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  z-index: 60;
}

.shoot-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.4);
  filter: brightness(1.05);
}

.shoot-btn:active {
  transform: translateY(1px) scale(0.99);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Countdown ──────────────────────────────────────────────── */

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.4) 70%);
  backdrop-filter: blur(1px);
  opacity: 0.5; /* 50% see-through */
  mix-blend-mode: screen;
}

.countdown::before,
.countdown::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  pointer-events: none;
}

.countdown::after {
  inset: 18%;
  border-color: rgba(255, 255, 255, 0.18);
}

.countdown span {
  font-size: 12rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.1em;
  animation: reel-count 1s ease-out;
}

@keyframes reel-count {
  0% {
    transform: scale(1.25) rotate(-2deg);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(2deg);
    opacity: 0.9;
  }
}

/* ── Flash effect ───────────────────────────────────────────── */

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 30;
  pointer-events: none;
}

.flash.animate {
  animation: flash-anim 0.4s ease-out forwards;
}

@keyframes flash-anim {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── QR screen ──────────────────────────────────────────────── */

.qr-screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  background: var(--color-bg);
  z-index: 40;
  gap: 0;
}

.qr-expiry {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 45;
}

.qr-expiry-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  background: rgba(255, 191, 58, 0.1);
}

#qr-expiry-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-primary);
}

.qr-expiry-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
  opacity: 0.85;
}

.qr-left {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.4));
  min-height: 100%;
}

.qr-container {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: calc(100vh - 4rem);
  aspect-ratio: 1 / 1;
}

.qr-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
}

.qr-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  background: linear-gradient(180deg, rgba(0, 7, 72, 0.9), rgba(0, 7, 72, 0.7));
  color: var(--color-primary);
}

.qr-screen h2 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: 0.03em;
}

.qr-hint {
  font-size: 1.1rem;
  color: var(--color-primary);
  opacity: 0.9;
}

.qr-retention {
  font-size: 0.95rem;
  color: var(--color-primary);
  opacity: 0.8;
}

.btn-reset {
  margin-top: 1rem;
  padding: 0.9rem 2.2rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #000748;
  background: var(--color-primary);
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
  box-shadow: 0 10px 30px rgba(255, 191, 58, 0.35);
}

.btn-reset:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(255, 191, 58, 0.45);
}

.btn-reset:active {
  transform: translateY(0);
}

/* ── Error toast ────────────────────────────────────────────── */

.error-toast {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #e74c3c;
  color: #fff;
  padding: 0.8rem 2rem;
  border-radius: 0.5rem;
  font-weight: 600;
  z-index: 50;
  transition: opacity var(--transition-speed);
}

/* ── Utility ────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}
