/* Shutterbench Gallery — client-facing template.
   --accent = photographer's brand color (set by gallery.js).
   Looks: body.look-classic (default) / body.look-editorial / body.look-noir. */
:root {
  --accent: #b48c5a;
  --bg: #ffffff;
  --ink: #1c1a17;
  --ink-soft: #6b665e;
  --line: rgba(28, 26, 23, 0.12);
  /* 27vw: keeps even a 16:9 frame's basis under half the page, so the
     two-per-row cap below almost never bites (a capped basis is no longer
     proportional to the photo, and the row would crop to even out) */
  --row-h: min(250px, 27vw);
  --display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --track: 0.01em;
}
body.look-editorial {
  --bg: #faf7f2;
  --ink: #262019;
  --ink-soft: #837a6d;
  --line: rgba(38, 32, 25, 0.14);
  --display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --track: 0.02em;
}
body.look-noir {
  --bg: #0f0f10;
  --ink: #f0eeea;
  --ink-soft: #98938b;
  --line: rgba(240, 238, 234, 0.14);
  --track: 0.16em;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body.look-noir { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
button, input { font: inherit; }

/* ---- lock screen ---- */
#lock { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; position: relative; overflow: hidden; }
/* The plate is a 32px blur of the cover, inlined by generate.ts and set as
   --lock-plate in showLock(). Scaled up and blurred again here, but that second
   blur is cosmetic only — the data URI already carries nothing but colour.
   Unset var -> `none` -> an empty transparent box, so an unset plate costs
   nothing and needs no extra rule. The inset bleed hides the blur's soft edge. */
#lock::before {
  content: "";
  position: absolute; inset: -6%;
  background: var(--lock-plate, none) center / cover no-repeat;
  /* Owner picked the stronger of two renders (2026-07-29). These numbers only
     decide how much of the SAME 499-byte plate is thrown away — the security
     boundary is the 32px source, not this blur. Weaker settings averaged a real
     photo down to flat neutral grey; the synthetic fixtures had lied about it. */
  filter: blur(16px) saturate(1.45);
  opacity: 0.85;
}
/* positioned, so the form paints above the plate rather than under it */
#lock-form { position: relative; }
#lock-form {
  width: min(380px, 100%);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2.75rem 2.25rem;
  background: var(--bg);
}
#lock-logo { max-height: 44px; max-width: 180px; margin-bottom: 1.25rem; }
#lock-form h1 { margin: 0 0 0.25rem; font-family: var(--display); letter-spacing: var(--track); font-size: 1.6rem; font-weight: 600; }
body.look-noir #lock-form h1 { text-transform: uppercase; font-size: 1.2rem; }
#lock-form p { color: var(--ink-soft); margin: 0.25rem 0 1.5rem; font-size: 0.95rem; }
#lock-pw {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.8rem;
  background: transparent;
  color: var(--ink);
  text-align: center;
}
.remember { display: block; color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 1.1rem; }
#lock-form button[type='submit'] {
  width: 100%;
  padding: 0.7rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.04em;
}
#lock-msg { color: #c0392b; min-height: 1.5em; margin: 0.8rem 0 0; font-size: 0.9rem; }
/* the manifest didn't load and there is no lock form to say so in */
#boot-err { min-height: 100dvh; margin: 0; padding: 2rem; display: grid; place-items: center; text-align: center; color: var(--ink-soft); }
#lock-form.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---- hero cover ---- */
/* isolate: the glow below blends with `screen`, and without a stacking context
   here it would blend against the page instead of against the photograph. */
#hero { position: relative; height: 92dvh; min-height: 420px; overflow: hidden; isolation: isolate; }
/* "Enhance cover" (opt-in per gallery): a blurred copy of the plate, screen-blended
   back over it — the Orton/bloom look. Screen barely moves the shadows and lifts
   the highlights, so the glow keys itself to the light with no masking at all.
   Same URL as #hero-img, so it is a cache hit, not a second download. Placed
   between the image and the scrim by document order — it must not wash the title. */
/* "Subtle zoom" (on by default): the cover settles once, 110% -> 100% over ten
   seconds, and then holds. `both` keeps it at 110% until .ready lands, so it
   always plays from the top instead of joining a cycle already under way.
   It gets its own element because #hero-img and #hero-glow already animate
   `scale` on the scroll timeline (sb-push) and `transform` belongs to the
   entrance transition — a third claim on either would win outright and eat one
   of them. Nested here, the two scales simply compose. */
