/* ══════════════════════════════════════════════════════════════════════════
   Zahra · Gallery page
   ══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  background: #060e08;
  color: #f0e8d8;
  font-family: 'EB Garamond', Georgia, serif;
  overflow-x: hidden;
  cursor: none;
  padding-top: 68px; /* header height */
}

::selection { background: rgba(200,168,74,.22); color: #e0cc80; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 4px; }
::-webkit-scrollbar-track        { background: #060e08; }
::-webkit-scrollbar-thumb        { background: #b83264; border-radius: 2px; }

/* ── Canvas & cursor ────────────────────────────────────────────────────── */
#petalCanvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
}
#cursorGlow {
  position: fixed;
  width: 380px; height: 380px;
  border-radius: 50%;
  pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(200,168,74,.05) 0%, rgba(184,50,100,.04) 40%, transparent 70%);
  transform: translate(-50%,-50%);
}
body::after {
  content: '';
  position: fixed;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #e89ab0;
  pointer-events: none; z-index: 9999;
  transform: translate(-50%,-50%);
  top: var(--cy, 50%); left: var(--cx, 50%);
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px; width: 0;
  background: linear-gradient(90deg, #b83264, #c8a84a, #4a8a5a);
  z-index: 10001;
  transition: width .1s linear;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#galleryHeader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 62px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(6,14,8,.88);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.header-back {
  display: flex; align-items: center; gap: .5rem;
  font-family: 'Josefin Sans', sans-serif;
  font-size: .62rem; font-weight: 300;
  letter-spacing: .2em; text-transform: uppercase;
  color: #9ab8a0;
  text-decoration: none;
  transition: color .2s;
}
.header-back svg { width: 16px; height: 12px; }
.header-back:hover { color: #c8a84a; }

.header-centre {
  display: flex; align-items: center; gap: .5rem;
  font-family: 'Cormorant Garamond', serif;
}
.header-arabic { font-size: 1.2rem; color: #e89ab0; font-weight: 300; letter-spacing: .1em; }
.header-dot    { color: rgba(200,168,74,.4); }
.header-title  { font-size: 1rem; color: #f0e8d8; font-weight: 400; letter-spacing: .06em; }

.header-count {
  font-family: 'Josefin Sans', sans-serif;
  font-size: .6rem; font-weight: 200;
  letter-spacing: .2em; text-transform: uppercase;
  color: #9ab8a0;
  text-align: right;
}
.header-count span:first-child { color: #c8a84a; font-size: .75rem; font-weight: 400; }

/* ── Controls bar ───────────────────────────────────────────────────────── */
.controls-bar {
  position: sticky;
  top: 62px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 2rem;
  background: rgba(6,14,8,.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.04);
  flex-wrap: wrap;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.ctrl-btn {
  font-family: 'Josefin Sans', sans-serif;
  font-size: .6rem; font-weight: 300;
  letter-spacing: .2em; text-transform: uppercase;
  color: #9ab8a0;
  background: none;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: .35rem .8rem;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.ctrl-btn:hover,
.ctrl-btn.ctrl-active {
  color: #c8a84a;
  border-color: rgba(200,168,74,.35);
  background: rgba(200,168,74,.06);
}

.ctrl-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  color: #9ab8a0;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  flex-shrink: 0;
}
.ctrl-icon svg { width: 14px; height: 14px; fill: currentColor; }
.ctrl-icon:hover,
.ctrl-icon.ctrl-active {
  color: #c8a84a;
  border-color: rgba(200,168,74,.35);
  background: rgba(200,168,74,.06);
}

.ctrl-select {
  font-family: 'Josefin Sans', sans-serif;
  font-size: .6rem; font-weight: 300;
  letter-spacing: .15em; text-transform: uppercase;
  color: #9ab8a0;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: .35rem .7rem;
  cursor: pointer;
  outline: none;
  transition: border-color .2s;
}
.ctrl-select:focus { border-color: rgba(200,168,74,.35); }
.ctrl-select option { background: #0a1510; color: #f0e8d8; }

/* spacer pushes sort to the right */
.ctrl-group:nth-child(3) { margin-left: auto; }

/* ── Gallery grid ───────────────────────────────────────────────────────── */
.gallery-grid {
  padding: 1.2rem 1.2rem 4rem;
  display: grid;
  gap: .7rem;
  position: relative;
  z-index: 1;
}

/* Small — 4 columns on desktop, 3 on tablet, 2 on mobile */
.gallery-grid.grid-sm {
  grid-template-columns: repeat(4, 1fr);
}
/* Medium — 3 columns desktop, 2 tablet */
.gallery-grid.grid-md {
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
/* Large / cinematic — 2 columns */
.gallery-grid.grid-lg {
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Media card ─────────────────────────────────────────────────────────── */
.media-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #0e1c12;
  border: 1px solid rgba(255,255,255,.05);
  transition: transform .35s cubic-bezier(0.34,1.56,0.64,1), box-shadow .35s, border-color .25s;
  will-change: transform;
}
.grid-sm .media-card { aspect-ratio: 1/1; border-radius: 6px; }
.grid-md .media-card { aspect-ratio: 4/5; border-radius: 10px; }
.grid-lg .media-card { aspect-ratio: 16/9; border-radius: 12px; }

.media-card:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(200,168,74,.15);
  border-color: rgba(200,168,74,.18);
}

.media-card img,
.media-card video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}
.media-card:hover img { transform: scale(1.04); }

/* Placeholder */
.media-placeholder {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.media-ph-icon { font-size: 1.4rem; opacity: .5; }
.grid-sm .media-ph-icon { font-size: 1rem; }
.media-ph-num {
  font-family: 'Josefin Sans', sans-serif;
  font-size: .5rem;
  letter-spacing: .2em;
  color: rgba(255,255,255,.2);
  text-transform: uppercase;
}

/* Overlay */
.media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6,14,8,.88) 0%, rgba(6,14,8,.2) 50%, transparent 100%);
  opacity: 0;
  transition: opacity .3s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: .8rem;
  gap: .2rem;
}
.media-card:hover .media-overlay { opacity: 1; }

.media-caption {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: .9rem;
  color: #f0e8d8;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.grid-sm .media-caption { font-size: .75rem; }

.media-date {
  font-family: 'Josefin Sans', sans-serif;
  font-size: .55rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #c8a84a;
}

/* Video indicator */
.video-badge {
  position: absolute;
  top: .5rem; left: .5rem;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(6,14,8,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.video-badge svg { width: 10px; height: 10px; fill: #f0e8d8; }

/* Date badge */
.media-badge {
  position: absolute;
  top: .5rem; right: .5rem;
  background: rgba(6,14,8,.7);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(200,168,74,.25);
  color: #c8a84a;
  font-family: 'Josefin Sans', sans-serif;
  font-size: .5rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .2rem .5rem;
  border-radius: 3px;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 6rem 2rem;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.3rem;
  color: #4a6848;
}

/* ── Lightbox ───────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0;
  z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
  transition: opacity .35s;
}
.lightbox.lb-open { pointer-events: all; opacity: 1; }

.lb-overlay {
  position: absolute; inset: 0;
  background: rgba(6,14,8,.92);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.lb-box {
  position: relative; z-index: 1;
  background: #0e1c12;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  overflow: hidden;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  width: 100%;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 120px rgba(0,0,0,.7);
  transform: scale(.93);
  transition: transform .4s cubic-bezier(0.16,1,0.3,1);
}
.lightbox.lb-open .lb-box { transform: scale(1); }

.lb-close {
  position: absolute; top: .8rem; right: .8rem;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(6,14,8,.7);
  color: #f0e8d8; font-size: 1.1rem;
  cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.lb-close:hover { background: #b83264; border-color: #b83264; }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(6,14,8,.7); backdrop-filter: blur(6px);
  color: #f0e8d8; font-size: 1.4rem;
  cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
}
.lb-nav:hover { background: rgba(200,168,74,.2); border-color: rgba(200,168,74,.4); }
.lb-prev { left: .8rem; }
.lb-next { right: .8rem; }

.lb-media {
  flex: 1; min-height: 0; overflow: hidden;
  position: relative; background: #060e08;
}
.lb-media img, .lb-media video {
  width: 100%; max-height: 70vh;
  object-fit: contain; display: block;
}
.lb-placeholder {
  display: none;
  width: 100%; height: 400px;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem;
}

.lb-info {
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.lb-caption {
  font-family: 'EB Garamond', serif;
  font-style: italic; font-size: 1rem;
  color: #f0e8d8; margin-bottom: .4rem;
}
.lb-meta {
  display: flex; gap: 1rem; flex-wrap: wrap;
  font-family: 'Josefin Sans', sans-serif;
  font-size: .58rem; letter-spacing: .18em;
  text-transform: uppercase; color: #c8a84a;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* iPad landscape (≤ 1024px) */
@media (max-width: 1024px) {
  .gallery-grid.grid-sm { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid.grid-lg { max-width: 100%; }
}

/* iPad portrait (≤ 768px) */
@media (max-width: 768px) {
  body { padding-top: 60px; }
  #galleryHeader { height: 60px; }
  .controls-bar { top: 60px; gap: .6rem; flex-wrap: wrap; padding: .6rem 1rem; }
  .ctrl-group:nth-child(3) { margin-left: 0; }

  .gallery-grid.grid-sm { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid.grid-md { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid.grid-lg { grid-template-columns: 1fr; }

  body::after { display: none; }
  #cursorGlow  { display: none; }
}

/* Large phone (≤ 600px) */
@media (max-width: 600px) {
  #galleryHeader { padding: 0 .8rem; }
  .header-back span { display: none; }
  .header-arabic { font-size: 1rem; }
  .header-title  { font-size: .85rem; }
  .header-count  { font-size: .55rem; }

  .controls-bar { padding: .5rem .8rem; gap: .4rem; }
  .ctrl-btn { padding: .3rem .65rem; font-size: .56rem; }

  .gallery-grid { padding: .5rem .5rem 4rem; gap: .4rem; }
  .gallery-grid.grid-sm { grid-template-columns: repeat(3, 1fr); gap: .4rem; }
  .gallery-grid.grid-md { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .gallery-grid.grid-lg { grid-template-columns: 1fr; }

  /* Compact card text on small grid */
  .grid-sm .media-caption { font-size: .7rem; }
  .grid-sm .video-badge   { width: 20px; height: 20px; }
  .grid-sm .video-badge svg { width: 8px; height: 8px; }

  /* Lightbox */
  .lb-prev { left: .4rem; width: 36px; height: 36px; font-size: 1.2rem; }
  .lb-next { right: .4rem; width: 36px; height: 36px; font-size: 1.2rem; }
  .lb-info { padding: .8rem 1rem; }
  .lb-caption { font-size: .9rem; }
}

/* Small phone (≤ 430px) */
@media (max-width: 430px) {
  .gallery-grid.grid-sm { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .media-ph-num { display: none; }
  .controls-bar { gap: .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  #petalCanvas { display: none; }
}
