:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: rgba(0, 0, 0, 0.4);
  --line: rgba(0, 0, 0, 0.08);
  --overlay: hsla(0, 0%, 100%, 0.94);
  --frame: #ffffff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-soft: 0 6px 22px rgba(0, 0, 0, 0.1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  /* Soft, Matas-like decelerate — long settle */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --dur: 0.9s;
  --dur-mid: 0.55s;
  --dur-fast: 0.4s;
  --stage-max-w: 1520px;
  --gutter: clamp(1rem, 2.5vw, 2rem);
  --hover-gutter: clamp(1.25rem, 2.5vw, 2.25rem);
  --base: 20px;
  --radius: 6px;
  --zoom-origin: 50% 50%;
  /* Shared distance from stage top → back chevron (album, about, retouch, gear) */
  --back-from-stage-top: 0px;
  --back-chevron-size: 2.7rem;
  /* Air under the chevron before headings / body text */
  --gap-under-back: 2rem;
  /* Absolute-back pages: pad content past chevron + gap (About, Retouch, Gear, Photo CV) */
  --content-under-back: calc(var(--back-chevron-size) + var(--gap-under-back));
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--base);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

/*
 * Mobile: document (body) must be the scroll container so iOS Safari can
 * collapse the URL bar. Inner overflow:auto on .view does NOT trigger that.
 */
@media (max-width: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
.nav-link:hover {
  opacity: 0.55;
}

/* Logo: no hover fade (keep solid black) */
a.header__title:hover {
  opacity: 1;
}

.muted {
  color: var(--muted);
}

.loading {
  color: var(--muted);
  margin: 2rem 0;
}

/* Hide scrollbars everywhere (scroll still works) */
.scroll-hidden,
.view,
.stage,
.stacks,
.photo-grid {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legacy */
}

.scroll-hidden::-webkit-scrollbar,
.view::-webkit-scrollbar,
.stage::-webkit-scrollbar,
.stacks::-webkit-scrollbar,
.photo-grid::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* —— Shell: full viewport, grid to bottom edge —— */

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-height: 100dvh;
  display: grid;
  grid-template-columns:
    [full-start] 1fr
    [content-start] min(var(--stage-max-w), calc(100% - 2 * var(--gutter)))
    [content-end] 1fr
    [full-end];
  grid-template-rows:
    [header] auto
    [stage] minmax(0, 1fr);
  padding: var(--gutter) 0 0;
  overflow: hidden;
}

.header,
.stage {
  grid-column: content-start / content-end;
}

@media (max-width: 720px) {
  .shell {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
    grid-template-columns: 1fr;
    /* Grow with content so the document can scroll (URL bar collapse) */
    grid-template-rows: auto auto;
  }

  .header,
  .stage {
    grid-column: 1;
  }
}

/* —— Header —— */

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  pointer-events: auto;
  z-index: 5;
  padding-bottom: clamp(1rem, 2.5vh, 1.75rem);
  transform-origin: top left;
  /* Same horizontal inset as stack grid so logo lines up with back arrow
     relative to content — logo stays at true content-left (no inset). */
  padding-left: 0;
  padding-right: 0;
}

