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

:root {
  --bar-bg: rgba(0, 0, 0, 0.55);
  --bar-blur: blur(12px);
  --accent: #ff4444;
  --accent-glow: rgba(255, 68, 68, 0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Prevent iOS bounce */
  overscroll-behavior: none;
  position: fixed;
  touch-action: pan-x pan-y;
}

/* === SPLASH SCREEN === */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a0000 50%, #0a0a0a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  padding-top: calc(2rem + var(--safe-top));
  padding-bottom: calc(2rem + var(--safe-bottom));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.splash.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.splash-logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  margin-bottom: 1.5rem;
  box-shadow: 0 0 40px var(--accent-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

.splash-title {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.splash-subtitle {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin-bottom: 2.5rem;
}

.splash-tap {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--accent);
  animation: pulse-text 1.5s ease-in-out infinite;
}

.splash-tap-ring {
  width: 80px;
  height: 80px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  animation: pulse-ring 2s ease-out infinite;
}

.splash-tap-ring svg {
  width: 32px;
  height: 32px;
  fill: var(--accent);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 40px var(--accent-glow); }
  50% { box-shadow: 0 0 60px var(--accent-glow), 0 0 100px rgba(255, 68, 68, 0.2); }
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* === SLIDESHOW CONTAINER === */
.slideshow {
  position: fixed;
  inset: 0;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* === PROGRESS BAR === */
.progress-bar {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.15);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s linear;
  width: 0%;
}

/* === SLIDES === */
.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  will-change: opacity;
}

.slide.active {
  opacity: 1;
  z-index: 2;
}

.slide.preloading {
  z-index: 1;
}

.slide-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  will-change: transform;
  animation: none;
}

.slide.active .slide-img {
  animation: kenburns 8s ease-in-out forwards;
}

@keyframes kenburns {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1%, -1%); }
}

/* Blur placeholder */
.slide-placeholder {
  position: absolute;
  inset: 0;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

.slide-placeholder.loaded {
  opacity: 0;
  pointer-events: none;
}

.slide-placeholder .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === TOP BAR === */
.top-bar {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  background: var(--bar-bg);
  -webkit-backdrop-filter: var(--bar-blur);
  backdrop-filter: var(--bar-blur);
  z-index: 50;
  margin-top: 3px; /* below progress bar */
}

.slide-counter {
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 60px;
}

.top-actions {
  display: flex;
  gap: 4px;
}

/* === BOTTOM BAR === */
.bottom-bar {
  position: fixed;
  bottom: var(--safe-bottom);
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 16px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  background: var(--bar-bg);
  -webkit-backdrop-filter: var(--bar-blur);
  backdrop-filter: var(--bar-blur);
  z-index: 50;
}

/* === BUTTONS === */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: none;
  color: #fff;
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

.btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.btn-play {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

.btn-play:active {
  background: rgba(255, 255, 255, 0.25);
}

.btn-play svg {
  width: 28px;
  height: 28px;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 0.9375rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === PHOTO INFO OVERLAY === */
.photo-info {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bar-bg);
  -webkit-backdrop-filter: var(--bar-blur);
  backdrop-filter: var(--bar-blur);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.875rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 200;
  max-width: 90vw;
}

.photo-info.show {
  opacity: 1;
}

/* === SWIPE HINT === */
.swipe-hint {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.swipe-hint.show {
  opacity: 1;
  pointer-events: auto;
}

.swipe-hint-icon {
  width: 60px;
  height: 60px;
  animation: swipe-anim 1.5s ease-in-out infinite;
}

.swipe-hint-icon svg {
  width: 100%;
  height: 100%;
  fill: #fff;
}

.swipe-hint-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

@keyframes swipe-anim {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-20px); }
}

/* === DOT INDICATORS (tablet+) === */
.dots {
  display: none;
}

/* === LANDSCAPE MOBILE === */
@media (orientation: landscape) and (max-height: 500px) {
  .top-bar {
    height: 40px;
    padding: 0 12px;
  }

  .bottom-bar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: auto;
    right: var(--safe-right);
    width: 56px;
    height: 100%;
    flex-direction: column;
    padding: 12px 0;
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: calc(12px + var(--safe-bottom));
    gap: 16px;
  }

  .btn-play {
    width: 48px;
    height: 48px;
  }
}

/* === TABLET (768px+) === */
@media (min-width: 768px) {
  .dots {
    display: flex;
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    gap: 8px;
    z-index: 50;
  }

  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transition: all 0.3s ease;
    border: none;
    padding: 0;
    cursor: pointer;
  }

  .dot.active {
    background: #fff;
    transform: scale(1.3);
  }

  .bottom-bar {
    gap: 32px;
  }

  .top-bar {
    height: 56px;
  }
}

/* === DESKTOP (1024px+) === */
@media (min-width: 1024px) {
  .top-bar, .bottom-bar {
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .slideshow:hover .top-bar,
  .slideshow:hover .bottom-bar,
  .slideshow.touch-device .top-bar,
  .slideshow.touch-device .bottom-bar {
    opacity: 1;
  }

  .btn:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  /* Side arrows for desktop */
  .nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .slideshow:hover .nav-arrow {
    opacity: 1;
  }

  .nav-arrow.left { left: 20px; }
  .nav-arrow.right { right: 20px; }

  .nav-arrow .btn {
    width: 56px;
    height: 56px;
    background: var(--bar-bg);
    -webkit-backdrop-filter: var(--bar-blur);
    backdrop-filter: var(--bar-blur);
    border-radius: 50%;
  }

  .nav-arrow .btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}

/* === PRINT (hide everything) === */
@media print {
  .top-bar, .bottom-bar, .dots, .progress-bar { display: none; }
}