#hero-zoom { position: absolute; inset: 0; }
body.zoom #hero.ready #hero-zoom { animation: sb-zoom 10s ease-out both; }
@keyframes sb-zoom { from { scale: 1.1; } }
#hero-glow {
  position: absolute;
  inset: -4%; /* overshoot: #hero-img scales, and a flush edge would show through */
  background: var(--hero-src) var(--hero-pos, center) / cover no-repeat;
  filter: blur(24px) brightness(1.25);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.9s ease-out 0.2s;
  pointer-events: none;
}
body.enhance #hero.ready #hero-glow { opacity: 0.45; }
#hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* --hero-pos is set by gallery.js for tall covers; the glow reads the same var
     so the two layers stay registered. */
  object-position: var(--hero-pos, 50% 50%);
  transform: scale(1.04);
  transition: transform 6s ease-out, opacity 0.8s ease-out;
  opacity: 0;
}
#hero.ready #hero-img { opacity: 1; transform: scale(1); }
#hero-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.12), rgba(0,0,0,0) 35%, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45));
}
#hero-inner {
  position: absolute; inset: auto 0 12dvh 0;
  text-align: center;
  color: #fff;
  padding: 0 1.5rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease-out 0.35s, transform 0.9s ease-out 0.35s;
}
#hero.ready #hero-inner { opacity: 1; transform: none; }
#hdr-logo { max-height: 48px; max-width: 190px; margin-bottom: 1rem; filter: drop-shadow(0 1px 8px rgba(0,0,0,0.4)); }
#hdr-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 3.6rem);
  font-weight: 600;
  letter-spacing: var(--track);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
}
body.look-noir #hdr-title { text-transform: uppercase; font-weight: 500; }
#hdr-count {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
}
#hero-cue {
  position: absolute; left: 50%; bottom: 3dvh;
  width: 22px; height: 22px;
  border-right: 2px solid rgba(255,255,255,0.8);
  border-bottom: 2px solid rgba(255,255,255,0.8);
  transform: translateX(-50%) rotate(45deg);
  animation: cue 2s infinite;
}
@keyframes cue { 50% { transform: translateX(-50%) translateY(6px) rotate(45deg); } }

/* ---- toolbar ---- */
#toolbar {
  display: flex; gap: 0.6rem; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 1.6rem 1rem;
}
/* Only earns its place in the slim fixed header. In the fallback toolbar it
   would just restate the cover's <h1> as unstyled body text. */
#bar-title { display: none; }
#toolbar button {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: 0.03em;
}
#toolbar button:hover { border-color: var(--accent); color: var(--accent); }
#zip-status { color: var(--ink-soft); font-size: 0.875rem; }

/* ---- justified grid ---- */
#grid { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px 4px; }
body.look-editorial #grid { gap: 10px; padding: 0 10px 10px; }
#grid .ph {
  position: relative;
  margin: 0;
  flex-grow: calc(var(--ar) * 100);
  /* never more than half the page: two photos always fit a row, so none is
     left alone to stretch full-width and crop. In practice this only catches
     panoramas; --row-h already scales down on narrow pages. */
  flex-basis: min(calc(var(--row-h) * var(--ar)), calc(50% - 5px));
  aspect-ratio: var(--ar);
  max-height: calc(var(--row-h) * 1.8);
  overflow: hidden;
  cursor: zoom-in;
  background: color-mix(in srgb, var(--ink) 7%, var(--bg));
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease-out, transform 0.55s ease-out;
}
#grid .ph.in { opacity: 1; transform: none; }
#grid .ph img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.6s ease-out;
}
#grid .ph:hover img { transform: scale(1.025); }
/* Only the LAST row has slack to soak up; finishLastRow in gallery.js decides
   whether it stretches, squeezes onto one line, or splits with the row above. */
#grid::after { content: ''; flex-grow: 1e4; }
#grid.fill-last::after { display: none; }
#grid .rowbreak { flex-basis: 100%; height: 0; }
/* a pair of landscapes on a line of their own (placePairs): half the page each,
   so a third never fits beside them, and no height cap, so nothing crops.
   Before .squeeze so the last-row join still wins. */
