/* =========================================================
   Photo Gallery - Clean & Cinematic Slideshow Styles
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600&family=Outfit:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-display: 'Cinzel', serif;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --accent-gold: #f3cf7a;
  --accent-rose: #fca5a5;
  --text-primary: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.78);
  --glass-bg: rgba(15, 20, 30, 0.45);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-blur: blur(14px);
  --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);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  position: fixed;
  inset: 0;
  background-color: #05070b;
  font-family: var(--font-sans);
  color: var(--text-primary);
  user-select: none;
  -webkit-touch-callout: none;
}

/* Slideshow Container */
.slideshow-viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  cursor: pointer;
  background: #000;
}

/* Vignette Gradients for Text Legibility */
.slideshow-viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.4) 100%),
              linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.3) 25%, transparent 50%),
              linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, transparent 20%);
  z-index: 10;
}

/* Slide Layers (Dual Buffer) */
.slide-layer {
  position: absolute;
  inset: -5%; /* extra margin so pan/zoom never exposes black edges */
  width: 110%;
  height: 110%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 1.4s;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.slide-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  will-change: transform;
}

/* Ken Burns Subtle Animations */
.kb-zoom-in {
  animation: kbZoomIn var(--anim-duration, 8s) ease-out forwards;
}

.kb-zoom-out {
  animation: kbZoomOut var(--anim-duration, 8s) ease-out forwards;
}

.kb-pan-right {
  animation: kbPanRight var(--anim-duration, 8s) ease-out forwards;
}

.kb-pan-left {
  animation: kbPanLeft var(--anim-duration, 8s) ease-out forwards;
}

.kb-zoom-pan-up {
  animation: kbZoomPanUp var(--anim-duration, 8s) ease-out forwards;
}

.kb-zoom-pan-down {
  animation: kbZoomPanDown var(--anim-duration, 8s) ease-out forwards;
}

@keyframes kbZoomIn {
  0% {
    transform: scale(1.0) translate(0%, 0%);
  }
  100% {
    transform: scale(1.09) translate(-1.2%, -0.8%);
  }
}

@keyframes kbZoomOut {
  0% {
    transform: scale(1.09) translate(1.2%, 0.8%);
  }
  100% {
    transform: scale(1.0) translate(0%, 0%);
  }
}

@keyframes kbPanRight {
  0% {
    transform: scale(1.06) translate(-2%, 0.5%);
  }
  100% {
    transform: scale(1.06) translate(2%, -0.5%);
  }
}

@keyframes kbPanLeft {
  0% {
    transform: scale(1.06) translate(2%, -0.5%);
  }
  100% {
    transform: scale(1.06) translate(-2%, 0.5%);
  }
}

@keyframes kbZoomPanUp {
  0% {
    transform: scale(1.02) translate(0%, 1.5%);
  }
  100% {
    transform: scale(1.09) translate(0.8%, -1.2%);
  }
}

@keyframes kbZoomPanDown {
  0% {
    transform: scale(1.09) translate(-0.8%, -1.2%);
  }
  100% {
    transform: scale(1.02) translate(0%, 1.2%);
  }
}

/* Paused State */
.slideshow-viewport.is-paused .slide-image {
  animation-play-state: paused !important;
}

/* Discreet Nav Buttons */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 25;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0.35;
  outline: none;
}

.nav-btn:hover {
  opacity: 0.95;
  background: rgba(30, 40, 60, 0.65);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-50%) scale(1.08);
}

.nav-btn.prev {
  left: 24px;
}

.nav-btn.next {
  right: 24px;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Top Quick Actions (Admin & Fullscreen) */
.top-bar {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 12px;
  z-index: 25;
  transition: opacity 0.4s ease;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.icon-btn:hover {
  opacity: 0.95;
  background: rgba(30, 40, 60, 0.7);
  transform: scale(1.05);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Cinematic Center Pause Watermark */
.pause-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pause-watermark.visible {
  opacity: 1;
  transform: scale(1);
}

.pause-watermark-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(12, 17, 26, 0.58);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 26px rgba(245, 158, 11, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  color: #f3cf7a;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  animation: subtlePulse 2.8s ease-in-out infinite;
}

@keyframes subtlePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 18px rgba(245, 158, 11, 0.15);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.65), 0 0 32px rgba(245, 158, 11, 0.35);
  }
}

/* Pause Indicator Badge */
.pause-badge {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top, 0px));
  left: calc(24px + env(safe-area-inset-left, 0px));
  padding: 8px 18px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pause-badge.visible {
  opacity: 0.92;
  transform: translateY(0);
}

.pause-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
}

/* Stylized Overlay Banner (Family Memories) */
.stylized-overlay {
  position: absolute;
  bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  left: calc(36px + env(safe-area-inset-left, 0px));
  max-width: calc(100vw - 72px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.overlay-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 24px;
  background: rgba(12, 17, 26, 0.52);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  max-width: 680px;
  pointer-events: auto;
  animation: fadeInOverlay 1s ease-out;
}

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

.overlay-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.overlay-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.overlay-text {
  display: flex;
  flex-direction: column;
}

.overlay-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  font-weight: 600;
  opacity: 0.9;
}

.overlay-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.overlay-item.daughter .overlay-label {
  color: var(--accent-rose);
}

/* Location Mini-Globe Overlay (Bottom-Right) */
.location-overlay {
  position: absolute;
  bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  right: calc(36px + env(safe-area-inset-right, 0px));
  z-index: 30;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(0);
}

.location-overlay.is-hidden {
  opacity: 0 !important;
  transform: translateY(12px) !important;
  pointer-events: none !important;
}

.location-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px 8px 10px;
  background: rgba(12, 17, 26, 0.58);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 40px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: fadeInOverlay 0.8s ease-out;
}

