/* ============================================
   Photobooth Page Styles
   ============================================ */

.photobooth-page {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
.pb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  position: sticky;
  top: 0;
  background: var(--glass-nav-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: var(--z-sticky);
  border-bottom: 1px solid var(--glass-nav-border);
  box-shadow: var(--glass-nav-shadow);
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.pb-header__title {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.2px;
}

.pb-header__spacer {
  width: 38px;
  height: 38px;
}

/* ============================================
   Step Indicator
   ============================================ */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-md);
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: all var(--transition-normal);
}

.step-dot.active {
  width: 28px;
  border-radius: 4px;
  background: var(--color-primary);
}

.step-dot.done {
  background: var(--color-gold);
}

/* ============================================
   Step Content
   ============================================ */
.step-content {
  display: none;
  padding: var(--space-md);
  animation: fadeInUp 0.4s ease forwards;
}

.step-content.active {
  display: block;
}

.step-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: var(--space-xs);
}

.step-desc {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-lg);
}

/* ============================================
   Step 1: Choose Mode (Camera / Upload)
   ============================================ */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  max-width: 380px;
  margin: 0 auto;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl) var(--space-md);
  background: var(--color-bg-card);
  border: 2px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
}

.mode-card:hover,
.mode-card.selected {
  border-color: var(--color-primary);
  background: rgba(183, 110, 121, 0.1);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.mode-card__icon {
  font-size: 2.5rem;
  display: block;
}

.mode-card__title {
  font-weight: 600;
  font-size: 1rem;
}

.mode-card__desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ============================================
   Format / Orientation Switcher (Pill Selector)
   ============================================ */
.orientation-switch-wrapper {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: var(--space-md);
}

.orient-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.orient-btn:hover {
  border-color: var(--color-gold);
  color: var(--color-text-primary);
}

.orient-btn.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(183, 110, 121, 0.25));
  border-color: var(--color-gold);
  color: var(--color-gold);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

/* ============================================
   Step 2: Camera / Upload
   ============================================ */

/* ============================================
   Step 2: Fullscreen Native Camera Mode
   ============================================ */
body.camera-active-fullscreen .pb-header,
body.camera-active-fullscreen .steps {
  display: none !important;
}

body.camera-active-fullscreen {
  overflow: hidden !important;
  background: #000000 !important;
}

body.camera-active-fullscreen .photobooth-page {
  padding: 0 !important;
  margin: 0 !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

body.camera-active-fullscreen .step-content--camera {
  padding: 0 !important;
  margin: 0 !important;
  height: 100% !important;
  width: 100% !important;
  max-width: 100% !important;
}

.camera-hud-view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 50;
  background: #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

/* Fullscreen Viewfinder Stage */
.camera-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  overflow: hidden;
}

.camera-container {
  position: relative;
  width: 100vw;
  max-width: min(100vw, calc((100dvh - 160px) * 3 / 4));
  aspect-ratio: 3/4;
  height: auto;
  border-radius: 0;
  overflow: hidden;
  background: #000000;
  border: none;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  transition: aspect-ratio 0.3s ease, max-width 0.3s ease;
}

.camera-container.is-landscape {
  aspect-ratio: 4/3;
  max-width: min(100vw, calc((100dvh - 160px) * 4 / 3));
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-container .frame-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.camera-container .frame-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 3x3 Composition Grid */
.camera-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  display: block;
  transition: opacity var(--transition-fast);
}

.camera-grid-overlay.hidden {
  opacity: 0;
}

.grid-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.6);
}

.grid-line-v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.grid-line-v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }
.grid-line-h1 { top: 33.33%; left: 0; right: 0; height: 1px; }
.grid-line-h2 { top: 66.66%; left: 0; right: 0; height: 1px; }

/* Floating Top HUD Controls */
.camera-hud-top {
  position: absolute;
  top: env(safe-area-inset-top, 14px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  z-index: 20;
  pointer-events: none;
}

.camera-hud-circle-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.camera-hud-circle-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.06);
}

.camera-hud-circle-btn:active {
  transform: scale(0.92);
}

.camera-hud-circle-btn.active {
  background: rgba(212, 175, 55, 0.3);
  border-color: var(--color-gold);
  color: var(--color-gold);
}

/* Floating Bottom HUD Console (Layer on Top of Camera Viewfinder) */
.camera-hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px calc(env(safe-area-inset-bottom, 16px) + 16px);
  gap: 16px;
  z-index: 20;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
  pointer-events: auto;
}

