/* ============================================
   3D Design portfolio — scoped to .page-3d only
   ============================================ */

/* Reserve scrollbar width so toggling overflow during FLIP does not shift the layout (end “blink”). */
html:has(body.page-3d) {
  scrollbar-gutter: stable;
}

/* Full-width main: override page.css .siteMain { max-width: 1100px } (higher specificity). */
body.page-3d {
  --p3d-edge: clamp(12px, 2.2vw, 36px);
  --p3d-text-max: 55rem; /* ~880px */
  --p3d-lead-max: 45rem; /* ~720px */
  --p3d-asset-ratio: 2 / 1; /* match approved turnaround sheet proportion */
  --p3d-gap-major: 7.5rem; /* 120px desktop */
  --p3d-gap-major-tablet: 5.5rem; /* 88px */
  --p3d-gap-major-mobile: 4rem; /* 64px */
  --p3d-section-header-gap: clamp(2.25rem, 3vw, 2.75rem); /* 36-44px */
}

@media (min-width: 900px) {
  body.page-3d {
    --p3d-edge: clamp(24px, 3vw, 48px);
  }
}

body.page-3d #main.siteMain {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  padding-left: var(--p3d-edge);
  padding-right: var(--p3d-edge);
  padding-top: clamp(1.5rem, 3.8vw, 2.75rem);
  padding-bottom: clamp(2.5rem, 5vw, 3.5rem);
}

@keyframes p3dRevealCell {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* #main.siteMain padding set on body.page-3d above */

/* Key Art breaks out slightly wider than the main column for a denser “poster wall” */
.p3d-section--keyArt {
  overflow-x: visible;
}

.p3d-section--keyArt .p3d-posterGrid {
  width: calc(100vw - 2 * var(--p3d-edge, 24px));
  max-width: none;
  margin-left: 50%;
  transform: translateX(-50%);
}

.p3d-section--keyArt .p3d-expandWrap {
  width: calc(100vw - 2 * var(--p3d-edge, 24px));
  margin-left: 50%;
  transform: translateX(-50%);
}

.p3d-section {
  padding: 0;
}

.p3d-section + .p3d-section {
  margin-top: var(--p3d-gap-major);
}

.p3d-section--intro + .p3d-section {
  margin-top: 5.5rem; /* 88px desktop intro->first section */
}

@media (max-width: 1199px) {
  .p3d-section + .p3d-section {
    margin-top: var(--p3d-gap-major-tablet);
  }

  .p3d-section--intro + .p3d-section {
    margin-top: 4.5rem;
  }
}

@media (max-width: 767px) {
  .p3d-section + .p3d-section {
    margin-top: var(--p3d-gap-major-mobile);
  }

  .p3d-section--intro + .p3d-section {
    margin-top: 4rem;
  }
}

/* ----- Page intro + section header system ----- */
.p3d-pageIntro {
  text-align: center;
  max-width: min(var(--p3d-text-max), 100%);
  margin-inline: auto;
}

.p3d-introTitle {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 2.125rem; /* 34px mobile */
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.1;
}

.p3d-introText {
  margin: 1.125rem auto 0; /* 18px */
  max-width: min(var(--p3d-lead-max), 100%);
  font-size: 1rem; /* 16px */
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.75);
}

/* Keep intro support copy to about two rows on desktop. */
@media (min-width: 1200px) {
  .p3d-pageIntro .p3d-introText {
    max-width: min(68rem, 100%);
  }
}

.p3d-sectionHeader {
  width: min(var(--p3d-text-max), 100%);
  margin: 0 auto var(--p3d-section-header-gap);
  text-align: center;
}

.p3d-sectionTitle,
.p3d-subsectionTitle {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.25rem; /* 20px mobile */
  font-weight: 700;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.97);
  line-height: 1.2;
}

