/* =========================================================================
   ON3 — Gallery (the home page)
   Builds on site.css (tokens, header, buttons, footer). One shuffled
   masonry wall of photos and videos, and a viewer that opens over it.
   ========================================================================= */

.gal { position: relative; isolation: isolate; padding-top: calc(64px + env(safe-area-inset-top)); background: radial-gradient(120% 60% at 50% 0%, var(--espresso-2), var(--espresso) 70%); }
.gal::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .08; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------- head
   One compact band: the title on the left, the shuffle icon on the right, so
   the wall starts within the first screen. */

.gal-head { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s4) 2px var(--s3); }
.gal-head h1, .gal-head h2 {
  font-family: var(--f-display); font-weight: 400;
  font-size: clamp(1rem, 0.85rem + 0.7vw, 1.35rem); line-height: 1.3; letter-spacing: 0.01em;
}
.gal-bar { display: flex; align-items: center; gap: var(--s1); }

/* Shuffle: a small icon button, no label (aria-label and title carry it). */
.gal-shuffle {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; flex: none;
  border: var(--hair); border-radius: 50%; background: none; color: var(--on-dark-dim); cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.gal-shuffle:hover { color: var(--on-dark); border-color: var(--on-dark-dim); }
.gal-shuffle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gal-shuffle.is-spun svg { transform: rotate(180deg); transition: transform var(--t-mid) var(--ease); }

/* ------------------------------------------------------------- hero film
   Full-bleed under the header, frameless like the wall. Holds a placeholder
   until the film lands; a <video> dropped in fills it the same way. */

.hero-film { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: min(78vh, 820px); overflow: hidden; background: var(--espresso-2); }
@media (max-width: 639px) { .hero-film { aspect-ratio: 4 / 5; max-height: 70vh; } }
.hero-film video, .hero-film img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-film__ph {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--s2);
  color: var(--on-dark-dim); font-family: var(--f-display); font-size: 0.625rem; letter-spacing: 0.18em; text-transform: uppercase;
  background: radial-gradient(80% 90% at 50% 40%, rgba(224, 164, 88, 0.10), transparent 70%), linear-gradient(180deg, var(--espresso-2), var(--espresso));
}
.hero-film__ph svg { width: 44px; height: 44px; padding: 12px 10px 12px 14px; border: var(--hair); border-radius: 50%; fill: currentColor; box-sizing: content-box; }

/* ------------------------------------------------------------- the wall
   gallery.js deals each tile into the shortest column, so the masonry keeps
   its order left-to-right and can grow as more tiles load. */

.wall-wrap { padding-inline: clamp(6px, 1.2vw, 16px); }
/* Framed: each tile in a thin white frame, with a little dark space between
   them, like a pin board. */
.wall-wrap--bleed { --gap: clamp(8px, 0.9vw, 14px); padding-inline: var(--gap); }
.wall { display: flex; align-items: flex-start; gap: var(--gap); }
.wall-wrap--bleed .tile { border: 1.5px solid #fbf7f0; border-radius: 12px; }
.wall__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.tile {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  overflow: hidden; isolation: isolate; background: var(--espresso-2);   /* isolation keeps Safari clipping while the photo scales on hover */
  aspect-ratio: var(--ar);
}
.tile img, .tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile img { opacity: 0; transition: opacity var(--t-mid) var(--ease), transform var(--t-slow) var(--ease); }
.tile img.is-loaded { opacity: 1; }
.tile video { opacity: 0; transition: opacity var(--t-mid) var(--ease); }
.tile video.is-playing { opacity: 1; }
.tile::after {   /* a warm lift on hover, like the lamp coming on */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(0deg, rgba(27, 19, 16, 0.45), transparent 45%);
  box-shadow: inset 0 0 0 1.5px var(--amber);
  transition: opacity var(--t-fast) var(--ease);
}
@media (hover: hover) {
  .tile:hover::after { opacity: 1; }
  .tile:hover img { transform: scale(1.025); }
}
.tile:focus-visible { box-shadow: var(--focus); }

.tile__dur {
  position: absolute; z-index: 1; left: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 7px; border-radius: var(--r-pill); pointer-events: none;
  font: 600 0.6875rem/1.3 var(--f-body); font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  background: rgba(27, 19, 16, 0.72); color: var(--on-dark); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile__dur::before { content: ""; width: 0; height: 0; border-left: 6px solid currentColor; border-block: 4px solid transparent; }

/* New tiles drift up as they arrive. */
@media (prefers-reduced-motion: no-preference) {
  .tile.is-new { animation: tile-in var(--t-slow) var(--ease) both; animation-delay: var(--dl, 0ms); }
  @keyframes tile-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
}

.gal-state { text-align: center; color: var(--on-dark-dim); padding: var(--s6) var(--gutter); font-family: var(--f-mono); font-size: 0.8125rem; }
.gal-state:empty { display: none; }
.gal-more { display: block; height: 1px; }

.gal-end { display: grid; justify-items: center; text-align: center; gap: var(--s3); padding-block: var(--s7) var(--s8); }
.gal-end .path__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s2); }

