.project-showcase {
  padding-block: clamp(3.75rem, 8vw, 7rem);
  background: var(--ink);
}

.project-showcase h2 {
  color: var(--white);
  text-wrap: initial;
}

.project-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  margin-block: 1.65rem 1.1rem;
}

.project-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.project-filters[hidden], .project-carousel-controls[hidden], .project-card[hidden], .project-empty[hidden], .project-list[hidden] { display: none; }
.project-controls:has(> :not([hidden])) + .project-carousel .project-list { margin-top: 0; }
.project-controls:not(:has(> :not([hidden]))) { display: none; }

.project-filters button {
  min-height: 2.75rem;
  padding: .5rem .85rem;
  border: 1px solid var(--rule-on-dark);
  border-radius: .2rem;
  background: transparent;
  color: var(--white);
  font: 700 .875rem var(--heading-font);
  cursor: pointer;
}

.project-filters button:hover { border-color: var(--accent); }
.project-filters button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--ink);
}
.project-filters button:focus-visible { outline-color: var(--accent); }

.project-list, .material-list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 1px;
  background: var(--graphite);
  list-style: none;
}

.project-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.1rem;
}

.project-list[data-carousel] {
  --project-gap: clamp(.85rem, 2vw, 1.45rem);
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 2 * var(--project-gap)) / 3);
  gap: var(--project-gap);
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: .55rem;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 1px;
  scrollbar-color: var(--rule-on-dark) transparent;
  scrollbar-width: thin;
  background: transparent;
}

.project-list[data-carousel] > .project-card {
  grid-column: auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: none;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #ffffff20;
  border-radius: .75rem;
  background: #11191f;
  scroll-snap-align: start;
}

.project-list[data-carousel="single"] { grid-auto-columns: min(100%, 29.5rem); }
.project-list[data-carousel]:focus-visible { outline: 2px solid var(--accent); outline-offset: .25rem; }

.project-carousel { position: relative; min-width: 0; }
.project-carousel-controls {
  display: grid;
  grid-template-columns: 2.75rem minmax(4rem, auto) 2.75rem;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  min-height: 1.5rem;
  margin-top: .75rem;
}

.project-carousel-count {
  color: var(--muted-on-dark);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
}

.project-carousel-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--rule-on-dark);
  border-radius: 50%;
  background: #11191f;
  color: var(--white);
  cursor: pointer;
}

.project-carousel-button::after {
  width: .43rem;
  height: .43rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(-1px) rotate(-45deg);
  content: "";
}

.project-carousel-button[data-carousel-prev]::after { transform: translateX(1px) rotate(135deg); }
.project-carousel-button:focus-visible { outline-color: var(--accent); }
.project-carousel-button:not([aria-disabled="true"]):hover { border-color: var(--accent); background: var(--brand); }
.project-carousel-button[aria-disabled="true"] { opacity: .46; cursor: default; }
.project-carousel-button[hidden] { display: none; }

@media (min-width: 1100px) {
  .project-carousel-controls { display: flex; justify-content: center; }
  .project-carousel-button {
    position: absolute;
    inset-block-start: calc((100% - 2.25rem) / 2);
    transform: translateY(-50%);
  }
  .project-carousel-button[data-carousel-prev] { inset-inline-end: calc(100% + .55rem); }
  .project-carousel-button[data-carousel-next] { inset-inline-start: calc(100% + .55rem); }
}

.project-card, .material-card { min-width: 0; background: var(--ink); }

.project-card-featured {
  grid-column: 1 / -1;
  background: var(--brand);
}

.project-card-photo { display: grid; }
.project-card-featured.project-card-photo {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: stretch;
}

