/* Gallery: page-scoped styles (mockup image7, slide 17, 1672px comp) */

/* ---------- Hero ----------------------------------------------------------
   Comp photo band is y0-447 with the nav sitting on top of it; the shared nav
   is opaque here, so the section is the 359px remainder and the crop is pulled
   up behind the bar rather than rescaled. */
.gallery-hero {
  position: relative;
  height: 359px;
  /* visible, not hidden (2026-08, transparent-nav change): hidden clipped the
     pulled-up crop at the hero's edge, so the photo never actually showed
     through the now-transparent bar */
  overflow: visible;
}

.gallery-hero::before {
  content: "";
  position: absolute;
  inset: -88px 0 0;
  background: url("../../assets/img/hero-gallery-caves.jpg") top center / cover no-repeat;
}

/* pulled up with the photo so the wash also carries the nav links */
.gallery-hero::after {
  content: "";
  position: absolute;
  inset: -88px 0 0;
  /* warm grey, tracking the regraded --page, not the old sampled near-black */
  background: linear-gradient(90deg, rgba(25, 22, 19, .86) 0%, rgba(25, 22, 19, .66) 30%, rgba(25, 22, 19, 0) 64%);
}

.gallery-hero > * {
  position: relative;
  z-index: 1;
}

/* the one page title in the deck set in title case rather than small caps */
.gallery-hero h1 {
  position: absolute;
  left: 68px;
  top: 46px;
  font-family: var(--f-display);
  font-size: 70px;
  font-weight: 500;
  line-height: 1;
  color: var(--head);
}

/* pinned to the 201px "Gallery" title, aligned with its left edge */
.gallery-hero .ornament-center {
  position: absolute;
  left: 68px;
  top: 152px;
  width: 201px;
  margin: 0;
}

.gallery-hero .hero-intro {
  position: absolute;
  left: 68px;
  top: 186px;
  width: 392px;
  /* raised from 16.5px (owner request, 2026-08: readability pass, matching
     the Projects page) */
  font-size: 18px;
  line-height: 1.34;
  color: var(--text);
}

/* the photo rights notice (owner text, 2026-10): deliberately the smallest,
   quietest voice in the hero, set under the intro on the same left edge and
   inside the left wash; the halo keeps it legible where the wash thins */
.gallery-hero .g-rights {
  position: absolute;
  left: 68px;
  top: 280px;   /* 22px air above (intro) and below (filter bar) */
  width: 470px;
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.42;
  color: rgba(222, 220, 214, .82);
  text-shadow:
    0 0 3px rgba(25, 22, 19, .9),
    0 1px 3px rgba(25, 22, 19, .85),
    0 2px 10px rgba(25, 22, 19, .6);
}

/* ---------- Filter bar ----------------------------------------------------
   Slide 17 runs the filters flush left on their own near-black strip, with the
   layout toggle pinned to the right edge. No dividers between labels here -
   that is the Projects strip. */
.gallery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 45px;
  padding: 0 62px 0 68px;
  background: var(--strip);
  border-bottom: 1px solid var(--hairline);
}

.gallery-bar .filter-strip {
  display: flex;
  align-items: center;
  gap: 42px;
}

.gallery-bar .filter-strip a {
  position: relative;
  font-family: var(--f-smallcaps);
  /* raised from 15px (owner request, 2026-08: readability pass) */
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .17em;
  color: #C5C5C2;
  text-decoration: none;
  transition: color .2s ease;
  padding: 15px 6px;
  margin: -15px -6px;
}

.gallery-bar .filter-strip a:hover { color: var(--gold-bright); }
.gallery-bar .filter-strip a.active { color: var(--gold); }

/* (the gold diamond under the active tab came off - owner request,
   2026-10; the active tab reads by its gold colour alone) */

.view-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
}

.view-toggle button {
  display: block;
  padding: 12px;
  margin: -9px;
  /* 3.25:1 on the regraded --strip - the old #6E6A62 slipped under the 3:1
     non-text minimum when the strip was lightened */
  color: #7A756B;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color .2s ease;
}

.view-toggle button:hover { color: var(--gold-bright); }
.view-toggle button.active { color: var(--gold); }

/* ---------- Grid ----------------------------------------------------------
   The comp's four columns are deliberately unequal (407/375/389/399), which is
   what keeps the two rows from reading as a spreadsheet. Those widths are kept
   as fr ratios so they hold at any wrap width. */
.gallery-grid {
  display: grid;
  /* four EQUAL columns of square cells (2026-10, Cave 61 set): the owner's
     field photos are mostly portrait phone shots and hand-held artifacts,
     which the old 2.5:1 strips sliced to a sliver - squares keep the subject
     in frame, and the viewer still opens the full photograph on click */
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 2px 42px 4px;
  background: var(--page);
}