.header__brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.header__title {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.header__sub {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.header__nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.nav-link {
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
  text-align: right;
  transition: opacity var(--dur-fast) var(--ease), color var(--dur-fast)
    var(--ease);
}

.nav-link.is-active {
  color: var(--fg);
}

/* —— Stage: fills rest of viewport to bottom —— */

.stage {
  position: relative;
  width: 100%;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  justify-self: stretch;
  padding-bottom: 0;
  /* Allow hover stacks to paint outside the content column a bit */
  overflow: visible;
}

@media (max-width: 720px) {
  .stage {
    height: auto;
    min-height: 60vh;
    margin-top: 0.5rem;
    /* Stage grows with the active view (not a fixed viewport pocket) */
    overflow: visible;
  }
}

.view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: var(--zoom-origin);
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    visibility var(--dur) var(--ease);
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.view[hidden] {
  display: block !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 0, 0) scale(1);
}

/* Mobile: active view in normal document flow → body scroll → URL bar shrinks */
@media (max-width: 720px) {
  .view {
    position: relative;
    inset: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    overscroll-behavior: auto;
    transform: none;
    will-change: opacity;
  }

  .view[hidden],
  .view:not(.is-active) {
    display: none !important;
    position: absolute;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
  }

  .view.is-active {
    display: flex !important;
    flex-direction: column;
    position: relative;
    height: auto;
    min-height: 50vh;
    overflow: visible;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  /* Soft enter/leave animations fight document flow on mobile — keep simple */
  .view.is-entering,
  .view.is-leaving,
  .view--home.is-leaving-zoom-in,
  .view--album.is-entering-zoom-in,
  .view--album.is-leaving-zoom-out,
  .view--home.is-entering-zoom-out {
    transform: none;
  }
}

/* Rest / active */
.view.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 2;
}

.view:not(.is-active) {
  z-index: 0;
}

/* Soft fade for about panel */
.view.is-entering {
  opacity: 0;
  transform: scale(0.97);
}

.view.is-leaving {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

/* Home → album: zoom in toward stack + fade */
.view--home.is-leaving-zoom-in {
  opacity: 0;
  transform: scale(1.14);
  pointer-events: none;
}

.view--album.is-entering-zoom-in {
  opacity: 0;
  transform: scale(1.1);
  visibility: visible;
  pointer-events: none;
}

/* Album → home: zoom out + fade */
.view--album.is-leaving-zoom-out {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.view--home.is-entering-zoom-out {
  opacity: 0;
  transform: scale(0.92);
  visibility: visible;
  pointer-events: none;
}

/* Home fills stage edge-to-edge at bottom */
.view--home {
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.view--album {
  overflow: auto;
  display: flex;
  flex-direction: column;
  /* Avoid content painting in a hairline gap above sticky chrome (Safari) */
  background: var(--bg);
  isolation: isolate;
}

/* —— Stack grid (larger, bottom-flush) —— */

.stacks {
  --stack-row-gap: clamp(1.75rem, 4vh, 3rem);
  --stack-col-gap: clamp(1rem, 2.5vw, 1.75rem);
  /* Scrollable air under last album labels (end of home list) */
  --stack-bottom-air: clamp(3.25rem, 6vh, 4.5rem);
  /* Fixed equal tracks — avoids auto-fill size drift (esp. iPad portrait) */
  --stack-cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--stack-cols), minmax(0, 1fr));
  gap: var(--stack-row-gap) var(--stack-col-gap);
  align-content: start;
  justify-items: stretch;
  width: 100%;
  /*
   * Content-sized height (not flex:1 + min-height:0).
   * With flex:1 the box was locked to the viewport; padding-bottom sat at the
   * viewport bottom while grid items overflowed past it — so end-of-scroll
   * had zero air under the last labels. flex:none grows with rows so padding
   * is truly after the last stack.
   */
  flex: none;
  min-height: 100%;
  box-sizing: border-box;
  padding: 0.25rem var(--hover-gutter) 0;
  padding-bottom: calc(
    var(--stack-bottom-air) + env(safe-area-inset-bottom, 0px)
  );
  overflow: visible;
}

/* Phablet / large phone */
@media (min-width: 520px) {
  .stacks {
    --stack-cols: 2;
  }
}

/* iPad portrait & small tablet: 3 equal columns */
@media (min-width: 700px) and (max-width: 1023px) {
  .stacks {
    --stack-cols: 3;
    --stack-row-gap: clamp(1.75rem, 3.5vh, 2.75rem);
    --stack-col-gap: clamp(1rem, 2vw, 1.5rem);
    --stack-bottom-air: clamp(3.25rem, 5.5vh, 4.25rem);
  }
}

/* iPad landscape / desktop: 4 equal columns */
@media (min-width: 1024px) {
  .stacks {
    --stack-cols: 4;
    --stack-row-gap: clamp(2rem, 5vh, 3.5rem);
    --stack-col-gap: clamp(1.25rem, 2vw, 2rem);
    --stack-bottom-air: clamp(3.5rem, 6.5vh, 4.75rem);
  }
}

.stack {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  /* Fill grid cell evenly — no max-width that shrinks some albums */
  width: 100%;
  max-width: none;
  min-width: 0;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.stack:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
  border-radius: 4px;
}

.stack__pile {
  position: relative;
  width: 100%;
  /* Strict square so every album tile is the same size */
  aspect-ratio: 1 / 1;
  height: auto;
  max-width: none;
  flex: 0 0 auto;
  overflow: visible;
}

.stack__layer {
  position: absolute;
  /* Same inset for every layer so multi/single stacks share footprint */
  inset: 8% 10%;
  background: var(--frame);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transform-origin: center center;
  transition: transform var(--dur-mid) var(--ease);
  will-change: transform;
  backface-visibility: hidden;
}

.stack__layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #eee;
}

/* layered polaroid offsets — keep scales equal (no size drift) */
.stack__layer:nth-child(1) {
  transform: rotate(-5deg) translate3d(-3%, 2%, 0);
  z-index: 1;
}

.stack__layer:nth-child(2) {
  transform: rotate(3.5deg) translate3d(3.5%, -1%, 0);
  z-index: 2;
}

.stack__layer:nth-child(3) {
  transform: rotate(-0.75deg) translate3d(0, 0, 0);
  z-index: 3;
}

/* Single-image albums: same frame size as multi-layer stacks */
.stack--single .stack__layer:nth-child(1) {
  transform: rotate(-1deg) translate3d(0, 0, 0);
}

.stack:hover .stack__layer:nth-child(1),
.stack:focus-visible .stack__layer:nth-child(1) {
  transform: rotate(-11deg) translate3d(-10%, 5%, 0);
}

.stack:hover .stack__layer:nth-child(2),
.stack:focus-visible .stack__layer:nth-child(2) {
  transform: rotate(9deg) translate3d(11%, -4%, 0);
}

.stack:hover .stack__layer:nth-child(3),
.stack:focus-visible .stack__layer:nth-child(3) {
  transform: rotate(0deg) translate3d(0, -5%, 0) scale(1.03);
}

.stack__label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.25;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.25rem;
  /* Fixed label band so long titles don’t change tile height */
  min-height: 1.25em;
  transition: color var(--dur-fast) var(--ease);
}