/* ------------------------------------------------------------- viewer */

.lb {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 0; border: 0;
  background: rgba(14, 10, 8, 0.97); color: var(--on-dark);
  flex-direction: column;
}
.lb[open] { display: flex; }
.lb::backdrop { background: rgba(0, 0, 0, 0.6); }
.lb__stage {
  position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 12px) clamp(8px, 4vw, 72px) 0; touch-action: pan-y;
}
.lb__stage img, .lb__stage video {
  max-width: 100%; max-height: 100%; width: auto; height: auto; min-width: 0; min-height: 0; object-fit: contain;
  border-radius: 4px; background: var(--espresso-2);
}
.lb__stage img { transition: opacity var(--t-fast) var(--ease); }
.lb__stage img.is-soft { filter: blur(8px); }
@media (prefers-reduced-motion: no-preference) {
  .lb__stage > .is-in { animation: lb-in var(--t-mid) var(--ease) both; }
  @keyframes lb-in { from { opacity: 0; transform: translateX(calc(var(--dir, 0) * 28px)); } to { opacity: 1; transform: none; } }
}
.lb__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) var(--gutter) calc(var(--s2) + env(safe-area-inset-bottom));
}
.lb__count { font-family: var(--f-mono); font-size: 0.75rem; color: var(--on-dark-dim); letter-spacing: 0.06em; }
.lb__nav { display: flex; gap: 6px; }
.lb__nav button {
  min-width: 48px; min-height: 48px; padding: 0 14px; border: var(--hair); border-radius: var(--r-pill);
  background: none; cursor: pointer; font-size: 1.25rem; line-height: 1;
}
.lb__nav button:hover { border-color: var(--on-dark-dim); }
.lb__nav .lb__close { font-family: var(--f-display); font-size: 0.625rem; letter-spacing: 0.14em; text-transform: uppercase; }


/* ------------------------------------------------------------- back to top
   A pill that drops in under the header once the first screen of the wall
   has scrolled away (gallery.js sets .is-shown), like a feed's "back to top". */

.to-top {
  position: fixed; z-index: 45; left: 50%; top: calc(64px + env(safe-area-inset-top) + 12px);
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px 0 13px;
  border: var(--hair); border-radius: var(--r-pill); cursor: pointer; white-space: nowrap;
  font-family: var(--f-display); font-size: 0.625rem; letter-spacing: 0.14em; text-transform: uppercase;
  background: rgba(27, 19, 16, 0.82); color: var(--on-dark); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0; visibility: hidden; transform: translate(-50%, -14px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), visibility 0s linear var(--t-fast), border-color var(--t-fast) var(--ease);
}
.to-top.is-shown { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.to-top:hover { border-color: var(--on-dark-dim); }
.to-top svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- hero film: the film itself
   js/hero-film.js loads it; the poster shows until it plays. A small
   pause/play button sits in the corner. */

.hero-film video { opacity: 1; background: var(--espresso-2); }
.hero-film__btn {
  position: absolute; z-index: 2; right: 12px; bottom: 12px;
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid rgba(243, 234, 217, 0.35); border-radius: 50%; cursor: pointer;
  background: rgba(27, 19, 16, 0.55); color: var(--on-dark);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.hero-film__btn:hover { background: rgba(27, 19, 16, 0.8); border-color: var(--on-dark-dim); }
.hero-film__btn svg { width: 15px; height: 15px; }
.hero-film__btn .i-pause { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.hero-film__btn .i-play { fill: currentColor; display: none; }
.hero-film__btn.is-paused .i-pause { display: none; }
.hero-film__btn.is-paused .i-play { display: block; }