.p3d-sectionTitle[data-kicker]::before,
.p3d-subsectionTitle[data-kicker]::before {
  content: attr(data-kicker);
  display: block;
  margin-bottom: 0.75rem; /* 12px */
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

/* Subsection headings should be single-line titles only (no small overline). */
.p3d-subsectionTitle::before {
  content: none !important;
}

.p3d-sectionHeader--sub {
  margin-bottom: clamp(1.35rem, 2.2vw, 1.75rem);
}

.p3d-subsectionLead {
  margin: 0.875rem auto 0; /* 14px */
  max-width: min(var(--p3d-lead-max), 100%);
  font-size: clamp(0.9rem, 1.05vw, 0.96rem);
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.74);
}

/* ----- Subsections (3D Assets) ----- */
.p3d-assetsSubsection {
  margin-top: clamp(3rem, 5vw, 4.5rem);
}

.p3d-assetsSubsection:first-of-type {
  margin-top: clamp(1.75rem, 3vw, 2.5rem);
}

@media (min-width: 768px) {
  .p3d-introTitle {
    font-size: 2.75rem; /* 44px tablet */
  }

  .p3d-sectionTitle {
    font-size: 1.5rem; /* 24px tablet */
  }

  .p3d-subsectionTitle {
    font-size: 1.28rem;
    font-weight: 600;
  }
}

@media (min-width: 1200px) {
  .p3d-introTitle {
    font-size: 3.5rem; /* 56px desktop */
  }

  .p3d-sectionTitle {
    font-size: 1.75rem; /* 28px desktop */
  }

  .p3d-subsectionTitle {
    font-size: 1.32rem;
    font-weight: 600;
  }
}

