/* styles.css — mobile modal nav buttons visible + mobile layout tweaks */

/* Fonts */
body,
button,
input,
select {
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Text",
    system-ui,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
}

/* color vars - modern color scheme */
:root {
  --bg-1: #0a0d14;
  --bg-2: #0f1419;
  --muted: rgba(255, 255, 255, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent-start: #6366f1; /* modern indigo */
  --accent-end: #8b5cf6; /* modern purple */
  --accent-hover: #818cf8;
  --white: #ffffff;
  --black: #000000;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
}

/* base */
html,
body {
  height: 100%;
  /* guard against accidental horizontal scroll caused by minor rounding differences */
  overflow-x: hidden;
}
body {
  background:
    radial-gradient(
      1400px 700px at 10% 10%,
      rgba(99, 102, 241, 0.08),
      transparent 8%
    ),
    radial-gradient(
      1200px 600px at 90% 80%,
      rgba(139, 92, 246, 0.06),
      transparent 8%
    ),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 65%);
  color: #e8f0f8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  position: relative;
}

/* blobs */
.bg-blob {
  position: fixed;
  pointer-events: none;
  filter: blur(70px) saturate(120%);
  opacity: 0.16;
  z-index: 0;
}
.blob-1 {
  width: 520px;
  height: 520px;
  left: -160px;
  top: -160px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-start), transparent 30%),
    linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border-radius: 46% 54% 60% 40% / 48% 46% 54% 52%;
}
.blob-2 {
  width: 640px;
  height: 640px;
  right: -260px;
  bottom: -120px;
  background:
    radial-gradient(circle at 70% 70%, var(--accent-end), transparent 30%),
    linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border-radius: 40% 60% 38% 62% / 46% 52% 48% 54%;
}

/* Simplify blobs on mobile — blur(70px) on fixed elements is very expensive */
@media (max-width: 768px) {
    .bg-blob {
        filter: blur(40px);
        opacity: 0.1;
    }
    .blob-1 {
        width: 300px;
        height: 300px;
    }
    .blob-2 {
        width: 360px;
        height: 360px;
    }
}

/* Additional QOL improvements */
.tile {
  cursor: pointer;
  contain: layout style paint;
}

.tile:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.6);
  outline-offset: 2px;
  border-radius: 14px;
}

/* Better tooltips */
[title] {
  cursor: help;
}

/* Improved button states */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Copy button animation */
#modalCopyUrl:active {
  transform: scale(0.95);
}

#modalCopyUrl.copied {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: rgba(16, 185, 129, 0.5);
}

#modalCopyUrl.copied i::before {
  content: "\f26b"; /* check icon */
}

/* navbar */
.blur-nav {
  backdrop-filter: blur(8px) saturate(120%);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  z-index: 20;
}

/* make inner nav actions wrap when there isn't enough space */
.navbar .container-fluid > .d-flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap; /* crucial: allow wrapping */
  justify-content: flex-end;
}

/* logo circle (if you still use it) */
.navbar-brand .logo-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  font-weight: 800;
  color: var(--white);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(61, 87, 255, 0.14);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

/* inputs — make flexible so it doesn't force overflow */
.input-group {
  min-width: 0; /* allow shrinking on small screens */
  flex: 1 1 240px; /* grow, shrink, base width */
  max-width: 520px;
  width: 100%;
}
/* form-control-dark styling moved to glass.css for consistency */

/* gradient button (Download All) - text white */
.btn-gradient {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  color: var(--white) !important;
  border: none;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(61, 87, 255, 0.12);
  border-radius: 12px;
  padding: 0.45rem 0.8rem;
  white-space: nowrap;
}

/* keep download button label visible on larger screens but optionally hide on very small (kept accessible via icon) */
#downloadAllBtn .btn-text {
  display: inline-block;
}

/* Animated subtitle */
.animated-subtitle {
  font-weight: 500;
  color: rgba(230, 238, 248, 0.9);
  margin-top: 0.25rem;
  margin-bottom: 0.45rem;
  display: inline-block;
  min-height: 1.2em;
  font-size: 0.98rem;
  position: relative;
  transition: color 0.3s ease;
}

/* Static text on mobile - no cursor */
.animated-subtitle.static-text::after {
  display: none;
}

/* typing cursor as pseudo element */
.animated-subtitle:not(.static-text)::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: linear-gradient(
    180deg,
    rgba(99, 102, 241, 0.9),
    rgba(139, 92, 246, 0.9)
  );
  margin-left: 6px;
  vertical-align: middle;
  animation: blink 1s steps(1) infinite;
  opacity: 0.95;
  box-shadow: 0 0 4px rgba(99, 102, 241, 0.5);
}

