/* Laptop + phone are exclusive to the opening carousel. The project collection
   and case-study device previews keep their existing styles. */
body.site-white[data-page="portfolio"] .portfolio-opening--devices {
  --portfolio-viewport: 100vh;
  min-height: var(--portfolio-viewport);
}
/* Keep the opening stable as mobile browser bars appear or disappear. */
@supports (height: 100svh) {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices { --portfolio-viewport: 100svh; }
}
body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout {
  height: calc(var(--portfolio-viewport) - var(--breadcrumb-opening-top, 104px) - var(--portfolio-bottom));
  min-height: min-content;
}
.portfolio-opening--devices .portfolio-carousel {
  height: 100%;
  min-height: 14rem;
  max-height: min(100%, 720px);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.5svh, 16px);
  justify-self: center;
}
.portfolio-opening--devices .portfolio-project-stage { display: grid; min-width: 0; }
body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-project {
  position: relative;
  inset: auto;
  grid-area: 1 / 1;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.5svh, 16px);
  min-width: 0;
  min-height: 0;
}
.portfolio-opening--devices .portfolio-project-caption,
.portfolio-opening--devices .portfolio-carousel-toolbar { padding-inline: 2%; }
.portfolio-opening--devices .portfolio-project-caption strong { overflow-wrap: normal; }

.portfolio-device-composition {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  min-width: 0;
  container-type: size;
  width: 100%;
}
/* The frame scales as one unit inside the space left by the real caption and
   toolbar. Neither a wide screen nor a long project name can push it below the fold. */