/* ----- Featured index cards ----- */
.p3d-featIndex {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .p3d-featIndex {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 768px) {
  .p3d-featIndex {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 1024px) {
  .p3d-featIndex {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (min-width: 1200px) {
  .p3d-featIndex {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
  }
}

.p3d-featCard {
  display: block;
  text-align: left;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  transition:
    border-color 0.35s ease,
    background 0.35s ease,
    transform 0.45s cubic-bezier(0.19, 1, 0.22, 1);
}

.p3d-featCard:hover,
.p3d-featCard:focus-visible {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-2px);
}

.p3d-featCard:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 3px;
}

.p3d-featCardMedia {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #111;
}

.p3d-featCardMedia img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition:
    transform 0.65s cubic-bezier(0.19, 1, 0.22, 1),
    filter 0.45s ease;
  filter: brightness(0.92) contrast(1.02);
}

.p3d-featCard:hover .p3d-featCardMedia img,
.p3d-featCard:focus-visible .p3d-featCardMedia img {
  transform: scale(1.04);
  filter: brightness(1.02) contrast(1.04);
}

@media (prefers-reduced-motion: reduce) {
  .p3d-featCard,
  .p3d-featCardMedia img {
    transition: none;
  }

  .p3d-featCard:hover,
  .p3d-featCard:focus-visible {
    transform: none;
  }

  .p3d-featCard:hover .p3d-featCardMedia img,
  .p3d-featCard:focus-visible .p3d-featCardMedia img {
    transform: none;
  }
}

.p3d-featCardBody {
  padding: 12px 14px 10px;
}

.p3d-featCardTitle {
  margin: 0;
  font-family: "Bebas Neue", "Inter", system-ui, sans-serif;
  font-size: clamp(22px, 1.35vw, 26px);
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.98);
  transition:
    transform 0.4s cubic-bezier(0.19, 1, 0.22, 1),
    color 0.25s ease;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p3d-featCard:hover .p3d-featCardTitle,
.p3d-featCard:focus-visible .p3d-featCardTitle {
  transform: translateX(3px);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .p3d-featCard:hover .p3d-featCardTitle,
  .p3d-featCard:focus-visible .p3d-featCardTitle {
    transform: none;
  }
}

@media (min-width: 1200px) {
  .p3d-featCardBody {
    padding: 16px 16px 14px;
  }
}

/* After .p3d-featCard so display:block does not override hidden cards */
.p3d-featCard.p3d-featCard--hidden {
  display: none;
}

.p3d-featIndex.is-expanded .p3d-featCard.p3d-featCard--hidden {
  display: block;
  animation: p3dRevealCell 0.5s cubic-bezier(0.22, 1, 0.32, 1) backwards;
}

/* ----- Featured detail: editorial 2-col spread ----- */
.p3d-detail {
  scroll-margin-top: 5.5rem;
  padding-bottom: clamp(2.75rem, 6vw, 4.25rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.p3d-detail:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.p3d-detail--board {
  border-bottom: none;
  padding-bottom: 0;
}

.p3d-detailBoard {
  width: auto;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p3d-detailBoard img {
  display: block;
  width: auto;
  height: min(97vh, 1320px);
  max-width: 99vw;
  max-height: 97vh;
  object-fit: contain;
  object-position: center;
}

.p3d-detailSpread {
  max-width: none;
  width: 100%;
  margin-inline: 0;
  display: grid;
  gap: 24px;
  align-items: start;
}

@media (min-width: 900px) {
  .p3d-detailSpread {
    /* ~40% poster column / ~60% content — matches reference editorials */
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    column-gap: clamp(20px, 2.5vw, 32px);
    row-gap: 0;
  }
}

.p3d-detailMainCol,
.p3d-detailSideCol {
  min-width: 0;
}

@media (max-width: 899px) {
  .p3d-detailSpread {
    grid-template-columns: 1fr;
  }

  .p3d-detailMainCol {
    order: 1;
  }

  .p3d-detailSideCol {
    order: 2;
  }
}

/* Portrait poster hero — matches .p3d-featCardMedia for FLIP */
.p3d-detailHero {
  position: relative;
  width: 100%;
  margin-inline: 0;
  aspect-ratio: 2 / 3;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: paint;
}

@media (max-width: 899px) {
  .p3d-detailHero {
    max-width: min(100%, 400px);
    margin-inline: auto;
  }
}

.p3d-detailHero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: brightness(0.92) contrast(1.02);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.32, 1);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform, opacity;
}

/* Overlay handoff: no opacity tween (clone → hero would “pulse” otherwise). */
.p3d-detail.p3d-detail--overlay .p3d-detailHero img {
  transition: none;
}

.p3d-detailHero--pending img,
.p3d-detailHero--handoff img {
  /* Safety: if these classes are present, never hide the destination bitmap. */
  opacity: 1 !important;
  visibility: visible !important;
  transition: none !important;
}

.p3d-detailMotion {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.35rem);
}

@media (max-width: 899px) {
  .p3d-detailMotion {
    margin-top: clamp(0.35rem, 1.5vw, 0.65rem);
  }
}

/* Pre-FLIP: hide detail column until WAAPI runs (no flash on scroll) */
.p3d-detail--flipPrep .p3d-detailSideCol {
  opacity: 0;
  transform: translate3d(0, 30px, 0);
}

.p3d-detail--flipPrep .p3d-detailMotion {
  opacity: 0;
  transform: translate3d(0, 10px, 0);
}

.p3d-detailTitle {
  margin: 0;
  font-size: clamp(1.35rem, 2.75vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.12;
}

.p3d-detailSupportsRow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 12px);
  width: 100%;
}

.p3d-detailSupport {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}

.p3d-detailSupport img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.p3d-detailSupport--empty {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  min-height: 0;
}

.p3d-detailCopy {
  margin-top: 0;
  max-width: 100%;
}

.p3d-meta {
  display: grid;
  gap: clamp(0.65rem, 1.5vw, 0.9rem);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.52);
}

.p3d-meta dt {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
}

.p3d-meta dd {
  margin: 0.2rem 0 0;
  color: rgba(255, 255, 255, 0.68);
}

/* Reference-style hierarchy: Role + description read first; credits stay compact */
.p3d-meta dt:nth-of-type(1) + dd {
  font-weight: 500;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.88);
}

.p3d-meta dt:nth-of-type(2) + dd {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.58);
  margin-bottom: 0.15rem;
}

