/* Project gallery — matches main portfolio light theme (standalone page + index embed) */

:root {
  --gallery-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.section--gallery {
  position: relative;
  isolation: isolate;
}

.section--gallery::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -1px;
  transform: translateX(-50%);
  width: min(100%, 56rem);
  height: 220px;
  background: radial-gradient(
    ellipse 90% 80% at 50% 0%,
    rgba(234, 179, 120, 0.14),
    rgba(196, 132, 110, 0.06) 45%,
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
}

.gallery-page {
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
}

.section--gallery .gallery-filters {
  margin-bottom: 1.75rem;
}

.gallery-filters--panel {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 251, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 32px rgba(62, 44, 34, 0.05);
}

.gallery-grid--embed {
  max-width: none;
  margin: 0;
  padding: 0 0 clamp(1rem, 3vw, 2rem);
}

.gallery-page__top {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem);
}

.gallery-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1.25rem;
  transition: opacity 0.2s var(--ease-out);
}

.gallery-back:hover {
  opacity: 0.85;
}

.gallery-page__title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.gallery-page__tagline {
  margin: 0 0 1.75rem;
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 42rem;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  align-items: center;
  justify-content: center;
}

.gallery-filter-btn {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 253, 251, 0.55);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.25s var(--gallery-ease), box-shadow 0.25s, color 0.2s, border-color 0.2s,
    background 0.25s;
}

a.gallery-filter-btn {
  text-decoration: none;
  color: var(--text-muted);
}

.gallery-filter-btn:hover {
  color: var(--text);
  border-color: rgba(168, 74, 46, 0.22);
  background: rgba(255, 253, 251, 0.98);
  box-shadow: 0 4px 16px rgba(168, 74, 46, 0.08);
  transform: translateY(-1px);
}

.gallery-filter-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #9a3412 0%, #b45309 52%, #a16207 100%);
  box-shadow: 0 8px 28px rgba(154, 52, 18, 0.22);
  transform: translateY(-1px);
}

.gallery-filter-btn--more {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.gallery-filter-btn__icon {
  display: block;
  flex-shrink: 0;
}


.gallery-grid {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem) clamp(4rem, 10vw, 6rem);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.35rem;
}

@keyframes gallery-card-in {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gallery-card--enter {
  animation: gallery-card-in 0.72s var(--gallery-ease) backwards;
  animation-delay: calc(var(--stagger, 0) * 0.075s);
}

.gallery-card {
  position: relative;
  border-radius: calc(var(--radius-lg) + 2px);
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, #fffdfb 0%, var(--paper-2, #f9f5f1) 100%);
  box-shadow: var(--shadow-card), 0 0 0 0 rgba(168, 74, 46, 0);
  cursor: pointer;
  text-align: left;
  transition: transform 0.4s var(--gallery-ease), border-color 0.35s, box-shadow 0.4s var(--gallery-ease);
  padding: 0;
  font: inherit;
  color: inherit;
  display: block;
  width: 100%;
  outline: none;
}

.gallery-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  pointer-events: none;
}

.gallery-card:hover {
  transform: translateY(-8px);
  border-color: rgba(168, 74, 46, 0.28);
  box-shadow: 0 22px 56px rgba(62, 44, 34, 0.11), 0 0 0 1px rgba(180, 83, 9, 0.12),
    0 0 40px -12px rgba(180, 83, 9, 0.18);
}

.gallery-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-card__media {
  position: relative;
  aspect-ratio: 8 / 5;
  overflow: hidden;
  background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
}

.gallery-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.65s var(--gallery-ease);
}

.gallery-card:hover .gallery-card__media img {
  transform: scale(1.07);
}

.gallery-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(to top, rgba(42, 36, 32, 0.78) 0%, rgba(42, 36, 32, 0.2) 42%, transparent 68%);
  opacity: 0;
  transition: opacity 0.4s var(--gallery-ease);
}

.gallery-card:hover .gallery-card__overlay {
  opacity: 1;
}