#grid .ph.big { flex-basis: calc(50% - 5px); max-height: none; }
#grid .ph.squeeze { flex-basis: 0; }
.fav-btn {
  position: absolute; top: 8px; inset-inline-end: 8px;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 999px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.ph:hover .fav-btn, .fav-btn.on { opacity: 1; }
.fav-btn.on { background: var(--accent); }
@media (hover: none) { .fav-btn { opacity: 1; } }
@media (max-width: 600px) { :root { --row-h: min(150px, 27vw); } #hero { height: 70dvh; } }

/* ---- favorites bar ---- */
#favbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 0.75rem; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: color-mix(in srgb, var(--ink) 94%, var(--bg));
  color: var(--bg);
  font-size: 0.9rem;
  z-index: 5;
}
body.look-noir #favbar { background: #1c1c1e; color: #f0eeea; }
#fav-count { font-weight: 600; }
#fav-msg { opacity: 0.85; }
#favbar button {
  color: inherit;
  background: none;
  border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}
#favbar button:hover { border-color: var(--accent); color: var(--accent); }
body.has-favbar { padding-bottom: 64px; }

/* ---- lightbox ---- */
#lb {
  border: 0; padding: 0; background: transparent;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
}
/* 0.96 let the grid ghost through behind the photograph and read as a bug */
#lb::backdrop { background: rgba(8, 8, 9, 0.985); }
#lb[open] { animation: lbin 0.25s ease-out; }
@keyframes lbin { from { opacity: 0; } }
#lb-img {
  position: absolute; inset: 0; margin: auto;
  /* the bar is ~56px and sits at bottom 0 while the image centres in the full
     height — it needs clearance on BOTH sides of centre, not one bar's worth */
  max-width: 100vw; max-height: calc(100dvh - 128px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.19s ease; /* paired with FADE in gallery.js */
}
#lb-img.swap { opacity: 0; }
#lb button { position: absolute; z-index: 2; background: none; border: 0; color: rgba(255,255,255,0.85); cursor: pointer; }
#lb-close { top: 10px; inset-inline-end: 14px; font-size: 2rem; }
#lb-prev, #lb-next { top: 50%; transform: translateY(-50%); font-size: 3rem; padding: 1rem; }
/* Logical, not left/right: under dir=rtl (he) the grid advances leftward, so
   Next belongs on the left. The ‹ › glyphs bidi-mirror on their own, so
   swapping the sides fixes the arrow direction in the same change. */
#lb-prev { inset-inline-start: 6px; }
#lb-next { inset-inline-end: 6px; }
#lb-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 1rem; align-items: center; justify-content: center;
  padding: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
}
#lb-bar button, #lb-bar a {
  position: static; color: inherit; text-decoration: none;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 999px; padding: 0.25rem 0.8rem;
}
#lb-bar .on { color: var(--accent); border-color: var(--accent); }

/* ---- footer ---- */
#foot { text-align: center; padding: 3rem 1rem 2.5rem; color: var(--ink-soft); font-size: 0.9rem; }
#foot a { color: inherit; }
#foot-contact { color: var(--accent) !important; text-decoration: none; margin-inline-end: 1.5rem; }
#foot-trial { opacity: 0.7; }

