/* ================================================================
   MAHOUACHI STUDIO — CATEGORY GALLERY
   Shared styles for all category gallery pages
   Design system: #1c1b1a bg · #e8003d accent · Syne/Outfit fonts
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&family=Syne:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:           #1c1b1a;
  --bg-card:      #242322;
  --bg-overlay:   rgba(28, 27, 26, 0.96);
  --accent:       #e8003d;
  --accent-dim:   rgba(232, 0, 61, 0.18);
  --text-primary: #f0ece8;
  --text-muted:   #8a8480;
  --border:       rgba(255,255,255,0.07);
  --heading-font: 'Syne', sans-serif;
  --body-font:    'Outfit', sans-serif;
  --radius:       4px;
  --transition:   0.35s ease;
  --header-h:     72px;
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header / Nav Dock ─────────────────────────────────────── */
#gallery-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(28, 27, 26, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content:space-between;
  z-index: 100;
  transition: background var(--transition);
}

.gallery-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 10px;
}

.gallery-logo img {
  height: 250px;
  width: auto;
  object-fit: contain;
}

.gallery-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--heading-font);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 30px;
  transition: all var(--transition);
}

.gallery-back-btn svg { flex-shrink: 0; transition: transform var(--transition); }

.gallery-back-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.gallery-back-btn:hover svg { transform: translateX(-3px); }

/* ── Hero Banner ───────────────────────────────────────────── */
#gallery-hero {
  margin-top: var(--header-h);
  padding: clamp(48px, 8vw, 96px) clamp(16px, 5vw, 56px) clamp(24px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 20% 50%, rgba(232, 0, 61, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 30%, rgba(232, 0, 61, 0.04) 0%, transparent 60%);
}

.gallery-hero-eyebrow {
  display: block;
  font-family: var(--heading-font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.gallery-hero-title {
  font-family: var(--heading-font);
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.gallery-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.gallery-count-badge span {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid rgba(232,0,61,0.25);
}

/* ── Grid Container (CSS Masonry) ──────────────────────────── */
#gallery-grid {
  padding: clamp(24px, 4vw, 48px) clamp(12px, 3vw, 32px);
  column-count: 4;
  column-gap: 12px;
}

/* ── Grid Items ────────────────────────────────────────────── */
.gallery-item {
  position: relative;
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  break-inside: avoid;
  margin-bottom: 12px;
  /* scroll-reveal starts hidden */
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s ease, box-shadow var(--transition);
}

.gallery-item.revealed {
  opacity: 1;
  transform: translateY(0);
}

.gallery-item:hover {
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  z-index: 2;
}

/* Stagger delays for revealed items */
.gallery-item:nth-child(3n+2) { transition-delay: 0.08s; }
.gallery-item:nth-child(3n+3) { transition-delay: 0.16s; }

/* ── Hover overlay (accent stripe on image) ───────────────── */
.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(232, 0, 61, 0.25) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
  z-index: 1;
  border-radius: var(--radius);
}

.gallery-item:hover::after {
  opacity: 1;
}

/* Accent border glow on hover */
.gallery-item::before {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) + 1px);
  transition: border-color var(--transition);
  pointer-events: none;
  z-index: 3;
}

.gallery-item:hover::before {
  border-color: rgba(232, 0, 61, 0.35);
}

/* ── Photo tiles ───────────────────────────────────────────── */
.gallery-item--photo .gallery-media-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

.gallery-item--photo img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item--photo:hover img {
  transform: scale(1.07);
}

/* ── Video tiles ───────────────────────────────────────────── */
.gallery-item--video .gallery-media-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

/* Poster image for video tiles */
.gallery-item--video .video-poster {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item--video:hover .video-poster {
  transform: scale(1.07);
}

/* Aspect ratio wrappers for portrait (reels) vs landscape */
.gallery-item--reel .gallery-media-wrap {
  aspect-ratio: 9/16;
}

.gallery-item--reel .video-poster,
.gallery-item--reel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Play button overlay ───────────────────────────────────── */
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28,27,26,0.30);
  transition: background var(--transition);
  z-index: 2;
}

.gallery-item--video:hover .play-overlay {
  background: rgba(28,27,26,0.12);
}

.play-btn-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background var(--transition);
  box-shadow: 0 6px 28px rgba(232,0,61,0.5);
}

.gallery-item--video:hover .play-btn-circle {
  transform: scale(1.15);
  background: #ff1a52;
}

.play-btn-circle svg {
  fill: #fff;
  margin-left: 3px;
}

/* ── Lightbox Overlay ─────────────────────────────────────── */
#gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 9, 0.97);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#gallery-lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lightbox-inner {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-media-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-image {
  max-width: 88vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  display: block;
}

#lightbox-video {
  max-width: 88vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  outline: none;
  background: #000;
  display: block;
}

/* Reel (vertical) video in lightbox */
#lightbox-video.reel-mode {
  max-width: min(440px, 88vw);
  max-height: 85vh;
  width: auto;
  height: auto;
}

/* ── Lightbox Controls ─────────────────────────────────────── */
.lightbox-close {
  position: fixed;
  top: 20px; right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 1010;
}