@keyframes blink {
  0%,
  50% {
    opacity: 0.95;
  }
  51%,
  100% {
    opacity: 0.2;
  }
}

/* Hide typing animation on mobile */
@media (max-width: 768px) {
  .animated-subtitle::after {
    display: none !important;
  }

  .animated-subtitle {
    color: rgba(230, 238, 248, 0.85);
  }
}

/* Gallery tiles */
.tile {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.008)
  );
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  transition:
    transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 0.18s ease;
  min-height: 120px;
  z-index: 2;
}
.tile:hover {
  transform: translateY(-10px);
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.6);
}

/* 16:9 thumbnail wrapper to force aspect ratio */
.thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.06));
  display: block;
  position: relative;
}
.thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.35s ease;
}
.tile:hover .thumb {
  transform: scale(1.04);
}

/* footer inside tile */
.tile .tile-footer {
  padding: 0.6rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(
    180deg,
    rgba(2, 6, 23, 0.02),
    rgba(2, 6, 23, 0.03)
  );
}
.tile .meta {
  font-size: 0.88rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

/* small UI bits */
.btn-tiny {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

/* modal */
.modal-content {
  background: linear-gradient(
    180deg,
    rgba(14, 17, 22, 0.9),
    rgba(8, 10, 14, 0.95)
  );
  border-radius: 14px;
}

/* modal nav buttons - visible on all screen sizes, but smaller on narrow screens */
.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1055; /* higher than modal backdrop/content to ensure clickable */
  width: 44px;
  height: 64px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  backdrop-filter: blur(4px);
  transition:
    background 0.12s ease,
    transform 0.12s ease,
    opacity 0.12s ease;
  opacity: 0.95;
  pointer-events: auto;
}
.modal-nav-btn:hover {
  background: rgba(0, 0, 0, 0.45);
  transform: translateY(-50%) scale(1.02);
}
.modal-nav-btn.prev {
  left: 8px;
}
.modal-nav-btn.next {
  right: 8px;
}

/* responsive tweaks to avoid horizontal scroll and reduce navbar footprint */
@media (max-width: 992px) {
  .input-group {
    max-width: 320px;
  }
}

@media (max-width: 768px) {
  /* reduce the navbar padding on smaller screens to save space */
  .navbar {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .navbar .container-fluid > .d-flex {
    gap: 0.35rem;
    justify-content: flex-end;
  }

  .input-group {
    flex: 1 1 180px;
    max-width: 100%;
  }

  .logo-image {
    width: 48px;
    height: 48px;
    margin-right: 8px;
  }

  .btn-group .dropdown-menu {
    right: 0;
    left: auto;
  }
}

@media (max-width: 640px), (pointer: coarse) {
  /* removes sticky-top navbar */
  .navbar.sticky-top {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
  }
}

@media (max-width: 576px) {
  /* Very small screens - make things compact */
  .navbar {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .navbar-brand .h6 {
    font-size: 0.95rem;
    line-height: 1;
  }

  /* shrink logo */
  .logo-image {
    width: 40px;
    height: 40px;
    margin-right: 8px;
  }

  /* make the search input responsive on very small screens */
  .input-group {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .form-control-dark {
    min-height: 42px;
    font-size: 0.9rem;
  }

  /* optionally hide long label in download button, keep icon accessible */
  #downloadAllBtn .btn-text {
    display: none;
  }

  /* make icon-only navbar buttons smaller */
  .navbar .btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.95rem;
  }

  /* ensure tile footers don't overflow */
  .tile .meta {
    max-width: 55%;
  }

  /* modal nav buttons — smaller and closer to edges but still visible and touch-friendly */
  .modal-nav-btn {
    width: 36px;
    height: 56px;
    font-size: 1.05rem;
    opacity: 0.98;
    background: rgba(0, 0, 0, 0.32);
  }
  .modal-nav-btn.prev {
    left: 6px;
  }
  .modal-nav-btn.next {
    right: 6px;
  }
}

/* keep modal nav buttons available even on very narrow phones; reduce size slightly */
@media (max-width: 420px) {
  .modal-nav-btn {
    width: 32px;
    height: 52px;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.36);
  }
  .modal-nav-btn.prev {
    left: 4px;
  }
  .modal-nav-btn.next {
    right: 4px;
  }
}

/* logo image style */
.logo-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 25%;
  border: 2px solid #ffffff33;
  margin-right: 10px;
}

