/* ==========================================================================
   Trevor Earley Photography — Gallery System
   Homepage preview grid, portfolio section grids, filter tabs, lightbox
   ========================================================================== */

/* ---- Preview grid (homepage bento — one photo per portfolio section) ---- */
.preview-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: repeat(2, minmax(320px, 45vh));
  gap: 2px;
  background: var(--color-border);
  grid-template-areas:
    "sports brand"
    "sports video";
}

.tile-sports      { grid-area: sports; }
.tile-brand       { grid-area: brand; }
.tile-video       { grid-area: video; }

.preview-tile {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.preview-tile img,
.preview-tile .img-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  transition: transform 0.7s var(--ease), filter 0.7s var(--ease);
}

.preview-tile:hover img,
.preview-tile:focus-visible img,
.preview-tile:hover .img-placeholder,
.preview-tile:focus-visible .img-placeholder {
  transform: scale(1.06);
}

.tile-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 7, 8, 0.88) 0%, rgba(6, 7, 8, 0.15) 55%, rgba(6, 7, 8, 0.05) 100%);
  transition: background 0.4s var(--ease);
}

.preview-tile:hover .tile-scrim,
.preview-tile:focus-visible .tile-scrim {
  background: linear-gradient(to top, rgba(6, 7, 8, 0.94) 0%, rgba(6, 7, 8, 0.3) 60%, rgba(6, 7, 8, 0.1) 100%);
}

.tile-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-3);
}

.tile-index {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--color-text-mute);
}

.tile-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2);
}

.tile-title {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  color: var(--color-text);
}

.tile-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  white-space: nowrap;
  transform: translateX(-6px);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}

.preview-tile:hover .tile-link,
.preview-tile:focus-visible .tile-link {
  transform: translateX(0);
  opacity: 1;
}

.tile-link svg {
  width: 14px;
  height: 14px;
}

.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(244, 244, 242, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 12, 13, 0.35);
  transition: transform 0.4s var(--ease), background 0.4s var(--ease);
}

.preview-tile:hover .play-badge,
.preview-tile:focus-visible .play-badge {
  transform: translate(-50%, -50%) scale(1.1);
  background: rgba(11, 12, 13, 0.55);
}

.play-badge svg {
  width: 18px;
  height: 18px;
  margin-left: 3px;
}

@media (max-width: 900px) {
  .preview-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "sports"
      "brand"
      "video";
  }

  .tile-sports { min-height: 60vh; }
  .preview-tile:not(.tile-sports) { min-height: 320px; }
}

/* ---- Portfolio page layout ---- */
.portfolio-hero {
  padding-block: calc(var(--header-h) + var(--space-5)) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}

.portfolio-hero .section-title {
  max-width: 20ch;
  margin-inline: auto;
}

.portfolio-hero .body-lg {
  max-width: 60ch;
  margin-inline: auto;
  margin-top: var(--space-2);
}

.jump-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  margin-top: var(--space-4);
}

.jump-links a {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  padding: 0.55rem 1.1rem;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}

.jump-links a:hover,
.jump-links a:focus-visible {
  border-color: var(--color-text);
  color: var(--color-text);
}

.portfolio-section {
  padding-block: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: var(--header-h);
}

.portfolio-section:last-of-type {
  border-bottom: none;
}

.section-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.section-num {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--color-text-mute);
  letter-spacing: 0.05em;
}

/* ---- Filter tabs (Action & Sports) ---- */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.filter-tab {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-mute);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  padding: 0.5rem 1rem;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.filter-tab:hover,
.filter-tab:focus-visible {
  color: var(--color-text);
  border-color: var(--color-text-dim);
}

