/* ============================================================================
   THE BEST ONE — gallery subsite
   Used by:  galleria/index.html, galleria/<barber>.html

   Loaded AFTER assets/tbo-page.css and depends on its tokens and chrome.
   Everything here is gallery-only: the photo grid, the provenance badges and
   the lightbox. Filter chips, buttons, nav, footer and reveals all come from
   tbo-page.css unchanged — a gallery page is a normal page with a grid on it.
   ========================================================================= */

/* ============================== 1. HEADERS ============================== */

.gal-hero{ padding:var(--space-tight) 0 2.4rem; background:var(--color-bg); }
.gal-hero h1{ font-size:clamp(2.4rem,7vw,4.6rem); font-weight:800; text-transform:uppercase; margin-top:0.7rem; letter-spacing:-0.02em; }
.gal-hero p.lead{ margin-top:1.2rem; max-width:56ch; font-size:1.1rem; font-weight:300; color:var(--color-text-soft); }

/* Per-barber header: portrait, name, count, book. Smaller than the bio-page
   hero on purpose — you came here for the photos, not to read again. */
.gal-head{ padding:1.6rem 0 2.4rem; background:var(--color-bg); }
.gal-head-grid{ display:grid; grid-template-columns:auto minmax(0,1fr); gap:clamp(1.2rem,3vw,2.2rem); align-items:center; }
.gal-avatar{ width:clamp(78px,11vw,116px); aspect-ratio:1/1; border-radius:50%; overflow:hidden; background:var(--color-accent-tint); flex:none; }
.gal-avatar img{ width:100%; height:100%; object-fit:cover; }
.gal-head h1{ font-size:clamp(2rem,6vw,3.6rem); font-weight:800; text-transform:uppercase; margin-top:0.4rem; letter-spacing:-0.02em; }
.gal-meta{ margin-top:0.7rem; display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; }
.gal-count{ font-family:var(--font-mono); font-size:0.72rem; letter-spacing:0.14em; text-transform:uppercase; color:var(--color-accent-deep); }
.gal-head p.lead{ margin-top:1rem; max-width:56ch; font-size:1.05rem; font-weight:300; color:var(--color-text-soft); }
.gal-head-actions{ margin-top:1.4rem; display:flex; gap:0.8rem; flex-wrap:wrap; }

/* ============================== 2. THE GRID ============================== */

.gal-section{ padding:0 0 var(--space-base); background:var(--color-bg); }

/* One aspect ratio for every tile. A gallery of mixed crops reads as an
   accident; a gallery of identical frames reads as a studio. */
.gal-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:1.2rem; }

.gal-card{
  position:relative; display:block; width:100%; padding:0; margin:0;
  aspect-ratio:4/5; border:none; border-radius:10px; overflow:hidden;
  background:var(--color-accent-tint); cursor:zoom-in; text-align:left;
  transition:box-shadow 0.4s var(--ease), transform 0.4s var(--ease);
}
.gal-card[hidden]{ display:none; }
.gal-card img{ width:100%; height:100%; object-fit:cover; transition:transform 0.55s var(--ease), filter 0.55s var(--ease); }
.gal-card:hover{ box-shadow:0 16px 30px rgba(18,22,17,0.22); }
.gal-card:hover img{ transform:scale(1.07); filter:saturate(1.12); }
.gal-card:focus-visible{ outline:3px solid var(--color-accent-deep); outline-offset:3px; }

/* Caption slides up on hover. On touch there is no hover, so it stays put —
   otherwise every caption is invisible on the devices most people use. */
.gal-cap{
  position:absolute; left:0; right:0; bottom:0; padding:0.95rem 1rem;
  background:linear-gradient(0deg, rgba(18,22,17,0.9), rgba(18,22,17,0.55) 55%, transparent);
  color:#fff; font-family:var(--font-mono); font-size:0.7rem; letter-spacing:0.1em;
  text-transform:uppercase; transform:translateY(100%);
  transition:transform 0.35s var(--ease);
}
.gal-card:hover .gal-cap,
.gal-card:focus-visible .gal-cap{ transform:translateY(0); }
@media (hover:none){ .gal-cap{ transform:translateY(0); } }

/* Marks a tile that opens a clip rather than a still. Sits opposite the
   credit so the two never collide on a tile that has both. */
.gal-play{
  position:absolute; top:0.7rem; right:0.7rem; z-index:2;
  display:grid; place-items:center; width:1.85rem; height:1.85rem; border-radius:999px;
  background:rgba(18,22,17,0.62); color:#fff;
  backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
}
.gal-play svg{ width:0.85rem; height:0.85rem; margin-left:1px; }