/* Mode Switcher Pill (iOS/Android Camera style) */
.camera-mode-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 6px 18px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mode-pill-opt {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
}

.mode-pill-opt.active {
  color: #FFE600; /* Camera bright yellow indicator */
  text-shadow: 0 0 10px rgba(255, 230, 0, 0.6);
}

/* Control Row (Gallery - Shutter - Flip) */
.camera-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  max-width: 360px;
}

.camera-hud-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 4px;
}

.gallery-icon-wrapper,
.flip-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.camera-hud-btn:hover .gallery-icon-wrapper,
.camera-hud-btn:hover .flip-icon-wrapper {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.08);
}

.camera-hud-btn:active .gallery-icon-wrapper,
.camera-hud-btn:active .flip-icon-wrapper {
  transform: scale(0.92);
}

.hud-btn-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

/* Native White Shutter Button */
.capture-btn-native {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: transparent;
  border: 4.5px solid #ffffff;
  padding: 3.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.35);
}

.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffffff;
  transition: all var(--transition-fast);
}

.capture-btn-native:hover {
  transform: scale(1.06);
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.55);
}

.capture-btn-native:active .shutter-inner {
  transform: scale(0.85);
  background: #FFE600;
}

/* Upload Zone */
.upload-zone {
  max-width: 380px;
  margin: 0 auto;
  border: 2px dashed rgba(183, 110, 121, 0.4);
  border-radius: var(--radius-lg);
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: rgba(183, 110, 121, 0.03);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(183, 110, 121, 0.08);
}

.upload-zone__icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.upload-zone__text {
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.upload-zone__hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.upload-zone input[type="file"] {
  display: none;
}

/* Upload Preview */
.upload-preview {
  max-width: 360px;
  margin: 0 auto;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3/4;
  display: none;
  transition: aspect-ratio 0.3s ease, max-width 0.3s ease;
}

.upload-preview.is-landscape {
  aspect-ratio: 4/3;
  max-width: 440px;
}

.upload-preview.has-image {
  display: block;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview .change-btn {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: 3;
}

/* ============================================
   Countdown Overlay
   ============================================ */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

.countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.countdown-number {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 40px rgba(183, 110, 121, 0.8);
  animation: countdownPop 1s ease;
}

@keyframes countdownPop {
  0% { transform: scale(2); opacity: 0; }
  30% { transform: scale(0.8); opacity: 1; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.countdown-flash {
  animation: flashCapture 0.5s ease;
}

@keyframes flashCapture {
  0% { background: white; }
  100% { background: rgba(0,0,0,0.4); }
}

/* ============================================
   Step 3: Frame & Filter Selection
   ============================================ */
.preview-container {
  position: relative;
  max-width: min(300px, 70vw);
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3/4;
  box-shadow: var(--shadow-lg);
  transition: aspect-ratio 0.3s ease, max-width 0.3s ease;
}

.preview-container.is-landscape {
  aspect-ratio: 4/3;
  max-width: min(400px, 90vw);
}

.preview-container img,
.preview-container canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-frame-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.preview-frame-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Frame Selector */
.selector-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.frame-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm) 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.frame-scroll::-webkit-scrollbar { display: none; }

.frame-option {
  flex: 0 0 auto;
  width: 64px;
  height: 85px;
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  scroll-snap-align: start;
}

.frame-option.is-landscape {
  width: 85px;
  height: 64px;
}

.frame-option:hover {
  border-color: rgba(183, 110, 121, 0.4);
}

.frame-option.selected {
  border-color: var(--color-gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.frame-option img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.frame-option--none {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-xs);
}

/* Filter Selector */
.filter-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm) 0;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar { display: none; }

.filter-option {
  flex: 0 0 auto;
  width: 64px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  scroll-snap-align: start;
}

.filter-option__preview {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  margin-bottom: 4px;
  transition: all var(--transition-fast);
}

.filter-option__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.filter-option.selected .filter-option__preview {
  border-color: var(--color-gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.filter-option__label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

.filter-option.selected .filter-option__label {
  color: var(--color-gold);
  font-weight: 600;
}

/* CSS Filters */
.filter-normal { filter: none; }
.filter-beauty { filter: brightness(1.07) contrast(0.96) saturate(1.12) drop-shadow(0 0 1px rgba(255,235,240,0.5)); }
.filter-rosy-glam { filter: brightness(1.08) contrast(1.04) saturate(1.24) hue-rotate(345deg); }
.filter-korean-glow { filter: brightness(1.12) contrast(0.95) saturate(1.15) drop-shadow(0 0 1px rgba(255,255,255,0.6)); }
.filter-romantic { filter: saturate(1.3) brightness(1.06) contrast(1.05) hue-rotate(330deg); }
.filter-dreamy { filter: brightness(1.15) contrast(0.95) saturate(1.35); }
.filter-warm { filter: saturate(1.4) brightness(1.08) sepia(0.22) contrast(1.05); }
.filter-vintage { filter: sepia(0.55) saturate(1.35) contrast(1.15) brightness(0.98); }
.filter-bw { filter: grayscale(1) contrast(1.35) brightness(1.05); }



/* ============================================
   Step 4: Name & Message Form
   ============================================ */
.form-section {
  max-width: 380px;
  margin: 0 auto;
}

.form-section .preview-mini {
  width: 120px;
  height: 160px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 auto var(--space-lg);
  box-shadow: var(--shadow-md);
}

.form-section .preview-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* ============================================
   Success Screen
   ============================================ */
.success-screen {
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
  animation: scaleIn 0.5s ease;
}

.success-screen__icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  animation: float 2s ease-in-out infinite;
}

.success-screen__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: var(--space-sm);
  color: var(--color-gold);
}

.success-screen__message {
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xl);
  line-height: 1.6;
}

.success-screen__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 280px;
  margin: 0 auto;
}

/* ============================================
   Hidden Canvas for Processing
   ============================================ */
#processingCanvas {
  display: none;
}