.project-visual { position: relative; min-width: 0; background: var(--graphite); }
.project-cover { position: absolute; inset: 0; display: block; }
.project-cover:focus-visible { z-index: 1; outline-offset: -.35rem; }
.project-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 52%;
}
.project-card:is([data-project="bmw-7-v12"], [data-project="cla-45-s-wash"]) .project-photo {
  object-position: center 69%;
}
.project-card[data-project="bmw-x5"] .project-photo { object-position: center 32%; }
.project-card[data-project="mg-cyberster"] .project-photo { object-fit: contain; background: #161c21; }

.project-card-featured .project-visual { min-height: clamp(17rem, 34vw, 29rem); }
.project-card-featured .project-copy { align-self: center; padding: clamp(1.75rem, 4vw, 3.75rem); }

.project-card-photo:not(.project-card-featured) { grid-template-areas: "cover"; min-height: clamp(17rem, 29vw, 24rem); }
.project-card-photo:not(.project-card-featured) .project-visual,
.project-card-photo:not(.project-card-featured) .project-copy { grid-area: cover; }
.project-card-photo:not(.project-card-featured) .project-copy {
  position: relative;
  align-self: end;
  pointer-events: none;
}
.project-card-photo:not(.project-card-featured) .project-copy :is(a, summary) { pointer-events: auto; }
.project-card-photo:not(.project-card-featured) .project-visual::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #0b101400 25%, #0b10148c 57%, #0b1014f7 93%);
  content: "";
}
.project-card-photo:not(.project-card-featured):is(:hover, :focus-within) .project-visual::after {
  background: linear-gradient(180deg, #0b101416 12%, #0b1014a8 50%, #0b1014fa 94%);
}

.project-list[data-carousel] .project-card .project-visual {
  grid-area: auto;
  align-self: start;
  min-height: 0;
}
.project-list[data-carousel] .project-cover {
  position: relative;
  inset: auto;
  aspect-ratio: 4 / 3;
}

.project-list[data-carousel] .project-card .project-visual::after { content: none; }
.project-list[data-carousel] .project-card .project-copy {
  display: flex;
  flex-direction: column;
  grid-area: auto;
  align-self: stretch;
  padding: clamp(1rem, 2vw, 1.55rem);
  pointer-events: auto;
}

.project-list[data-carousel] .project-card h3 { font-size: clamp(1.3rem, 2vw, 1.8rem); }
.project-list[data-carousel] .project-open { align-self: flex-start; margin-top: auto; }

.project-copy, .material-card {
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.project-kind {
  margin-bottom: .5rem;
  color: var(--accent);
  font: 700 .875rem var(--heading-font);
}

.project-card h3, .material-card h3 {
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.15;
}

.project-card-featured h3 { font-size: clamp(1.8rem, 4vw, 3.5rem); }
.project-open {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: .55rem;
  color: var(--accent);
  text-underline-offset: .2em;
}
.project-showcase[data-gallery-enabled] .project-card-photo details { display: none; }
.project-card details { margin-top: .55rem; }
.project-card summary {
  width: fit-content;
  min-height: 2.75rem;
  padding-block: .6rem;
  color: var(--accent);
  cursor: pointer;
}

.project-teaser { display: none; }
.project-detail { margin-top: .4rem; }
.project-detail p, .project-teaser p, .material-card p { color: var(--muted-on-dark); }
.project-detail a, .project-empty a {
  display: inline-block;
  margin-top: .8rem;
  color: var(--accent);
  text-underline-offset: .2em;
}

.project-empty { padding-block: 1.4rem; color: var(--muted-on-dark); }
.project-empty a { margin: 0; }
.project-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .project-teaser {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    max-width: 46ch;
    transition: grid-template-rows .2s ease, opacity .2s ease, margin-top .2s ease;
  }

  .project-teaser p { min-height: 0; overflow: hidden; }
  .project-card:is(:hover, :focus-within) .project-copy:not(:has(details[open])) .project-teaser {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: .6rem;
  }

  .project-list[data-carousel] .project-teaser {
    display: block;
    height: 2.6rem;
    margin-top: .6rem;
    overflow: hidden;
  }

  .project-list[data-carousel] .project-teaser p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .875rem;
    line-height: 1.45;
  }
}

.project-stills {
  display: grid;
  grid-template-columns: repeat(auto-fit, 5rem);
  gap: .55rem;
  margin: .75rem 0 0;
  padding: 0;
  list-style: none;
}

.project-stills a { display: block; margin: 0; }
.project-stills img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

