/* PORTRAITS filmstrip - a self-contained, full-viewport gallery view.
 *
 * Exclusively for page-portraits.php (enqueued only when that template is
 * active). Uses the site's existing color/spacing tokens throughout - no
 * new colors invented except the three plain 35mm-negative greys this
 * layout specifically needs (filmstrip background, inactive frame, active
 * frame), which have no equivalent in tokens.css and aren't reused anywhere
 * else on the site.
 */

.page-template-page-portraits-php .site-footer,
.page-template-page-filmstrip-gallery-php .site-footer {
  display: none;
}

/* Prevents the page itself from ever scrolling on this template. Without
   this, base.css's global `body > main { flex: 1 0 auto; }` rule
   (flex-shrink:0, unconditional, shared by every page - not to be changed
   here) combined with an explicit height on .portraits below it can be
   forced taller than the viewport by the flex item's own automatic
   content-based minimum size - the classic flexbox "can't shrink past
   content" behavior. The visible symptom was a page-level scrollbar pair
   (vertical + horizontal, meeting in the browser's own scrollbar-corner
   in the bottom-right) and the counter scrolling out of view beneath the
   fold. Fixed at the source below (flex:1 1 auto + min-height:0 lets
   .portraits actually shrink to the real remaining space); this is a
   belt-and-suspenders guarantee that nothing on this one template can
   ever produce a page scrollbar, not a substitute for that fix - there is
   nothing left to clip once the sizing itself is correct. */
body.page-template-page-portraits-php,
body.page-template-page-filmstrip-gallery-php {
  height: 100vh;
  height: 100dvh; /* dynamic viewport height - accounts for mobile Safari's
                     collapsing address/toolbar chrome; browsers that don't
                     support dvh ignore this line and keep the 100vh above */
  overflow: hidden;
}

.portraits {
  display: flex;
  flex-direction: row;
  /* No explicit height: this is the flex item base.css already gives
     `flex: 1 0 auto` (body > main) - overridden here, scoped only to this
     template, to flex:1 1 auto + min-height:0 so it takes exactly the
     real remaining space below the header (whatever the header's actual
     rendered height is) and can shrink to fit it, instead of a hardcoded
     calc(100vh - var(--header-height)) that assumed the header is always
     exactly --header-height tall. */
  flex: 1 1 auto;
  min-height: 0;
  background-color: var(--color-background);
  overflow: hidden;
  outline: none;
  border: 0;
  border-radius: 0;
}

/* Filmstrip - fixed 120px column, dark background, independently
   scrollable, its own scrollbar hidden (the frames themselves are the
   only scroll affordance needed). */
.portraits__filmstrip {
  flex: 0 0 120px;
  width: 120px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #080808;
  border-right: 1px solid var(--color-border-subtle);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;

  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.portraits__filmstrip::-webkit-scrollbar {
  display: none;
}

/* One 35mm negative frame - square corners, no card styling. Reduced
   opacity + dark grey when inactive; full opacity + warm-grey background
   when selected. Real <button> for keyboard/AT support. */
.portraits__frame {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background-color: #1b1b1b;
  cursor: pointer;
  opacity: 0.55;
  appearance: none;
  -webkit-appearance: none;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.portraits__frame:hover {
  opacity: 0.8;
}

.portraits__frame:focus-visible {
  outline: 1px solid var(--color-text);
  outline-offset: 2px;
}

.portraits__frame[aria-current="true"] {
  background-color: #d7d1c7;
  opacity: 1;
}

/* Sprocket perforations - a plain repeating pattern of small rectangular
   holes along the top/bottom of each frame, punched through to the
   filmstrip's own dark background so they read as holes rather than
   printed marks. Purely a 35mm-negative visual cue, not a decorative
   flourish - the spec calls for it explicitly. */
.portraits__sprocket {
  display: block;
  flex: 0 0 auto;
  height: 6px;
  margin: 3px 4px;
  background-image: repeating-linear-gradient(
    to right,
    #080808 0,
    #080808 3px,
    transparent 3px,
    transparent 7px
  );
}

.portraits__frame-thumb {
  display: block;
  width: 100%;
  height: 84px;
  object-fit: cover; /* cropping is permitted only here, inside the thumbnail */
  filter: grayscale(1);
}

.portraits__frame-number {
  display: block;
  flex: 0 0 auto;
  padding: 3px 0 2px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: var(--nav-letter-spacing);
  color: var(--color-text-muted);
}

.portraits__frame[aria-current="true"] .portraits__frame-number {
  color: #1b1b1b;
}

/* Viewer - the remaining width, one centered portrait. */
.portraits__viewer {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-width: 0;
  padding: var(--space-24);
  overflow: hidden;
}

/* The warm-white photographic-print border - a plain padded box behind the
   image, no drop shadow. box-sizing:border-box keeps the 16px border
   itself inside the min(72vw,720px) cap rather than adding to it. */
.portraits__frame-figure {
  margin: 0;
  box-sizing: border-box;
  max-width: min(72vw, 720px);
  max-height: 100%;
  padding: 16px;
  background-color: var(--color-text);
  display: inline-flex;
}

.portraits__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - var(--header-height) - (var(--space-24) * 2) - 32px);
  object-fit: contain;
  transition: opacity 0.17s ease;
}

