/* 3DPE Project Gallery layout · ported from static gallery 2026-06-05.
 * Auto-enqueued for slug "gallery". The stale `.site-header{position:static}`
 * rule from the static file is intentionally dropped so the canonical sticky
 * nav works. Nav/footer come from brand.css; this is gallery-only styling. */
  /* Gallery-only styles. Brand palette comes from the real brand.css above. */
  :root {
    --gal-bg: #0F1219;
    --gal-bg-elev: #181a24;
    --gal-bg-chip: #232634;
    --gal-border: rgba(255,255,255,0.08);
    --gal-border-hover: rgba(255,255,255,0.18);
    --gal-text: #f5f5f7;
    --gal-text-dim: #a8a8b3;
    --gal-text-faint: #6b6b78;
    --gal-mint: #1EE6BE;
    --gal-purple-dark: #713794;
    --gal-purple-light: #A373BF;
    --gal-focus: #1EE6BE;
    --gal-radius: 14px;
    --gal-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --gal-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --gal-dur-fast: 140ms;
    --gal-dur-med: 240ms;
    --gal-dur-slow: 420ms;
  }
  /* Re-scoped 2026-06-05: the ported gallery body only gets `service-page` (light
     theme) from the service template, never `gallery-page`, so this dark theme was
     dead and the light theme showed through (James). gallery.css loads ONLY on the
     gallery slug, so matching `body.service-page` here is gallery-only and safe;
     `body.gallery-page` kept so it still works if that class is added server-side. */
  body.gallery-page,
  body.service-page {
    margin: 0;
    background:
      radial-gradient(1200px 700px at 50% -150px, rgba(113, 55, 148, 0.30), transparent 60%),
      radial-gradient(900px 500px at 80% 10%, rgba(30, 230, 190, 0.08), transparent 65%),
      var(--gal-bg) !important;
    color: var(--gal-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
  }
  ::selection { background: var(--gal-mint); color: var(--gal-bg); }

  /* Hero */
  .gal-hero {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(40px, 6vw, 72px) clamp(20px, 4vw, 48px) clamp(20px, 3vw, 32px);
    text-align: center;
  }
  .gal-eyebrow {
    color: var(--gal-mint);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 14px;
  }
  .gal-hero h1 {
    font-size: clamp(40px, 7vw, 76px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 18px;
    background: linear-gradient(180deg, #fff 0%, #c8c8d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .gal-lead {
    font-size: clamp(16px, 1.5vw, 19px);
    color: var(--gal-text-dim);
    max-width: 620px;
    margin: 0 auto 36px;
  }
  .gal-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    flex-wrap: wrap;
  }
  .gal-stat-num {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
  }
  .gal-stat-label {
    font-size: 12px;
    color: var(--gal-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
  }

  /* Filters */
  .gal-filters {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(15, 18, 25, 0.78);
    border-bottom: 1px solid var(--gal-border);
    padding: 12px clamp(20px, 4vw, 48px);
    margin: 24px 0 24px;
  }
  .gal-filters-inner {
    max-width: 1400px; margin: 0 auto;
    display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  }
  .gal-chip {
    appearance: none;
    border: 1px solid var(--gal-border);
    background: var(--gal-bg-chip);
    color: var(--gal-text);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 14px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    min-height: 36px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background var(--gal-dur-fast) var(--gal-ease-out),
                border-color var(--gal-dur-fast) var(--gal-ease-out),
                transform var(--gal-dur-fast) var(--gal-ease-out),
                color var(--gal-dur-fast) var(--gal-ease-out);
  }
  .gal-chip:hover { border-color: var(--gal-border-hover); background: #2a2d3a; }
  .gal-chip:active { transform: scale(0.96); }
  .gal-chip[aria-pressed="true"] {
    background: var(--gal-mint); color: var(--gal-bg); border-color: var(--gal-mint);
  }
  .gal-chip:focus-visible { outline: 2px solid var(--gal-focus); outline-offset: 2px; }
  .gal-chip .gal-count { font-variant-numeric: tabular-nums; color: var(--gal-text-faint); font-size: 12px; }
  .gal-chip[aria-pressed="true"] .gal-count { color: rgba(15,18,25,0.7); }

  /* Mosaic grid — CSS Grid with dense packing */
  .gallery {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(12px, 2vw, 24px) 64px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 1fr;
    grid-auto-flow: dense;
    gap: 10px;
  }
  /* (removed the .gallery::before spacer — it occupied the top-left cell but had
     height:0 so it sized nothing; tile aspect-ratios drive the square rows. 2026-06-05) */
  @media (max-width: 1280px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
  @media (max-width: 980px)  { .gallery { grid-template-columns: repeat(3, 1fr); } }
  @media (max-width: 680px)  { .gallery { grid-template-columns: repeat(2, 1fr); gap: 6px; } }

  .tile {
    aspect-ratio: 1 / 1;
    border-radius: var(--gal-radius);
    overflow: hidden;
    background: var(--gal-bg-elev);
    position: relative;
    cursor: zoom-in;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.2);
    transition: transform var(--gal-dur-med) var(--gal-ease-out),
                box-shadow var(--gal-dur-med) var(--gal-ease-out);
    display: block;
    border: 0; padding: 0; width: 100%;
    color: inherit; font: inherit; text-align: left;
  }
  .tile.size-hero      { grid-column: span 2; grid-row: span 2; aspect-ratio: 1 / 1; }
  .tile.size-feature-w { grid-column: span 2; grid-row: span 1; aspect-ratio: 2 / 1; }
  .tile.size-feature-t { grid-column: span 1; grid-row: span 2; aspect-ratio: 1 / 2; }
  /* On narrow screens, heroes drop to 2x2 still (full row when 2-col), features collapse */
  @media (max-width: 680px) {
    .tile.size-feature-w { grid-column: span 2; aspect-ratio: 2 / 1; }
    .tile.size-feature-t { grid-column: span 1; aspect-ratio: 1 / 2; }
  }
  .tile:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.4), 0 20px 48px rgba(0,0,0,0.35); }
  .tile:active { transform: translateY(0) scale(0.98); transition-duration: 80ms; }
  .tile:focus-visible { outline: 2px solid var(--gal-focus); outline-offset: 3px; }
  .tile img {
    display: block;
    width: 100%; height: 100%;
    object-fit: cover;          /* per-item rules below override fit + bg + position */
    transition: transform var(--gal-dur-slow) var(--gal-ease-out);
  }
  .tile[data-fit="contain"] img { object-fit: contain; }
  .tile:hover img { transform: scale(1.04); }
  .tile-meta {
    position: absolute;
    inset: auto 0 0 0;
    padding: 28px 14px 12px;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.78) 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--gal-dur-med) var(--gal-ease-out),
                transform var(--gal-dur-med) var(--gal-ease-out);
    pointer-events: none;
  }
  .tile:hover .tile-meta, .tile:focus-visible .tile-meta { opacity: 1; transform: translateY(0); }
  .tile.size-hero .tile-meta, .tile.size-feature-w .tile-meta, .tile.size-feature-t .tile-meta { font-size: 15px; padding-bottom: 16px; }
  .tile-cat {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gal-mint);
    margin-bottom: 4px;
    font-weight: 600;
  }

  /* Lightbox */
  .lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--gal-dur-med) var(--gal-ease-out);
  }
  .lightbox.open { display: flex; opacity: 1; }
  .lightbox-img {
    max-width: 92vw; max-height: 86vh;
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    transform: scale(0.96);
    transition: transform var(--gal-dur-med) var(--gal-ease-spring);
  }
  .lightbox.open .lightbox-img { transform: scale(1); }
  .lightbox-caption {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    color: var(--gal-text-dim);
    font-size: 14px;
    background: rgba(20,20,24,0.8);
    padding: 8px 16px; border-radius: 999px;
    border: 1px solid var(--gal-border);
  }
  .lb-btn {
    position: absolute;
    background: rgba(30,30,36,0.85);
    border: 1px solid var(--gal-border);
    color: var(--gal-text);
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
  }
  .lb-btn:hover { background: rgba(50,50,58,0.95); }
  .lb-btn:active { transform: scale(0.92); }
  .lb-btn:focus-visible { outline: 2px solid var(--gal-focus); outline-offset: 2px; }
  .lb-close { top: 20px; right: 20px; }
  .lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
  .lb-next { right: 20px; top: 50%; transform: translateY(-50%); }

  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
    .tile:hover { transform: none; }
    .tile:hover img { transform: none; }
  }
  .tile[data-hidden="true"] { display: none; }

  /* Let the staging header scroll away — only the filter bar should pin so the gallery
     gets full viewport once you're in it. */


