/* ===== Gallery Page Styles ===== */

.gallery-main {
  padding-bottom: 4rem;
}

/* ===== Page Header ===== */
.gallery-page-head {
  text-align: center;
  padding: 3.5rem 1.5rem 2.5rem;
}

.gallery-page-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--purple-900);
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}

.gallery-page-lead {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--purple-700);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ===== Controls Bar (Tabs + Search) ===== */
.gallery-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  top: 0;
  z-index: 100;
}

/* ===== Tabs ===== */
.gallery-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gallery-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--lavender-200);
  background: transparent;
  color: var(--purple-700);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.gallery-tab:hover {
  border-color: var(--purple-400);
  background: var(--lavender-50);
  color: var(--purple-900);
}

.gallery-tab.active {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-600));
  border-color: var(--purple-600);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(91, 33, 182, 0.3);
}

.gallery-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(91, 33, 182, 0.12);
  color: var(--purple-700);
  transition: all 0.2s ease;
}

.gallery-tab.active .gallery-tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: var(--white);
}

/* ===== Results Info ===== */
.gallery-results-info {
  text-align: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  color: var(--purple-600);
  background: linear-gradient(135deg, #f8f5ff, #faf8ff);
  border-bottom: 1px solid var(--lavender-100);
}

/* ===== Grid ===== */
.gallery-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: max-content;
  align-items: start;
  gap: 1.25rem;
  padding: 2rem;
  max-width: 1500px;
  margin: 0 auto;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  background: var(--white);
  border: 2px solid var(--lavender-200);
  box-shadow: 0 4px 12px rgba(91, 33, 182, 0.07);
}

.gallery-item:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(91, 33, 182, 0.18);
  border-color: var(--purple-400);
}

.gallery-item.hidden {
  display: none;
}

.gallery-img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.35s ease;
}

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

/* ===== Hover Overlay with Name ===== */
.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(60, 7, 160, 0.92) 0%, rgba(91, 33, 182, 0.5) 60%, transparent 100%);
  color: var(--white);
  padding: 2rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.gallery-item-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.gallery-item-category {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
}

/* ===== Empty State ===== */
.gallery-empty {
  column-span: all;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--purple-400);
  width: 100%;
}

.gallery-empty svg {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.gallery-empty p {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--purple-700);
  margin: 0 0 0.35rem;
}

.gallery-empty span {
  font-size: 0.9rem;
  color: var(--purple-400);
}

/* ===== Lightbox Popup ===== */
.gallery-popup {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 3, 30, 0.92);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.gallery-popup.is-open {
  display: flex;
}

.gallery-popup-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 88vw;
  max-height: 92vh;
}

.gallery-popup-content {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  display: block;
  transition: opacity 0.2s ease;
}

.gallery-popup-counter {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-popup-close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.gallery-popup-close:hover {
  background: var(--purple-600);
  border-color: var(--purple-500);
  transform: scale(1.1);
}

.gallery-popup-nav {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
  backdrop-filter: blur(4px);
}

.gallery-popup-nav:hover {
  background: var(--purple-600);
  border-color: var(--purple-500);
  transform: scale(1.1);
}

.gallery-popup-nav:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .gallery-controls {
    padding: 1rem 1.25rem;
    flex-direction: column;
    align-items: stretch;
    top: 0;
  }

  .gallery-tabs {
    justify-content: center;
  }

  .gallery-masonry {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.85rem;
    padding: 1.25rem 1rem;
  }
}

@media (max-width: 480px) {
  .gallery-masonry {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    padding: 1rem 0.75rem;
  }

  .gallery-popup-nav {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.5rem;
  }

  .gallery-popup-content {
    max-height: 72vh;
  }
}

/* ===== Tutorials ===== */
.tutorial-section { max-width: 1500px; margin: 0 auto; padding: 2rem; }
.tutorial-section[hidden], .tutorial-empty[hidden] { display: none; }
.tutorial-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.tutorial-card { overflow: hidden; border-radius: var(--radius-lg); cursor: pointer; background: var(--white); border: 2px solid var(--lavender-200); box-shadow: 0 4px 12px rgba(91, 33, 182, 0.07); transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease; }
.tutorial-card:hover, .tutorial-card:focus-visible { transform: translateY(-6px); box-shadow: 0 16px 32px rgba(91, 33, 182, 0.18); border-color: var(--purple-400); outline: none; }
.tutorial-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--lavender-50); overflow: hidden; }
.tutorial-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tutorial-play { position: absolute; inset: 0; margin: auto; width: 3.4rem; height: 3.4rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding-left: 0.2rem; background: rgba(91, 33, 182, 0.88); color: var(--white); font-size: 1.2rem; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); transition: transform 0.25s ease; }
.tutorial-card:hover .tutorial-play { transform: scale(1.12); }
.tutorial-info { padding: 0.9rem 1rem 1.1rem; }
.tutorial-info h3 { margin: 0 0 0.25rem; font-size: 1rem; font-weight: 700; color: var(--purple-900); }
.tutorial-info p { margin: 0; font-size: 0.85rem; color: var(--purple-600); line-height: 1.5; }
.tutorial-empty { text-align: center; padding: 3rem 1rem; font-size: 1.05rem; color: var(--purple-600); }
.tutorial-popup { display: none; position: fixed; inset: 0; background: rgba(10, 3, 30, 0.92); z-index: 1000; justify-content: center; align-items: center; padding: 1rem; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tutorial-popup.is-open { display: flex; }
.tutorial-popup-inner { width: min(960px, 94vw); }
.tutorial-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }
.tutorial-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tutorial-popup-title { margin: 0.75rem 0 0; text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 0.95rem; }
@media (max-width: 640px) { .tutorial-section { padding: 1rem; } .tutorial-grid { grid-template-columns: 1fr; } }
