/* =========================================================
   AR.dev - Gallery page
   Page-specific layout only. Cards, chips, links, buttons and
   the closing panel are styled in styles.css.
   Sections: hero · filters · grid · closing panel · lightbox
========================================================= */

.gallery-page {
  overflow-x: clip;
}

/* Hero card */

.gallery-hero-copy {
  max-width: 850px;
}

.gallery-summary-number {
  margin-top: 22px;
  font-family: var(--font-heading);
  font-size: clamp(4.5rem, 7vw, 6.5rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.1em;
}

.gallery-summary > p {
  margin-top: 10px;
  font-size: 0.92rem;
}

.gallery-summary-list {
  margin: auto 0 0;
  padding-top: 26px;
}

.gallery-summary-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-block: 9px;
  border-top: 1px solid var(--color-border);
}

.gallery-summary-list dt {
  color: var(--color-muted);
  font-size: 0.82rem;
}

.gallery-summary-list dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
}

/* Toolbar and filters */

.gallery-section {
  padding-block: var(--section-space);
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.gallery-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 26px 40px;
}

.gallery-toolbar h2 {
  max-width: 14ch;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.gallery-status {
  margin-top: 26px;
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

/* Grid and cards */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 22px;
}

.gallery-item {
  min-width: 0;
}

.gallery-card {
  display: flex;
  height: 100%;
  flex-direction: column;
  padding: 12px;
}

.gallery-media {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
}

.gallery-media img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: top center;
  transition: transform var(--transition-slow);
}

.gallery-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.gallery-play {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.35),
    0 10px 24px rgba(32, 34, 31, 0.18);
  transition: transform var(--transition-base);
}

.gallery-play svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
  fill: var(--color-ink);
  stroke: var(--color-ink);
}

.gallery-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  padding: 18px 8px 8px;
}

.gallery-meta {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-body h3 {
  margin-top: 12px;
  font-size: 1.28rem;
  font-weight: 750;
  letter-spacing: -0.05em;
}

.gallery-caption {
  margin-top: 9px;
  margin-bottom: 22px;
  font-size: 0.86rem;
  line-height: 1.7;
}

@media (hover: hover) {
  .gallery-card:hover .gallery-media img {
    transform: scale(1.035);
  }

  .gallery-card:hover .gallery-play {
    transform: scale(1.08);
  }
}

/* Closing panel */

.gallery-cta {
  padding-top: clamp(24px, 4vw, 48px);
  padding-bottom: clamp(84px, 11vw, 140px);
}

.gallery-cta h2 {
  max-width: 17ch;
  margin-top: 20px;
}

/* Lightbox
   Native <dialog>: focus trap, Esc to close and top-layer stacking
   come from the browser. Built to match the case study window on the
   Projects page: same shell, top bar, hero, meta grid and footer. */

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  width: min(1060px, 94vw);
  max-width: none;
  height: min(94dvh, 1000px);
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--color-ink);
}

.lightbox::backdrop {
  background: rgba(32, 34, 31, 0.58);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.lightbox-shell {
  position: relative;
  display: flex;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  background: var(--wash), var(--color-bg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.lightbox-bar {
  position: relative;
  z-index: 4;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px 12px 26px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(244, 242, 237, 0.92);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.lightbox-count {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.lightbox-bar-actions {
  display: flex;
  gap: 8px;
}

.lightbox-btn {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-ink);
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast);
}

.lightbox-btn svg {
  width: 19px;
  height: 19px;
}

.lightbox-btn:hover {
  border-color: var(--color-ink);
  background: var(--color-accent);
}

.lightbox-btn:active {
  transform: scale(0.94);
}

.lightbox-btn:disabled:hover {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.lightbox-progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  pointer-events: none;
}

.lightbox-progress span {
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--color-accent-dark);
  transition: transform var(--transition-base);
}

.lightbox-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

.lightbox-article {
  padding: clamp(28px, 5vw, 60px) clamp(20px, 5vw, 64px) clamp(32px, 5vw, 60px);
}

/* Hero */

.lightbox-hero h2 {
  max-width: 18ch;
  margin-top: 18px;
  font-size: clamp(2.2rem, 5.2vw, 4.2rem);
  line-height: 1;
  letter-spacing: -0.075em;
}

.lightbox-lead {
  max-width: 60ch;
  margin-top: 24px;
  color: var(--color-ink);
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.8;
}

.lightbox-status {
  margin-top: 22px;
  color: var(--color-muted);
}

.lightbox-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  margin: 34px 0 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-border);
}

.lightbox-meta > div {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.72);
}

.lightbox-meta dt {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lightbox-meta dd {
  margin: 6px 0 0;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.4;
}

.lightbox-cover {
  margin: 26px 0 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-soft);
  box-shadow: var(--shadow-soft);
}

.lightbox-cover img {
  width: 100%;
  height: auto;
}

.lightbox-cover video {
  width: 100%;
  max-height: 72dvh;
  aspect-ratio: 16 / 9;
  background: #000000;
  object-fit: contain;
}

/* Footer */

.lightbox-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 24px;
  margin-top: clamp(36px, 5vw, 56px);
  padding-top: 26px;
  border-top: 1px solid var(--color-border);
}

.lightbox-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.lightbox :focus-visible {
  outline-color: var(--color-focus);
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] .lightbox-shell {
    animation: lightbox-in 300ms var(--ease-out);
  }

  .lightbox[open]::backdrop {
    animation: lightbox-fade 300ms ease;
  }

  @keyframes lightbox-in {
    from {
      opacity: 0;
      transform: translateY(18px) scale(0.985);
    }
  }

  @keyframes lightbox-fade {
    from {
      opacity: 0;
    }
  }
}

/* Responsive */

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* A lone last visible card spans the row (class set in main.js) */
  .gallery-item.is-last-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .gallery-filters {
    flex-wrap: nowrap;
    margin-inline: calc(var(--page-gutter) * -1);
    padding-inline: var(--page-gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .gallery-filters::-webkit-scrollbar {
    display: none;
  }

  .gallery-chip {
    flex: 0 0 auto;
  }

  .gallery-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery-cta-inner {
    padding: 26px 22px;
    border-radius: var(--radius-lg);
  }

  .lightbox {
    width: 100vw;
    height: 100dvh;
  }

  .lightbox-shell {
    border: 0;
    border-radius: 0;
  }

  .lightbox-bar {
    padding-left: 18px;
  }

  .lightbox-hero h2 {
    font-size: clamp(2.1rem, 11vw, 3.2rem);
  }

  .lightbox-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .lightbox-next {
    justify-content: space-between;
  }
}