/* Featured overlay is now larger; raise detail typography for readability. */
.p3d-featOverlaySlot .p3d-detailTitle {
  font-size: clamp(2rem, 2.8vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: 0.035em;
}

.p3d-featOverlaySlot .p3d-meta {
  gap: clamp(0.8rem, 1.4vw, 1.05rem);
}

.p3d-featOverlaySlot .p3d-meta dt {
  font-size: 0.8rem;
  letter-spacing: 0.13em;
  color: rgba(255, 255, 255, 0.5);
}

.p3d-featOverlaySlot .p3d-meta dd {
  margin: 0.28rem 0 0;
  font-size: 1.05rem;
  line-height: 1.62;
  color: rgba(255, 255, 255, 0.84);
}

.p3d-featOverlaySlot .p3d-meta dt:nth-of-type(1) + dd {
  font-size: 1.15rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.96);
}

.p3d-featOverlaySlot .p3d-meta dt:nth-of-type(2) + dd {
  font-size: 1.1rem;
  line-height: 1.66;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 0.25rem;
}

@media (max-width: 899px) {
  .p3d-featOverlaySlot .p3d-detailTitle {
    font-size: clamp(1.35rem, 4.8vw, 1.8rem);
    letter-spacing: 0.03em;
  }

  .p3d-featOverlaySlot .p3d-meta dd {
    font-size: 0.9rem;
    line-height: 1.62;
  }
}

@media (min-width: 900px) {
  .p3d-detailSideCol {
    padding-top: 0.15rem;
    padding-right: clamp(0, 1.5vw, 0.75rem);
  }
}

/* ----- Featured card → detail FLIP (shared element) ----- */
/* During FLIP: hide only the thumbnail so the clone reads as the same surface */
.p3d-featCard--flipHideMedia .p3d-featCardMedia {
  visibility: hidden;
}

.p3d-featCard--flipHideMedia {
  pointer-events: none;
}

html.p3d-flip-active,
html.p3d-featOverlay-open,
html.p3d-flip-active body,
html.p3d-featOverlay-open body {
  overflow: hidden !important;
  touch-action: none;
}

/* SEO / a11y: full article HTML stays in source; visually hidden until opened in overlay */
.p3d-section--featuredDock {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

/* ----- Featured project overlay (centered detail) ----- */
.p3d-featOverlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.2rem, 1vw, 0.5rem);
  padding-top: max(clamp(0.2rem, 1vw, 0.5rem), env(safe-area-inset-top, 0px));
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.p3d-featOverlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* Instant shell while FLIP runs — opacity fade fights the flying clone and reads as a blink. */
html.p3d-flip-active .p3d-featOverlay.is-open {
  transition: none;
}

.p3d-featOverlayAmbient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.p3d-featOverlayAmbientPane {
  position: absolute;
  top: -4%;
  bottom: -4%;
  width: min(44vw, 540px);
  overflow: hidden;
}

.p3d-featOverlayAmbientPane--prev {
  left: 0;
}

.p3d-featOverlayAmbientPane--next {
  right: 0;
}

.p3d-featOverlayAmbientPane img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1.12);
  filter: blur(36px) brightness(0.42) saturate(0.9);
  opacity: 0.95;
}

.p3d-featOverlayAmbientPane::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.p3d-featOverlayAmbientPane--prev::after {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.55) 55%,
    rgba(0, 0, 0, 0.92) 100%
  );
}

.p3d-featOverlayAmbientPane--next::after {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.55) 45%,
    rgba(0, 0, 0, 0.2) 100%
  );
}

.p3d-featOverlayBackdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(0, 0, 0, 0.86) 22%,
    rgba(0, 0, 0, 0.86) 78%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

.p3d-featOverlayFrame {
  position: relative;
  z-index: 2;
  width: min(96vw, 1840px);
  max-height: min(98vh, 1240px);
  height: auto;
  display: flex;
  flex-direction: column;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72);
  /* Match .p3d-featOverlaySlot padding for nav alignment with hero column */
  --p3d-feat-slot-pad: clamp(1rem, 2.5vw, 1.5rem);
}