/* page fade in */
body {
  animation: fadeInAnimation ease 1s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}
@keyframes fadeInAnimation {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* -------------------------
   Category chips 
   -------------------------
*/

/* Chip color vars (override here if you want different tones) */
:root {
  --chip-bg: rgba(255, 255, 255, 0.02);
  --chip-border: rgba(255, 255, 255, 0.06);
  --chip-text: #e8f0ff;
  --chip-count-bg: rgba(0, 0, 0, 0.18);

  /* Active (selected) chip colors — improved contrast & pop */
  --chip-active-start: var(--accent-start, #6366f1);
  --chip-active-end: var(--accent-end, #8b5cf6);
  --chip-active-text: #ffffff;
  --chip-active-border: rgba(99, 102, 241, 0.3);
  --chip-active-shadow: 0 14px 40px rgba(99, 102, 241, 0.18);
  --chip-focus-ring: rgba(99, 102, 241, 0.2);
}

/* chips wrapper and nav buttons (single source of truth) */
.chips-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  position: relative;
  z-index: 10;
  margin-left: -6px;
  margin-right: -6px;
}

/* scrollable region (left <-> right) */
.chips-scroll {
  flex: 1 1 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 6px 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* webkit scrollbar styling (horizontal) */
.chips-scroll::-webkit-scrollbar {
  height: 10px;
}

.chips-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chips-scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* chip (pill) base - override Bootstrap button styles */
.chips-scroll .chip,
.chip,
.chips-scroll .chip.btn,
.chip.btn {
  -webkit-tap-highlight-color: transparent;
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.75rem !important;
  border-radius: 999px !important;
  white-space: nowrap; /* preserve full label (no truncation) */
  cursor: pointer;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
  color: var(--chip-text) !important;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.015),
    rgba(255, 255, 255, 0.01)
  ) !important;
  border: 1px solid var(--chip-border) !important;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
  min-height: 36px !important;
  height: auto !important;
  line-height: 1 !important;
  transform: translateY(0) !important; /* ensure stable base transform */
  box-sizing: border-box !important;
  flex-shrink: 0;
  width: auto !important;
  margin: 0 !important;
}

/* count badge inside chip */
.chips-scroll .chip .count,
.chip .count {
  display: inline-block;
  background: var(--chip-count-bg);
  padding: 0.08rem 0.35rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  opacity: 0.95;
  margin-left: 6px;
}

/* hover & active press feedback - only on devices with pointer */
@media (hover: hover) and (pointer: fine) {
  .chips-scroll .chip:hover,
  .chip:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.48);
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
  }

  .chips-scroll .chip:active,
  .chip:active {
    transform: translateY(0) !important;
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
  }
}

/* Ensure chips maintain size on touch devices (no pointer) */
@media (pointer: coarse), (hover: none) {
  .chips-scroll .chip,
  .chip {
    transform: translateY(0) !important;
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
    height: auto !important;
  }

  .chips-scroll .chip.active,
  .chip.active {
    transform: translateY(0) !important;
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
    height: auto !important;
  }

  .chips-scroll .chip:active,
  .chip:active {
    transform: translateY(0) !important;
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
  }
}

/* ACTIVE (selected) chip — stronger, accessible visual */
.chips-scroll .chip.active,
.chip.active {
  background: linear-gradient(
    110deg,
    var(--chip-active-start) 0%,
    var(--chip-active-end) 100%
  ) !important;
  color: var(--chip-active-text) !important;
  border: 1px solid var(--chip-active-border) !important;
  box-shadow: var(--chip-active-shadow);
  padding: 0.42rem 0.75rem !important;
  min-height: 36px !important;
  height: auto !important;
  transform: translateY(0) !important; /* base transform for touch devices */
}

/* Active chip transform only on pointer devices */
@media (hover: hover) and (pointer: fine) {
  .chips-scroll .chip.active,
  .chip.active {
    transform: translateY(-4px) !important;
  }
}

/* improve label contrast inside active chip (if you used custom spans) */
.chips-scroll .chip.active .count,
.chip.active .count {
  background: rgba(255, 255, 255, 0.12);
  color: var(--chip-active-text);
  font-weight: 800;
}

/* focus-visible (keyboard) */
.chips-scroll .chip:focus,
.chips-scroll .chip:focus-visible,
.chip:focus,
.chip:focus-visible {
  outline: 3px solid var(--chip-focus-ring);
  outline-offset: 3px;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(124, 92, 255, 0.12);
}

