/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--page-background);  /* one gradient over the whole page height */
  color: var(--ink);
  font: 400 var(--size-text)/1.6 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

/* Paints the phone's status-bar band behind the sticky header */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--paper);
}

main { flex: 1; outline: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, p, figure { margin: 0; }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

.page {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
}
.skip-link:focus { left: 8px; }

.noscript { padding: 24px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  background: var(--paper);
}

.site-name {
  font: 300 1.3125rem/1 var(--font-display);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  gap: clamp(16px, 2.2vw, 34px);
  font-size: 0.875rem;
}

.site-nav a {
  position: relative;
  padding-block: 6px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: color 0.25s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after { transform: scaleX(1); }

.menu-button { display: none; font-size: 0.875rem; padding: 8px 0 8px 16px; }

/* Phone menu: narrow windows, upright tablets and phones (see css/tokens.css) */
@media (max-width: 900px),
       (pointer: coarse) and (orientation: portrait),
       (pointer: coarse) and (max-height: 500px) {
  .menu-button { display: block; position: relative; z-index: 2; }

  .site-nav {
    position: fixed;
    inset: 0;
    z-index: 1;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
    padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
    background: var(--paper);
    font: 300 clamp(1.75rem, 7vw, 2.25rem)/1.3 var(--font-display);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s ease, visibility 0.25s;
  }

  .site-nav a { align-self: flex-start; color: var(--ink); }
  .site-nav a::after { bottom: 6px; }

  .menu-open .site-nav { visibility: visible; opacity: 1; }
  .site-name { position: relative; z-index: 2; }
}

/* ---------- Homepage ---------- */
.home-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(32px, 5vw, 80px);
  padding-bottom: clamp(48px, 7vw, 96px);
}

.home-tagline {
  flex: 0 1 15rem;
  min-width: 0;
  font: 300 var(--size-lead)/1.4 var(--font-display);
  text-wrap: balance;
}

.home-photos {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: clamp(10px, 1.4vw, 20px);
  --hero-height: calc(100svh - var(--header-height) - 28px);
}

/* No crop: the photo scales until it reaches either limit */
.home-photos img { width: auto; height: auto; }

.home-photos--single img {
  max-height: var(--hero-height);
  max-width: min(100%, calc(100vw - 2 * var(--gutter) - 15rem - clamp(32px, 5vw, 80px)));
}

.home-photos--triptych img {
  max-height: var(--hero-height);
  flex: 0 1 auto;
  min-width: 0;
}

/* Covers keep their own proportions and share a baseline */
.category-index {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: clamp(10px, 1.4vw, 20px);
  padding-bottom: clamp(56px, 8vw, 112px);
}

.category-link { display: block; }

.category-link img {
  width: 100%;
  height: auto;
  background: var(--placeholder);
  transition: opacity 0.35s ease;
}

.category-link:hover img { opacity: 0.86; }

.category-link span {
  display: block;
  padding-top: 10px;
  font-size: 0.875rem;
}

@media (max-width: 1024px) {
  .home-hero { flex-direction: column-reverse; align-items: stretch; gap: 28px; }
  .home-tagline { flex: none; max-width: 22rem; }
  .home-photos--single img { max-width: 100%; margin-inline: auto; }
}

@media (max-width: 640px) {
  .home-photos--triptych { flex-direction: column; }
  .home-photos--triptych img { width: 100%; height: auto; }

  .category-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 10px; }
  .category-link:first-child { grid-column: 1 / -1; }
}

/* ---------- Homepage slider ---------- */

/*
  The slider homepage is the header plus the slider, filling the window
  exactly. The slider takes whatever height the header leaves, so no page
  scroll appears. Other pages are not affected.
*/
.home-fit body { height: 100vh; height: 100dvh; min-height: 0; }
.home-fit main { display: flex; flex-direction: column; min-height: 0; }
.home-fit .site-footer { display: none; }

.slider {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--slider-background);
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: var(--slider-background);
  transition: opacity var(--slider-fade) cubic-bezier(0.4, 0, 0.2, 1);
}

