/* iOS-inspired Gallery Styles */
:root {
  --bg: #0d0d0d;
  --ink: #fffee6;
  --ink-muted: rgba(255,254,230,0.7);
  --border: rgba(255,254,230,0.12);
  --glass: rgba(255,255,255,0.06);
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial;
}

/* Page-specific navbar gradient/blur (no hard border) */
.navbar.navbar-expand-sm.fixed-top {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg,
    rgba(13,13,13,0.48) 0%,
    rgba(13,13,13,0.20) 55%,
    rgba(13,13,13,0.00) 100%) !important;
  backdrop-filter: blur(16px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
  border: none !important;
  box-shadow: none !important;
}
.navbar.navbar-expand-sm.fixed-top::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -22px;
  height: 22px;
  background: linear-gradient(180deg, rgba(13,13,13,0.18) 0%, rgba(13,13,13,0) 100%);
  pointer-events: none;
}

/* Name Gate Overlay (refined glass iOS vibe) */
.gate-overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 800px at 50% 10%, rgba(255,255,255,0.06), rgba(13,13,13,0.9) 60%), linear-gradient(180deg, rgba(13,13,13,0.65), rgba(13,13,13,0.9)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1500; opacity: 1; visibility: visible; transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), visibility 400ms cubic-bezier(0.4, 0, 0.2, 1), transform 400ms cubic-bezier(0.4, 0, 0.2, 1); padding: env(safe-area-inset-top, 0) 16px calc(16px + env(safe-area-inset-bottom, 0)) 16px; }
.gate-overlay:not(.active) { opacity: 0; visibility: hidden; pointer-events: none; transform: scale(0.95); }
.gate-card { width: min(92vw, 520px); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 18px; padding: 22px 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.45); text-align: center; }
.gate-title { margin: 0 0 6px 0; color: var(--ink); font-size: 1.7rem; letter-spacing: -0.02em; }
.gate-subtitle { margin: 0 0 14px 0; color: var(--ink-muted); }
.gate-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.gate-input { padding: 12px 14px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.22); color: var(--ink); border-radius: 12px; outline: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }
.gate-input::placeholder { color: rgba(255,254,230,0.55); }
.gate-input:focus { border-color: rgba(255,254,230,0.38); box-shadow: 0 0 0 3px rgba(255,254,230,0.12); }
.gate-button { padding: 12px 16px; background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.12)); color: #0d0d0d; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 12px; cursor: pointer; font-weight: 700; letter-spacing: 0.02em; }
.gate-button:hover { background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.16)); }
.gate-status { margin-top: 8px; color: var(--ink-muted); min-height: 1.2em; }

/* Mobile responsive fixes for gate modal */
@media (max-width: 480px) {
  .gate-card { 
    width: 88vw; 
    padding: 18px 16px; 
    margin: 0 8px;
  }
  .gate-title { font-size: 1.5rem; }
  .gate-subtitle { font-size: 0.9rem; margin-bottom: 12px; }
  .gate-form { 
    grid-template-columns: 1fr; 
    gap: 12px; 
  }
  .gate-input { 
    padding: 14px 16px; 
    font-size: 16px; /* Prevents zoom on iOS */
  }
  .gate-button { 
    padding: 14px 20px; 
    font-size: 16px;
    width: 100%;
    justify-self: center;
  }
}

.gallery-main { padding-top: 8px; }