.globe-viewport {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: radial-gradient(circle at 35% 35%, #182234, #080c14);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.85), 0 3px 10px rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.globe-viewport svg {
  display: block;
  width: 100%;
  height: 100%;
}

.globe-sphere {
  fill: #0c121e;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 0.5px;
}

.globe-graticule {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.5px;
}

.globe-land {
  fill: rgba(255, 255, 255, 0.22);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.4px;
}

.globe-country-highlight {
  fill: #f59e0b !important;
  stroke: #fbbf24 !important;
  stroke-width: 0.8px !important;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.8));
}

.globe-pin {
  fill: #ef4444;
  stroke: #ffffff;
  stroke-width: 1px;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.95));
}

.location-text {
  display: flex;
  flex-direction: column;
}

.location-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  font-weight: 600;
  opacity: 0.9;
}

.location-country {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

/* Subtle Progress Bar */
.progress-bar-container {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 25;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d97706, #f59e0b, #fbbf24);
  transition: width 0.1s linear;
}

/* Auto-hide controls when user is idle */
body.hide-controls .nav-btn,
body.hide-controls .top-bar {
  opacity: 0 !important;
  pointer-events: none;
}

/* Empty State / No Photos */
.empty-gallery {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 32px;
  z-index: 15;
  background: #0b0f17;
}

.empty-gallery h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
}

.empty-gallery p {
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.6;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #f59e0b;
  color: #0b0f17;
  font-weight: 600;
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: #fbbf24;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
}

/* Responsive adjustments: Portrait orientation & mobile devices */
@media (orientation: portrait), (max-width: 640px) {
  /* Prevent layer inset overflow from cropping top & bottom of photo */
  .slide-layer {
    inset: 0;
    width: 100%;
    height: 100%;
  }

  /* Controls: Top-Bar */
  .top-bar {
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    gap: 8px;
    z-index: 35;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Controls: Nav Buttons */
  .nav-btn {
    width: 38px;
    height: 38px;
  }

  .nav-btn.prev {
    left: calc(10px + env(safe-area-inset-left, 0px));
  }

  .nav-btn.next {
    right: calc(10px + env(safe-area-inset-right, 0px));
  }

  .nav-btn svg {
    width: 18px;
    height: 18px;
  }

  /* Milestone Reminders: Moved to Top-Left, Compact */
  .stylized-overlay {
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    bottom: auto;
    right: auto;
    max-width: calc(100vw - 120px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    z-index: 30;
  }

  .overlay-card {
    padding: 8px 12px;
    gap: 5px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    background: rgba(12, 17, 26, 0.65);
  }

  .overlay-item {
    gap: 8px;
  }

  .overlay-icon {
    width: 22px;
    height: 22px;
    font-size: 0.82rem;
  }

  .overlay-label {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
  }

  .overlay-title {
    font-size: 0.82rem;
    line-height: 1.25;
    word-break: normal;
    overflow-wrap: break-word;
  }

  /* Photo Location Mini-Globe: Always visible at Bottom-Right with safe area */
  .location-overlay {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    right: calc(16px + env(safe-area-inset-right, 0px)) !important;
    z-index: 35 !important;
  }

  .location-card {
    gap: 8px;
    padding: 5px 12px 5px 6px;
    border-radius: 30px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    background: rgba(12, 17, 26, 0.65);
  }

  .globe-viewport {
    width: 38px;
    height: 38px;
    border-width: 1px;
  }

  .location-label {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }

  .location-country {
    font-size: 0.88rem;
  }

  /* Pause Badge: Bottom-left, completely away from top-left milestones */
  .pause-badge {
    top: auto;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    transform: translateY(8px);
    padding: 6px 14px;
    font-size: 0.75rem;
    z-index: 35;
  }

  .pause-badge.visible {
    transform: translateY(0);
  }
}

/* Responsive adjustments: Landscape orientation on compact screens (e.g., iPhone 16 Pro Max landscape) */
@media (orientation: landscape) and (max-height: 500px) {
  /* Controls: Top-Bar */
  .top-bar {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    gap: 8px;
    z-index: 35;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  /* Nav Buttons */
  .nav-btn {
    width: 36px;
    height: 36px;
  }

  .nav-btn.prev {
    left: calc(12px + env(safe-area-inset-left, 0px));
  }

  .nav-btn.next {
    right: calc(12px + env(safe-area-inset-right, 0px));
  }

  /* Milestone Overlay in Landscape: Compact */
  .stylized-overlay {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    max-width: calc(60vw - env(safe-area-inset-left, 0px));
    z-index: 30;
  }

  .overlay-card {
    padding: 8px 14px;
    gap: 4px;
    border-radius: 12px;
    background: rgba(12, 17, 26, 0.65);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }

  .overlay-item {
    gap: 8px;
  }

  .overlay-icon {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
  }

  .overlay-label {
    font-size: 0.60rem;
    letter-spacing: 0.08em;
  }

  .overlay-title {
    font-size: 0.82rem;
    line-height: 1.2;
  }

  /* Photo Location Mini-Globe in Landscape: Compact */
  .location-overlay {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    right: calc(16px + env(safe-area-inset-right, 0px)) !important;
    z-index: 35 !important;
  }

  .location-card {
    gap: 8px;
    padding: 5px 12px 5px 6px;
    border-radius: 28px;
    background: rgba(12, 17, 26, 0.65);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }

  .globe-viewport {
    width: 38px;
    height: 38px;
    border-width: 1px;
  }

  .location-label {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }

  .location-country {
    font-size: 0.85rem;
  }

  /* Pause Badge in Landscape: Compact at Top-Left */
  .pause-badge {
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: calc(16px + env(safe-area-inset-left, 0px));
    padding: 6px 14px;
    font-size: 0.75rem;
  }
}