/* The new slide fades in on top; the old one stays put underneath until then. */
.slide.is-leaving { opacity: 1; z-index: 1; transition: none; }
.slide.is-active { opacity: 1; z-index: 2; }

.slide-image { user-select: none; -webkit-user-select: none; }

/*
  "full": the whole photo, never cropped, centred, as large as the slider
  allows with a white frame of --slider-frame on every side. Where the window
  is shaped differently from the photo, the white is wider on two sides.
*/
.slide--full {
  padding: var(--slider-frame);
  padding-left: max(var(--slider-frame), env(safe-area-inset-left, 0px));
  padding-right: max(var(--slider-frame), env(safe-area-inset-right, 0px));
}

.slide--full .slide-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

/* "center": the whole photo, small and centred on white, like a print on a wall */
.slide--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide--center .slide-image {
  width: auto;
  height: var(--slider-portrait-height);
  max-width: min(80%, var(--slider-portrait-max-width));
  object-fit: contain;
}

/*
  "triptych": several photos side by side as one slide, all the same height,
  with equal gaps, centred. The row is as tall as --slider-triptych-height
  allows, and lower where the window is too narrow for it (the photos'
  proportions, --triptych-ratio, are read by js/slider.js). Never cropped.
*/
.slide--triptych {
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-triptych {
  display: flex;
  gap: var(--slider-triptych-gap);
  height: min(
    var(--slider-triptych-height),
    calc((100cqw - 2 * var(--gutter) - (var(--triptych-count, 3) - 1) * var(--slider-triptych-gap)) / var(--triptych-ratio, 2))
  );
}

.slide-triptych .slide-image {
  flex: none;
  width: auto;
  height: 100%;
}

/* Phones held upright: three across would be tiny, so the photos stand in a
   column, top to bottom in the same order, sharing the slider height. */
@media (max-width: 599px) and (orientation: portrait) {
  .slide-triptych { flex-direction: column; height: auto; }
  .slide-triptych .slide-image {
    height: calc((100cqh - 2 * var(--gutter) - (var(--triptych-count, 3) - 1) * var(--slider-triptych-gap)) / var(--triptych-count, 3));
  }
}

.slider-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 112px;
  transform: translateY(-50%);
  color: var(--ink);
  opacity: 0.5;
  transition: opacity 0.3s ease, color 0.6s ease;
}

.slider-arrow:hover,
.slider-arrow:focus-visible { opacity: 1; }
.slider-arrow:focus-visible { outline: 1px solid currentColor; outline-offset: -8px; }
.slider-arrow svg { display: block; overflow: visible; }

.slider-arrow--prev { left: max(clamp(0px, 1vw, 16px), env(safe-area-inset-left, 0px)); }
.slider-arrow--next { right: max(clamp(0px, 1vw, 16px), env(safe-area-inset-right, 0px)); }