/* Responsive square grid: 3/4/5 columns */
.ios-grid { display: grid; gap: 2px; grid-template-columns: repeat(3, 1fr); }
@media (min-width: 768px) { .ios-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .ios-grid { grid-template-columns: repeat(5, 1fr); } }
.grid-item { position: relative; overflow: hidden; background: #141414; cursor: pointer; }
.grid-item .thumb-inner { width: 100%; aspect-ratio: 1 / 1; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 160ms ease; }
.grid-item:hover img { transform: scale(1.02); }

/* iOS-style smooth photo app transitions */
.modal { 
  position: fixed !important; 
  inset: 0 !important; 
  display: grid !important; 
  place-items: center !important; 
  z-index: 2000 !important; 
  opacity: 0 !important; 
  visibility: hidden !important; 
  pointer-events: none !important;
  transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), visibility 400ms cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.modal.active { 
  opacity: 1 !important; 
  visibility: visible !important; 
  pointer-events: all !important;
}

.modal.hidden { 
  opacity: 0 !important; 
  visibility: hidden !important; 
  pointer-events: none !important; 
}

/* Background blur with smooth transition */
.modal-backdrop { 
  position: absolute; 
  inset: 0; 
  background: rgba(0,0,0,0.6); 
  backdrop-filter: blur(14px) saturate(140%); 
  -webkit-backdrop-filter: blur(14px) saturate(140%); 
  z-index: 0; 
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.modal.active .modal-backdrop { 
  opacity: 1;
}

.modal-dialog { 
  position: relative; 
  width: 100vw; 
  height: 100vh; 
  max-width: none; 
  max-height: none; 
  background: transparent; 
  border: none; 
  border-radius: 0; 
  overflow: hidden; 
  box-shadow: none; 
  z-index: 1; 
}

.modal-figure { 
  margin: 0; 
  width: 100%; 
  height: 100%; 
  position: relative; 
  display: block; 
}

/* Modal image with smooth iOS-style transitions */
#modal-image { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100vw; 
  height: 100vh; 
  object-fit: contain; 
  background: transparent; 
  will-change: transform;
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
  opacity: 0;
  transform-origin: center center;
}

.modal.active #modal-image { 
  opacity: 1;
}

/* Caption chip with smooth fade-in */
#modal-caption { 
  position: absolute; 
  left: 50%; 
  bottom: 24px; 
  transform: translateX(-50%) translateY(20px); 
  max-width: min(90vw, 1100px); 
  padding: 10px 14px; 
  color: var(--ink); 
  background: rgba(17,17,17,0.55); 
  border: 1px solid rgba(255,255,255,0.18); 
  border-radius: 12px; 
  font-size: 14px; 
  text-align: center; 
  z-index: 2; 
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1) 0.1s;
}

.modal.active #modal-caption { 
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Controls with smooth fade-in */
.control { 
  position: absolute; 
  background: rgba(17,17,17,0.55); 
  color: var(--ink); 
  border: 1px solid rgba(255,255,255,0.18); 
  width: 40px; 
  height: 40px; 
  border-radius: 50%; 
  display: grid; 
  place-items: center; 
  cursor: pointer; 
  font-size: 22px; 
  z-index: 2; 
  transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1), transform 400ms cubic-bezier(0.4, 0, 0.2, 1), background 150ms ease;
  opacity: 0;
  transform: scale(0.8);
}

.modal.active .control { 
  opacity: 1;
  transform: scale(1);
}

/* Stagger control animations */
.modal.active .control.close { 
  transition-delay: 100ms;
}

.modal.active .control.prev { 
  transition-delay: 150ms;
}

.modal.active .control.next { 
  transition-delay: 200ms;
}

.control:hover { background: rgba(17,17,17,0.68); }
.control:active { transform: scale(0.95); background: rgba(17,17,17,0.75); }
.control.close { right: 12px; top: 12px; }
.control.prev { left: 10px; top: 50%; transform: translateY(-50%); }
.control.next { right: 10px; top: 50%; transform: translateY(-50%); }

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
  .control:hover { background: rgba(17,17,17,0.55); }
  .control:active { transform: scale(0.9); background: rgba(17,17,17,0.8); }
}

/* Mobile modal improvements */
@media (max-width: 768px) {
  #modal-image { 
    width: 95vw; 
    height: 95vh; 
    object-fit: contain;
  }
  
  #modal-caption { 
    bottom: 20px; 
    left: 50%; 
    transform: translateX(-50%); 
    max-width: 85vw;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.4;
  }
  
  .control { 
    width: 48px; 
    height: 48px; 
    font-size: 20px;
  }
  
  .control.close { 
    right: 16px; 
    top: 16px; 
    width: 44px; 
    height: 44px;
  }
  
  .control.prev { 
    left: 16px; 
    top: 50%; 
    transform: translateY(-50%);
  }
  
  .control.next { 
    right: 16px; 
    top: 50%; 
    transform: translateY(-50%);
  }
}