/* ===== TEMP REVIEW NUMBERS (1-84) - remove after James decides T/B/M + sizing ===== */
.tile::after {
  content: attr(data-num);
  position: absolute; top: 8px; left: 8px; z-index: 6;
  background: var(--gal-mint, #1EE6BE); color: #0F1219;
  font-family: system-ui, -apple-system, sans-serif; font-weight: 800;
  font-size: 30px; line-height: 1; padding: 8px 14px; border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.6); pointer-events: none;
}


/* XL wide banner tile (e.g. the large-scale dinosaur) - bigger than feature-w, keeps ~2:1 so wide images fill. 2026-06-05 */
.tile.size-feature-xl { grid-column: span 3; grid-row: span 2; aspect-ratio: 3 / 2; }
@media (max-width: 980px) { .tile.size-feature-xl { grid-column: span 3; } }
@media (max-width: 680px) { .tile.size-feature-xl { grid-column: span 2; } }


/* tall banner (mirror of feature-xl wide banner) - for big PORTRAIT subjects so they fill. 2026-06-05 */
.tile.size-feature-yl { grid-column: span 2; grid-row: span 3; aspect-ratio: 2 / 3; }
@media (max-width: 680px) { .tile.size-feature-yl { grid-column: span 2; grid-row: span 3; } }