.lightbox-close:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: rotate(90deg);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 1010;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px);
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.lightbox-nav--prev { left: 16px; }
.lightbox-nav--next { right: 16px; }

.lightbox-counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  z-index: 1010;
}

.lightbox-counter strong { color: var(--text-primary); }

/* Loading spinner inside lightbox */
.lightbox-spinner {
  position: absolute;
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: none;
}

.lightbox-loading .lightbox-spinner { display: block; }

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

/* ── Footer ────────────────────────────────────────────────── */
#gallery-footer {
  padding: 20px clamp(16px, 5vw, 56px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(255,255,255,0.015);
}

.gallery-footer-copy {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.gallery-footer-socials {
  display: flex;
  gap: 8px;
}

.gallery-footer-socials a {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: all var(--transition);
}

.gallery-footer-socials a:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Scroll-to-top button ──────────────────────────────────── */
#scroll-top-btn {
  position: fixed;
  bottom: 28px; right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform var(--transition);
  z-index: 999;
  box-shadow: 0 4px 18px rgba(232,0,61,0.4);
}

#scroll-top-btn.visible {
  opacity: 1;
  pointer-events: all;
}

#scroll-top-btn:hover { transform: translateY(-3px); }

/* ── Preloader ─────────────────────────────────────────────── */
#gallery-preloader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

#gallery-preloader.hidden {
  opacity: 0;
  pointer-events: none;
}

.preloader-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Info Bar (bottom drawer — gallery info + contact form) ── */
#gallery-info-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 95;
  transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#gallery-info-bar.collapsed {
  transform: translateY(calc(100% - 48px));
}

.info-bar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: rgba(28, 27, 26, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--heading-font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--transition);
  user-select: none;
}

.info-bar-toggle:hover {
  color: var(--text-primary);
}

.info-bar-toggle svg {
  transition: transform 0.4s ease;
}

#gallery-info-bar.collapsed .info-bar-toggle svg {
  transform: rotate(180deg);
}

.info-bar-body {
  background: rgba(20, 19, 18, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 32px clamp(20px, 5vw, 48px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-height: 70vh;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .info-bar-body {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px;
  }
}

.info-bar-section h3 {
  font-family: var(--heading-font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.info-bar-section p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0;
}

.info-bar-section .gallery-count-badge {
  margin-top: 8px;
}

/* ── Contact form in info bar ─────────────────────────────── */
.info-bar-contact input[type="text"],
.info-bar-contact input[type="email"],
.info-bar-contact textarea {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 16px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.85rem;
  transition: border-color var(--transition), background var(--transition);
  box-sizing: border-box;
}

.info-bar-contact input:focus,
.info-bar-contact textarea:focus {
  border-color: var(--accent);
  background: rgba(232, 0, 61, 0.08);
  outline: none;
}

.info-bar-contact textarea {
  height: 80px;
  padding: 12px 16px;
  resize: vertical;
}

.info-bar-contact ._gotcha {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}

.info-bar-contact .form-response {
  font-size: 0.82rem;
  margin-bottom: 10px;
  min-height: 0;
}

.info-bar-contact .form-response .form-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 0.82rem;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.info-bar-contact .form-response .form-msg.success {
  background: rgba(0, 200, 100, 0.12);
  color: #4ade80;
  border: 1px solid rgba(0, 200, 100, 0.2);
}

.info-bar-contact .form-response .form-msg.error {
  background: rgba(232, 0, 61, 0.12);
  color: #ff6b6b;
  border: 1px solid rgba(232, 0, 61, 0.25);
}

.info-bar-contact .btn-submit {
  display: block;
  width: 100%;
  padding: 0.75em 1.8em;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: background var(--transition), transform 0.25s ease, opacity var(--transition);
}

.info-bar-contact .btn-submit:hover {
  background: #cc0035;
  transform: translateY(-1px);
}

.info-bar-contact .btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.info-bar-contact .btn-submit.loading .btn-text {
  opacity: 0.6;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

.btn-submit.loading .btn-spinner {
  display: inline-block;
}

/* ── Navigation progress indicator ──────────────────────────── */
#scroll-progress {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.04);
  z-index: 99;
}

#scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff3366);
  transition: width 0.15s ease;
}

/* ── Back button enhanced hover effect ──────────────────────── */
.gallery-back-btn {
  position: relative;
  overflow: hidden;
}

.gallery-back-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-dim);
  border-radius: 30px;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  z-index: -1;
}

.gallery-back-btn:hover::before {
  transform: scaleX(1);
  transform-origin: left;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  #gallery-grid { column-count: 3; }
}

@media (max-width: 768px) {
  #gallery-grid { column-count: 2; column-gap: 8px; }

  .gallery-item { margin-bottom: 8px; }

  .gallery-hero-title { letter-spacing: -0.01em; }

  .lightbox-nav--prev { left: 8px; }
  .lightbox-nav--next { right: 8px; }

  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-close { top: 12px; right: 12px; }
}

@media (max-width: 480px) {
  #gallery-grid { column-count: 2; column-gap: 4px; }
  .gallery-item { margin-bottom: 4px; }
}

/* ── Transition helpers ────────────────────────────────────── */
body.lightbox-open { overflow: hidden; }