.gallery-grid figure {
  position: relative;   /* anchors the caption overlay */
  margin: 0;
  overflow: hidden;
  background: var(--panel);
}

/* ---------- Caption overlay -----------------------------------------------
   Fades in over the image on hover (or keyboard focus within); on touch
   devices js/main.js toggles .show-cap on tap instead, since there is no
   hover. The image stays visible under the wash, and the overlay tracks the
   figure's own square shape exactly. Text is placeholder copy for now. */
.g-cap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 18px 24px;
  background: rgba(0, 0, 0, .65);
  opacity: 0;
  transition: opacity .3s ease;
}

.gallery-grid figure:hover .g-cap,
.gallery-grid figure:focus-within .g-cap,
.gallery-grid figure.show-cap .g-cap { opacity: 1; }

.g-cap h3 {
  font-family: var(--f-smallcaps);
  font-weight: 600;
  /* raised from 17px (owner request, 2026-08: readability pass) */
  font-size: 18px;
  letter-spacing: .09em;
  color: #FFFFFF;
}

.g-cap p {
  margin-top: 7px;
  max-width: 340px;
  /* raised from 14px (owner request, 2026-08: readability pass) */
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, .92);
}

.gallery-grid img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transition: transform .4s cubic-bezier(.2, .7, .3, 1);
}

.gallery-grid figure:hover img { transform: scale(1.04); }

.gallery-grid figure[hidden] { display: none; }

/* list layout: one image per row, wider and shallower, for scanning the
   archive rather than browsing it */
.gallery-grid.list {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px 42px 14px;
}

/* one selector on purpose: an nth-child variant here would out-specify the
   760px override below and leave the later rows taller than the first ones */
.gallery-grid.list img { height: 240px; }

/* ---------- Responsive fallback ---------- */
@media (max-width: 1200px) {
  .gallery-hero { height: auto; min-height: 260px; padding: 34px 24px 32px; }
  /* nothing is registered on the comp coordinates any more, so the crop sits
     square in the band rather than pulled up behind the bar */
  .gallery-hero::before { inset: 0; }
  .gallery-hero::after { inset: 0; background: linear-gradient(90deg, rgba(25, 22, 19, .9), rgba(25, 22, 19, .58)); }
  /* relative rather than static: the z-index that lifts these above the wash
     comes from `.gallery-hero > *`, and z-index does nothing on an
     unpositioned box */
  .gallery-hero h1,
  .gallery-hero .ornament-center,
  .gallery-hero .hero-intro,
  .gallery-hero .g-rights { position: relative; left: auto; top: auto; }
  .gallery-hero h1 { font-size: 48px; }
  .gallery-hero .ornament-center { margin: 16px 0 14px; }
  .gallery-hero .hero-intro { width: auto; max-width: 520px; }
  .gallery-hero .g-rights { width: auto; max-width: 520px; margin-top: 16px; }

  .gallery-bar {
    height: auto;
    flex-wrap: wrap;
    padding: 12px 24px;
  }
  .gallery-bar .filter-strip { flex-wrap: wrap; gap: 14px 28px; }

  .gallery-grid { grid-template-columns: 1fr 1fr; padding: 10px 24px 14px; }
  .gallery-grid.list { padding: 10px 24px 14px; }
}