.portfolio-device-frame {
  --device-ratio: 1.7;
  display: block;
  position: relative;
  aspect-ratio: var(--device-ratio);
  width: 100%;
  width: min(100cqw, calc(100cqh * var(--device-ratio)));
  /* Keep the frame within its grid track while container units settle. */
  max-width: 100%;
  isolation: isolate;
  user-select: none;
}
.portfolio-device-frame::after {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: 0;
  left: 7%;
  width: 90%;
  height: 8%;
  border-radius: 50%;
  background: #203b4a1c;
  filter: blur(15px);
  pointer-events: none;
}
.portfolio-device-laptop { display: block; position: absolute; width: 96%; left: 0; top: 5%; }
.portfolio-device-laptop-lid {
  display: block;
  position: relative;
  width: 91%;
  margin-inline: auto;
  padding: 1.4% 1.05% 1.65%;
  border-radius: 2.2% 2.2% 1% 1% / 3.7% 3.7% 1.5% 1.5%;
  background: linear-gradient(125deg, #d8dadd, #9d9fa3 40%, #e6e7e8 80%, #9c9fa4);
}
.portfolio-device-laptop-lid::before {
  content: ""; position: absolute; inset: 3px; border-radius: inherit; background: #171a1e;
}
.portfolio-device-laptop-lid::after {
  content: "";
  position: absolute;
  top: 1%;
  left: calc(50% - 2px);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #293342;
}
.portfolio-device-laptop-screen {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1890 / 1063;
  border-radius: 2px;
  background: #f7f6f2;
}
/* Preserve every screenshot's proportions and its captured scrollbar. */
.portfolio-device-composition img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center top;
  -webkit-user-drag: none;
}
.portfolio-device-laptop-base {
  display: block;
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 2.35%;
  border-radius: 1px 1px 45% 45% / 1px 1px 70% 70%;
  background: linear-gradient(#eceeef 0%, #c4c8cd 25%, #d4d7db 48%, #969ca3 92%, #727880);
}
.portfolio-device-laptop-base::after {
  content: "";
  position: absolute;
  top: 0;
  left: 41%;
  width: 18%;
  height: 37%;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(#9a9fa6, #c4c8cd);
}
.portfolio-device-phone {
  display: block;
  position: absolute;
  width: 21.5%;
  right: .6%;
  bottom: 0;
  border-radius: 18% / 7.4%;
  padding: .7%;
  background: linear-gradient(120deg, #dadbde, #6e747c 22%, #d9dce0 45%, #737982 85%, #bec1c5);
}
.portfolio-device-phone::before {
  content: ""; position: absolute; right: -2px; top: 25%; width: 2px; height: 10%; border-radius: 0 2px 2px 0; background: #7c838c;
}
body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-device-phone-face {
  position: relative;
  display: block;
  overflow: hidden;
  border: 3px solid #15181c !important;
  border-radius: 16% / 6.2%;
  background: #f7f6f2;
}
/* Keep the entire rectangular capture between the rounded corner regions,
   including the scrollbar and its bottom arrow. */
.portfolio-device-phone-island { display: block; position: relative; aspect-ratio: 6; background: #f7f6f2; }
.portfolio-device-phone-island::after {
  content: ""; position: absolute; top: 25%; left: 32%; width: 36%; height: 54%; border-radius: 999px; background: #111317;
}
.portfolio-device-phone-screen { display: block; position: relative; aspect-ratio: 360 / 800; overflow: hidden; }
.portfolio-device-phone-home { display: block; position: relative; aspect-ratio: 6; background: #f7f6f2; }
.portfolio-device-phone-home::after {
  content: ""; position: absolute; width: 35%; left: 32.5%; height: 3px; bottom: 30%; border-radius: 99px; background: #202328;
}

@media (max-width: 900px), (max-width: 1100px) and (min-height: 700px) and (max-aspect-ratio: 6/5) {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout {
    grid-template-rows: auto auto minmax(min-content, 1fr) auto;
  }
  .portfolio-opening--devices .portfolio-carousel { max-width: 740px; }
}
@media (width < 700px) {
  .portfolio-opening--devices .portfolio-carousel { min-height: 12rem; gap: 8px; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-project { gap: 8px !important; }
  .portfolio-opening--devices .portfolio-project-caption strong { font-size: 1rem; }
  .portfolio-opening--devices .portfolio-project-caption small { font-size: .75rem; }
}
@media (width < 600px) {
  .portfolio-device-frame { --device-ratio: 1.35; }
  .portfolio-device-laptop { top: 13%; width: 90%; }
  .portfolio-device-phone { width: 30.5%; right: 1%; padding: .8%; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-device-phone-face { border-width: 2px !important; }
  .portfolio-device-laptop-lid::after { width: 2px; height: 2px; left: calc(50% - 1px); }
}
/* Very short portrait windows still leave room for the final navigation link.
   Keep the minimum in rem so enlarged text can expand the section naturally. */
@media (max-height: 480px) and (width < 700px) and (orientation: portrait) {
  .portfolio-opening--devices .portfolio-carousel { min-height: 10rem; }
  .portfolio-opening--devices .portfolio-opening-contact { margin-top: 8px; }
}
/* Landscape phones share the desktop arrangement, including widths below 700px. */
@media (max-height: 700px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout {
    --portfolio-inline-space: 32px;
    width: calc(100% - var(--portfolio-inline-space));
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    grid-template-rows: auto minmax(min-content, 1fr) auto;
    gap: 6px 20px;
  }
  .portfolio-opening--devices .portfolio-opening-copy .eyebrow { display: none; }
  .portfolio-opening--devices .portfolio-opening-copy { padding: 0; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices h1 {
    font-size: clamp(1.125rem, 4.8svh, 1.75rem);
  }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-copy p {
    margin-block: 8px;
    font-size: .8125rem !important;
    line-height: 1.35 !important;
  }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-contact {
    min-height: 44px;
    padding: 8px 12px;
    font-size: .75rem !important;
  }
  .portfolio-opening--devices .portfolio-carousel { min-height: 10rem; gap: 4px; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-project { gap: 4px !important; }
  .portfolio-opening--devices .portfolio-project-caption strong { font-size: .875rem; }
  .portfolio-opening--devices .portfolio-project-caption small { font-size: .625rem; }
  .portfolio-opening--devices .portfolio-carousel-toolbar { min-height: 44px; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-carousel-controls button { width: 44px; height: 44px; }
  .portfolio-device-frame { --device-ratio: 1.7; }
  .portfolio-device-laptop { top: 5%; width: 96%; }
  .portfolio-device-phone { width: 21.5%; right: .6%; padding: .7%; }
}
/* A stable header footprint prevents the first screen jumping when scrolling. */
body[data-page="portfolio"] .site-header .nav-shell,
body[data-page="portfolio"] .site-header.is-scrolled .nav-shell { min-height: 68px; }
html.nav-compact body[data-page="portfolio"] .site-header .nav-shell,
html.nav-compact body[data-page="portfolio"] .site-header.is-scrolled .nav-shell { min-height: 64px; }
html:not(.js-enabled) body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout {
  height: auto;
}
html:not(.js-enabled) .portfolio-opening--devices .portfolio-carousel { height: 28rem; }
@media (width < 700px) {
  html:not(.js-enabled) .portfolio-opening--devices .portfolio-carousel { height: 20rem; }
}
/* Older browsers keep a proportional preview in normal flow. */
@supports not (width: 1cqh) {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout { height: auto; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-carousel { height: auto; max-height: none; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-project { grid-template-rows: auto auto; }
  .portfolio-device-composition { display: block; container-type: normal; }
}
@media print {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices { min-height: 0; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-opening-layout { height: auto; min-height: 0; }
}
