/* ==========================================================
   QRFoto Photobooth — Main Stylesheet (Kiosk Dark Theme)
   ========================================================== */

:root {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-card:       #1c2333;
  --accent:        #f97316;
  --accent-hover:  #ea6c0a;
  --accent-light:  rgba(249,115,22,0.15);
  --text-primary:  #e6edf3;
  --text-muted:    #8b949e;
  --border:        #30363d;
  --success:       #3fb950;
  --danger:        #f85149;
  --radius:        16px;
  --radius-sm:     8px;
  --shadow:        0 8px 32px rgba(0,0,0,0.5);
  --transition:    all 0.25s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  user-select: none;
}

/* ── Screen Layout ── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: 2rem;
  animation: fadeIn 0.4s ease;
}
.screen.active { display: flex; }

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

/* ── Kiosk Buttons ── */
.btn-kiosk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.2rem 3rem;
  font-size: 1.5rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-width: 220px;
  letter-spacing: 0.05em;
}
.btn-kiosk:active { transform: scale(0.96); }
.btn-kiosk-primary   { background: var(--accent); color: #fff; }
.btn-kiosk-primary:hover { background: var(--accent-hover); }
.btn-kiosk-secondary { background: var(--bg-card); color: var(--text-primary); border: 2px solid var(--border); }
.btn-kiosk-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-kiosk-danger    { background: var(--danger); color: #fff; }
.btn-kiosk-success   { background: var(--success); color: #fff; }

/* ── Logo Row ── */
.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
}
.logo-row img {
  max-height: 80px;
  max-width: 200px;
  object-fit: contain;
}

/* ── Home Screen ── */
#screen-home { background: var(--bg-primary); text-align: center; }
#screen-home h1 {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
#screen-home p.tagline {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.85);
  margin-bottom: 2rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}

/* ── Full-bleed home screen ── */
.screen-fullbleed {
  padding: 0;
  position: relative;
  overflow: hidden;
}

.home-preview-full {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
}
.home-preview-full video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-preview-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.55) 0%,
    rgba(0,0,0,0.05) 22%,
    rgba(0,0,0,0.05) 55%,
    rgba(0,0,0,0.75) 100%
  );
  pointer-events: none;
}

.home-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: 2.5rem 2rem;
}
.home-overlay-spacer { flex: 1; }
.home-overlay-bottom { text-align: center; padding-bottom: 1rem; }

.btn-kiosk-xl {
  padding: 1.6rem 4.5rem;
  font-size: 1.9rem;
  box-shadow: 0 10px 40px rgba(249,115,22,0.4);
}

/* Camera screen preview box */
.preview-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #000;
}
.preview-container video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-preview { width: 100%; max-width: 853px; height: 480px; }

/* Full-bleed camera screen, letterboxed to preserve the frame's aspect ratio */
.camera-preview-full {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100dvh * 9 / 16);
  max-height: calc(100vw * 16 / 9);
  aspect-ratio: 9 / 16;
  background: #000;
}
@supports not (height: 100dvh) {
  .camera-stage { max-width: calc(100vh * 9 / 16); }
}
.camera-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-title {
  text-align: center;
  font-size: 2.4rem;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.7);
}

/* Frame overlay on preview */
.frame-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.frame-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Frame Selection Screen ── */
#screen-frames {
  background: var(--bg-primary);
  padding-left: 0;
  padding-right: 0;
}
#screen-frames h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
  padding: 0 2rem;
}

/* Swipeable, full-height portrait carousel */
.frames-grid {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  height: 62vh;
  height: 62dvh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 0.5rem 2rem;
  scrollbar-width: thin;
}
.frame-card {
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 9 / 16;
  background: var(--bg-card);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  overflow: hidden;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
}
.frame-card:hover  { border-color: var(--accent); }
.frame-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.frame-card img  {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  background: #000;
}
.frame-card span { display: block; padding: 0.6rem; font-size: 0.9rem; color: var(--text-muted); flex: 0 0 auto; }

.no-frame-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  color: var(--text-muted);
  font-size: 3rem;
  background: #000;
}

/* ── Camera Screen ── */
#screen-camera { background: var(--bg-primary); }
#screen-camera h2 { font-size: 2rem; font-weight: 700; margin-bottom: 1.5rem; text-align: center; }

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 10;
  font-size: 10rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px var(--accent);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.flash-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 999;
  pointer-events: none;
  animation: flashAnim 0.4s ease-out forwards;
}
@keyframes flashAnim {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Review/QR Screen ── */
#screen-qr { background: var(--bg-primary); text-align: center; }
#screen-qr h2 { font-size: 2.2rem; font-weight: 700; margin-bottom: 1.5rem; }

.qr-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
}
.qr-photo {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  max-width: 480px;
}
.qr-photo img { display: block; width: 100%; }

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
#qrcode canvas, #qrcode img {
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 12px;
}
.scan-msg {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 220px;
  line-height: 1.5;
}

/* ── Upload progress ── */
.upload-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 220px;
}
.upload-progress-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
#upload-status-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}
#upload-status-text.error { color: var(--danger); }

.countdown-bar {
  width: 100%;
  max-width: 600px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 1.5rem;
  overflow: hidden;
}
.countdown-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 1s linear;
}

/* ── Idle attract overlay ── */
#idle-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  overflow: hidden;
}
#idle-overlay.active { display: flex; }

.idle-slideshow {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.idle-slideshow img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.idle-slideshow img.active { opacity: 1; }

.idle-slideshow-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1;
}

.idle-overlay-content {
  position: relative;
  z-index: 2;
  text-align: center;
}
.idle-overlay-content h2 { font-size: 3rem; color: var(--text-primary); text-shadow: 0 2px 16px rgba(0,0,0,0.7); }
.idle-overlay-content p  { font-size: 1.4rem; color: rgba(255,255,255,0.85); text-shadow: 0 2px 16px rgba(0,0,0,0.7); }

/* ── Camera Controls ── */
.camera-controls {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
  z-index: 2;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Loading spinner ── */
.spinner {
  width: 48px; height: 48px;
  border: 5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .camera-preview { height: 280px; }
  .btn-kiosk { font-size: 1.2rem; padding: 1rem 2rem; }
  .btn-kiosk-xl { font-size: 1.4rem; padding: 1.2rem 3rem; }
  .qr-layout { flex-direction: column; }
  #screen-home h1 { font-size: 2rem; }
  .frames-grid { height: 55vh; height: 55dvh; padding: 0.5rem 1rem; }
}

/* ── Print ── */
#print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    display: block;
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 0;
  }
  #print-photo {
    width: 100%;
    height: auto;
    display: block;
  }
}