@media (max-width: 760px) {
  .gallery-hero h1 { font-size: 38px; }
  /* phones keep two square columns: one column of 16 squares would run
     sixteen screens long */
  .gallery-grid { grid-template-columns: 1fr 1fr; }
  /* ~160px tiles: tighter padding, and the longest owner titles clamp at
     five lines in the tile (the 18px floor holds; the full title shows in
     the viewer one tap later) */
  .g-cap { padding: 10px; }
  .g-cap h3 {
    letter-spacing: .04em;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    overflow: hidden;
  }
  .gallery-grid.list img { height: 200px; }

  .gallery-bar .filter-strip a { padding: 13px 0; margin: -5px 0; }
  .view-toggle button { padding: 12px; margin: -1px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-grid img { transition: none; }
  .gallery-grid figure:hover img { transform: none; }
}

/* ---------- Motion (site-motion variant only) ---------- */

/* hero photo settle — desktop comp only; below 1201px the responsive layout
   re-anchors the crop (inset: 0) and the settle would misregister */
@media (min-width: 1201px) {
  .motion .gallery-hero::before {
    animation: mSettle var(--m-dur-settle) var(--m-ease-out) both;
    transform-origin: bottom center;
  }
}

/* hero entrance: title rises, ornament draws from centre, intro follows —
   all three are positioned boxes, so this is transform/opacity only */
.motion .gallery-hero h1 { animation: mRise var(--m-dur-hero) var(--m-ease-out) .15s both; }
.motion .gallery-hero .ornament-center { --orn-delay: 550ms; }
.motion .gallery-hero .hero-intro { animation: mRise var(--m-dur-hero) var(--m-ease-out) .65s both; }
.motion .gallery-hero .g-rights { animation: mFade var(--m-dur-hero) var(--m-ease-out) .9s both; }

/* filter bar is a functional strip: a plain fade, no movement */
.motion .gallery-bar { animation: mFade var(--m-dur-hero) var(--m-ease-out) .45s both; }

/* caption overlay polish: the wash eases in on the shared curve, and the
   title/description resolve up 6px inside it, the line trailing the heading
   by 60ms. States mirror the overlay's own triggers exactly — hover,
   keyboard focus, and the tap-toggled .show-cap (touch parity). */
.motion .g-cap { transition: opacity .45s var(--m-ease-out); }

.motion .g-cap h3,
.motion .g-cap p {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity .45s var(--m-ease-out),
    transform .45s var(--m-ease-out);
}

.motion .g-cap p { transition-delay: 60ms; }

.motion .gallery-grid figure:hover .g-cap h3,
.motion .gallery-grid figure:hover .g-cap p,
.motion .gallery-grid figure:focus-within .g-cap h3,
.motion .gallery-grid figure:focus-within .g-cap p,
.motion .gallery-grid figure.show-cap .g-cap h3,
.motion .gallery-grid figure.show-cap .g-cap p {
  opacity: 1;
  transform: none;
}

/* the wipe-up entrance settles the photograph from a whisper of extra scale
   INSIDE its mask; after the entrance (.rv-done, or an instant reveal) the
   original hover-zoom transition takes back over */
.motion .gallery-grid figure[data-reveal="wipe-up"]:not(.rv-done):not(.m-instant) img {
  transition: transform var(--m-dur-wipe) var(--m-ease-inout) var(--rv-delay, 0ms);
}
.motion .gallery-grid figure[data-reveal="wipe-up"]:not(.is-in) img {
  transform: scale(1.06);
}

/* ---------- The viewer (Held Frame prototype, 2026-09) ---------------------
   js/gallery-viewer.js: the clicked photograph leaves its cell and expands
   into the immersive state - the stage below IS the travelling photo. The
   overlay lives on <body>, outside .wrap, so the zoom fitter never touches
   it. Minimal chrome: the image, a caption lower-left, one close control. */
.gallery-grid figure { cursor: pointer; }
@media (hover: hover) {
  .gallery-grid figure { cursor: zoom-in; }
}

.gv {
  position: fixed;
  inset: 0;
  z-index: 300;
}
.gv[hidden] { display: none; }

/* the room: near-black warm, no texture - the photograph is the only light */
.gv-back {
  position: absolute;
  inset: 0;
  background: rgba(16, 14, 12, .95);
  opacity: 0;
  transition: opacity .5s var(--m-ease-out);
}
.gv.gv-open .gv-back { opacity: 1; }

/* the travelling photograph: starts at the cell's exact rectangle (inline,
   set by JS) and transitions to the centred full-composition rectangle.
   left/top/width/height on ONE fixed element for ~.55s - the deliberate
   exception to transform-only, because the crop and the full frame have
   different aspects and scaling would distort the image. */
.gv-stage {
  position: fixed;
  margin: 0;
  overflow: hidden;
  cursor: zoom-out;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65);
  transition:
    left .55s var(--m-ease-inout),
    top .55s var(--m-ease-inout),
    width .55s var(--m-ease-inout),
    height .55s var(--m-ease-inout);
}
.gv-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;   /* equals contain once the rect matches the aspect */
  display: block;
}

/* caption, lower-left, arrives only after the photograph has settled */
.gv-cap {
  position: fixed;
  left: 52px;
  bottom: 44px;
  max-width: 480px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .45s var(--m-ease-out) .08s, transform .45s var(--m-ease-out) .08s;
  pointer-events: none;
}
.gv.gv-settled .gv-cap { opacity: 1; transform: none; }

.gv-cap::before {
  content: "";
  display: block;
  width: 42px;
  height: 1px;
  margin-bottom: 12px;
  background: var(--gold);
}
.gv-cap h3 {
  font-family: var(--f-smallcaps);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .09em;
  color: var(--gold-bright);
}
.gv-cap p {
  margin-top: 7px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}

