/**
 * photo-gallery-modal.css
 * Photo Gallery Modal Component Styles (BEM Methodology)
 * Fullscreen modal with animations
 */

/* ==========================================================================
   x-cloak Directive
   ========================================================================== */

[x-cloak] {
  display: none !important;
}

/* ==========================================================================
   Modal Container
   ========================================================================== */

.photo-gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.95);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.photo-gallery-modal--open {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Modal Header
   ========================================================================== */

.photo-gallery-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  flex-shrink: 0;
}

.photo-gallery-modal__counter {
  font-size: 16px;
  font-weight: 500;
}

.photo-gallery-modal__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.photo-gallery-modal__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.photo-gallery-modal__close:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* ==========================================================================
   Modal Body (Main Image Area)
   ========================================================================== */

.photo-gallery-modal__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.photo-gallery-modal__stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.photo-gallery-modal__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  transition: transform 0.25s ease-out;
}

/* Drag state */
.photo-gallery-modal__image--dragging {
  transition: none;
}

/* ==========================================================================
   Navigation Arrows
   ========================================================================== */

.photo-gallery-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.photo-gallery-modal__nav--prev {
  left: 20px;
}

.photo-gallery-modal__nav--next {
  right: 20px;
}

.photo-gallery-modal__nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #333;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.photo-gallery-modal__nav-btn:hover {
  background: white;
  transform: scale(1.1);
}

.photo-gallery-modal__nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.photo-gallery-modal__nav-btn:focus {
  outline: 3px solid white;
  outline-offset: 2px;
}

/* Hide on mobile */
@media (max-width: 767px) {
  .photo-gallery-modal__nav {
    display: none;
  }
}

/* ==========================================================================
   Thumbnail Strip
   ========================================================================== */

.photo-gallery-modal__thumbnails {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(0, 0, 0, 0.8);
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.photo-gallery-modal__thumbnails::-webkit-scrollbar {
  height: 6px;
}

.photo-gallery-modal__thumbnails::-webkit-scrollbar-track {
  background: transparent;
}

.photo-gallery-modal__thumbnails::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.photo-gallery-modal__thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}

.photo-gallery-modal__thumbnail:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.photo-gallery-modal__thumbnail--active {
  border-color: white;
  transform: scale(1.05);
}

.photo-gallery-modal__thumbnail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* ==========================================================================
   Zoom Controls
   ========================================================================== */

.photo-gallery-modal__zoom-controls {
  position: absolute;
  bottom: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.photo-gallery-modal__zoom-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #333;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.photo-gallery-modal__zoom-btn:hover {
  background: white;
  transform: scale(1.1);
}

.photo-gallery-modal__zoom-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Hide on mobile (use pinch gesture instead) */
@media (max-width: 767px) {
  .photo-gallery-modal__zoom-controls {
    display: none;
  }
}

/* ==========================================================================
   Attribution
   ========================================================================== */

.photo-gallery-modal__attribution {
  position: absolute;
  bottom: 90px;
  left: 20px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  max-width: calc(100% - 40px);
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.photo-gallery-modal__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: white;
}

.photo-gallery-modal__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: toko-spin 0.8s linear infinite;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes modalFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.photo-gallery-modal--opening {
  animation: modalFadeIn 0.3s ease-out;
}

.photo-gallery-modal--closing {
  animation: modalFadeOut 0.2s ease-in;
}

/* ==========================================================================
   Touch Gestures Visual Feedback
   ========================================================================== */

.photo-gallery-modal__gesture-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.photo-gallery-modal__gesture-hint--left {
  right: 20px;
  animation: swipeLeft 0.5s ease-out;
}

.photo-gallery-modal__gesture-hint--right {
  left: 20px;
  animation: swipeRight 0.5s ease-out;
}

@keyframes swipeLeft {
  0% {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) translateX(-30px);
  }
}

@keyframes swipeRight {
  0% {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) translateX(30px);
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus visible for keyboard navigation */
.photo-gallery-modal *:focus-visible {
  outline: 3px solid white;
  outline-offset: 2px;
}

/* Screen reader only */
.photo-gallery-modal__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .photo-gallery-modal,
  .photo-gallery-modal__image,
  .photo-gallery-modal__nav-btn,
  .photo-gallery-modal__zoom-btn,
  .photo-gallery-modal__thumbnail {
    transition: none !important;
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .photo-gallery-modal__nav-btn,
  .photo-gallery-modal__zoom-btn,
  .photo-gallery-modal__close {
    border: 2px solid currentColor;
  }

  .photo-gallery-modal__thumbnail--active {
    border-width: 3px;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
  .photo-gallery-modal__header {
    padding: 12px 16px;
  }

  .photo-gallery-modal__stage {
    padding: 12px;
  }

  .photo-gallery-modal__thumbnails {
    padding: 12px 16px;
  }

  .photo-gallery-modal__thumbnail {
    width: 60px;
    height: 45px;
  }

  .photo-gallery-modal__attribution {
    bottom: 70px;
    left: 16px;
    font-size: 11px;
    max-width: calc(100% - 32px);
  }
}
