/* ============================================================
   OMG Gallery — Theme Styles
   v1.0.0 2026-05-02
   Scope: per-theme layout overrides — base styles in frontend.css
   ============================================================ */

/* ── 1. GRID THEME ───────────────────────────────────────── */
.omg-gallery--grid:not(.omg-gallery-wrap),
.omg-gallery--grid > .omg-gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--omg-cols, 3), minmax(0, 1fr));
  gap: var(--omg-gap, 12px);
}

.omg-gallery--grid .omg-gallery-item {
  aspect-ratio: 1;
}

.omg-gallery--grid > .omg-gallery-grid > .omg-gallery-item {
  margin: 0;
  min-width: 0;
}

.omg-gallery--grid .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 768px) {
  .omg-gallery--grid:not(.omg-gallery-wrap),
  .omg-gallery--grid > .omg-gallery-grid {
    grid-template-columns: repeat(var(--omg-cols-tablet, 2), minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .omg-gallery--grid:not(.omg-gallery-wrap),
  .omg-gallery--grid > .omg-gallery-grid {
    grid-template-columns: repeat(var(--omg-cols-mobile, 1), minmax(0, 1fr));
  }
}

/* ── 2. MASONRY THEME ────────────────────────────────────── */
.omg-gallery--masonry {
  columns: var(--omg-cols, 3);
  column-gap: var(--omg-gap, 12px);
}

.omg-gallery--masonry .omg-gallery-item {
  display: block;
  break-inside: avoid;
  margin-bottom: var(--omg-gap, 12px);
}

.omg-gallery--masonry .omg-gallery-photo {
  width: 100%;
  height: auto;
  display: block;
}

/* JS-driven masonry grid variant */
.omg-gallery-masonry-grid {
  display: grid;
  grid-template-columns: repeat(var(--omg-cols, 3), 1fr);
  grid-auto-rows: var(--omg-row-height, 10px);
  gap: var(--omg-gap, 12px);
}

.omg-gallery-masonry-grid .omg-gallery-item {
  overflow: hidden;
}

.omg-gallery-masonry-grid .omg-gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 768px) {
  .omg-gallery--masonry {
    columns: var(--omg-cols-tablet, 2);
  }

  .omg-gallery-masonry-grid {
    grid-template-columns: repeat(var(--omg-cols-tablet, 2), 1fr);
  }
}

@media (max-width: 480px) {
  .omg-gallery--masonry {
    columns: var(--omg-cols-mobile, 1);
  }

  .omg-gallery-masonry-grid {
    grid-template-columns: repeat(var(--omg-cols-mobile, 1), 1fr);
  }
}

/* ── 3. MOSAIC THEME ─────────────────────────────────────── */
.omg-gallery--mosaic {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 200px;
  gap: var(--omg-gap, 12px);
}

.omg-gallery--mosaic .omg-gallery-item {
  overflow: hidden;
}

.omg-gallery--mosaic .omg-gallery-item--featured {
  grid-column: span 2;
  grid-row: span 2;
}

.omg-gallery--mosaic .omg-gallery-item--wide {
  grid-column: span 2;
}

.omg-gallery--mosaic .omg-gallery-item--tall {
  grid-row: span 2;
}

.omg-gallery--mosaic .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 768px) {
  .omg-gallery--mosaic {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 160px;
  }

  .omg-gallery--mosaic .omg-gallery-item--featured {
    grid-column: span 2;
    grid-row: span 1;
  }

  .omg-gallery--mosaic .omg-gallery-item--wide {
    grid-column: span 2;
  }

  .omg-gallery--mosaic .omg-gallery-item--tall {
    grid-row: span 1;
  }
}

@media (max-width: 480px) {
  .omg-gallery--mosaic {
    grid-template-columns: 1fr;
    grid-auto-rows: 200px;
  }

  .omg-gallery--mosaic .omg-gallery-item--featured,
  .omg-gallery--mosaic .omg-gallery-item--wide,
  .omg-gallery--mosaic .omg-gallery-item--tall {
    grid-column: span 1;
    grid-row: span 1;
  }
}

/* ── 4. JUSTIFIED THEME ──────────────────────────────────── */
.omg-gallery--justified {
  display: flex;
  flex-wrap: wrap;
  gap: var(--omg-gap, 8px);
  align-items: flex-start;
}

.omg-gallery--justified .omg-gallery-row {
  display: flex;
  gap: var(--omg-gap, 8px);
  width: 100%;
  overflow: hidden;
}

