/**
 * photo-gallery-grid.css
 * Photo Gallery Grid Component Styles (BEM Methodology)
 */

/* ==========================================================================
   Photo Gallery Grid Container
   ========================================================================== */

.photo-gallery-grid {
  width: 100%;
  margin-bottom: 24px;
}

/* Desktop Grid Layout (768px+) */
@media (min-width: 768px) {
  .photo-gallery-grid {
    display: grid;
    grid-template-columns: 60% 20% 20%;
    grid-template-rows: 200px 200px;
    gap: 8px;
    height: 408px; /* 200px * 2 + 8px gap */
  }
}

/* ==========================================================================
   Main Image (60% width, 2 rows)
   ========================================================================== */

.photo-gallery-grid__main {
  display: none; /* Mobile: hide main, use carousel instead */
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  cursor: pointer;
}

@media (min-width: 768px) {
  .photo-gallery-grid__main {
    display: block; /* Desktop: show main grid image */
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    aspect-ratio: unset;
    height: 100%;
    min-height: unset;
  }
}

.photo-gallery-grid__main-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.photo-gallery-grid__main:hover .photo-gallery-grid__main-image {
  transform: scale(1.05);
}

/* ==========================================================================
   Thumbnail Grid (4 sub images)
   ========================================================================== */

.photo-gallery-grid__thumbnails {
  display: none;
}

@media (min-width: 768px) {
  .photo-gallery-grid__thumbnails {
    display: contents;
  }
}

.photo-gallery-grid__thumbnail {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #e0e0e0;
  cursor: pointer;
}

@media (min-width: 768px) {
  .photo-gallery-grid__thumbnail {
    display: block;
  }
}

.photo-gallery-grid__thumbnail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition:
    transform 0.2s ease,
    opacity 0.3s ease;
}

.photo-gallery-grid__thumbnail:hover .photo-gallery-grid__thumbnail-image {
  transform: scale(1.05);
}

/* Lazy loading states */
.photo-gallery-grid__thumbnail-image.lazy-loading {
  filter: blur(10px);
  transform: scale(1.05);
}

.photo-gallery-grid__thumbnail-image.lazy-loaded {
  filter: blur(0);
  transform: scale(1);
}

.photo-gallery-grid__thumbnail-image.lazy-error {
  opacity: 0.5;
}

/* ==========================================================================
   Hover Overlay
   ========================================================================== */

.photo-gallery-grid__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.photo-gallery-grid__main:hover .photo-gallery-grid__overlay,
.photo-gallery-grid__thumbnail:hover .photo-gallery-grid__overlay {
  opacity: 1;
}

.photo-gallery-grid__overlay-icon {
  color: white;
  font-size: 32px;
}

/* ==========================================================================
   "+N More" Badge
   ========================================================================== */

.photo-gallery-grid__more-badge {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 30;
}

.photo-gallery-grid__more-badge:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* ==========================================================================
   Mobile Carousel (< 768px)
   ========================================================================== */

.photo-gallery-grid__carousel {
  display: block;
  position: relative;
}

@media (min-width: 768px) {
  .photo-gallery-grid__carousel {
    display: none;
  }
}

.photo-gallery-grid__carousel-main {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.photo-gallery-grid__carousel-track {
  width: 100%;
  height: 100%;
  will-change: transform;
}

.photo-gallery-grid__carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: auto;
}

/* Carousel Navigation Arrows */
.photo-gallery-grid__carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.photo-gallery-grid__carousel-main:hover .photo-gallery-grid__carousel-arrow,
.photo-gallery-grid__carousel-arrow:focus {
  opacity: 1;
}

/* タッチデバイスでは常に表示 */
@media (hover: none) {
  .photo-gallery-grid__carousel-arrow {
    opacity: 0.7;
  }
}

.photo-gallery-grid__carousel-arrow--prev {
  left: 8px;
}

.photo-gallery-grid__carousel-arrow--next {
  right: 8px;
}

/* Photo Counter */
.photo-gallery-grid__carousel-counter {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  z-index: 10;
  pointer-events: none;
}

/* ==========================================================================
   Carousel Indicators
   ========================================================================== */

.photo-gallery-grid__indicators {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 0 16px;
}

.photo-gallery-grid__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c0c0c0;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-gallery-grid__indicator--active {
  background: var(--color-primary, #ff6b35);
  transform: scale(1.2);
}

.photo-gallery-grid__indicator-more {
  font-size: 12px;
  color: #666;
  font-weight: 500;
  margin-left: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.photo-gallery-grid__indicator-more:hover {
  color: var(--color-primary, #ff6b35);
}

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

.photo-gallery-grid__loading {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 12px;
}

@media (min-width: 768px) {
  .photo-gallery-grid__loading {
    height: 408px;
  }
}

.photo-gallery-grid__spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top: 4px solid var(--color-primary, #ff6b35);
  border-radius: 50%;
  animation: toko-spin 0.8s linear infinite;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.photo-gallery-grid__error {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 12px;
  color: #999;
  padding: 24px;
  text-align: center;
}

.photo-gallery-grid__error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.photo-gallery-grid__error-message {
  font-size: 14px;
  color: #666;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.photo-gallery-grid__empty {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-light, #f5f5f5);
  border-radius: 12px;
  color: var(--color-text-secondary, #999);
  padding: 24px 16px;
  text-align: center;
}

.photo-gallery-grid__empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
  color: var(--color-text-secondary, #ccc);
  opacity: 0.6;
}

.photo-gallery-grid__empty-message {
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  margin-bottom: 0;
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

[data-theme='dark'] .photo-gallery-grid__carousel-main {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

[data-theme='dark'] .photo-gallery-grid__loading,
[data-theme='dark'] .photo-gallery-grid__error,
[data-theme='dark'] .photo-gallery-grid__empty {
  background: var(--color-surface, #1e1e1e);
}

[data-theme='dark'] .photo-gallery-grid__indicator {
  background: #555;
}

[data-theme='dark'] .photo-gallery-grid__indicator-more {
  color: #aaa;
}

[data-theme='dark'] .photo-gallery-grid__error-message,
[data-theme='dark'] .photo-gallery-grid__empty-message {
  color: var(--color-text-secondary, #b3b3b3);
}

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

.photo-gallery-grid__main:focus,
.photo-gallery-grid__thumbnail:focus {
  outline: 3px solid var(--color-primary, #ff6b35);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .photo-gallery-grid__main-image,
  .photo-gallery-grid__thumbnail-image,
  .photo-gallery-grid__overlay,
  .photo-gallery-grid__indicator {
    transition: none !important;
  }

  .photo-gallery-grid__main:hover .photo-gallery-grid__main-image,
  .photo-gallery-grid__thumbnail:hover .photo-gallery-grid__thumbnail-image {
    transform: none !important;
  }
}

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

  .photo-gallery-grid__overlay {
    background: rgba(0, 0, 0, 0.8);
  }
}