.p3d-featOverlaySlot {
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  padding: clamp(0.75rem, 1.6vw, 1.25rem);
  -webkit-overflow-scrolling: touch;
}

.p3d-featOverlaySlot .p3d-detail {
  scroll-margin-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.p3d-featOverlaySlot .p3d-detail--board {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p3d-featOverlaySlot .p3d-detail--board .p3d-detailBoard {
  width: auto;
  margin-inline: auto;
}

.p3d-featOverlaySlot .p3d-detail--board img {
  margin-inline: auto;
  width: auto;
  height: min(97vh, 1320px);
  max-width: 99vw;
  max-height: 97vh;
}

/* Exact board-image mode: shrink-wrap frame around board and remove dead padding. */
.p3d-featOverlayFrame:has(.p3d-detail--board) {
  width: 99vw;
  max-height: 98vh;
  height: 98vh;
  border-color: rgba(255, 255, 255, 0.06);
}

.p3d-featOverlayFrame:has(.p3d-detail--board) .p3d-featOverlaySlot {
  padding: clamp(0.15rem, 0.4vw, 0.35rem);
  overflow: hidden;
}

/* Reference-style featured detail layout: taller editorial split, minimal dead space. */
@media (min-width: 900px) {
  .p3d-featOverlaySlot .p3d-detail {
    min-height: 0;
    display: block;
  }

  .p3d-featOverlaySlot .p3d-detailSpread {
    width: 100%;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.48fr);
    column-gap: clamp(16px, 1.7vw, 22px);
    align-items: start;
  }

  .p3d-featOverlaySlot .p3d-detailMainCol {
    display: block;
    min-height: 0;
  }

  .p3d-featOverlaySlot .p3d-detailHero {
    height: auto;
    min-height: clamp(420px, 58vh, 700px);
    aspect-ratio: 2 / 3;
  }

  .p3d-featOverlaySlot .p3d-detailSideCol {
    display: block;
    min-height: 0;
    padding-top: 0;
    padding-right: 0;
  }

  .p3d-featOverlaySlot .p3d-detailMotion {
    width: 100%;
    min-height: 0;
    gap: clamp(0.62rem, 0.9vw, 0.85rem);
  }

  .p3d-featOverlaySlot .p3d-detailSupportsRow {
    gap: clamp(8px, 1vw, 10px);
  }

  .p3d-featOverlaySlot .p3d-detailCopy {
    margin-top: clamp(0.12rem, 0.4vw, 0.3rem);
    padding-top: 0;
  }
}

.p3d-featOverlayClose {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 6;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  background: rgba(10, 10, 10, 0.92);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.p3d-featOverlayClose:hover,
.p3d-featOverlayClose:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.45);
}

.p3d-featOverlayNav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 7;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.p3d-featOverlayNav:hover,
.p3d-featOverlayNav:focus-visible {
  background: rgba(22, 22, 22, 0.82);
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* Desktop: pin controls to the poster column (2fr of 2fr+3fr), not the copy column */
@media (min-width: 900px) {
  .p3d-featOverlayNav--prev {
    left: -32px;
    right: auto;
  }

  .p3d-featOverlayNav--next {
    right: -32px;
    left: auto;
  }
}

/* Stacked layout: bottom bar so arrows never sit over title / meta */
@media (max-width: 899px) {
  .p3d-featOverlaySlot {
    padding-bottom: calc(var(--p3d-feat-slot-pad) + 3.5rem);
  }

  .p3d-featOverlayNav {
    top: auto;
    bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
    transform: none;
  }

  .p3d-featOverlayNav--prev {
    left: calc(50% - 52px);
    right: auto;
  }

  .p3d-featOverlayNav--next {
    right: calc(50% - 52px);
    left: auto;
  }
}

.p3d-flip-clone {
  position: fixed;
  z-index: 999998;
  left: 0;
  top: 0;
  border-radius: 2px;
  overflow: hidden;
  pointer-events: none;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  will-change: transform;
  transform: translateZ(0);
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.p3d-flip-clone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: brightness(0.92) contrast(1.02);
}

@media (prefers-reduced-motion: reduce) {
  .p3d-flip-clone {
    display: none !important;
  }

  .p3d-featIndex.is-expanded .p3d-featCard.p3d-featCard--hidden,
  .p3d-posterGrid.is-expanded .p3d-posterCell--hidden,
  .p3d-assetGrid.is-expanded .p3d-assetCell--hidden {
    animation: none;
  }
}

/* ----- Poster grid ----- */
.p3d-posterGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 560px) {
  .p3d-posterGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 780px) {
  .p3d-posterGrid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (min-width: 1040px) {
  .p3d-posterGrid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@media (min-width: 1320px) {
  .p3d-posterGrid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 6px;
  }
}

.p3d-posterCell {
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: block;
  width: 100%;
  background: transparent;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.32, 1),
    filter 0.4s ease;
}

