body.portfolio-product {
  --line: 1.3rem;
  --measure: 26rem;
  --cover-space: var(--page-gutter);
  --hero-top: var(--cover-space);
  --peek: 3rem;
  --cover-fit: max(420px, calc(100svh - var(--hero-top) - var(--cover-space) - var(--peek)));
  --cover-h: var(--cover-fit);
  --media-gap: calc(2 * var(--line));
  --cover-ratio: 0.76;
  --rail: 1.75rem;
  --rail-gap: var(--page-gutter);
  --rail-space: calc(var(--rail-gap) + var(--rail) + 0.625rem);
  --space-min: max(var(--rail-space), 8vw);
  --error: #a4392f;
  --field-line: rgba(20, 20, 26, 0.22);
}

/* Chrome 120-124 pass allow_browser but lack round(); they keep the unrounded height. */
@supports (height: round(down, 1px, 1px)) {
  body.portfolio-product {
    --cover-h: round(down, var(--cover-fit), var(--line));
  }
}

html:has(> body.portfolio-product) {
  overscroll-behavior: none;
  scroll-padding-top: calc(1.5rem + 2.125rem + var(--page-gutter));
}

.page {
  container-type: inline-size;
}

.work {
  margin: 0;
}

.wall {
  --cover-box: min(var(--cover-h), (100cqw - var(--measure) - 3 * var(--space-min)) / var(--cover-ratio));
  display: grid;
  grid-template-columns: minmax(var(--space-min), 1fr) var(--measure) minmax(var(--space-min), 1fr) calc(var(--cover-box) * var(--cover-ratio)) minmax(var(--space-min), 1fr);
}

.hero {
  padding-top: var(--hero-top);
}

.details-col {
  grid-column: 2;
  position: sticky;
  top: var(--hero-top);
  align-self: start;
  min-width: 0;
  min-height: var(--cover-h);
  display: grid;
  align-content: center;
}

.details {
  font-size: 0.8125rem;
  line-height: var(--line);
}

.work-title {
  margin: 0 0 var(--line);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: calc(2 * var(--line));
  text-wrap: balance;
}

/* Title SVGs are exported at one lettering scale and cropped to their own
   height, so their intrinsic size is the display size. Only titles wider than
   the column shrink; max-height bounds older uploads made to other scales.
   An SVG exported without a width and height has no natural size, and some
   browsers stretch its box to the column; contain + left keeps the lettering
   at the left edge of the box instead of centred in it. */