.stack:hover .stack__label,
.stack:focus-visible .stack__label {
  color: var(--fg);
}

/* —— Album view —— */

.album-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  /*
   * Same distance from stage top as .back-link--view (top: var(--back-from-stage-top)).
   * Path from page top is identical on all views:
   *   shell padding-top (--gutter) + header + stage margin-top + --back-from-stage-top
   */
  margin: var(--back-from-stage-top) 0 0.5rem;
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  isolation: isolate;
  /* Flush left with header logo — no extra inset */
  padding: 0 0 1.35rem;
  margin-left: 0;
  overflow: visible;
  background: linear-gradient(
    to bottom,
    var(--bg) 0%,
    var(--bg) 58%,
    hsla(0, 0%, 100%, 0.92) 78%,
    hsla(0, 0%, 100%, 0) 100%
  );
}

/* Seal subpixel / overscroll gap above sticky bar (Safari) */
.album-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -40px;
  height: 40px;
  background: var(--bg);
  pointer-events: none;
  z-index: -1;
}

/* Same glyph as lightbox__nav--prev (‹). Left edge flush with logo. */
.back-link {
  font-size: var(--back-chevron-size);
  line-height: 1;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 1em;
  min-height: 1em;
  margin: 0;
  padding: 0.02em 0.15em 0.02em 0;
  border-radius: var(--radius);
  overflow: visible;
  transition:
    opacity var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.back-link > span {
  display: block;
  line-height: 1;
}

.back-link:hover {
  color: var(--fg);
  opacity: 1;
}

.back-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.album-title {
  /* Same gap under chevron as About/Retouch/Gear/Photo CV headings */
  margin: var(--gap-under-back) 0 0;
  padding: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/*
 * Masonry photo grid (CSS multi-column), centered in the stage.
 * Items stack tightly; fill order is top-to-bottom, then left-to-right.
 *
 * column-fill MUST stay balance when height is auto: auto-fill packs everything
 * into one tall column (Chrome + Safari) and destroys the masonry.
 *
 * WebKit / Safari (equal-size photos, uneven vertical rhythm e.g. CHGP col 3):
 * - vertical gap via padding-bottom, not margin-bottom (Safari inflates margins
 *   between column boxes with break-inside: avoid)
 * - display:block + width:100% only (inline-block breaks multicol in Chrome)
 * - aspect-ratio from JS so lazy decode does not reflow column balancing
 */
.photo-grid {
  --photo-gap: clamp(0.75rem, 1.5vw, 1.15rem);
  /* Always aim for 4 columns (desktop/tablet); width fills stage for even cols */
  --cols: 4;
  column-gap: var(--photo-gap);
  column-fill: balance;
  column-count: var(--cols);
  column-width: auto;
  padding-bottom: max(3.5rem, calc(3rem + env(safe-area-inset-bottom, 0px)));
  align-self: stretch;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
}

/* Mobile: one column full width (!important beats inline --cols from JS) */
@media (max-width: 699px) {
  .photo-grid {
    --cols: 1 !important;
    width: 100%;
    align-self: stretch;
  }
}

/* iPad portrait: still 4 columns if width allows; slightly tighter gap */
@media (min-width: 700px) and (max-width: 1023px) {
  .photo-grid {
    --cols: 4;
    --photo-gap: clamp(0.55rem, 1.2vw, 0.9rem);
  }
}

.photo-grid__item {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  /* Gap as padding (not margin) — Safari multicol + margin-bottom + break-avoid
     leaves uneven vertical spacing between equal-height photos. */
  margin: 0;
  padding: 0 0 var(--photo-gap);
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  /* Clip image radius only; padding-bottom (gap) stays outside overflow paint */
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 0;
  font-size: 0;
  display: block;
  /* avoid-column: slightly better packing in WebKit than plain "avoid" */
  break-inside: avoid-column;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: none;
  transition:
    transform var(--dur-mid) var(--ease),
    opacity var(--dur-mid) var(--ease);
  transform-origin: center center;
}

.photo-grid__item:hover {
  transform: scale(1.015);
}

/* Click/tap: no ring. Keyboard Tab: soft ring only (not solid black) */
.photo-grid__item:focus {
  outline: none;
  box-shadow: none;
}
.photo-grid__item:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.28);
  outline-offset: 2px;
}