.omg-gallery--justified .omg-gallery-item {
  flex-grow: 1;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.omg-gallery--justified .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* JS sets --ratio on each item and computes flex-basis */
.omg-gallery--justified .omg-gallery-item[style] {
  flex-basis: 0;
}

@media (max-width: 480px) {
  .omg-gallery--justified .omg-gallery-row {
    flex-wrap: wrap;
  }

  .omg-gallery--justified .omg-gallery-item {
    flex-basis: calc(50% - 4px);
    flex-grow: 0;
    aspect-ratio: 1;
  }
}

/* ── 5. SLIDESHOW THEME ──────────────────────────────────── */
.omg-gallery--slideshow {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.omg-gallery--slideshow .omg-gallery-stage {
  position: relative;
  width: 100%;
  background: #000;
}

.omg-gallery--slideshow .omg-gallery-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}

.omg-gallery--slideshow .omg-gallery-slide.is-active {
  opacity: 1;
  pointer-events: auto;
  position: relative;
}

.omg-gallery--slideshow .omg-gallery-slide .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

@keyframes omgSlideFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.omg-gallery--slideshow .omg-gallery-slide.is-entering {
  animation: omgSlideFade 0.5s ease forwards;
}

/* Slideshow nav buttons */
.omg-slideshow-prev,
.omg-slideshow-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.omg-slideshow-prev {
  left: 12px;
}

.omg-slideshow-next {
  right: 12px;
}

.omg-slideshow-prev:hover,
.omg-slideshow-next:hover {
  background: rgba(0, 0, 0, 0.8);
}

.omg-slideshow-prev:disabled,
.omg-slideshow-next:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Slideshow dots */
.omg-slideshow-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
  list-style: none;
  margin: 0;
}

.omg-slideshow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
}

.omg-slideshow-dot.is-active {
  background: #1a1a1a;
}

/* Slideshow counter */
.omg-slideshow-counter {
  text-align: center;
  font-size: 12px;
  color: #777;
  padding-bottom: 8px;
}

@media (max-width: 480px) {
  .omg-slideshow-prev,
  .omg-slideshow-next {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* ── 6. FILMSTRIP THEME ──────────────────────────────────── */
.omg-gallery--filmstrip {
  display: flex;
  flex-direction: column;
  gap: var(--omg-gap, 12px);
}

.omg-filmstrip-main {
  width: 100%;
  position: relative;
  overflow: hidden;
  background: #000;
}

.omg-filmstrip-main .omg-gallery-photo {
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transition: opacity 0.25s ease;
}

.omg-filmstrip-main.is-loading .omg-gallery-photo {
  opacity: 0;
}

.omg-filmstrip-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.omg-filmstrip-strip::-webkit-scrollbar {
  height: 4px;
}

.omg-filmstrip-strip::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.omg-filmstrip-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 56px;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  background: none;
  padding: 0;
}

.omg-filmstrip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.omg-filmstrip-thumb.is-active {
  border-color: #d4a84b;
}

.omg-filmstrip-thumb:hover {
  border-color: rgba(212, 168, 75, 0.6);
}

@media (max-width: 480px) {
  .omg-filmstrip-thumb {
    flex: 0 0 56px;
    width: 56px;
    height: 44px;
  }
}

/* ── 7. EDITORIAL THEME ──────────────────────────────────── */
.omg-gallery--editorial {
  display: flex;
  flex-direction: column;
  gap: var(--omg-gap, 24px);
}

.omg-editorial-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--omg-gap, 12px);
  align-items: stretch;
}

.omg-editorial-row:nth-child(even) {
  grid-template-columns: 1fr 1fr 2fr;
}

.omg-editorial-row .omg-gallery-item {
  overflow: hidden;
  border-radius: 4px;
}

.omg-editorial-row .omg-gallery-item--lead {
  grid-column: 1;
}

.omg-editorial-row:nth-child(even) .omg-gallery-item--lead {
  grid-column: 3;
}

.omg-editorial-row .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 200px;
}

.omg-editorial-row .omg-gallery-item:not(.omg-gallery-item--lead) .omg-gallery-photo {
  min-height: 140px;
}

@media (max-width: 768px) {
  .omg-editorial-row,
  .omg-editorial-row:nth-child(even) {
    grid-template-columns: 1fr 1fr;
  }

  .omg-editorial-row .omg-gallery-item--lead,
  .omg-editorial-row:nth-child(even) .omg-gallery-item--lead {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .omg-editorial-row,
  .omg-editorial-row:nth-child(even) {
    grid-template-columns: 1fr;
  }

  .omg-editorial-row .omg-gallery-item--lead,
  .omg-editorial-row:nth-child(even) .omg-gallery-item--lead {
    grid-column: 1;
  }
}

/* ── 8. POLAROID THEME ───────────────────────────────────── */
.omg-gallery--polaroid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 20px;
  justify-content: center;
}

.omg-gallery--polaroid .omg-gallery-item {
  background: #fff;
  padding: 10px 10px 36px;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.15);
  transform: rotate(var(--rotation, 0deg));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: visible;
  border-radius: 2px;
  flex: 0 0 auto;
}