@media (prefers-reduced-motion: reduce) {
  .portraits__image {
    transition: none;
  }
}

/* Frameless modifier (LINES/ARTBOX, page-filmstrip-gallery.php) - removes
   the warm-white print-border background/padding only; every other rule
   above (filmstrip, sprockets, numbering, counter, centering,
   object-fit:contain, transition) is untouched and still applies exactly
   as it does for PORTRAITS, since both templates render the same classes.
   Dropping the 16px padding also removes its contribution to the image's
   own max-height budget, so the frameless image gets slightly more usable
   space than the framed one - not a separate layout, just one fewer
   subtracted amount in the same formula. */
.portraits--frameless .portraits__frame-figure {
  background-color: transparent;
  padding: 0;
}

.portraits--frameless .portraits__image {
  max-height: calc(100vh - var(--header-height) - (var(--space-24) * 2));
}

.portraits__counter {
  position: absolute;
  right: 64px;
  bottom: 24px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: var(--nav-letter-spacing);
  color: var(--color-text-muted);
}

.portraits__admin-notice {
  margin: auto;
  padding: var(--space-24);
  max-width: var(--measure-text);
  font-family: var(--font-sans);
  font-size: var(--nav-font-size);
  letter-spacing: var(--nav-letter-spacing);
  color: var(--color-text-muted);
  text-align: center;
}

/* Mobile: filmstrip moves to the bottom, becomes a short horizontally
   scrolling row; sprockets/numbers drop (there isn't room for them at a
   56px frame width without competing with the photograph itself). */
@media (max-width: 900px) {
  .portraits {
    flex-direction: column;
  }

  .portraits__viewer {
    order: 1; /* viewer first row - the markup renders the filmstrip first
                 for tab order, so visual order is flipped here only */
    flex: 1 1 auto;
    padding: 10px;
    min-height: 0;
  }

  .portraits__frame-figure {
    max-width: 100%;
    padding: 10px;
  }

  .portraits__image {
    max-height: calc(100vh - var(--header-height) - 104px - 20px - 20px);
  }

  .portraits__counter {
    right: var(--space-24);
    bottom: var(--space-16);
  }

  .portraits__filmstrip {
    order: 2; /* second row, below the viewer - see the order:1 note above */
    flex: 0 0 104px;
    width: 100%;
    height: 104px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    gap: 8px;
    border-right: 0;
    border-top: 1px solid var(--color-border-subtle);
  }

  .portraits__frame {
    flex: 0 0 56px;
    width: 56px;
    height: 100%;
  }

  .portraits__sprocket,
  .portraits__frame-number {
    display: none;
  }

  .portraits__frame-thumb {
    height: 100%;
  }

  /* Frameless modifier, mobile: same removal as desktop (no background/
     padding), and one fewer subtracted 20px in the max-height budget
     (the frame-figure's own mobile padding no longer exists to account
     for) - the viewer's own 10px top/bottom padding is untouched and
     still subtracted once. */
  .portraits--frameless .portraits__frame-figure {
    padding: 0;
  }

  .portraits--frameless .portraits__image {
    max-height: calc(100vh - var(--header-height) - 104px - 20px);
  }
}