.filter-tab.is-active {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

/* ---- Gallery grid ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--color-bg-alt);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

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

.gallery-item img,
.gallery-item .img-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  transition: transform 0.6s var(--ease);
}

.gallery-item:hover img,
.gallery-item:focus-visible img,
.gallery-item:hover .img-placeholder,
.gallery-item:focus-visible .img-placeholder {
  transform: scale(1.05);
}

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-2);
  background: linear-gradient(to top, rgba(6, 7, 8, 0.9), rgba(6, 7, 8, 0));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.gallery-item:hover .gallery-caption,
.gallery-item:focus-visible .gallery-caption {
  opacity: 1;
  transform: translateY(0);
}

.gallery-caption .sport {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text);
}

.gallery-caption .meta {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-mute);
  margin-top: 2px;
}

.expand-icon {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(244, 244, 242, 0.35);
  border-radius: 50%;
  background: rgba(11, 12, 13, 0.4);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.gallery-item:hover .expand-icon,
.gallery-item:focus-visible .expand-icon {
  opacity: 1;
  transform: scale(1);
}

.expand-icon svg {
  width: 13px;
  height: 13px;
}

@media (max-width: 1100px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-caption { opacity: 1; transform: none; }
  .expand-icon { display: none; }
}

/* ---- Video section: CTA linking out to external portfolio ---- */
.video-cta {
  position: relative;
  isolation: isolate;
  text-align: center;
  padding-block: var(--space-7);
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt) url("../assets/images/video-tile-cover.jpg") center / cover no-repeat;
  overflow: hidden;
}

.video-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, rgba(6, 7, 8, 0.92) 0%, rgba(6, 7, 8, 0.72) 60%, rgba(6, 7, 8, 0.5) 100%);
}

.video-cta-copy {
  max-width: 60ch;
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

.video-cta .btn svg {
  width: 14px;
  height: 14px;
}

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 7, 8, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-inner {
  position: relative;
  width: min(92vw, 1200px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-figure {
  position: relative;
  width: 100%;
  max-height: 74vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
}

.lightbox-figure img {
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  object-fit: contain;
}

.lightbox-figure .img-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 74vh;
  border: none;
}

.lightbox-caption {
  width: 100%;
  padding-top: var(--space-2);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.lightbox-caption-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lightbox-caption .sport {
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-transform: uppercase;
  color: var(--color-text);
}

.lightbox-caption .meta {
  font-size: 0.85rem;
  color: var(--color-text-mute);
}

.lightbox-caption .counter {
  font-size: 0.8rem;
  color: var(--color-text-mute);
  font-variant-numeric: tabular-nums;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: rgba(11, 12, 13, 0.6);
  color: var(--color-text);
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  border-color: var(--color-text);
  background: rgba(11, 12, 13, 0.85);
}

.lightbox-close {
  top: -6px;
  right: -6px;
  transform: translate(50%, -50%);
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev { left: -24px; }
.lightbox-next { right: -24px; }

.lightbox-close svg,
.lightbox-prev svg,
.lightbox-next svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 700px) {
  .lightbox-inner { width: 100vw; padding-inline: var(--space-2); }
  .lightbox-prev { left: 4px; }
  .lightbox-next { right: 4px; }
  .lightbox-close { top: 8px; right: 8px; transform: none; }
}

/* ---- Grid modal (scrollable sub-gallery overview) ---- */
.grid-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 7, 8, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
  padding: var(--space-3);
}

.grid-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.grid-modal-inner {
  width: min(94vw, 1400px);
  height: min(90vh, 1100px);
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.grid-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.grid-modal-title {
  font-size: 1.25rem;
}

.grid-modal-count {
  font-size: 0.8rem;
  color: var(--color-text-mute);
}

.grid-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  flex-shrink: 0;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.grid-modal-close:hover,
.grid-modal-close:focus-visible {
  border-color: var(--color-text);
  background: var(--color-bg-alt);
}

.grid-modal-close svg {
  width: 16px;
  height: 16px;
}

.grid-modal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.grid-modal-columns {
  column-count: 3;
  column-gap: var(--space-2);
}

.grid-modal-columns button {
  display: block;
  width: 100%;
  margin-bottom: var(--space-2);
  break-inside: avoid;
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: opacity 0.3s var(--ease);
}

.grid-modal-columns button:hover,
.grid-modal-columns button:focus-visible {
  opacity: 0.85;
}

.grid-modal-columns img {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 900px) {
  .grid-modal-columns { column-count: 2; }
}

@media (max-width: 560px) {
  .grid-modal-columns { column-count: 1; }
  .grid-modal-inner { height: min(94vh, 1100px); }
}