.photo-grid__item img {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: var(--radius);
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  /* Lock box before decode when JS sets --ar / aspect-ratio */
  aspect-ratio: var(--ar, auto);
}

/* —— Text panels (About) ——
 * Must stay position:absolute (from .view) so the panel fills .stage.
 * position:relative here would pull it out of the overlay stack and
 * break deep-links / leave home covering About & Gear.
 */

.view--panel {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  /* do not set position:relative — keep absolute inset:0 from .view */
}

.panel {
  max-width: 34rem;
  padding: 0 0 max(3.5rem, calc(3rem + env(safe-area-inset-bottom, 0px)));
  position: relative;
}

/* About: wider two-column block, centered in the stage (no “About” title) */
.panel--about {
  max-width: min(100%, 52rem);
  width: 100%;
  margin: auto;
  padding-top: var(--content-under-back);
  padding-bottom: max(2.5rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
}

/* Desktop: shift whole about block ~3rem up from vertical center */
@media (min-width: 721px) {
  .panel--about {
    transform: translateY(-3rem);
  }
}

/*
 * Absolute back on about/retouch/gear/photo-cv — same offset as .album-bar
 * margin-top (both use --back-from-stage-top from the stage top).
 */
.back-link--view {
  position: absolute;
  top: var(--back-from-stage-top);
  left: 0;
  z-index: 4;
  margin: 0;
}

/* Ensure flex display wins over .view[hidden]{display:block!important} once shown */
.view--panel:not([hidden]),
.view--gear:not([hidden]),
.view--retouch:not([hidden]),
.view--photo-cv:not([hidden]) {
  display: flex !important;
}

/* —— Photo CV (hidden from menu; ?view=photo-cv; no lightbox) —— */

.view--photo-cv {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 0 0 max(2.5rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
}

.photo-cv {
  width: 100%;
  max-width: min(100%, 1100px);
  margin: 0 auto;
  /* Same heading start as About text (under back chevron) */
  padding: var(--content-under-back) 0 0;
  box-sizing: border-box;
}

.pcv-section {
  margin: 0 0 clamp(2rem, 5vh, 3rem);
}

.pcv-section__title {
  margin: 0 0 1rem;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  max-width: 36rem;
}

/* Fixed column layout — order comes from section.md (stable, not random).
 * Desktop: 3 columns; tablet: 2; mobile: 1.
 */
.pcv-grid {
  display: flex;
  align-items: flex-start;
  gap: clamp(0.55rem, 1.2vw, 0.9rem);
}

.pcv-grid__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.55rem, 1.2vw, 0.9rem);
}