/* Whose work it is. Present only on a tile credited to one barber — a
   shop-wide photo names nobody. The text follows the selected filter — see
   renderCredits() in assets/tbo-gallery.js. */
.gal-who{
  position:absolute; top:0.7rem; left:0.7rem; z-index:2;
  font-family:var(--font-mono); font-size:0.6rem; letter-spacing:0.12em; text-transform:uppercase;
  background:rgba(18,22,17,0.62); color:#fff; padding:0.35rem 0.6rem; border-radius:999px;
  backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
}

/* Empty state — a barber with no photos yet must not render a bare page. */
.gal-empty{
  padding:clamp(2.5rem,7vw,4.5rem) clamp(1.5rem,5vw,3rem); text-align:center;
  border:1px dashed rgba(27,31,26,0.22); border-radius:12px; background:var(--color-surface);
}
.gal-empty h3{ font-family:var(--font-display); font-weight:800; font-size:1.3rem; text-transform:uppercase; margin-top:0.8rem; }
.gal-empty p{ margin-top:0.8rem; font-weight:300; color:var(--color-text-soft); max-width:46ch; margin-inline:auto; }
.gal-empty .btn{ margin-top:1.6rem; }

/* ---------------------------------------------------------------------
   SELECTION HEADLINE — who the grid is currently showing.

   It sits between the sticky chip bar and the grid and says in words what
   the pressed chip says in a token, which is what makes the filter legible
   once you have scrolled the chips out of view. The link only appears for a
   barber; "Kaikki" has nowhere else to go.
   --------------------------------------------------------------------- */
.gal-selected{
  display:flex; align-items:baseline; gap:0.7rem 1.4rem; flex-wrap:wrap;
  margin-bottom:2rem; padding-bottom:1.1rem;
  border-bottom:1px solid rgba(27,31,26,0.1);
}
.gal-selected-title{
  font-family:var(--font-display); font-weight:800;
  font-size:clamp(1.35rem,3.2vw,2rem); text-transform:uppercase; letter-spacing:-0.01em;
}
.gal-selected-link{
  margin-left:auto; font-family:var(--font-mono); font-size:0.72rem;
  letter-spacing:0.12em; text-transform:uppercase; font-weight:600;
  color:var(--color-accent-deep); border-bottom:1px solid transparent;
}
.gal-selected-link:hover{ border-bottom-color:currentColor; }
.gal-selected-link[hidden]{ display:none; }

/* Result count when a filter is active and nothing matches. */
.gal-noresult{ padding:3rem 0; text-align:center; color:var(--color-text-soft); font-weight:300; }

/* ========================= 3. BARBER CARD ROW ========================= */
/* Reuses .other-card from tbo-page.css; only the column count differs,
   because the hub lists all five rather than the four "others". */
.gal-barbers{ padding:var(--space-base) 0; background:var(--color-surface); }
.gal-barbers-grid{ display:grid; grid-template-columns:repeat(5,1fr); gap:1.1rem; }

/* ============================== 4. LIGHTBOX ============================== */
/* Built on <dialog>.showModal(), the same primitive tuotteet.html uses for the
   product modal: the focus trap, the Escape key and inertness of the page
   behind come from the browser instead of from hand-written key handling. */

.lightbox{
  width:100vw; max-width:100vw; height:100dvh; max-height:100dvh;
  padding:0; border:none; overflow:hidden; color:var(--color-bg);
  /* The dialog fills the viewport, so its own background is the dark field.
     Relying on ::backdrop alone left the page readable behind the photo. */
  background:rgba(10,11,8,0.96);
}
.lightbox::backdrop{ background:rgba(10,11,8,0.96); }
.lightbox[open]{ display:grid; grid-template-rows:auto minmax(0,1fr) auto; }

.lb-bar{
  display:flex; align-items:center; justify-content:space-between; gap:1rem;
  padding:clamp(0.8rem,2.5vw,1.4rem) clamp(1rem,4vw,2.2rem); color:rgba(245,245,240,0.75);
}
.lb-index{ font-family:var(--font-mono); font-size:0.72rem; letter-spacing:0.16em; text-transform:uppercase; }