.work-title-mark {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(5 * var(--line));
  object-fit: contain;
  object-position: left center;
  filter: url(#ink-ink);
}

.group {
  padding-block: calc(var(--line) - 1px) var(--line);
  border-top: 1px solid var(--hairline);
}

.group:last-child {
  padding-bottom: 0;
}

.group-title {
  margin: 0;
  color: var(--ink);
  font-size: inherit;
  font-weight: 500;
}

.specs {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 var(--line);
  margin: 0;
}

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

.specs dd {
  margin: 0;
  color: var(--ink);
  text-align: right;
}

.specs .sold {
  color: var(--error);
  font-weight: 500;
}

.description p {
  margin: 0;
  color: var(--read-ink);
  text-align: justify;
  text-wrap: pretty;
  hyphens: manual;
  word-spacing: -0.04em;
}

.description p + p {
  margin-top: var(--line);
}

.work-enquire {
  position: relative;
  display: inline-block;
  padding-bottom: 0.4em;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: var(--line);
  text-decoration: none;
}

.enquire-rule {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 6px;
  overflow: visible;
  color: var(--accent);
  clip-path: inset(-8px -8px -8px -8px);
  pointer-events: none;
  transition: color 0.2s ease;
}

.enquire-rule path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.work-enquire:hover .enquire-rule,
.work-enquire:focus-visible .enquire-rule {
  color: var(--ink);
}

.waitlist-note {
  margin: 0 0 calc(var(--line) / 2);
  color: var(--muted);
}

.waitlist-done {
  margin: 0;
  color: var(--ink);
}

.waitlist-done:empty {
  display: none;
}

.field {
  position: relative;
  border: 1px solid var(--field-line);
  background: var(--bg);
  transition: border-color 0.15s;
}

.field:focus-within {
  border-color: var(--ink);
}

.field input {
  display: block;
  width: 100%;
  height: calc(2 * var(--line) - 2px);
  padding: 0.875rem 5.5rem 0.125rem 0.75rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.field label {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  color: var(--muted);
  transform: translateY(-50%) scale(1);
  transform-origin: left top;
  pointer-events: none;
  transition: transform 0.18s ease, color 0.15s;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-1rem) scale(0.8);
}

.field-submit {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 0.5rem 0 0.75rem;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  opacity: 0;
  visibility: hidden;
  transform: translateX(4px);
  transition: opacity 0.18s, transform 0.18s, visibility 0s 0.18s;
}

.field-submit span {
  padding: 0.1875rem 0.5625rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.field-submit:hover span {
  background: #000;
}

.field-submit:focus-visible {
  outline: none;
}

.field-submit:focus-visible span {
  outline: 1.5px solid var(--ink);
  outline-offset: 2px;
}

.field input:not(:placeholder-shown) ~ .field-submit {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.field.is-invalid {
  border-color: var(--error);
}

.field.is-invalid label {
  color: var(--error);
}

.field-error {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}

.field-error > div {
  min-height: 0;
  overflow: hidden;
}

.field-error p {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  padding-top: 0.5rem;
  color: var(--error);
  font-size: 0.75rem;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.2s, transform 0.2s;
}

.field-error svg {
  flex: none;
  width: 1em;
  height: 1em;
}

.field-error a {
  color: inherit;
  text-underline-offset: 0.15em;
}

.field.is-invalid + .field-error {
  grid-template-rows: 1fr;
}

.field.is-invalid + .field-error p {
  opacity: 1;
  transform: none;
}

@media (pointer: coarse) {
  .field input {
    height: max(calc(2 * var(--line) - 2px), 46px);
    font-size: 16px;
  }
}

.work-figure {
  display: contents;
  margin: 0;
}

.shot-thumbs {
  display: none;
}

.work-shots {
  grid-column: 4;
  grid-row: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--media-gap);
}

.shot {
  display: block;
  width: min(100%, var(--cover-h) * var(--r, var(--cover-ratio)));
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: zoom-in;
  font: inherit;
}

.shot:disabled {
  cursor: default;
  opacity: 1;
}

.shot img,
.shot video {
  display: block;
  width: 100%;
  height: auto;
}

.rail {
  grid-column: 5;
  grid-row: 1;
  position: sticky;
  top: var(--hero-top);
  align-self: start;
  justify-self: start;
  height: min(var(--cover-h), 100svh - var(--hero-top) - var(--cover-space));
  margin-left: var(--rail-gap);
  padding: 3px 3px 3px 0;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

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

.rail-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-block: auto;
  padding-left: 0.625rem;
}

.rail-track,
.rail-mark {
  position: absolute;
  left: 0;
  width: 1px;
}

.rail-track {
  top: 0;
  bottom: 0;
  background: var(--hairline);
}

.rail-mark {
  top: 0;
  height: 0;
  background: var(--ink);
}

.rail-thumb {
  display: block;
  width: var(--rail);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.rail-thumb:hover {
  opacity: 1;
}

.rail-thumb:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
  opacity: 1;
}

.rail-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

@media (min-width: 961px) {
  body.portfolio-product {
    --hero-top: calc(1.5rem + 2.125rem + var(--cover-space));
  }

  body.portfolio-product main {
    padding-top: 0;
  }

  .work-shots.is-single {
    min-height: var(--cover-h);
    justify-content: center;
  }
}

@media (max-width: 960px) {
  html:has(> body.portfolio-product) {
    scroll-padding-top: var(--mobile-header-h);
  }

  body.portfolio-product {
    --measure: 21rem;
    --peek: 0px;
    --header-h: var(--mobile-header-h);
  }

  .hero {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: calc(var(--header-h) + var(--page-gutter)) var(--page-gutter) 0;
  }

  .work-shots {
    display: contents;
  }

  .shot {
    order: 3;
    align-self: center;
    width: 100%;
    margin-top: 48px;
  }

  .shot:first-child {
    order: 1;
    margin-top: 0;
  }

  .details-col {
    order: 2;
    align-self: stretch;
    position: static;
    min-height: 0;
    display: block;
    padding: 40px 0 64px;
  }

  .rail {
    display: none;
  }
}

@media (max-width: 620px) {
  body.portfolio-product {
    --frame-gap: clamp(10px, 1vw, 20px);
  }

  .hero {
    padding-top: var(--header-h);
  }

  .work-figure {
    display: block;
    order: 1;
    width: calc(100% + 2 * var(--page-gutter));
    min-width: 0;
    margin-inline: calc(-1 * var(--page-gutter));
  }

  .work-shots {
    display: grid;
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    gap: var(--frame-gap);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .work-shots::-webkit-scrollbar {
    display: none;
  }

  .work-shots .shot {
    order: initial;
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    width: 100%;
    min-width: 0;
    margin: 0;
    aspect-ratio: var(--cover-ratio);
    border-inline: var(--mount-line-w) solid var(--mount-line);
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .work-shots .shot:first-child {
    padding: var(--mat);
  }

  .work-shots .shot img,
  .work-shots .shot video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  /* Keep the entire film visible in the phone carousel. */
  .work-shots .shot video {
    object-fit: contain;
  }

  .shot-thumbs {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 3px var(--page-gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .shot-thumbs::-webkit-scrollbar {
    display: none;
  }

  .shot-thumb:first-child {
    margin-inline-start: auto;
  }

  .shot-thumb:last-child {
    margin-inline-end: auto;
  }

  .details-col {
    padding-top: 28px;
  }

  .work-title {
    margin-bottom: calc(0.5 * var(--line));
  }

  .work-title-mark {
    zoom: 0.8;
  }

  .shot-thumb {
    display: block;
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.25s ease;
  }

  .shot-thumb.is-current {
    opacity: 1;
  }

  .shot-thumb:focus-visible {
    outline: 1px solid var(--ink);
    outline-offset: 2px;
  }

  .shot-thumb img {
    display: block;
    width: auto;
    height: 40px;
    aspect-ratio: var(--cover-ratio);
    object-fit: cover;
  }
}

.viewer {
  --viewer-mat: clamp(18px, 1.9vw, 34px);
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;

  grid-template-rows: auto minmax(0, 1fr) auto;

  background: var(--bg);
  opacity: 0;

  transition: opacity 0.14s ease;
}

.viewer::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)' opacity='0.34'/%3E%3C/svg%3E");
}

.viewer:not([open]) {
  display: none;
}

.viewer.is-open {
  opacity: 1;
  transition: opacity 0.18s ease;
}

.viewer-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(16px, 2.4vh, 30px) clamp(18px, 3vw, 44px);
}

.viewer-work {
  margin: 0;
  color: var(--muted);
  font-size: 0.84375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.viewer-close {
  display: block;
  padding: 10px;
  margin: -10px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
  transition: color 0.2s ease;
}

.viewer-close svg {
  display: block;
  width: clamp(19px, 1.5vw, 24px);
  height: auto;
}

.viewer-close path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
}

.viewer-close:hover,
.viewer-close:focus-visible {
  color: var(--ink);
}

.viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 clamp(20px, 5vw, 76px);
}

.viewer-frame {
  position: relative;
  border: var(--viewer-mat) solid transparent;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 0 0 var(--mount-line-w) var(--mount-line);
  opacity: 1;
  transition: opacity 0.14s ease-out;
}

.viewer-frame.is-changing {
  opacity: 0;
  transition-duration: 0.1s;
}

.viewer-frame:not(.is-mounted) {
  border-width: 0;
}

.viewer-frame.is-mounted {
  border-color: var(--mount-pad);
  background: var(--mount-pad);
}

.viewer-mat-probe {
  position: absolute;
  width: 0;
  height: 0;
  border: var(--viewer-mat) solid transparent;
  pointer-events: none;
  visibility: hidden;
}

.viewer-img,
.viewer-video {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  object-fit: contain;
  transform: translate(-50%, -50%);
}

.viewer-step {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(72px, 13vw, 210px);
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.viewer-step[hidden] {
  display: none;
}

.viewer-step--prev {
  left: 0;
}

.viewer-step--next {
  right: 0;
}

.viewer-step svg {
  width: clamp(11px, 1.1vw, 16px);
  height: auto;
  opacity: 0.4;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease,
    color 0.2s ease;
}

.viewer-step path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
}

.viewer-step:hover svg,
.viewer-step:focus-visible svg {
  color: var(--ink);
  opacity: 1;
}

.viewer-step--prev:hover svg {
  transform: translateX(-4px);
}

.viewer-step--next:hover svg {
  transform: translateX(4px);
}

.viewer-step[disabled] {
  cursor: default;
  pointer-events: none;
}

.viewer-step[disabled] svg {
  opacity: 0;
}

.viewer-foot {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 13px;
  padding: clamp(14px, 2vh, 24px) clamp(18px, 3vw, 44px) clamp(20px, 3vh, 36px);
  text-align: center;
}

.viewer-dots {
  display: flex;
  gap: 11px;
}

.viewer-dots[hidden] {
  display: none;
}

.viewer-dot {
  padding: 6px;
  margin: -6px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  line-height: 0;
}

.viewer-dot-mark {
  display: block;
  width: 11px;
  height: 11px;
}

.viewer-dot-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.viewer-dot path {
  fill: currentColor;
  fill-opacity: 0;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linejoin: round;
  stroke-opacity: 0.3;
  transition:
    fill-opacity 0.25s ease,
    stroke-opacity 0.25s ease;
}

.viewer-dot:hover path {
  stroke-opacity: 0.62;
}

.viewer-dot.is-current path {
  fill-opacity: 1;
  stroke-opacity: 1;
}

.viewer::backdrop {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .viewer-step:hover svg { transform: none; }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.viewer-dot:nth-child(4n + 1) .viewer-dot-mark { transform: rotate(-9deg); }
.viewer-dot:nth-child(4n + 2) .viewer-dot-mark { transform: rotate(6deg); }
.viewer-dot:nth-child(4n + 3) .viewer-dot-mark { transform: rotate(-3deg); }
.viewer-dot:nth-child(4n + 4) .viewer-dot-mark { transform: rotate(11deg); }