/* ---- cover motion ----------------------------------------------------------
   The cover holds while the photographs rise over it, like a title card being
   dissolved out of: the image pushes in slowly, the type leaves ahead of it,
   and a veil takes the rest. Scroll-driven CSS — no listeners, no rAF, nothing
   to jank. Browsers without scroll timelines skip the whole block and keep
   today's static cover, which is why there is no JS fallback.
   Motion lives on `translate`/`scale`, NOT `transform`: the entrance transition
   above owns `transform`, and an animation would win over it and eat the fade-in. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    #hero { position: sticky; top: 0; }
    /* the pinned cover is positioned, so static siblings would paint UNDER it —
       these have to be raised and opaque or the grid scrolls through the photo */
    #grid, #foot { position: relative; z-index: 1; background: var(--bg); }
    /* the rising page casts onto the cover it is covering — this is the whole
       reason the layering reads as depth instead of as two stacked pictures */
    #grid { box-shadow: 0 -34px 60px -24px rgba(0, 0, 0, 0.4); }

    /* The controls used to sit in a band of empty page between the cover and the
       first photograph — chrome interrupting the handoff at its worst moment.
       Now the photographs meet the cover directly and this arrives as a slim
       header once the cover is spent. */
    #toolbar {
      position: fixed; inset: 0 0 auto 0; z-index: 4;
      justify-content: space-between; flex-wrap: nowrap;
      padding: 0.55rem clamp(0.75rem, 3vw, 1.6rem);
      background: color-mix(in srgb, var(--bg) 88%, transparent);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--line);
      translate: 0 -100%;
      animation: sb-bar linear both;
      animation-timeline: scroll(root);
      /* Lengths on a scroll() timeline resolve against the SCROLL RANGE, not the
         document. A short gallery whose range never reaches 78dvh would leave
         this in its before-phase forever — the bar pinned off-screen and the
         controls unreachable by mouse and touch. The percentages are the floor
         that guarantees it completes on any page length. */
      animation-range: min(78dvh, 45%) min(94dvh, 62%);
    }
    /* it is off-screen, not hidden, so a keyboard could otherwise land focus on
       a control nobody can see — !important beats the animation, by the cascade */
    #toolbar:focus-within { translate: 0 !important; }
    #toolbar button { padding: 0.35rem 0.95rem; font-size: 0.85rem; }
    #bar-title {
      display: block;
      font-family: var(--display); letter-spacing: var(--track); font-size: 0.95rem;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      margin-inline-end: auto;
    }
    body.look-noir #bar-title { text-transform: uppercase; font-size: 0.8rem; }

    /* Warm near-black, and NOT var(--bg): dissolving the cover into the page's
       own paper was tried and reads as haze over the photograph rather than as
       depth beneath it. var(--ink) is no good either — noir's ink is light. */
    #hero::after {
      content: ''; position: absolute; inset: 0;
      background: #0b0908; opacity: 0; pointer-events: none;
    }

    /* the glow rides the same push, or it separates from the plate it blooms */
    #hero-img, #hero-glow {
      animation: sb-push linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100dvh;
    }
    #hero-inner {
      animation: sb-leave linear both;
      animation-timeline: scroll(root);
      animation-range: 0 72dvh;
    }
    /* deliberately shorter than the 92dvh it takes to cover the hero: the strip
       still showing has to fall back before the grid arrives, or two versions of
       the same photograph compete on screen */
    #hero::after {
      animation: sb-veil linear both;
      animation-timeline: scroll(root);
      animation-range: 0 60dvh;
    }
    /* keep the bob, fade the arrow the moment the scroll it asks for begins */
    #hero-cue {
      animation: cue 2s infinite, sb-cue-out linear both;
      animation-timeline: auto, scroll(root);
      animation-range: normal, 0 16dvh;
    }

    /* The page arrives as paper before it arrives as photographs. Without this
       breath the grid butts straight into the cover on a hard edge, which is
       the single thing that made the handoff read cheap.
       A spacer row, not padding-top: the look-* rules set `padding` as a
       shorthand and out-specify a plain `#grid`, so padding silently no-ops in
       editorial. This also can't be a margin — the cover is pinned behind the
       grid and a margin would let it show through the gap. */
    #grid::before { content: ''; flex-basis: 100%; height: clamp(2.5rem, 9dvh, 7rem); }

    /* Every photograph drifts inside its own frame as it crosses the viewport,
       and NOT all at the same rate — a field where neighbours move differently
       reads as depth, where one uniform rate just reads as the page sliding.
       1.18 is the overscan the largest amplitude (9%) travels through. */
    #grid .ph img {
      scale: 1.18;
      animation: sb-drift-a linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    #grid .ph:nth-child(3n) img { animation-name: sb-drift-b; }
    #grid .ph:nth-child(4n) img { animation-name: sb-drift-c; }
    @keyframes sb-drift-a { from { translate: 0 -7%; } to { translate: 0 7%; } }
    @keyframes sb-drift-b { from { translate: 0 4%; } to { translate: 0 -6%; } }
    @keyframes sb-drift-c { from { translate: 0 -3%; } to { translate: 0 9%; } }

    /* scale outruns the rise (0.07 overscan per side vs 0.05 travel) so the
       photo can never expose an edge, at any point in the range */
    @keyframes sb-push { to { scale: 1.14; translate: 0 -5%; } }
    @keyframes sb-bar { from { translate: 0 -100%; } to { translate: 0 0; } }
    @keyframes sb-leave { to { translate: 0 -9dvh; } }
    @keyframes sb-veil { to { opacity: 0.82; } }
    @keyframes sb-cue-out { to { opacity: 0; } }
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  #hero-img, #hero-inner, #grid .ph { opacity: 1 !important; transform: none !important; }
  #hero-cue { display: none; }
}