/* The image is absolutely positioned rather than a centred grid item on
   purpose. As a grid item its max-height:100% resolved against a track whose
   height the engine treats as indefinite, so a 1024px-tall photo rendered at
   1024px and pushed the caption off screen. Against a positioned ancestor the
   percentage is definite, and object-fit does the letterboxing. The padding
   is on the image so object-fit contains inside it (box-sizing is global). */
.lb-stage{ position:relative; min-height:0; }
.lb-img{
  position:absolute; inset:0; width:100%; height:100%;
  padding:0 clamp(3.2rem,9vw,5.5rem); object-fit:contain;
}
.js .lb-img{ opacity:0; transition:opacity 0.28s var(--ease); }
.js .lb-img.ready{ opacity:1; }

/* A clip fills the stage on the same terms as a still, but sized to its own
   aspect ratio rather than stretched to the stage: the browser draws the
   native control bar at the ELEMENT's width, so a full-width element under a
   portrait clip puts the scrubber out in the dark either side of it.
   inset:0 + margin:auto centres whatever size that works out to.
   `hidden` needs forcing because the rule above sets display via position,
   and the element is toggled with the attribute rather than a class. */
.lb-video{
  position:absolute; inset:0; margin:auto;
  width:auto; height:auto;
  max-width:calc(100% - 2 * clamp(3.2rem,9vw,5.5rem)); max-height:100%;
}
.lb-video[hidden]{ display:none; }

.lb-foot{ padding:clamp(0.9rem,2.5vw,1.5rem) clamp(1rem,4vw,2.2rem) clamp(1.4rem,3vw,2rem); text-align:center; }
.lb-cap{ font-family:var(--font-display); font-weight:700; font-size:clamp(1.05rem,2.4vw,1.5rem); text-transform:uppercase; letter-spacing:-0.01em; color:var(--color-bg); }
.lb-who{ margin-top:0.5rem; font-family:var(--font-mono); font-size:0.68rem; letter-spacing:0.14em; text-transform:uppercase; color:var(--color-accent); }

.lb-btn{
  display:grid; place-items:center; width:46px; height:46px; flex:none;
  border-radius:50%; border:1px solid rgba(245,245,240,0.28); background:rgba(245,245,240,0.06);
  color:var(--color-bg); cursor:pointer; padding:0;
  transition:background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.lb-btn:hover{ background:var(--color-accent); border-color:var(--color-accent); color:var(--color-black); }
.lb-btn:focus-visible{ outline:3px solid var(--color-accent); outline-offset:3px; }
.lb-btn svg{ width:20px; height:20px; pointer-events:none; }
.lb-btn[disabled]{ opacity:0.3; cursor:default; }
.lb-btn[disabled]:hover{ background:rgba(245,245,240,0.06); border-color:rgba(245,245,240,0.28); color:var(--color-bg); }

.lb-nav{ position:absolute; top:50%; transform:translateY(-50%); z-index:3; }
.lb-prev{ left:clamp(0.3rem,1.5vw,1rem); }
.lb-next{ right:clamp(0.3rem,1.5vw,1rem); }
.lb-nav:hover{ transform:translateY(-50%) scale(1.08); }

/* ============================ 5. RESPONSIVE ============================ */

@media (max-width:980px){
  .gal-barbers-grid{ grid-template-columns:repeat(3,1fr); }
}
@media (max-width:860px){
  .gal-grid{ grid-template-columns:repeat(2,1fr); }
  .gal-head-grid{ grid-template-columns:1fr; text-align:left; }
}
@media (max-width:620px){
  .gal-grid{ gap:0.7rem; }
  .gal-barbers-grid{ grid-template-columns:repeat(2,1fr); }
  /* margin-left:auto pushes the link to a cramped right edge here; give it
     its own line under the headline instead. */
  .gal-selected-link{ margin-left:0; width:100%; }
  /* The arrows stay pinned to the stage edges; they already sit inside the
     image's own side padding, so they never cover the photo. Shrink both
     together so the photo gets as much of a narrow screen as possible. */
  .lb-btn{ width:40px; height:40px; }
  .lb-btn svg{ width:18px; height:18px; }
  .lb-img{ padding-inline:clamp(2.8rem,12vw,3.4rem); }
  .lb-video{ max-width:calc(100% - 2 * clamp(2.8rem,12vw,3.4rem)); }
  .lb-bar{ padding-inline:1rem; }
}

@media (prefers-reduced-motion:reduce){
  .gal-card, .gal-card img, .gal-cap, .lb-btn, .lb-img{ transition:none !important; }
  .gal-card:hover img{ transform:none; }
}
