.project-selection {
  padding-block: 100px 125px;
}
.project-selection-heading {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: end;
  gap: 10%;
  margin-bottom: 48px;
}
.project-selection-heading p {
  color: var(--muted);
  line-height: 1.85;
  max-width: 48ch;
  margin-bottom: 22px;
}
.project-preview-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 45px 50px;
}
.project-preview:first-child {
  grid-row: span 2;
}
.project-preview figure {
  aspect-ratio: 1.65;
  overflow: hidden;
}
.project-preview:first-child figure {
  aspect-ratio: auto;
  height: calc(100% - 62px);
  min-height: 520px;
}
.project-preview img {
  transition: transform 650ms cubic-bezier(0.2, 0.65, 0.3, 1);
}
.project-preview:is(:hover, :focus-visible) img {
  transform: scale(1.025);
}
.project-preview > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  padding-top: 18px;
}
.project-preview h3 {
  font-size: clamp(23px, 2.2vw, 37px);
}
.project-preview span {
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--orange);
}
/* The project page keeps each stage readable while the visitor changes view. */
html:has(.project-stories) {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}
.projects-opening {
  padding-top: 55px;
  padding-bottom: 45px;
}
.projects-intro {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: end;
  gap: 8%;
  margin-top: 30px;
}
.projects-intro h1 {
  font-size: var(--title-page);
}
.projects-intro p {
  padding-bottom: 12px;
  font-size: clamp(17px, 1.65vw, 24px);
  line-height: 1.7;
  max-width: 30ch;
  color: var(--muted);
}
.projects-gallery-link {
  display: inline-block;
  margin-top: 24px;
  font-size: 16px;
}
.project-index {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 30px;
  padding-inline: clamp(20px, 2.2vw, 36px);
  scroll-padding-inline: 24px;
  position: sticky;
  top: calc(var(--header) - 1px);
  z-index: 8;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.project-index a {
  position: relative;
  padding: 20px 0;
  font-size: 14px;
  white-space: nowrap;
}
.project-index a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--orange);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 350ms ease;
}
.project-index a[aria-current]::after,
.project-index a:hover::after {
  transform: scaleX(1);
}
.project-story {
  padding-block: 85px;
  scroll-margin-top: 72px;
}
.project-story + .project-story {
  border-top: 1px solid var(--line);
}
.project-story-heading {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 10%;
  align-items: end;
  margin-bottom: 38px;
}
.project-story-heading h2 {
  font-size: var(--title-section);
  margin-top: 17px;
}
.project-service {
  font-size: 13px;
  border-bottom: 1px solid var(--orange);
  padding-bottom: 4px;
}
.project-story-heading > p {
  color: var(--muted);
  line-height: 1.85;
  max-width: 48ch;
  padding-bottom: 6px;
}
.project-photo-link {
  position: relative;
  display: block;
  min-width: 0;
  overflow: hidden;
  background: #e9edef;
  isolation: isolate;
  cursor: zoom-in;
}
.project-photo-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.photo-enlarge {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 9px 15px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 3px 16px rgba(28, 56, 84, 0.12);
  opacity: 0;
  transform: translateY(3px);
  transition:
    opacity 200ms ease,
    transform 250ms ease,
    background 250ms ease;
}
.project-photo-link:is(:hover, :focus-visible) .photo-enlarge {
  opacity: 1;
  transform: translateY(0);
  background: white;
}
.comparison-label {
  position: absolute;
  top: 16px;
  left: 16px;
  color: white;
  background: var(--blue);
  padding: 9px 17px;
  font-size: 15px;
  line-height: 1.3;
}
.comparison-panel[data-state="after"] .comparison-label {
  background: var(--orange);
  color: #132d45;
}
.project-result {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 28px;
  align-items: end;
}
.project-result .project-photo-link {
  aspect-ratio: 4 / 5;
}
.project-result img {
  object-fit: cover;
}
.project-result > figure:last-child {
  margin-top: 80px;
}
.project-result > figure:last-child .project-photo-link {
  aspect-ratio: 3 / 4;
}
.project-result figcaption {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.project-comparison {
  --view-ease: cubic-bezier(0.22, 1, 0.36, 1);
}
.comparison-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding-block: 8px 22px;
}
.comparison-toolbar > p {
  font-size: 16px;
  color: var(--muted);
}
.comparison-views {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 5px;
}
.comparison-views[hidden] {
  display: none;
}
.comparison-views button {
  border: 0;
  padding: 10px 20px;
  background: transparent;
  color: var(--blue);
  border-radius: 2px;
  font-size: 13px;
  transition:
    background 200ms ease,
    color 200ms ease;
}
.comparison-views button[aria-pressed="true"] {
  background: var(--blue);
  color: white;
}
.comparison-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  height: clamp(260px, calc((100vw - 2 * var(--gutter) - 20px) * 0.375), 610px);
  transition:
    grid-template-columns 750ms var(--view-ease),
    height 750ms var(--view-ease),
    gap 750ms var(--view-ease);
}
.comparison-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  opacity: 1;
  transition: opacity 400ms ease;
}
.project-comparison[data-view="before"] .comparison-stage {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
  gap: 0;
}
.project-comparison[data-view="after"] .comparison-stage {
  grid-template-columns: minmax(0, 0fr) minmax(0, 1fr);
  gap: 0;
}
.project-comparison[data-view="before"] [data-state="after"],
.project-comparison[data-view="after"] [data-state="before"] {
  opacity: 0;
  pointer-events: none;
}
.project-comparison:not([data-view="compare"]) .comparison-stage {
  height: clamp(480px, 56vw, 820px);
}
.comparison-portrait .comparison-stage {
  height: clamp(500px, 58vw, 850px);
}
.comparison-footnote {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding-top: 17px;
  font-size: 14px;
  color: var(--muted);
}
.comparison-footnote p {
  max-width: 62ch;
}
.comparison-footnote > span {
  max-width: 28ch;
  text-align: right;
}
.project-story-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  margin-top: 40px;
}
.project-story-action > p {
  font-size: 17px;
}
.project-place {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 38px;
  max-width: 600px;
}
.project-place .project-photo-link {
  width: 135px;
  height: 170px;
  flex: 0 0 auto;
}
.project-place img {
  object-fit: cover;
}
.project-place .photo-enlarge {
  inset: auto 8px 8px auto;
  padding: 5px 9px;
  font-size: 10px;
}
.project-place h3 {
  font-size: 24px;
  margin-bottom: 12px;
}
.project-place p {
  font-size: 16px;
  color: var(--muted);
}
.project-lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 24px;
  background: rgba(12, 29, 44, 0.97);
  color: white;
  overflow: hidden;
}
.project-lightbox::backdrop {
  background: rgba(12, 29, 44, 0.85);
}
.lightbox-content {
  height: 100%;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-close {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 12px;
  margin-bottom: 15px;
  min-height: 44px;
  color: white;
  background: transparent;
  border: 1px solid #768b9b;
  font-size: 14px;
}
.lightbox-close span {
  font-size: 24px;
  line-height: 1;
}
.lightbox-content figure {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.lightbox-content img {
  display: block;
  width: auto;
  height: auto;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100dvh - 155px);
  object-fit: contain;
}
.lightbox-content figcaption {
  padding-top: 15px;
  font-size: 13px;
  text-align: center;
}
@media (max-width: 800px) {
  .project-selection-heading {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .project-selection {
    padding-block: 65px;
  }
  .project-preview-grid {
    gap: 32px 25px;
  }
  .project-preview > div {
    flex-direction: column;
    gap: 8px;
  }
  .project-preview:first-child figure {
    height: calc(100% - 90px);
    min-height: 370px;
  }
  .projects-intro {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .projects-intro p {
    max-width: none;
    font-size: 17px;
  }
  .projects-intro h1 {
    font-size: var(--title-page);
  }
  .project-index {
    gap: 28px;
  }
  .project-index a {
    padding-block: 17px;
    font-size: 13px;
  }
  .project-story-heading {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .project-story {
    padding-block: 55px;
  }
  .project-story-heading h2 {
    font-size: var(--title-section);
  }
  .project-story-heading > p {
    font-size: 16px;
    max-width: 65ch;
  }
  .comparison-footnote {
    gap: 20px;
  }
  .comparison-footnote > span {
    display: none;
  }
  .comparison-stage {
    gap: 14px;
  }
  .comparison-label {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 13px;
  }
  .project-story-action > p {
    font-size: 16px;
  }
}
@media (max-width: 550px) {
  .project-selection-heading h2 {
    font-size: var(--title-section);
  }
  .project-preview-grid {
    grid-template-columns: 1fr;
  }
  .project-preview:first-child {
    grid-row: auto;
  }
  .project-preview:first-child figure {
    height: auto;
    min-height: 0;
    aspect-ratio: 1;
  }
  .project-preview > div {
    flex-direction: row;
    align-items: baseline;
  }
  .project-preview h3 {
    font-size: 24px;
  }
  .projects-opening {
    padding-top: 30px;
    padding-bottom: 25px;
  }
  .projects-intro h1 {
    font-size: var(--title-page);
  }
  .projects-intro p {
    font-size: 16px;
  }
  .project-story-heading h2 {
    font-size: var(--title-section);
  }
  .project-result {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .project-result > figure:last-child {
    margin-top: 0;
  }
  .project-result .project-photo-link,
  .project-result > figure:last-child .project-photo-link {
    aspect-ratio: 3 / 4;
  }
  .comparison-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .comparison-views {
    width: 100%;
  }
  .comparison-views button {
    flex: 1;
    padding: 10px 14px;
  }
  .comparison-stage {
    --photo-height: calc((100vw - 2 * var(--gutter)) * 0.75);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    height: calc(2 * var(--photo-height) + 24px);
    gap: 24px;
    transition:
      grid-template-rows 700ms var(--view-ease),
      height 700ms var(--view-ease),
      gap 700ms var(--view-ease);
  }
  .comparison-portrait .comparison-stage {
    height: calc(2 * var(--photo-height) + 24px);
    --photo-height: calc((100vw - 2 * var(--gutter)) * 1.33333);
  }
  .project-comparison[data-view="before"] .comparison-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 0fr);
    height: var(--photo-height);
  }
  .project-comparison[data-view="after"] .comparison-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 0fr) minmax(0, 1fr);
    height: var(--photo-height);
  }
  .comparison-footnote {
    padding-top: 10px;
  }
  .project-story-action {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
    margin-top: 30px;
  }
  .photo-enlarge {
    right: 10px;
    bottom: 10px;
  }
  .project-place {
    gap: 20px;
  }
  .project-place .project-photo-link {
    width: 100px;
    height: 145px;
  }
  .project-place h3 {
    font-size: 21px;
  }
  .project-place p {
    font-size: 12px;
  }
  .project-lightbox {
    padding: 15px;
  }
  .lightbox-content img {
    max-height: calc(100dvh - 135px);
  }
  .lightbox-content figcaption {
    font-size: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.project-stories) {
    scroll-behavior: auto;
  }
  .comparison-stage,
  .comparison-panel,
  .comparison-views button,
  .project-index a::after,
  .photo-enlarge,
  .project-preview img {
    transition: none !important;
  }
  .project-preview:is(:hover, :focus-visible) img {
    transform: none;
  }
}