.gallery-card__cta {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.gallery-card__cta-arrow {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f0c4a8;
  transform: translateX(0);
  transition: transform 0.35s var(--gallery-ease);
}

.gallery-card:hover .gallery-card__cta-arrow {
  transform: translateX(4px);
}

.gallery-card__body {
  padding: 1.2rem 1.3rem 1.45rem;
  position: relative;
}

.gallery-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.gallery-card__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.gallery-card__gh {
  flex-shrink: 0;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.gallery-card:hover .gallery-card__gh {
  opacity: 1;
}

.gallery-card__gh img {
  width: 22px;
  height: 22px;
  display: block;
}

.gallery-card__desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.gallery-card.is-hidden {
  display: none;
}

.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Modal */
@keyframes gallery-modal-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gallery-modal {
  width: min(92vw, 900px);
  max-height: 90vh;
  padding: 0;
  border: 1px solid rgba(120, 90, 72, 0.22);
  border-radius: calc(var(--radius-lg) + 4px);
  background: linear-gradient(180deg, #fffdfb 0%, var(--paper-2, #f9f5f1) 100%);
  box-shadow: 0 40px 100px rgba(62, 44, 34, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}

.gallery-modal[open] {
  animation: gallery-modal-in 0.42s var(--gallery-ease);
}

.gallery-modal::backdrop {
  background: rgba(42, 36, 32, 0.48);
  backdrop-filter: blur(10px);
}

.gallery-modal__inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.gallery-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid var(--border);
}

.gallery-modal__intro {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.gallery-modal__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 0.5rem;
}

.gallery-modal__github {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  width: fit-content;
  padding: 0.4rem 0.65rem;
  margin: -0.4rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-modal__github:hover {
  color: #7c341f;
  background: rgba(168, 74, 46, 0.14);
  border-color: rgba(168, 74, 46, 0.22);
  box-shadow: 0 2px 14px rgba(168, 74, 46, 0.12);
}

.gallery-modal__github:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-modal__github img {
  display: block;
  flex-shrink: 0;
  opacity: 0.88;
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.gallery-modal__github:hover img {
  opacity: 1;
  transform: scale(1.08);
  filter: contrast(1.05);
}

.gallery-modal__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, border-color 0.25s, transform 0.35s var(--gallery-ease);
}

.gallery-modal__close:hover {
  background: rgba(168, 74, 46, 0.1);
  border-color: rgba(168, 74, 46, 0.32);
  transform: rotate(90deg);
}

.gallery-modal__scroll {
  overflow-y: auto;
  padding: 0 1.35rem 1.5rem;
}

.gallery-carousel {
  position: relative;
  margin: 1rem 0 1.25rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(145deg, #ebe4dc, #ddd2c8);
  aspect-ratio: 16 / 9;
  box-shadow: 0 16px 48px rgba(62, 44, 34, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.gallery-carousel__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--paper-2, #f9f5f1);
}

.gallery-carousel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transition: background 0.2s;
}

.gallery-carousel__nav:hover {
  background: #fff;
}

.gallery-carousel__prev {
  left: 0.65rem;
}

.gallery-carousel__next {
  right: 0.65rem;
}

.gallery-carousel__dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0 0;
}

.gallery-carousel__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.gallery-carousel__dot.is-active {
  background: var(--accent);
  transform: scale(1.15);
}

.gallery-modal__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.gallery-modal__tag {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(62, 44, 34, 0.06);
}

.gallery-modal__tag--section {
  background: linear-gradient(135deg, rgba(168, 74, 46, 0.14), rgba(180, 83, 9, 0.1));
  color: #92400e;
  border-color: rgba(168, 74, 46, 0.22);
}

.gallery-modal__tag--extra {
  background: rgba(62, 44, 34, 0.06);
  color: var(--text-muted);
  border-color: rgba(62, 44, 34, 0.12);
  font-weight: 500;
}

.gallery-modal__body {
  margin-top: 0.5rem;
}

.gallery-modal__details {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
  color: var(--text-muted);
  text-align: left;
  white-space: pre-line;
}

@media (max-width: 540px) {
  .gallery-carousel__nav {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card--enter {
    animation: none;
    opacity: 1;
  }

  .gallery-card:hover {
    transform: translateY(-4px);
  }

  .gallery-card:hover .gallery-card__media img {
    transform: none;
  }

  .gallery-card:hover .gallery-card__cta-arrow {
    transform: none;
  }

  .gallery-modal[open] {
    animation: none;
  }

  .gallery-filter-btn:hover,
  .gallery-filter-btn.is-active {
    transform: none;
  }

  .gallery-modal__close:hover {
    transform: none;
  }
}
