/* ============================================
   Book Photo Booth - Main Styles
   ============================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* === Screen System === */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   Screen 1: 책 선택 화면
   ============================================ */
#screen-select {
  padding: var(--space-5);
  overflow-y: auto;
  background: linear-gradient(135deg, var(--color-bg) 0%, #FFF0E0 100%);
}

.select-header {
  text-align: center;
  padding: var(--space-6) 0 var(--space-5);
}

.select-header h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-black);
  background: linear-gradient(135deg, var(--color-primary), var(--color-fun-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.select-header p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  margin-top: var(--space-2);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-5);
  padding: var(--space-4) 0 var(--space-8);
  max-width: 1000px;
  margin: 0 auto;
}

.book-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform var(--transition-bounce), box-shadow var(--transition-normal);
  aspect-ratio: 3/4;
  position: relative;
}

.book-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-xl);
}

.book-card:active {
  transform: translateY(-2px) scale(0.98);
}

.book-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card .book-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-3);
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: var(--color-text-white);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: var(--space-10);
  color: var(--color-text-light);
  grid-column: 1 / -1;
}

.empty-state .empty-icon {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-4);
}

.empty-state p {
  font-size: var(--font-size-lg);
}

.admin-link {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  background: var(--color-bg-card);
  color: var(--color-text-light);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.admin-link:hover {
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* ============================================
   Screen 2: 시작 화면
   ============================================ */
#screen-start {
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

.start-cover {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  top: 0;
  left: 0;
}

.start-overlay {
  position: relative;
  z-index: var(--z-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.btn-start {
  padding: var(--space-5) var(--space-8);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-black);
  color: var(--color-text-white);
  background: linear-gradient(135deg, var(--color-primary), var(--color-fun-pink));
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: all var(--transition-bounce);
  animation: pulse 2s infinite;
}

.btn-start:hover {
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.6);
}

.btn-start:active {
  transform: scale(0.95);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 107, 107, 0.4); }
  50% { box-shadow: 0 0 40px rgba(255, 107, 107, 0.7); }
}

.btn-back {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-base);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-white);
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(4px);
}

.btn-back:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   Screen 3: 촬영 화면
   ============================================ */
#screen-camera {
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#compositeCanvas {
  max-width: 100%;
  max-height: calc(100% - 80px);
  object-fit: contain;
}

.camera-ui {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  gap: var(--space-5);
}

.shot-counter {
  color: var(--color-text-white);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  min-width: 80px;
}

.btn-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-text-white);
  border: 4px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}

.btn-shutter::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--color-primary);
  transition: all var(--transition-fast);
}

.btn-shutter:hover {
  transform: scale(1.1);
}

.btn-shutter:active::after {
  background: var(--color-primary-dark);
  inset: 6px;
}

.btn-shutter:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 120px;
  justify-content: flex-end;
}

.zoom-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
  color: var(--color-text-white);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-black);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  line-height: 1;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.7);
}

.zoom-btn:active {
  transform: scale(0.9);
}

.zoom-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.zoom-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.zoom-level {
  color: var(--color-text-white);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  min-width: 36px;
  text-align: center;
}

/* Countdown Overlay */
.countdown-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: var(--z-countdown);
}

.countdown-overlay.active {
  display: flex;
}

.countdown-number {
  font-size: var(--font-size-hero);
  font-weight: var(--font-weight-black);
  color: var(--color-text-white);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: countPop 0.5s ease;
}

@keyframes countPop {
  0% { transform: scale(2); opacity: 0; }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

/* Flash Effect */
.flash-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: white;
  z-index: var(--z-flash);
}

.flash-overlay.active {
  display: block;
  animation: flash 0.3s ease-out;
}

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

/* ============================================
   Screen 4: 결과 화면
   ============================================ */
#screen-result {
  padding: var(--space-5);
  align-items: center;
  overflow-y: auto;
  background: linear-gradient(135deg, var(--color-bg) 0%, #E8F8F5 100%);
}

.result-header {
  text-align: center;
  padding: var(--space-4) 0;
}

.result-header h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-black);
  color: var(--color-secondary-dark);
}

.result-header p {
  font-size: var(--font-size-md);
  color: var(--color-text-light);
  margin-top: var(--space-1);
}

.result-grid {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  max-width: 500px;
  width: 100%;
  padding: var(--space-4) 0;
}

.result-photo {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  border: 4px solid var(--color-secondary);
  max-width: 100%;
}

.result-photo img {
  width: 100%;
  height: auto;
  display: block;
}

.result-actions {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  flex-wrap: wrap;
  justify-content: center;
}

/* === Shared Button Styles === */
.btn {
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-bounce);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
  color: var(--color-text-white);
}

.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: var(--color-text-white);
}

/* ============================================
   Utilities
   ============================================ */
.hidden-video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .select-header h1 {
    font-size: var(--font-size-2xl);
  }

  .result-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .btn-start {
    font-size: var(--font-size-xl);
    padding: var(--space-4) var(--space-6);
  }

  .countdown-number {
    font-size: 4rem;
  }
}

@media (min-width: 1024px) {
  .book-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