/* Set per slide with "arrows" in site.js */
.slider--prev-light .slider-arrow--prev,
.slider--next-light .slider-arrow--next { color: #ffffff; opacity: 0.75; }
.slider--prev-light .slider-arrow--prev:hover,
.slider--next-light .slider-arrow--next:hover,
.slider--prev-light .slider-arrow--prev:focus-visible,
.slider--next-light .slider-arrow--next:focus-visible { opacity: 1; }

@media (max-width: 599px) {
  .slider-arrow { width: 44px; height: 88px; }
  .slider-arrow svg { width: 11px; height: 24px; }
}

/* ---------- Category pages ---------- */

/*
  The category name, top left, on its own: the same spacing on every
  category page. It starts at the left edge of the photos below it.
  (Travel sets --diary-inset when its opening is narrower than the page.)
*/
.page-head {
  /* Top spacing 12px less than the original clamp(16px, 2.2vw, 32px). To undo, remove "calc(" and " - 12px)". */
  padding-block: calc(clamp(16px, 2.2vw, 32px) - 12px) clamp(18px, 2vw, 28px);
  margin-left: var(--diary-inset, 0px);
}

.page-title {
  font: 300 var(--size-title)/1.15 var(--font-display);
  letter-spacing: -0.005em;
  text-wrap: balance;
}

/* Travel and Sport & Outdoor: the category name 8% smaller, same style otherwise. */
.page--diary .page-title,
.page--editorial .page-title { font-size: calc(var(--size-title) * 0.92); }

/* Tile positions are calculated in js/gallery.js */
.gallery {
  position: relative;
  margin-bottom: clamp(48px, 6vw, 80px);
}

.tile {
  position: absolute;
  display: block;
  overflow: hidden;
  background: var(--placeholder);
  cursor: zoom-in;
  animation: tile-in 0.5s ease both;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.35s ease;
}

.tile:hover img { opacity: 0.88; }

@keyframes tile-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gallery-empty { color: var(--ink-soft); }

/* ---------- Travel diary ---------- */

/* Heading and spacing come from the shared gallery styles, as in Portraits */
/* Sport & Outdoor ("editorial") uses the full page width, as Portraits does. */
.page--diary { max-width: calc(var(--travel-width) + 2 * var(--gutter)); }

/* Sport & Outdoor: the photos 10% smaller, centred, with more room at the sides. Phones keep the full width. */
@media (min-width: 600px) {
  .page--editorial .page-head,
  .page--editorial .gallery { width: 90%; margin-inline: auto; }
}

.diary-notes { position: absolute; inset: 0; pointer-events: none; }

.diary-caption {
  position: absolute;
  font: italic 300 0.9375rem/1.3 var(--font-display);
  color: var(--ink-soft);
}

/* ---------- Stays & Spaces ---------- */

/* The gallery uses the full page width, as Portraits does. */

.spaces-notes { position: absolute; inset: 0; pointer-events: none; }

/* Section headings: a small spaced title and the place under it */
.spaces-heading { position: absolute; display: grid; gap: 1px; }

.spaces-heading h2 {
  font: 500 0.75rem/1.4 var(--font-text);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.spaces-heading p {
  font: italic 300 0.9375rem/1.35 var(--font-display);
  color: var(--ink-soft);
}

/* ---------- Full-width opening photo ---------- */

/* Full width where the height allows it. Otherwise the whole photo stays visible. */
.category-opening {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: clamp(12px, 1.3vw, 18px);
  cursor: zoom-in;
}

.category-opening img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100svh - var(--header-height) - 12px);
}

.category-closing {
  padding-bottom: clamp(32px, 4vw, 56px);
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.category-closing a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.gallery:has(+ .category-closing) { margin-bottom: 24px; }

/* ---------- About and Contact ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
  padding-block: clamp(20px, 3vw, 44px) clamp(56px, 8vw, 112px);
}

.split img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100svh - var(--header-height) - 28px);
  background: var(--placeholder);
}

.prose {
  display: grid;
  gap: 1.1em;
  max-width: 34rem;
  min-width: 0;
}

.prose .page-title { padding-bottom: 0.25em; }
.prose p:not(.lead) { color: var(--ink); }
.prose .lead { font: 300 var(--size-lead)/1.5 var(--font-display); }

/* Contact: the last page of a magazine. A large heading and a quiet line on
   the left; the details sit lower on the right, under thin rules. */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  column-gap: clamp(48px, 8vw, 160px);
  align-items: end;
  align-content: center;  /* the composition sits a little above the middle of the window */
  min-height: calc(100svh - var(--header-height) - 96px);
  padding-block: clamp(40px, 8vh, 112px) clamp(56px, 10vh, 136px);
}