:root:has(.project-dialog[open]) { overflow: hidden; }
.project-dialog {
  width: min(70rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #ffffff36;
  border-radius: .75rem;
  background: #11191f;
  color: var(--white);
}

.project-dialog::backdrop { background: #070b0ee6; backdrop-filter: blur(6px); }
.project-dialog-inner {
  --gallery-stage-height: min(78dvh, 48rem);
  --gallery-gutter: clamp(1.25rem, 3vw, 2.5rem);
  display: grid;
  grid-template-areas: "stage heading" "stage info";
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  grid-template-rows: auto 1fr;
}

.project-dialog-header {
  grid-area: heading;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: .65rem;
  padding: var(--gallery-gutter) var(--gallery-gutter) 0;
  background: #11191f;
}

.project-dialog-header h2 {
  font-size: clamp(1.65rem, 3vw, 2.8rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-wrap: initial;
}

.project-dialog-header .project-kind { margin-bottom: .5rem; }

.project-gallery-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--rule-on-dark);
  border-radius: 50%;
  background: transparent;
  color: var(--white);
  font: 1.25rem/1 Arial, sans-serif;
  cursor: pointer;
}

.project-gallery-button:hover { border-color: var(--accent); background: var(--brand); }
.project-gallery-close { font-size: 1.65rem; }

.project-gallery-stage {
  grid-area: stage;
  display: grid;
  place-items: center;
  height: 100%;
  min-height: var(--gallery-stage-height);
  padding: .4rem;
  background: radial-gradient(ellipse at center, #17242c, #0b1116 78%);
  touch-action: pan-y pinch-zoom;
}

.project-gallery-stage a {
  display: block;
  width: 100%;
  height: calc(var(--gallery-stage-height) - .8rem);
  cursor: zoom-in;
}

.project-gallery-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-dialog-info {
  grid-area: info;
  display: grid;
  grid-template-areas: "description" "navigation" "thumbnails" "source";
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: .9rem;
  min-width: 0;
  padding: 1rem var(--gallery-gutter) var(--gallery-gutter);
}

.project-gallery-navigation {
  grid-area: navigation;
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--muted-on-dark);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.project-gallery-navigation [data-gallery-counter] { min-width: 3rem; text-align: center; }
.project-gallery-navigation [data-gallery-prev][hidden] + [data-gallery-counter] { min-width: 0; }

.project-gallery-thumbs {
  grid-area: thumbnails;
  display: flex;
  min-width: 0;
  gap: .45rem;
  overflow-x: auto;
  padding: .3rem;
  margin: -.3rem;
  scrollbar-color: var(--accent) transparent;
}

.project-gallery-thumbs button {
  flex: 0 0 auto;
  width: clamp(3.2rem, 6vw, 4.25rem);
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: .35rem;
  background: #0b1116;
  cursor: pointer;
}

.project-gallery-thumbs button[aria-current] { border-color: var(--accent); }
.project-gallery-thumbs button:focus-visible { outline-offset: 1px; }
.project-gallery-thumbs img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.project-gallery-description {
  grid-area: description;
  color: var(--muted-on-dark);
}

.project-gallery-source {
  grid-area: source;
  justify-self: start;
  color: var(--accent);
  text-underline-offset: .2em;
}

.project-gallery-thumbs[hidden], .project-gallery-button[hidden], .project-gallery-source[hidden] { display: none; }

@media (max-width: 760px) {
  .project-dialog { width: min(36rem, calc(100% - 1rem)); max-height: calc(100dvh - 1rem); }
  .project-dialog-inner {
    --gallery-stage-height: min(58dvh, 118vw, 31rem);
    --gallery-gutter: 1rem;
    grid-template-areas: "heading" "stage" "info";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }

  .project-dialog-header {
    position: sticky;
    top: 0;
    z-index: 1;
    align-items: center;
    padding-block: .75rem;
  }

  .project-dialog-header h2 { font-size: clamp(1.2rem, 6vw, 1.8rem); }
  .project-dialog-header .project-kind { margin-bottom: .2rem; font-size: .8rem; }
  .project-dialog-info {
    grid-template-areas: "navigation" "thumbnails" "description" "source";
    padding-top: .65rem;
  }

  .project-gallery-navigation { justify-content: center; }
  .project-gallery-thumbs button { width: 3.25rem; }
}

.studio-materials { margin-top: clamp(3rem, 6vw, 5rem); }
.studio-materials h2 { font-size: clamp(2.1rem, 4vw, 3.65rem); }
.material-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.35rem;
}
.material-card p { margin-top: .7rem; }
.material-card h3 a {
  text-decoration-color: var(--muted-on-dark);
  text-decoration-thickness: .045em;
  text-underline-offset: .17em;
}
.material-card h3 a:is(:hover, :focus-visible) {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.material-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 10rem);
  height: 3.25rem;
  margin-bottom: 1.25rem;
  padding: .55rem .85rem;
  border: 1px solid var(--graphite);
  background: var(--ink);
  border-radius: .2rem;
}

.material-logo img { width: 100%; height: 100%; object-fit: contain; }

@media (max-width: 1050px) {
  .project-list[data-carousel="multiple"] { grid-auto-columns: calc((100% - var(--project-gap)) / 2); }
}

@media (max-width: 700px) {
  .project-list, .project-card-featured.project-card-photo, .material-list { grid-template-columns: minmax(0, 1fr); }
  .project-list[data-carousel="multiple"] { grid-auto-columns: 83%; }
  .project-card-featured .project-visual { min-height: 0; aspect-ratio: 4 / 3; }
}

@media (prefers-reduced-motion: reduce) {
  .project-teaser { transition: none; }
}