@media (max-width: 899px) {
  .pcv-grid {
    flex-wrap: wrap;
  }

  .pcv-grid__col {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .pcv-grid__col:nth-child(3) {
    flex-basis: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .pcv-grid__col:nth-child(3) .pcv-grid__item {
    flex: 1 1 calc(50% - 0.4rem);
  }
}

@media (max-width: 520px) {
  .pcv-grid {
    flex-direction: column;
  }

  .pcv-grid__col,
  .pcv-grid__col:nth-child(3) {
    flex: 1 1 auto;
    width: 100%;
    flex-direction: column;
  }

  .pcv-grid__col:nth-child(3) .pcv-grid__item {
    flex: 1 1 auto;
  }
}

.pcv-grid__item {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  background: transparent;
}

.pcv-grid__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
}

/* —— Gear view (hidden from menu; ?view=gear) —— */

.view--gear {
  display: flex;
  flex-direction: column;
  overflow: auto;
  /* keep absolute inset:0 from .view */
  padding: 0 0 max(2.5rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
}

.gear {
  width: 100%;
  max-width: min(100%, 960px);
  margin: 0 auto;
  /* Same heading start as About text (under back chevron) */
  padding: var(--content-under-back) 0 0;
  box-sizing: border-box;
}

.gear-section {
  /* Space between Camera / Lenses / Light… blocks */
  margin: 0 0 clamp(3.25rem, 7vh, 5rem);
}

.gear-section__title {
  margin: 0 0 0.85rem;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.gear-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 0.75rem;
}

@media (min-width: 520px) {
  .gear-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem 0.85rem;
  }
}

@media (min-width: 800px) {
  .gear-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.gear-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: inherit;
}

.gear-card__media {
  margin: 0;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: transparent;
  line-height: 0;
}

.gear-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  box-sizing: border-box;
}

.gear-card__title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.gear-card__link {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
}

.gear-card:hover .gear-card__title {
  opacity: 0.7;
}

.gear-card:hover .gear-card__link {
  color: var(--fg);
}

.gear-card:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* —— Retouch view —— */

.view--retouch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: auto;
  /* keep absolute inset:0 from .view */
  padding: 0 0 max(2.5rem, calc(2rem + env(safe-area-inset-bottom, 0px)));
}