/* ============================================
   Mobile Viewport 100dvh Fit (No Scrolling Needed)
   ============================================ */
@media (max-width: 600px), (max-height: 850px) {
  .photobooth-page {
    min-height: 100dvh;
    padding-bottom: 6px;
  }

  .pb-header {
    padding: 6px 12px;
  }

  .steps {
    padding: 4px 12px;
    gap: 5px;
  }

  .step-dot {
    width: 6px;
    height: 6px;
  }

  .step-dot.active {
    width: 20px;
  }

  .step-content {
    padding: 2px 10px;
  }

  .step-title {
    font-size: 1.05rem;
    margin-bottom: 1px;
  }

  .step-desc {
    font-size: 0.75rem;
    margin-bottom: 6px;
  }

  .orientation-switch-wrapper {
    margin-bottom: 6px;
    gap: 6px;
  }

  .orient-btn {
    padding: 4px 12px;
    font-size: 0.74rem;
    gap: 4px;
  }

  .orient-btn svg {
    width: 14px;
    height: 14px;
  }

  .camera-hud-view .camera-container {
    width: 100vw;
    max-width: min(100vw, calc((100dvh - 160px) * 3 / 4));
    aspect-ratio: 3/4;
    height: auto;
  }

  .camera-hud-view .camera-container.is-landscape {
    aspect-ratio: 4/3;
    max-width: min(100vw, calc((100dvh - 160px) * 4 / 3));
  }

  .camera-hud-bottom {
    padding: 16px 16px calc(env(safe-area-inset-bottom, 16px) + 12px);
    gap: 12px;
  }

  .camera-mode-pill {
    padding: 4px 14px;
    gap: 16px;
  }

  .mode-pill-opt {
    font-size: 0.72rem;
  }

  .capture-btn-native {
    width: 70px;
    height: 70px;
    border-width: 4px;
    padding: 3px;
  }

  .gallery-icon-wrapper,
  .flip-icon-wrapper {
    width: 48px;
    height: 48px;
  }

  .gallery-icon-wrapper svg,
  .flip-icon-wrapper svg {
    width: 22px;
    height: 22px;
  }

  .preview-container {
    max-height: min(44dvh, 44vh, 320px);
    aspect-ratio: 3/4;
    width: auto;
    margin: 0 auto 6px;
  }

  .preview-container.is-landscape {
    max-height: min(32dvh, 32vh, 230px);
    aspect-ratio: 4/3;
  }

  .frames-carousel-track {
    gap: 8px;
    padding: 4px;
  }

  .filter-option {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .form-section .preview-mini {
    width: 90px;
    height: 120px;
    margin: 0 auto 8px;
  }

  .form-group {
    margin-bottom: 8px;
  }

  .form-label {
    font-size: 0.8rem;
    margin-bottom: 2px;
  }

  .form-input, .form-textarea {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
}