.gv-close {
  position: fixed;
  right: 22px;
  top: 16px;
  width: 44px;
  height: 44px;
  font: 400 34px/1 var(--f-display);
  color: #D8CBB2;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  padding: 0 0 8px;   /* recentres Cormorant's low-riding multiplication sign */
  opacity: 0;
  transition: opacity .4s var(--m-ease-out), color .2s ease, background .2s ease;
}
.gv.gv-open .gv-close { opacity: 1; }
.gv-close:hover { color: #fff; background: rgba(255, 255, 255, .1); }

@media (max-width: 760px) {
  .gv-cap { left: 20px; bottom: 22px; right: 20px; max-width: none; }
  .gv-cap h3 { font-size: 17px; }
  .gv-cap p { font-size: 14px; }
  .gv-close { right: 8px; top: 8px; }
}

/* ---------- Free Sourcebook tile (owner request, 2026-10) ------------------
   The first square of the Spice Cave set: a link to download.html carrying
   the Download page's own copy (hook + description). Same square cell as the
   photos; a dark panel with the GI cards' double gold hairline, the 3D book
   render left, the copy right. Hover lifts the book and nudges the chevron -
   the tile itself never moves (it carries the scroll reveal). */
.g-promo {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: 40% 1fr;
  align-items: center;
  column-gap: 18px;
  padding: 22px 22px 22px 18px;
  overflow: hidden;
  background: linear-gradient(160deg, #332C22 0%, #26221B 100%);
  border: 1px solid rgba(210, 162, 76, .34);
  color: var(--text);
  text-decoration: none;
}

.g-promo::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(210, 162, 76, .16);
  pointer-events: none;
}

.g-promo[hidden] { display: none; }

/* .gallery-grid prefix: the photo rule (.gallery-grid img) would otherwise
   force this render into a square cover crop */
.gallery-grid .g-promo-book {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)) drop-shadow(0 16px 26px rgba(0, 0, 0, .4));
  transition: transform .45s cubic-bezier(.22, .61, .21, 1);
}

.g-promo-text { display: flex; flex-direction: column; gap: 10px; }

.g-promo-kicker {
  font-family: var(--f-smallcaps);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2em;
  color: var(--gold);
}

.g-promo-hook {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 500;
  font-size: 19px;
  line-height: 1.25;
  color: var(--gold-bright);
}

.g-promo-desc {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
}

.g-promo-cta {
  display: block;
  margin-top: 4px;
  line-height: 1.3;
  font-family: var(--f-smallcaps);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--gold-bright);
}
.g-promo-cta .chev { display: inline-block; margin-left: 4px; font-size: 20px; line-height: 1; vertical-align: -1px; transition: transform .25s ease; }

.g-promo:hover .g-promo-book,
.g-promo:focus-visible .g-promo-book { transform: translateY(-5px); }
.g-promo:hover .g-promo-cta .chev,
.g-promo:focus-visible .g-promo-cta .chev { transform: translateX(3px); }
.g-promo:hover { border-color: rgba(210, 162, 76, .6); }

/* tablets: the cells are still roomy, but the long description goes */
@media (max-width: 1200px) {
  .g-promo-desc { display: none; }
}

/* phones: ~160px squares - the book and the call to action only */
@media (max-width: 760px) {
  .g-promo { grid-template-columns: 1fr; justify-items: center; align-content: center; row-gap: 6px; padding: 10px 8px; text-align: center; }
  .gallery-grid .g-promo-book { width: auto; height: 92px; }
  .g-promo-kicker, .g-promo-hook { display: none; }
  .g-promo-cta { font-size: 15px; letter-spacing: .06em; }
}

@media (prefers-reduced-motion: reduce) {
  .g-promo-book, .g-promo-cta .chev { transition: none; }
}

/* empty tab note (Herodian Juglet, added with no photographs yet - owner
   request, 2026-11-02): js/main.js shows it when a tab matches nothing */
.g-empty {
  margin: 0;
  padding: 70px 24px 90px;
  background: var(--page);
  text-align: center;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 22px;
  color: #CFCCC5;
}
.g-empty[hidden] { display: none; }

/* ---------- Herodian Juglet note (owner request, 2026-11-12) ---------------
   The owner's account of the 1988 find fills the square left empty when
   juglet-07 was removed: a text tile "in the same caption way" - the
   caption overlay's centred white 15px copy, always shown, on the photo
   cells' own panel colour. Shown in the Juglet tab AND (owner request,
   2026-11-24) in the All view, where it shuffles in with the photographs
   like every other tile - the earlier All-tab hide rule is gone. Below the
   desktop comp a paragraph this long cannot fit a half-width square, so it
   spans the row. */
.g-note {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  overflow: hidden;
  background: var(--panel);
  text-align: center;
}

.g-note p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, .92);
}

@media (max-width: 1200px) {
  .g-note { grid-column: 1 / -1; aspect-ratio: auto; padding: 22px 24px; }
  .g-note p { max-width: 640px; }
  /* shuffled into All, the full-row note can land after an odd number of
     tiles; dense packing lets the next photo fill the half-row it would
     otherwise leave empty (curated tabs are unaffected - nothing follows) */
  .gallery-grid { grid-auto-flow: row dense; }
}