.retouch {
  width: 100%;
  max-width: min(100%, 36rem);
  margin: 0 auto;
  padding: var(--content-under-back) 0 0;
  box-sizing: border-box;
}

.retouch__intro {
  margin: 0 0 1.75rem;
  max-width: 36rem;
  font-size: 1.05rem;
  line-height: 1.5;
  text-align: center;
  margin-inline: auto;
}

/* Single column, centered stack of pairs */
.retouch-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Space between each before/after (or sequence) card */
  gap: clamp(3.25rem, 7vh, 5rem);
  width: 100%;
}

.retouch-card {
  min-width: 0;
  width: 100%;
  max-width: 36rem;
}

.retouch-card--wide {
  width: 100%;
  max-width: 36rem;
}

.retouch-card__meta {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.retouch-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.retouch-card__credit {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Before / After compare slider
 * After image is in-flow (sets height). Before is clipped overlay;
 * JS sets before img width = .ba clientWidth so crops align.
 */
.ba {
  --ba-pos: 50%;
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f3f3f3;
  touch-action: none;
  user-select: none;
  cursor: ew-resize;
  line-height: 0;
}

.ba__after {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.ba__before-wrap {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1;
  width: var(--ba-pos);
  overflow: hidden;
  pointer-events: none;
}

.ba__before {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  max-width: none;
  display: block;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.ba__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--ba-pos);
  z-index: 2;
  width: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ba__handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.ba__grip {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: ew-resize;
  color: var(--fg);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

.ba__labels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.55rem;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  padding: 0 0.65rem;
  pointer-events: none;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.ba:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

/* Sequence card */
.seq {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f3f3f3;
  line-height: 0;
}

.seq__img {
  width: 100%;
  height: auto;
  display: block;
  background: #f3f3f3;
}

.seq__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.seq__chip {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.seq__chip:hover {
  color: var(--fg);
  border-color: rgba(0, 0, 0, 0.2);
}

.seq__chip.is-active {
  color: var(--fg);
  border-color: var(--fg);
  background: rgba(0, 0, 0, 0.04);
}

.seq__chip:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.panel__title {
  margin: 0.35rem 0 1rem;
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/*
 * About: bio + links left, photo right.
 * Stack on narrow viewports (text first, then photo).
 */
.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.25rem, 3.5vw, 2.75rem);
  align-items: start;
}

.about-photo {
  margin: 0;
  line-height: 0;
  min-width: 0;
}

.about-photo img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  object-fit: cover;
}

.about-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.prose p {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  line-height: 1.55;
  font-weight: 400;
}

/* Matas-style channel labels (Email / LinkedIn / Instagram) */
.about-links {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.about-links a {
  color: var(--fg);
  text-decoration: none;
  font-size: 1.05rem;
  line-height: 1.45;
  transition: opacity var(--dur-fast) var(--ease);
}

.about-links a:hover {
  opacity: 0.55;
}

@media (max-width: 720px) {
  /* Back arrow: same top as album/gear (top: 0 via .back-link--view) */
  .view--panel.is-active,
  .view--retouch.is-active {
    padding-top: 0;
    box-sizing: border-box;
  }

  .about-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .about-photo {
    max-width: 100%;
  }
}

/* —— Lightbox ——
 * Safari crops portrait images when max-height uses 90vh/100vh larger than the
 * *visible* viewport (browser chrome). Prefer 100svh fallback + JS visualViewport
 * vars (--vv-w/--vv-h). Figure fills the grid cell (definite size); img is
 * max 100% of that cell — no circular max-width:100% on auto parent.
 */

.lightbox {
  --lb-pad-t: max(1.25rem, env(safe-area-inset-top, 0px));
  --lb-pad-r: max(1.25rem, env(safe-area-inset-right, 0px));
  --lb-pad-b: max(1.25rem, env(safe-area-inset-bottom, 0px));
  --lb-pad-l: max(1.25rem, env(safe-area-inset-left, 0px));
  --lb-nav: 2.75rem;
  position: fixed;
  top: 0;
  left: 0;
  /* Default: small viewport (never taller than chrome-visible area).
     JS overrides with visualViewport size + offset while open. */
  width: 100%;
  width: var(--vv-w, 100%);
  height: 100svh;
  height: var(--vv-h, 100svh);
  max-height: 100svh;
  max-height: var(--vv-h, 100svh);
  z-index: 50;
  box-sizing: border-box;
  overflow: hidden;
  background: var(--overlay);
  display: grid;
  grid-template-columns: var(--lb-nav) minmax(0, 1fr) var(--lb-nav);
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  padding: var(--lb-pad-t) var(--lb-pad-r) var(--lb-pad-b) var(--lb-pad-l);
  /*
   * Fade only opacity (not visibility) — Safari often drops opacity transitions
   * when visibility is also animated, so close felt like the old long delay.
   */
  --lb-fade: 0.14s;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--lb-fade) ease-out;
}

.lightbox[hidden] {
  display: grid !important;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.lightbox.is-open {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

/* Closing: stay visible so Safari paints the opacity fade, then JS sets [hidden] */
.lightbox.is-closing {
  visibility: visible;
  pointer-events: none;
  opacity: 0;
}

.lightbox.is-closing .lightbox__figure img {
  /* Kill long enter animation / img transitions so they don't lag close in WebKit */
  animation: none !important;
  transition: none !important;
}

.lightbox__figure {
  margin: 0;
  /* Fill middle grid cell — definite containing block for the img */
  width: 100%;
  height: 100%;
  max-width: min(1400px, 100%);
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  line-height: 0;
  overflow: hidden;
}

.lightbox__figure img {
  display: block;
  /* Fallback before JS fitLightboxImage() sets explicit px size */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  box-shadow: var(--shadow);
  transform: scale(1);
  /* Only animate opacity/transform — never width/height (JS sets those) */
  transition:
    transform var(--dur) var(--ease),
    opacity var(--dur-mid) var(--ease);
}

/* Open animation only — not on prev/next src swaps (class toggled in JS) */
.lightbox.is-open .lightbox__figure img.is-entering {
  animation: lightbox-in var(--dur) var(--ease) both;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.96) translate3d(0, 8px, 0);
  }
  to {
    opacity: 1;
    transform: scale(1) translate3d(0, 0, 0);
  }
}

/* macOS-style: close control top-left — same radius as back arrow / photos */
.lightbox__close,
.lightbox__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-radius: var(--radius);
  line-height: 1;
  user-select: none;
  transition:
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

.lightbox__close {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  left: max(1.25rem, env(safe-area-inset-left, 0px));
  right: auto;
  z-index: 60;
  font-size: 1.75rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.lightbox__nav {
  font-size: 2.25rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
}

.lightbox__nav:hover,
.lightbox__close:hover {
  color: var(--fg);
  opacity: 1;
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* —— Auth gate (work-in-progress, same idea as Opskriftsbanken) —— */

html.auth-locked body > :not(#auth-gate) {
  visibility: hidden !important;
  pointer-events: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: var(--bg);
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-card {
  width: min(100%, 22rem);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
}

.auth-card__title {
  margin: 0 0 0.2rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-card__sub {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.auth-card__text {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 0.65rem;
  text-align: left;
}

.auth-label {
  display: block;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--fg);
}

.auth-input:focus {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.auth-error {
  margin: 0;
  color: #a11;
  font-size: 0.88rem;
  text-align: center;
}

.auth-submit {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  background: var(--fg);
  color: #fff;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease);
}

.auth-submit:hover {
  opacity: 0.85;
}

.auth-submit:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Reduced motion —— */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .stack:hover .stack__layer,
  .stack:focus-visible .stack__layer {
    transform: none;
  }

  .lightbox.is-open .lightbox__figure img.is-entering {
    animation: none;
  }
}