.contact-heading {
  font: 300 clamp(3.25rem, 1.6rem + 5.2vw, 7.5rem)/0.98 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Keeps the heading exactly where it stood when a two-line sentence sat below it. */
.contact-intro { padding-bottom: calc(4.4 * clamp(1.0625rem, 0.95rem + 0.45vw, 1.3125rem)); }

.contact-details {
  position: relative;
  left: -75px;  /* the details sit a little closer to the heading, at the same width */
  display: grid;
  gap: 22px;
  margin: 0;
  padding-bottom: 0.6em;
}

.contact-row {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.contact-row dt {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.contact-row dd {
  margin: 0;
  min-width: 0;
  font: 300 1.3125rem/1.35 var(--font-display);
  overflow-wrap: anywhere;
}

.contact-link {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 0.2s ease;
  user-select: text;
}
.contact-link:hover,
.contact-link:focus-visible { text-decoration-color: currentColor; }

.copy-button {
  margin-left: 14px;
  font-family: var(--font-text);
  font-size: var(--size-small);
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.copy-button:hover { color: var(--ink); }

/* About: an editorial spread. The portrait sits on the left, a little in
   from the edge; the name, a quiet line and the biography start level with
   its top edge on the right. */
.about {
  /* The first column is as wide as the portrait, so the gap alone sets the distance to the text. */
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: clamp(48px, 14vw, 280px);
  align-items: start;
  padding-block: clamp(24px, 3vw, 48px) clamp(64px, 9vw, 128px);
}

.about-portrait { margin: 0 0 0 38px; }

/* 82% of the window height that was used before, so the portrait leads without dominating */
.about-portrait img {
  max-height: calc((100svh - var(--header-height) - 72px) * 0.82);
  background: none;
}

.about-text {
  max-width: 31rem;
  gap: 1.15em;
  margin-top: 25px;  /* the text starts a little below the top of the portrait */
  padding-bottom: clamp(0px, 3vw, 48px);
}

.about-head { display: grid; gap: 8px; margin-bottom: 1.6em; }

.about-name {
  font: 300 clamp(2.2rem, 1.672rem + 1.936vw, 3.3rem)/1.05 var(--font-display);
  letter-spacing: -0.01em;
}

.about-role {
  font: italic 300 calc(var(--size-lead) * 0.92)/1.4 var(--font-display);
  color: var(--ink-soft);
}

.about-text p:not(.about-role) { font-size: 0.956rem; line-height: 1.75; }

@media (max-width: 760px),
       (pointer: coarse) and (orientation: portrait),
       (pointer: coarse) and (max-height: 500px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}

/* Contact on phones, upright tablets and narrow windows: the details below the heading. */
@media (max-width: 900px),
       (pointer: coarse) and (orientation: portrait),
       (pointer: coarse) and (max-height: 500px) {
  .contact {
    grid-template-columns: minmax(0, 1fr);
    row-gap: clamp(48px, 10vw, 72px);
    align-items: start;
    align-content: start;
    min-height: 0;
  }
  .contact-intro { padding-bottom: 0; }
  .contact-details { left: 0; }
}

/* About on phones, upright tablets and narrow windows: the portrait above the text. */
@media (max-width: 900px),
       (pointer: coarse) and (orientation: portrait),
       (pointer: coarse) and (max-height: 500px) {
  .about { grid-template-columns: minmax(0, 1fr); row-gap: clamp(32px, 8vw, 56px); }
  .about-portrait { margin-left: 0; }
  .about-portrait img { max-height: 78svh; }
  .about-text { margin-top: 0; padding-bottom: 0; }
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 24px;
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: 0 28px;
  font-size: var(--size-small);
  color: var(--ink-soft);
}

/* ---------- Phones: homepage and Contact ---------- */

/* Parts that exist on phones only. */
.home-signature,
.menu-icon { display: none; }

/*
  Phones (up to 767 px wide). Larger screens are not affected by anything here.
  Homepage: the name, centred, in spaced capitals; the slider; and
  "maciejurban.com" small at the bottom. Every page: the menu button is three
  thin lines instead of the word "Menu". Contact: centred, a little lower.
*/
@media (max-width: 767px) {
  /* Menu button: three thin lines, 22 px wide, in a 44 px touch area whose
     right edge keeps to the page margin. The word stays for screen readers. */
  .menu-button {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .menu-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .menu-icon {
    display: block;
    width: 22px;
    height: 15px;
    background:
      linear-gradient(currentColor, currentColor) 0 0 / 100% 1px no-repeat,
      linear-gradient(currentColor, currentColor) 0 7px / 100% 1px no-repeat,
      linear-gradient(currentColor, currentColor) 0 14px / 100% 1px no-repeat;
  }

  .home-fit .site-header { justify-content: center; }

  .home-fit .site-name {
    top: 19px;              /* a little lower; the header and the menu button stay put */
    padding-left: 0.22em;   /* balances the letter spacing after the last letter */
    font: 300 clamp(1.0625rem, 5.4vw, 1.4375rem)/1 var(--font-display);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink);
  }

  /* The menu button stays at the right, its middle line level with the middle
     of the capitals of the name, which sits 19 px low. Measured at 375-430 px
     wide, that middle is 18.0-18.4 px below the header's centre. */
  .home-fit .menu-button {
    position: absolute;
    top: calc(50% + 18px);
    right: max(var(--gutter), env(safe-area-inset-right, 0px));
    transform: translateY(-50%);
  }

  /* Phone slider: one portrait at a time, every one in the same frame. */
  .slide--portrait {
    container-type: size;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--slider-frame);
    padding-left: max(var(--slider-frame), env(safe-area-inset-left, 0px));
    padding-right: max(var(--slider-frame), env(safe-area-inset-right, 0px));
  }

  /* The frame's size comes from the slider alone, never from the photo, so it
     is fixed before any photo loads and identical on every slide. */
  .slide--portrait .slide-image {
    flex: none;
    width: min(100cqw, calc(100cqh * (var(--portrait-ratio, 2 / 3))));
    height: auto;
    aspect-ratio: var(--portrait-ratio, 2 / 3);
    object-fit: cover;
    object-position: 50% 50%;
  }

  .home-signature {
    display: block;
    flex: none;
    padding: 6px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px));
    background: var(--slider-background);
    font-size: 0.75rem;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-align: center;
    color: var(--ink);
  }

  /* Contact: centred; the heading 38 px lower, the details 95 px lower, a little smaller. */
  .contact {
    text-align: center;
    padding-top: calc(clamp(40px, 8vh, 112px) + 38px);
  }
  .contact-details { margin-top: 57px; }
  .contact-row dt { font-size: 0.65rem; }
  .contact-row dd { font-size: 1.15rem; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--lightbox);
  color: var(--ink);
  overflow: hidden;
  outline: none;
}

.lightbox::backdrop { background: var(--lightbox); }

.lightbox[open] { animation: tile-in 0.3s ease both; }

.lightbox-figure {
  position: absolute;
  inset: 64px clamp(16px, 7vw, 110px) 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lightbox-figure img {
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  touch-action: pan-y;
}

.lightbox-figure figcaption {
  flex: none;
  font-size: var(--size-small);
  color: var(--ink-soft);
  text-align: center;
}
.lightbox-figure figcaption:empty { display: none; }

.lightbox-count {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: max(var(--gutter), env(safe-area-inset-left, 0px));
  font-size: var(--size-small);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.lightbox-button {
  position: absolute;
  font-size: var(--size-small);
  color: var(--ink-soft);
  padding: 12px;
  transition: color 0.2s ease;
}
.lightbox-button:hover { color: var(--ink); }

.lightbox-close {
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: max(calc(var(--gutter) - 12px), env(safe-area-inset-right, 0px));
}

.lightbox-prev, .lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: clamp(16px, 7vw, 110px);
  height: 40%;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}
.lightbox-prev { left: env(safe-area-inset-left, 0px); }
.lightbox-next { right: env(safe-area-inset-right, 0px); }

/* On phones and upright tablets, navigation moves under the photo so it stays reachable by thumb */
@media (max-width: 760px),
       (pointer: coarse) and (orientation: portrait),
       (pointer: coarse) and (max-height: 500px) {
  .lightbox-figure { inset: 56px 12px 64px; }
  .lightbox-prev, .lightbox-next {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: auto;
    height: auto;
    padding: 12px 16px;
  }
}

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