.omg-gallery--polaroid .omg-gallery-item:hover {
  transform: rotate(0deg) scale(1.04);
  box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

.omg-gallery--polaroid .omg-gallery-link {
  display: block;
  overflow: hidden;
}

.omg-gallery--polaroid .omg-gallery-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  display: block;
  transform: none;
}

.omg-gallery--polaroid .omg-gallery-item:hover .omg-gallery-photo {
  transform: none;
}

.omg-gallery--polaroid .omg-gallery-caption {
  position: static;
  background: transparent;
  color: #555;
  font-family: "Segoe Script", "Bradley Hand", cursive;
  font-size: 12px;
  text-align: center;
  padding: 8px 4px 0;
  transform: none;
  transition: none;
  pointer-events: auto;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.omg-gallery--polaroid .omg-gallery-item:hover .omg-gallery-caption {
  transform: none;
}

/* Polaroid rotation patterns for natural scatter */
.omg-gallery--polaroid .omg-gallery-item:nth-child(5n+1) { --rotation:  -2.5deg; }
.omg-gallery--polaroid .omg-gallery-item:nth-child(5n+2) { --rotation:   1.8deg; }
.omg-gallery--polaroid .omg-gallery-item:nth-child(5n+3) { --rotation:  -1.2deg; }
.omg-gallery--polaroid .omg-gallery-item:nth-child(5n+4) { --rotation:   2.8deg; }
.omg-gallery--polaroid .omg-gallery-item:nth-child(5n+5) { --rotation:  -0.7deg; }

@media (max-width: 480px) {
  .omg-gallery--polaroid .omg-gallery-photo {
    width: 140px;
    height: 140px;
  }

  .omg-gallery--polaroid .omg-gallery-caption {
    max-width: 140px;
  }

  .omg-gallery--polaroid {
    gap: 16px;
    padding: 12px;
  }
}

/* ── 9. CINEMATIC THEME ──────────────────────────────────── */
.omg-gallery--cinematic {
  background: #0a0a0a;
  padding: 0;
  position: relative;
}

.omg-cinematic-stage {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
}

/* Letterbox bars */
.omg-cinematic-stage::before,
.omg-cinematic-stage::after {
  content: '';
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  height: 10%;
  background: #0a0a0a;
  z-index: 2;
  pointer-events: none;
}

.omg-cinematic-stage::before {
  top: 0;
}

.omg-cinematic-stage::after {
  bottom: 0;
}

.omg-cinematic-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.omg-cinematic-frame.is-active {
  opacity: 1;
  position: relative;
}

.omg-cinematic-frame .omg-gallery-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Cinematic control strip */
.omg-cinematic-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: #111;
  border-top: 1px solid #222;
}

.omg-cinematic-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  transition: color 0.2s;
  border-radius: 4px;
}

.omg-cinematic-btn:hover {
  color: #fff;
}

.omg-cinematic-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.omg-cinematic-counter {
  color: #777;
  font-size: 12px;
  font-family: monospace;
  letter-spacing: 0.05em;
  min-width: 60px;
  text-align: center;
}

/* Cinematic filmstrip */
.omg-cinematic-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 12px;
  background: #0a0a0a;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.omg-cinematic-strip::-webkit-scrollbar {
  height: 3px;
}

.omg-cinematic-strip::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

.omg-cinematic-thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 40px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  opacity: 0.55;
  transition: opacity 0.2s, border-color 0.2s;
  background: none;
  padding: 0;
  border-radius: 2px;
}

.omg-cinematic-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.omg-cinematic-thumb.is-active {
  border-color: #d4a84b;
  opacity: 1;
}

.omg-cinematic-thumb:hover {
  opacity: 0.9;
}

/* Cinematic caption overlay */
.omg-gallery--cinematic .omg-gallery-caption {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 20px 16px 12px;
  z-index: 3;
}

@media (max-width: 480px) {
  .omg-cinematic-thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 32px;
  }

  .omg-cinematic-controls {
    padding: 8px 12px;
    gap: 8px;
  }

  .omg-cinematic-btn {
    font-size: 16px;
  }
}

/* ── 10. REDUCED MOTION — THEME OVERRIDES ────────────────── */
@media (prefers-reduced-motion: reduce) {
  .omg-gallery--slideshow .omg-gallery-slide,
  .omg-gallery--slideshow .omg-gallery-slide.is-entering {
    transition: none;
    animation: none;
  }

  .omg-gallery--polaroid .omg-gallery-item,
  .omg-gallery--polaroid .omg-gallery-item:hover {
    transform: none;
    transition: none;
  }

  .omg-gallery--cinematic .omg-cinematic-frame {
    transition: none;
  }

  .omg-filmstrip-main .omg-gallery-photo {
    transition: none;
  }
}
