/* Style System - Material Design 3 Light Theme for PuriKura */

:root {
  --md-sys-color-background: #fdfbff;
  --md-sys-color-on-background: #1a1c1e;
  --md-sys-color-surface: #f0f4f8;
  --md-sys-color-surface-variant: #e0e2ec;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-on-surface-variant: #43474e;
  
  --md-sys-color-primary: #0061a4;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d1e4ff;
  --md-sys-color-on-primary-container: #001d36;
  
  --md-sys-color-secondary: #535f70;
  --md-sys-color-on-secondary: #ffffff;
  
  --md-sys-color-tertiary: #6b5778;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  
  --md-sys-color-outline: #73777f;
  
  --md-shape-corner-small: 8px;
  --md-shape-corner-medium: 16px;
  --md-shape-corner-large: 28px;
  --md-shape-corner-full: 9999px;
  
  --md-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.12);
  --md-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.12);
  --md-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.08), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
  
  --font-family: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Three.js Canvas */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* UI Overlay Container */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(253, 251, 255, 0.85);
  backdrop-filter: blur(12px);
  padding: 12px 24px;
  border-radius: var(--md-shape-corner-medium);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--md-elevation-1);
}

.logo-icon {
  font-size: 32px;
  color: var(--md-sys-color-primary);
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--md-sys-color-primary);
}

.logo-text p {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Start Button (Extended FAB with hover detection) */
.md-fab-extended {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  padding: 16px 28px;
  border-radius: var(--md-shape-corner-large);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--md-elevation-2);
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.md-fab-extended:hover {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0px 8px 16px rgba(0, 97, 164, 0.25);
}

/* Idle Prompt */
.idle-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(253, 251, 255, 0.85);
  backdrop-filter: blur(12px);
  padding: 24px 40px;
  border-radius: var(--md-shape-corner-medium);
  border: 1px solid rgba(0, 0, 0, 0.06);
  max-width: 450px;
  box-shadow: var(--md-elevation-2);
}

.idle-prompt span {
  font-size: 48px;
  color: var(--md-sys-color-primary);
  margin-bottom: 16px;
  display: inline-block;
}

.idle-prompt p {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--md-sys-color-on-background);
}

/* Countdown Overlay */
#countdown-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(253, 251, 255, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 15;
}

.countdown-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  border: 6px solid var(--md-sys-color-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--md-elevation-3);
  animation: pulse-countdown 1s infinite alternate;
}

#countdown-number {
  font-size: 80px;
  font-weight: 700;
  color: var(--md-sys-color-on-primary-container);
}

.countdown-label {
  margin-top: 24px;
  font-size: 24px;
  font-weight: 600;
  color: var(--md-sys-color-primary);
  letter-spacing: 0.5px;
}

/* Active Session Overlay */
#session-overlay {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(186, 26, 26, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: var(--md-shape-corner-full);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: var(--md-elevation-1);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #fff;
  animation: blink 1s infinite;
}

.capture-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--md-sys-color-tertiary);
  color: var(--md-sys-color-on-tertiary);
  padding: 8px 16px;
  border-radius: var(--md-shape-corner-medium);
  font-size: 14px;
  font-weight: 600;
  animation: flash-badge 0.5s ease-out;
}

/* Timeline/Progress Bar at bottom */
.timeline-container {
  background: rgba(240, 244, 248, 0.9);
  backdrop-filter: blur(12px);
  padding: 24px 32px 16px 32px;
  border-radius: var(--md-shape-corner-large);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--md-elevation-2);
  pointer-events: auto;
  position: relative;
}

.timeline-track {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: var(--md-shape-corner-full);
  overflow: hidden;
  position: relative;
}

.timeline-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-tertiary) 100%);
  border-radius: var(--md-shape-corner-full);
  transition: width 0.1s linear;
}

.timeline-ticks {
  position: absolute;
  top: 10px;
  left: 32px;
  right: 32px;
  height: 20px;
}

.tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 8px;
  background: rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