/* Chip nav (flanking buttons) */
.chip-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;

  /* Base highlight for nav buttons */
  background: linear-gradient(
    135deg,
    rgba(61, 87, 255, 0.15) 0%,
    rgba(61, 214, 199, 0.12) 100%
  );
  border: 1px solid rgba(124, 92, 255, 0.2);
  color: #fff;
  box-shadow: 0 8px 22px rgba(2, 6, 23, 0.48);
  backdrop-filter: blur(8px) saturate(120%);
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    opacity 0.12s ease;
}

/* hover feedback: slightly brighter gradient - only on pointer devices */
@media (hover: hover) and (pointer: fine) {
  .chip-nav:hover {
    transform: translateY(-2px);
    background: linear-gradient(
      135deg,
      rgba(61, 87, 255, 0.25) 0%,
      rgba(61, 214, 199, 0.18) 100%
    );
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.52);
  }
}

/* active press feedback */
.chip-nav:active {
  transform: translateY(0);
  background: linear-gradient(
    135deg,
    rgba(61, 87, 255, 0.18) 0%,
    rgba(61, 214, 199, 0.14) 100%
  );
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.42);
}

/* disabled state */
.chip-nav[disabled] {
  opacity: 0.45;
  pointer-events: none;
  transform: translateY(0);
  background: rgba(6, 8, 12, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* keyboard focus on the scroll container itself */
.chips-scroll:focus {
  outline: 2px solid rgba(99, 102, 241, 0.14);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Ensure inner spans don't wrap */
.chips-scroll .chip > * {
  white-space: nowrap;
}

/* Force consistent chip sizing on all devices - override any conflicting styles */
.chips-scroll .chip.btn,
.chip.btn {
  vertical-align: baseline !important;
  text-align: center !important;
  text-decoration: none !important;
}

/* Prevent any size changes on touch devices */
@media (pointer: coarse) {
  .chips-scroll .chip,
  .chip,
  .chips-scroll .chip.btn,
  .chip.btn,
  .chips-scroll .chip.active,
  .chip.active,
  .chips-scroll .chip:active,
  .chip:active,
  .chips-scroll .chip:hover,
  .chip:hover {
    padding: 0.42rem 0.75rem !important;
    min-height: 36px !important;
    max-height: none !important;
    height: auto !important;
    transform: translateY(0) !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
  }

  @media (max-width: 640px) {
    .chips-scroll .chip,
    .chip,
    .chips-scroll .chip.btn,
    .chip.btn,
    .chips-scroll .chip.active,
    .chip.active,
    .chips-scroll .chip:active,
    .chip:active,
    .chips-scroll .chip:hover,
    .chip:hover {
      padding: 0.36rem 0.62rem !important;
      font-size: 0.86rem !important;
    }
  }
}

/* Gallery column — skip rendering off-screen tiles entirely */
#gallery > .col-6,
#gallery > .col-sm-4,
#gallery > .col-md-3,
#gallery > .col-xl-3 {
    content-visibility: auto;
    contain-intrinsic-size: auto 200px;
}

/* responsive adjustments */
@media (max-width: 640px) {
  .chip-nav {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .chips-scroll {
    padding: 6px 6px;
    gap: 0.4rem;
  }

  .chips-scroll .chip,
  .chip,
  .chips-scroll .chip.btn,
  .chip.btn {
    padding: 0.36rem 0.62rem !important;
    font-size: 0.86rem !important;
    min-height: 36px !important;
    height: auto !important;
    transform: translateY(0) !important;
  }

  .chips-scroll .chip.active,
  .chip.active {
    padding: 0.36rem 0.62rem !important;
    font-size: 0.86rem !important;
    min-height: 36px !important;
    height: auto !important;
    transform: translateY(0) !important;
  }
}

/* Progressive modal preview styles */
.modal-preview-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
  text-align: center;
}

/* spinner overlay centered */
.modal-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  display: none;
  width: 48px;
  height: 48px;
  pointer-events: none;
}

/* simple spinner (using border) */
.modal-spinner::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-sizing: border-box;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: modal-spin 1s linear infinite;
}

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

/* blurred placeholder effect while loading full-res */
.modal-img-blur {
  filter: blur(8px) saturate(0.95);
  transform: scale(1.02);
  transition:
    filter 300ms ease,
    opacity 250ms ease,
    transform 300ms ease;
}

/* when fully loaded: remove blur */
.modal-img-loaded {
  filter: none;
  transform: none;
  opacity: 1;
  transition: opacity 220ms ease;
}

