:root {
  --bg: #8a8a8a;      /* a step lighter than 18% grey (#777), the photographer's middle grey */
  --paper: #ffffff;
  --night: #000000;
  --card: #1b1b1c;
  --card-inset: 48px;
  --ink: #141414;
  --ink-strong: #000000;
  --muted: rgb(0 0 0 / 0.55);

  --font: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --tracking: 0.3px;

  --nav-h: 100px;
  --photo-max-w: 60vw;
  --photo-max-h: 53.5vh;

  --thumb-w: 150px;
  --thumb-gap-x: 40px;
  --thumb-gap-y: 40px;
  --thumbs-pad-top: 40px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: var(--tracking);
  -webkit-font-smoothing: antialiased;
}

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

img { display: block; }

/* ---------- Intro ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--night);
  color: var(--paper);
  cursor: pointer;
}

.intro-text {
  text-align: center;
}

.intro-name,
.intro-role {
  margin: 0;
  font-size: 16px;
  line-height: 1.86;
  letter-spacing: var(--tracking);
  opacity: 0;
}

.intro-name {
  font-weight: 500;
}

.intro-role {
  font-weight: 400;
  color: rgb(255 255 255 / 0.62);
}

/* ---------- Index (single photo) ---------- */

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
}

/* The copy that flies between the big photo and its thumbnail */
.fly {
  position: fixed;
  z-index: 14;
  object-fit: cover;
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

.photo {
  max-width: var(--photo-max-w);
  max-height: var(--photo-max-h);
  width: auto;
  height: auto;
  object-fit: contain;
  -webkit-user-drag: none;
}

.caption {
  display: none;
}

/* ---------- Thumbs ---------- */

.thumbs {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  padding: var(--thumbs-pad-top) 0 calc(var(--nav-h) + 40px);
  -webkit-overflow-scrolling: touch;
}

.thumbs[hidden] { display: none; }

.thumbs {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Grid sits in the middle of the free space; auto margins fall back to 0 when it overflows */
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, var(--thumb-w));
  justify-content: center;
  align-items: start;
  column-gap: var(--thumb-gap-x);
  row-gap: var(--thumb-gap-y);
  width: 100%;
  max-width: calc(6 * var(--thumb-w) + 5 * var(--thumb-gap-x));
  margin: auto;
}

/* ---------- Segment picker (top of Thumbs) ---------- */

.segments {
  position: relative;
  z-index: 5;
  flex: none;
}

.segments-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-strong);
  transition: opacity 200ms var(--ease-out);
}

.segments-toggle:hover .segments-chevron { transform: translateY(1px); }
.segments-toggle[aria-expanded="true"] .segments-chevron { transform: rotate(180deg); }
.segments-toggle:active { opacity: 0.55; }
.segments-toggle:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

.segments-chevron {
  width: 11px;
  height: 7px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 320ms var(--ease-out);
}

.segments-list {
  position: absolute;
  top: 100%;
  left: 50%;
  margin: 6px 0 0;
  padding: 10px 0;
  min-width: 140px;
  list-style: none;
  text-align: center;
  background: var(--bg); /* reads cleanly over the thumbnails below */
  transform: translateX(-50%);
}

.segments-list[hidden] { display: none; }

.segment-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 10px;
  font-size: 14px;
  color: var(--muted);
  transition: color 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.segment-btn:hover,
.segment-btn.is-current { color: var(--ink-strong); }
.segment-btn.is-current { font-weight: 500; }
.segment-btn:active { opacity: 0.55; }
.segment-btn:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* Dense layout for large galleries: the original 85px, 11-across grid */
.thumbs-grid.is-dense {
  grid-template-columns: repeat(auto-fill, 85px);
  column-gap: 30px;
  row-gap: 32px;
  max-width: calc(11 * 85px + 10 * 30px);
  margin: 32px auto 0;
}

.thumb {
  display: block;
  width: 100%;
  opacity: 0;
}

.thumb img {
  width: 100%;
  height: auto;
  background: rgb(0 0 0 / 0.08);
  transition: opacity 260ms var(--ease-out);
}