.tick::after {
  content: '';
  position: absolute;
  top: -8px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 4px var(--md-sys-color-primary);
}

.tick span {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  font-weight: 600;
}

.timeline-label {
  margin-top: 16px;
  text-align: right;
  font-size: 14px;
  color: var(--md-sys-color-on-background);
  font-weight: 600;
}

/* Flash Overlay */
.camera-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
}

.camera-flash.flash-active {
  opacity: 1;
  transition: none;
}

/* Gallery Screen */
#gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--md-sys-color-background);
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  overflow-y: auto;
}

.gallery-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gallery-title {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-tertiary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gallery-subtitle {
  font-size: 16px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 32px;
  text-align: center;
}

.gallery-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  width: 100%;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.photo-card {
  aspect-ratio: 4 / 3;
  background: var(--md-sys-color-surface);
  border-radius: var(--md-shape-corner-medium);
  overflow: hidden;
  box-shadow: var(--md-elevation-1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: transform 0.3s ease;
}

.photo-card:hover {
  transform: scale(1.02);
  box-shadow: var(--md-elevation-2);
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--md-sys-color-on-surface-variant);
}

.photo-placeholder span {
  font-size: 48px;
}

.captured-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Side Panel with QR Code and Actions */
.share-panel {
  background: var(--md-sys-color-surface);
  border-radius: var(--md-shape-corner-large);
  padding: 32px;
  box-shadow: var(--md-elevation-2);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  padding: 16px;
  border-radius: var(--md-shape-corner-medium);
  box-shadow: var(--md-elevation-1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

#qr-code {
  width: 180px;
  height: 180px;
}

.qr-label {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1c1b1f;
  letter-spacing: 0.5px;
}

.action-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom MD buttons */
.md-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 52px;
  padding: 0 24px;
  border-radius: var(--md-shape-corner-full);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.md-button span {
  line-height: 1;
}

.md-button-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md-button-primary:hover {
  box-shadow: 0px 4px 12px rgba(0, 97, 164, 0.2);
  transform: translateY(-1px);
}

.md-button-tonal {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.md-button-tonal:hover {
  background-color: #bcd6ff;
}

.md-button-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-primary);
}

.md-button-outlined:hover {
  background-color: rgba(0, 97, 164, 0.05);
}

/* Animations */
@keyframes pulse-countdown {
  from {
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(0, 97, 164, 0.15);
  }
  to {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 97, 164, 0.35);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes flash-badge {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

.animate-bounce {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

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

/* Responsive UI rules */
@media (max-width: 900px) {
  .gallery-content {
    grid-template-columns: 1fr;
  }
  .share-panel {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
  }
  .action-buttons {
    max-width: 320px;
  }
}

/* Motion Hand Pointer */
.hand-pointer {
  position: absolute;
  width: 68px;
  height: 68px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0px 6px 20px rgba(0, 97, 164, 0.45), 0 0 0 6px rgba(0, 97, 164, 0.25);
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.hand-pointer span {
  font-size: 32px;
}

.hand-pointer.hovering {
  background-color: #2e7d32; /* Green on successful hover overlap */
  box-shadow: 0px 6px 20px rgba(46, 125, 50, 0.55), 0 0 0 8px rgba(46, 125, 50, 0.35);
  transform: translate(-50%, -50%) scale(1.15);
}

.pointer-guide {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translate(-50%, 10px);
  background-color: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hand-pointer.hover-button .pointer-guide {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Vertical Filter Options styling (Right side of screen, larger buttons) */
.filter-options-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  background: rgba(32, 32, 32, 0.75);
  backdrop-filter: blur(16px);
  padding: 20px 16px;
  border-radius: var(--md-shape-corner-large);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--md-elevation-3);
  z-index: 15;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.filter-options-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(20px, -50%);
}

.filter-btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 24px;
  width: 140px;
  text-align: center;
  border-radius: var(--md-shape-corner-medium);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.filter-btn:hover, .filter-btn.hover-state {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.08);
}

.filter-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 4px 12px rgba(0, 97, 164, 0.45);
}