/* crossfade helper: image initially invisible then fade in */
.modal-img-fade {
  opacity: 0;
  transition: opacity 260ms ease;
}

/* visible */
.modal-img-visible {
  opacity: 1;
}

/* keep image responsive */
#modalImage {
  max-height: 80vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

#modalImage.loading {
  opacity: 0.5;
  filter: blur(4px);
}

/* overlay to ensure spinner is above blurred image */
.modal-img-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}

/* fallback message style if image fails */
.modal-image-error {
  width: 100%;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  background: #07111c;
  border-radius: 8px;
}

/* Loading skeleton for gallery tiles */
.skeleton-tile {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.008)
  );
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  min-height: 120px;
  aspect-ratio: 16 / 9;
}

.skeleton-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.08),
    transparent
  );
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Improved empty state */
#emptyState {
  padding: 4rem 2rem;
  animation: fadeInUp 0.5s ease;
}

#emptyState i {
  opacity: 0.5;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Improved search input focus state - handled in glass.css */

/* Clear search button styling - moved to glass.css */

/* Smooth gallery transitions */
#gallery {
  animation: fadeIn 0.4s ease;
}

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

/* Tile entrance animation */
.tile {
  animation: tileFadeIn 0.3s ease backwards;
}

.tile:nth-child(1) {
  animation-delay: 0.05s;
}
.tile:nth-child(2) {
  animation-delay: 0.1s;
}
.tile:nth-child(3) {
  animation-delay: 0.15s;
}
.tile:nth-child(4) {
  animation-delay: 0.2s;
}
.tile:nth-child(5) {
  animation-delay: 0.25s;
}
.tile:nth-child(6) {
  animation-delay: 0.3s;
}
.tile:nth-child(n + 7) {
  animation-delay: 0.35s;
}

@keyframes tileFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Improved button hover states */
.btn-outline-light:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.btn-outline-light:active {
  transform: translateY(0);
}

/* Better focus states for accessibility */
.btn:focus-visible,
.chip:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.6);
  outline-offset: 2px;
}

/* Improved download button states */
.btn-tiny {
  transition: all 0.2s ease;
}

.btn-tiny:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Better modal transitions */
.modal.fade .modal-dialog {
  transition:
    transform 0.3s ease-out,
    opacity 0.3s ease-out;
  transform: scale(0.9) translateY(-20px);
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
}

/* Improved chip hover states - only on pointer devices */
.chip {
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover:not(.active) {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.04)
    );
    border-color: rgba(255, 255, 255, 0.12);
  }
}

/* Better loading text */
#summary {
  transition: opacity 0.3s ease;
}

#summary:empty::before {
  content: "Loading…";
  opacity: 0.6;
}

/* Modal hints styling */
.modal-hints {
  padding: 0.5rem 0;
}

.modal-hints kbd {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-family:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
}

/* Hide keyboard hints on mobile */
@media (max-width: 768px) {
  .modal-hints {
    display: none !important;
  }
}

/* Toast styling */
.toast {
  background: linear-gradient(
    180deg,
    rgba(20, 24, 32, 0.95),
    rgba(12, 14, 20, 0.98)
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  min-width: 300px;
}

.toast-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-body {
  padding: 0.75rem 1rem;
}

/* Search input hint - removed, using placeholder instead */

/* Improved responsive spacing */
@media (max-width: 768px) {
  .tile {
    animation-delay: 0s !important;
  }

  #emptyState {
    padding: 3rem 1.5rem;
  }

  .input-group {
    max-width: 100%;
  }

  .glass-section .row > .col-auto {
    flex-direction: column;
    width: 100%;
  }

  .glass-section .row > .col-auto > * {
    width: 100%;
  }
}

/* Better touch targets on mobile */
@media (pointer: coarse) {
  .btn,
  .chip,
  .modal-nav-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-tiny {
    min-height: 36px;
    min-width: 36px;
  }
}

/* Improved modal on small screens */
@media (max-width: 576px) {
  .modal-body {
    padding: 0.75rem;
  }

  .modal-actions {
    flex-direction: column;
    width: 100%;
  }

  .modal-actions .btn {
    width: 100%;
    min-width: auto;
  }

  .modal-nav-btn {
    width: 40px;
    height: 60px;
  }

  .modal-hints {
    display: none !important;
  }
}

/* Better accessibility - skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Respect user motion preferences — disables ALL animations/transitions for perf + a11y */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .bg-blob {
        display: none;
    }
}