.thumb:active img { opacity: 0.7; }
.thumb:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--nav-h);
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* Keeps the nav readable when the grid scrolls underneath it */
body[data-mode="thumbs"] .nav {
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

.nav-row {
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.nav-row[hidden] { display: none; }

.nav-row[data-for="index"] { font-size: 12px; }

.nav-btn {
  padding: 8px 0;
  font-weight: 400;
  color: var(--ink);
  transition: color 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.nav-btn.is-active {
  font-weight: 500;
  color: var(--ink-strong);
}

.nav-btn:hover { color: var(--ink-strong); }
.nav-btn:active { opacity: 0.55; }
.nav-btn:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

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

.nav-sep {
  width: 19px;
  height: 1px;
  margin: 0 10px;
  background: var(--ink);
}

.nav-label { color: var(--ink); }

/* Info sits in the same bar as Index/Thumbs, so it fades with them */
.nav-info {
  position: absolute;
  right: 28px;
  top: 50%;
  translate: 0 -50%;
  padding: 14px 12px;
  font-size: 12px;
  pointer-events: auto;
}

.nav-info[hidden] { display: none; }

/* ---------- Info card ---------- */

.info {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
}

.info[hidden] { display: none; }

/* Dark grey card the size of an enlarged photo. Left-aligned like a letterhead: name at
   the top, contacts and quote at the foot, all held half an inch (48px) in from the edges. */
.info-card {
  display: flex;
  width: min(var(--photo-max-w), calc(var(--photo-max-h) * 0.8));
  aspect-ratio: 4 / 5;
  padding: var(--card-inset);
  background: var(--card);
  color: var(--paper);
  text-align: left;
}

.info-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
}

.info-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.info-name,
.info-role {
  margin: 0;
  font-size: 16px;
  line-height: 1.86;
  letter-spacing: var(--tracking);
}

.info-name { font-weight: 500; }
.info-role { font-weight: 400; color: rgb(255 255 255 / 0.62); }

.info-contacts {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 2.1;
}

.info-contacts a {
  color: rgb(255 255 255 / 0.82);
  text-decoration: none;
  transition: color 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.info-contacts a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.info-contacts a:active { opacity: 0.6; }
.info-contacts a:focus-visible { outline: 1px solid #fff; outline-offset: 3px; }

.info-quote {
  max-width: 230px;
  margin: 28px 0 0;
  padding-top: 22px;
  border-top: 1px solid rgb(255 255 255 / 0.14);
}

.info-quote blockquote {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: rgb(255 255 255 / 0.7);
}

.info-quote figcaption {
  margin-top: 10px;
  font-size: 11px;
  color: rgb(255 255 255 / 0.42);
}

.nav-dash {
  margin: 0 5px;
  color: var(--muted);
}

/* ---------- Cursor label ---------- */

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  pointer-events: none;
  white-space: nowrap;
  /* Always black, the same as the buttons */
  color: var(--ink-strong);
  transition: opacity 120ms var(--ease-out);
  opacity: 0;
  will-change: transform;
}

.cursor.is-visible { opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  body[data-mode="index"]:not(.in-nav) .stage { cursor: none; }
  body[data-mode="thumbs"] .thumb { cursor: none; }
}

/* ---------- Touch / small screens ---------- */

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }

  .caption {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-h) - 10px);
    margin: 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
  }

  body[data-mode="thumbs"] .caption { opacity: 0; }
}

@media (max-width: 700px) {
  :root {
    --nav-h: 84px;
    --photo-max-w: calc(100vw - 32px);
    --photo-max-h: 62vh;
    --thumbs-pad-top: 28px;
  }

  .nav-info { right: 4px; }

  :root { --card-inset: 28px; }

  .thumbs-grid,
  .thumbs-grid.is-dense {
    grid-template-columns: repeat(3, 1fr);
    column-gap: 14px;
    row-gap: 18px;
    padding: 0 16px;
  }

  .thumbs-grid.is-dense {
    grid-template-columns: repeat(4, 1fr);
    column-gap: 10px;
    row-gap: 12px;
    margin-top: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thumb img, .nav-btn, .cursor { transition: none; }
}
