:root {
  --page: #f2f0eb;
  --paper: #f7f5f0;
  --ink: #1d1e1d;
  --muted: #676a68;
  --line: #c9c7c1;
  --line-soft: rgba(29, 30, 29, 0.13);
  --gutter: clamp(22px, 4.5vw, 68px);
  --max: 1500px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  left: 18px;
  top: 14px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--page);
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.gallery-header {
  width: min(calc(100% - (2 * var(--gutter))), var(--max));
  margin: 0 auto;
  padding: 28px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.gallery-home {
  display: inline-flex;
  gap: 8px;
  text-decoration: none;
}

.gallery-home:hover,
.gallery-home:focus-visible {
  color: var(--ink);
}

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

main {
  width: min(calc(100% - (2 * var(--gutter))), var(--max));
  margin: 0 auto;
  padding-bottom: clamp(80px, 10vw, 150px);
}

.gallery-opening {
  max-width: 760px;
  padding: clamp(96px, 12vw, 175px) 0 clamp(68px, 8vw, 112px);
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-opening h1 {
  margin: 0;
  font-size: clamp(3.4rem, 8vw, 7.5rem);
  font-weight: 430;
  letter-spacing: -0.065em;
  line-height: 0.92;
}

.gallery-lede {
  margin: 1.4rem 0 0;
  max-width: 560px;
  font-size: clamp(1.05rem, 1.7vw, 1.35rem);
  line-height: 1.45;
}

.gallery-random-note {
  margin: 2rem 0 0;
  max-width: 540px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: clamp(24px, 3.8vw, 58px);
  row-gap: clamp(55px, 7vw, 96px);
  align-items: start;
}

.story-card {
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.story-card figure {
  margin: 0 0 16px;
}

.story-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: contain;
  object-position: left bottom;
}

.story-card-copy {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.story-card h2 {
  margin: 0;
  font-size: clamp(1.16rem, 1.55vw, 1.48rem);
  font-weight: 470;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.story-card-copy p {
  margin: 0.55rem 0 0;
  max-width: 300px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.48;
}

.story-card-copy > span {
  display: block;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story-card[href] img,
.story-card[href] h2 {
  transition: opacity 150ms ease, transform 150ms ease;
}

.story-card[href]:hover img,
.story-card[href]:focus-visible img {
  opacity: 0.88;
}

.story-card[href]:hover h2,
.story-card[href]:focus-visible h2 {
  transform: translateX(4px);
}

.story-card[href]:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 8px;
}

.story-card--future {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.story-future-space {
  min-height: clamp(90px, 11vw, 170px);
}

.story-gap {
  min-height: clamp(150px, 20vw, 315px);
}

@media (max-width: 1120px) {
  .story-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .gallery-header {
    padding-top: 22px;
  }

  .gallery-opening {
    padding-top: 78px;
    padding-bottom: 62px;
  }

  .story-grid {
    display: block;
  }

  .story-card {
    display: block;
    margin-bottom: 54px;
  }

  .story-card img {
    width: min(100%, 580px);
    max-height: none;
    object-position: left top;
  }

  .story-card-copy {
    width: min(100%, 580px);
  }

  .story-card--future {
    min-height: 0;
    margin-top: 70px;
  }

  .story-future-space,
  .story-gap {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .story-card[href] img,
  .story-card[href] h2 {
    transition: none;
  }
}


/* Story prototype ------------------------------------------------------- */
.story-main {
  width: min(calc(100% - (2 * var(--gutter))), var(--max));
  margin: 0 auto;
  padding-bottom: clamp(72px, 10vw, 140px);
}

.story-opening {
  max-width: 900px;
  padding: clamp(90px, 11vw, 155px) 0 clamp(66px, 8vw, 108px);
}

.story-opening h1 {
  margin: 0;
  font-size: clamp(3.2rem, 7vw, 6.8rem);
  font-weight: 430;
  letter-spacing: -0.06em;
  line-height: 0.94;
}

.story-intent {
  margin: 1.35rem 0 0;
  max-width: 680px;
  font-size: clamp(1.2rem, 2.3vw, 2rem);
  font-weight: 430;
  letter-spacing: -0.025em;
  line-height: 1.28;
}

.story-order-note {
  margin: 1.55rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.story-field {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2.5vw, 38px);
  row-gap: clamp(34px, 5vw, 72px);
  align-items: start;
}

.story-image {
  grid-column: span 5;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
  appearance: none;
}

.story-image--wide {
  grid-column: span 7;
}

.story-image--medium {
  grid-column: span 5;
}

.story-image--portrait {
  grid-column: span 4;
}

.story-image--small {
  grid-column: span 3;
}

.story-image--offset {
  margin-top: clamp(28px, 5vw, 72px);
}

.story-image--offset-small {
  margin-top: clamp(12px, 3vw, 38px);
}

.story-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 620px;
  object-fit: contain;
  object-position: left top;
  transition: opacity 150ms ease;
}

.story-image:hover img,
.story-image:focus-visible img {
  opacity: 0.84;
}

.story-image:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 7px;
}

.story-return {
  margin-top: clamp(84px, 12vw, 170px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.story-return a {
  color: var(--muted);
  font-size: 0.76rem;
  text-decoration: none;
}

.story-return a:hover,
.story-return a:focus-visible {
  color: var(--ink);
}

.lightbox-open {
  overflow: hidden;
}

.story-lightbox[hidden] {
  display: none;
}

.story-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  grid-template-columns: minmax(50px, 7vw) minmax(0, 1fr) minmax(50px, 7vw);
  grid-template-rows: 58px minmax(0, 1fr);
  background: rgba(242, 240, 235, 0.98);
}

.story-lightbox-backdrop {
  position: absolute;
  inset: 0;
}

.story-lightbox-toolbar {
  position: relative;
  z-index: 2;
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line-soft);
}

.story-lightbox-close {
  border: 0;
  padding: 7px 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}

.story-lightbox-count {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.story-lightbox-stage {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 3vw, 42px);
}

.story-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.story-lightbox-nav {
  position: relative;
  z-index: 2;
  grid-row: 2;
  align-self: stretch;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.story-lightbox-nav:hover,
.story-lightbox-nav:focus-visible {
  color: var(--ink);
}

.story-lightbox-prev { grid-column: 1; }
.story-lightbox-next { grid-column: 3; }

@media (max-width: 900px) {
  .story-image,
  .story-image--wide,
  .story-image--medium {
    grid-column: span 6;
  }

  .story-image--portrait {
    grid-column: span 5;
  }

  .story-image--small {
    grid-column: span 4;
  }
}

@media (max-width: 700px) {
  .story-opening {
    padding-top: 76px;
    padding-bottom: 54px;
  }

  .story-field {
    display: block;
  }

  .story-image,
  .story-image--wide,
  .story-image--medium,
  .story-image--portrait,
  .story-image--small {
    display: block;
    width: 100%;
    margin: 0 0 34px;
  }

  .story-image img {
    width: min(100%, 620px);
    max-height: none;
  }

  .story-lightbox {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .story-lightbox-stage {
    padding: 10px 4px 18px;
  }
}

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


/* Story v0.3 — controlled randomness + viewer refinement --------------- */
.story-image--wide img {
  max-height: 660px;
}

.story-image--portrait img,
.story-image--small img {
  max-height: 560px;
}

.story-lightbox-toolbar {
  gap: 18px;
}

.story-lightbox-count {
  margin-left: auto;
}

.story-lightbox-hint {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.02em;
}

.story-lightbox-stage {
  touch-action: pan-y;
}

@media (hover: hover) and (pointer: fine) {
  .story-lightbox-hint {
    display: none;
  }
}

@media (max-width: 700px) {
  .story-lightbox-toolbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .story-lightbox-hint {
    display: none;
  }

  .story-image--wide img,
  .story-image--portrait img,
  .story-image--small img {
    max-height: none;
  }
}

/* Galleries v1.3 — survey scale vs inspection scale --------------------
   The story field is intentionally smaller than the lightbox.
   Entering a story should feel like seeing a field of related images;
   opening one should feel like moving closer to inspect it. */
@media (min-width: 701px) {
  .story-field {
    max-width: 1260px;
  }

  .story-image--wide {
    grid-column: span 6;
  }

  .story-image img {
    max-height: 520px;
  }

  .story-image--wide img {
    max-height: 560px;
  }

  .story-image--portrait img,
  .story-image--small img {
    max-height: 480px;
  }
}

/* Galleries v1.5 — mobile coherence ------------------------------------
   On phones the Stories index becomes a compact visual list. Within a story,
   image hierarchy is retained rather than flattening everything to full width.
   The lightbox then becomes the distinctly larger inspection view. */
@media (max-width: 760px) {
  /* Stories index: compact list rather than a stack of near-screen images. */
  .story-card {
    display: grid;
    grid-template-columns: minmax(96px, 34vw) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 42px;
  }

  .story-card figure {
    margin: 0;
  }

  .story-card img {
    width: 100%;
    max-height: 170px;
    object-fit: contain;
    object-position: left top;
  }

  .story-card-copy {
    width: auto;
    padding-top: 10px;
  }

  .story-card h2 {
    font-size: clamp(1.08rem, 5.2vw, 1.32rem);
  }

  .story-card-copy p {
    margin-top: 0.42rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 700px) {
  /* Story survey: retain image-specific visual weights on small screens. */
  .story-field {
    display: block;
  }

  .story-image,
  .story-image--wide,
  .story-image--medium,
  .story-image--portrait,
  .story-image--small {
    display: block;
    margin-top: 0;
    margin-bottom: 38px;
  }

  .story-image {
    width: 86%;
  }

  .story-image--wide {
    width: 100%;
  }

  .story-image--medium {
    width: 86%;
  }

  .story-image--portrait {
    width: 72%;
  }

  .story-image--small {
    width: 62%;
  }

  .story-image--offset {
    margin-left: auto;
  }

  .story-image--offset-small {
    margin-left: 8%;
  }

  .story-image img,
  .story-image--wide img,
  .story-image--medium img,
  .story-image--portrait img,
  .story-image--small img {
    width: 100%;
    max-height: none;
  }

  /* Inspection view: give the image almost the entire phone screen. */
  .story-lightbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 54px minmax(0, 1fr);
  }

  .story-lightbox-toolbar {
    grid-column: 1;
    grid-row: 1;
    padding-left: 16px;
    padding-right: 16px;
  }

  .story-lightbox-stage {
    grid-column: 1;
    grid-row: 2;
    padding: 10px 10px 20px;
  }

  .story-lightbox-nav {
    position: absolute;
    z-index: 4;
    top: 54px;
    bottom: 0;
    width: 48px;
    padding: 0;
  }

  .story-lightbox-prev {
    left: 0;
  }

  .story-lightbox-next {
    right: 0;
  }
}