@media (max-width: 480px) {
  #modal-image { 
    width: 100vw; 
    height: 100vh; 
  }
  
  #modal-caption { 
    bottom: 16px; 
    max-width: 90vw;
    padding: 10px 14px;
    font-size: 12px;
  }
  
  .control { 
    width: 52px; 
    height: 52px; 
    font-size: 22px;
  }
  
  .control.close { 
    right: 12px; 
    top: 12px; 
    width: 48px; 
    height: 48px;
  }
  
  .control.prev { 
    left: 12px; 
  }
  
  .control.next { 
    right: 12px; 
  }
}

/* Glass background decoration */
.glass-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(800px 400px at 10% 15%, rgba(255,255,255,0.05), transparent 60%),
    radial-gradient(600px 500px at 85% 20%, rgba(255,255,255,0.04), transparent 55%),
    radial-gradient(700px 500px at 50% 90%, rgba(255,255,255,0.03), transparent 60%);
  filter: saturate(120%);
}

/* Glass surface wrapper for grid - edge-to-edge (no visible boundary) */
.glass-surface {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Full-screen loader overlay */
.gallery-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 800px at 50% 10%, rgba(255,255,255,0.04), rgba(13,13,13,0.92) 60%), linear-gradient(180deg, rgba(13,13,13,0.7), rgba(13,13,13,0.9));
  z-index: 10;
  transition: opacity 300ms ease, visibility 300ms ease;
}
.gallery-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.gallery-loader .spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.9);
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
.gallery-loader .loader-text { color: var(--ink-muted); font-size: 14px; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 768px) {
  .glass-surface { margin: 0; max-width: none; }
}

/* iOS-style glass content sheen without boundaries */
/* Subtle separators between tiles */
.ios-grid { position: relative; }
.ios-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.00) 40%),
    linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00) 35%);
  mix-blend-mode: soft-light;
  z-index: 0;
}

/* Elevate images slightly to catch the sheen */
.grid-item { position: relative; z-index: 1; }

/* Softer navbar blend for iOS glass look */
.navbar.navbar-expand-sm.fixed-top {
  background: linear-gradient(180deg,
    rgba(13,13,13,0.48) 0%,
    rgba(13,13,13,0.20) 55%,
    rgba(13,13,13,0.00) 100%) !important;
}

/* Readability gradients at top/bottom (non-interactive) */
.modal-dialog::before,
.modal-dialog::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 80px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1) 300ms;
}

.modal.active .modal-dialog::before,
.modal.active .modal-dialog::after {
  opacity: 1;
}

.modal-dialog::before { top: 0; background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0)); }
.modal-dialog::after { bottom: 0; background: linear-gradient(0deg, rgba(0,0,0,0.55), rgba(0,0,0,0)); }

/* Safe-area aware caption */
#modal-caption {
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

/* Larger, touch-friendly controls */
.control { width: 46px; height: 46px; font-size: 22px; transition: opacity 150ms ease, background 150ms ease, transform 150ms ease; }
@media (max-width: 480px) {
  .control { width: 52px; height: 52px; font-size: 24px; }
  .control.prev { left: 6px; }
  .control.next { right: 6px; }
  .control.close { top: 8px; right: 8px; }
}

/* Hide chrome when requested */
.modal.chrome-hidden #modal-caption,
.modal.chrome-hidden .control { 
  opacity: 0; 
  pointer-events: none; 
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Drag-to-dismiss visual (applied inline via transform/opacity) */
#modal-image { transition: transform 150ms ease; touch-action: none; user-select: none; -webkit-user-drag: none; }

/* Gallery unlock animation */
.gallery-container { opacity: 1; transform: none; }
.gallery-container.unlocked { opacity: 1; transform: none; }

/* Grid items */

/* Enhanced touch feedback for iOS-style interactions */
.grid-item:active img {
  transform: scale(0.98);
  transition: transform 100ms ease;
}

/* Smooth scale transition for hover effects */
.grid-item img { transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1); }

/* Stagger the grid items appearance */
/* Removed staggered delays for instant appearance */