.p3d-posterCell:hover,
.p3d-posterCell:focus-visible {
  transform: scale(1.03);
  z-index: 1;
}

.p3d-posterCell:hover img,
.p3d-posterCell:focus-visible img {
  filter: brightness(1.05);
}

.p3d-posterCell:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .p3d-posterCell:hover,
  .p3d-posterCell:focus-visible {
    transform: none;
  }

  .p3d-posterCell:hover img,
  .p3d-posterCell:focus-visible img {
    filter: none;
  }
}

.p3d-posterCell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: filter 0.4s ease;
}

.p3d-posterCell--hidden {
  display: none;
}

.p3d-posterGrid.is-expanded .p3d-posterCell--hidden {
  display: block;
  animation: p3dRevealCell 0.5s cubic-bezier(0.22, 1, 0.32, 1) backwards;
}

/* ----- Asset grid (wide landscape tiles — multi-view sheets, 3×n on desktop) ----- */
.p3d-assetGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(10px, 1.5vw, 14px);
}

@media (min-width: 640px) {
  .p3d-assetGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .p3d-assetGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.p3d-assetCell {
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
  background: #111;
  border-radius: 2px;
  overflow: hidden;
  aspect-ratio: var(--p3d-asset-ratio);
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.32, 1),
    filter 0.4s ease;
}

.p3d-assetCell:hover,
.p3d-assetCell:focus-visible {
  transform: scale(1.03);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 12px 30px rgba(0, 0, 0, 0.45);
}

.p3d-assetCell:hover img,
.p3d-assetCell:focus-visible img {
  filter: brightness(1.2) saturate(1.08);
}

.p3d-assetCell:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .p3d-assetCell:hover,
  .p3d-assetCell:focus-visible {
    transform: none;
  }

  .p3d-assetCell:hover img,
  .p3d-assetCell:focus-visible img {
    filter: none;
  }
}

.p3d-assetCell img {
  width: 100%;
  height: 100%;
  /* Fill the 2:1 card cleanly; export incoming assets in 2:1 to avoid crop. */
  object-fit: cover;
  object-position: center;
  display: block;
  transition: filter 0.4s ease;
}

.p3d-assetCell--hidden {
  display: none;
}

.p3d-assetGrid.is-expanded .p3d-assetCell--hidden {
  display: block;
  animation: p3dRevealCell 0.5s cubic-bezier(0.22, 1, 0.32, 1) backwards;
}

/* ----- Expand toggles ----- */
.p3d-expandWrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.p3d-expandWrap:has(.p3d-expandBtn.is-hidden) {
  display: none;
}

.p3d-expandBtn {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.85rem 1.75rem;
  cursor: pointer;
  border-radius: 2px;
  transition:
    color 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}

.p3d-expandBtn:hover,
.p3d-expandBtn:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.p3d-expandBtn[aria-expanded="true"] {
  margin-top: 0;
}

.p3d-expandBtn.is-hidden {
  display: none;
}

/* ----- Lightbox ----- */
.p3d-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
  background: rgba(0, 0, 0, 0.92);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.p3d-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.p3d-lightboxBackdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
}

.p3d-lightboxInner {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.p3d-lightboxFig {
  margin: 0;
  max-height: calc(92vh - 3rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.p3d-lightboxFig img {
  max-width: 100%;
  max-height: calc(92vh - 3.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

/* Assets: open close to fullscreen for easier review. */
.p3d-lightbox--assets .p3d-lightboxInner {
  max-width: 98vw;
  width: 98vw;
  max-height: 96vh;
  height: 96vh;
  gap: 0;
}

.p3d-lightbox--assets .p3d-lightboxFig {
  max-height: none;
  height: 100%;
  width: 100%;
}

.p3d-lightbox--assets .p3d-lightboxFig img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.p3d-lightbox--assets .p3d-lightboxCap {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  text-align: center;
  z-index: 4;
  width: max-content;
  max-width: calc(100vw - 48px);
}

.p3d-lightbox--assets .p3d-lightboxCapTitle,
.p3d-lightbox--assets .p3d-lightboxCapMeta {
  padding-left: 0;
  padding-right: 0;
  margin-left: auto;
  margin-right: auto;
}

.p3d-lightbox--assets .p3d-lightboxCapTitle {
  margin: 0;
  font-size: clamp(16px, 1.1vw, 20px);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.95);
}

.p3d-lightbox--assets .p3d-lightboxCapMeta {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.62);
  display: block;
  text-align: center;
  line-height: 1.3;
  max-width: calc(100vw - 48px);
  white-space: nowrap;
}

/* Key Art: full theatrical poster scale (intrinsic aspect) + title under image */
.p3d-lightbox--posters .p3d-lightboxInner {
  width: auto;
  max-width: min(96vw, calc((95vh - 5.5rem) * 2 / 3));
  box-sizing: border-box;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
}

.p3d-lightbox--posters .p3d-lightboxFig {
  margin: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  border-radius: 2px;
}

.p3d-lightbox--posters .p3d-lightboxFig img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(93vh, calc(100vh - 7.5rem));
  object-fit: contain;
  object-position: center;
}

.p3d-lightbox--posters .p3d-lightboxCap {
  display: none;
}

.p3d-lightboxCap {
  margin: 0;
  text-align: center;
  max-width: 36rem;
}

.p3d-lightboxCapTitle {
  margin: 0;
  padding: 0 0.75rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(1.0625rem, 2.6vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.28;
  color: rgba(255, 255, 255, 0.96);
}

.poster-title,
.p3d-lightbox--posters .p3d-lightboxCapTitle {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 10px;
}

.p3d-lightboxCapTitle[hidden] {
  display: none !important;
}

.p3d-lightboxCapMeta {
  margin: 0;
  padding: 0 0.75rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.p3d-lightbox--posters .p3d-lightboxCapMeta {
  display: none;
}

.p3d-lightboxClose {
  position: absolute;
  top: clamp(0.5rem, 2vw, 1rem);
  right: clamp(0.5rem, 2vw, 1rem);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  background: rgba(10, 10, 10, 0.85);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.p3d-lightboxClose:hover,
.p3d-lightboxClose:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

.p3d-lightboxNav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  background: rgba(10, 10, 10, 0.75);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.p3d-lightboxNav:hover,
.p3d-lightboxNav:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
}

.p3d-lightboxNav--prev {
  left: clamp(0.35rem, 2vw, 1rem);
}

.p3d-lightboxNav--next {
  right: clamp(0.35rem, 2vw, 1rem);
}

@media (max-width: 600px) {
  .p3d-lightboxNav {
    top: auto;
    bottom: 0.5rem;
    transform: none;
  }

  .p3d-lightboxNav--prev {
    left: calc(50% - 52px);
  }

  .p3d-lightboxNav--next {
    right: calc(50% - 52px);
    left: auto;
  }
}

body.p3d-lightbox-open {
  overflow: hidden;
}
