/* The portfolio has its own viewport-sized opening; other page heroes stay independent. */
body.site-white[data-page="portfolio"] .portfolio-opening {
  --portfolio-gap: clamp(16px, 3svh, 32px);
  --portfolio-bottom: max(16px, var(--content-safe-area-bottom));
  box-sizing: border-box;
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--breadcrumb-opening-top, 104px) 0 var(--portfolio-bottom);
  background: #fff;
}
body.site-white[data-page="portfolio"] .portfolio-opening-layout {
  --portfolio-inline-space: clamp(40px, 8vw, 160px);
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  grid-template-rows: auto minmax(auto, 1fr) auto;
  align-items: center;
  gap: var(--portfolio-gap) clamp(24px, 3vw, 48px);
  width: min(1600px, calc(100% - var(--portfolio-inline-space)));
  max-width: none;
  height: calc(100svh - var(--breadcrumb-opening-top, 104px) - var(--portfolio-bottom));
  /* Enlarged text may increase the opening naturally instead of overlapping the project. */
  min-height: min-content;
  margin: 0 auto;
  padding: 0;
}
.portfolio-opening .breadcrumb-nav {
  /* Match the shared inner-hero container without resizing the project grid.
     Recover the section width from its real layout width, excluding scrollbars. */
  --portfolio-breadcrumb-limit: var(--container);
  --portfolio-breadcrumb-space: 56px;
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: start;
  justify-self: center;
  width: min(var(--portfolio-breadcrumb-limit), calc(100% + var(--portfolio-inline-space) - var(--portfolio-breadcrumb-space)));
  max-width: none;
  margin: 0;
}
/* Keep these in sync with the responsive .inner-hero .container rules. */
@media (max-width: 900px) {
  .portfolio-opening .breadcrumb-nav { --portfolio-breadcrumb-limit: 820px; --portfolio-breadcrumb-space: 28px; }
}
@media (max-width: 640px) {
  .portfolio-opening .breadcrumb-nav { --portfolio-breadcrumb-space: 24px; }
}
@media (max-width: 370px) {
  .portfolio-opening .breadcrumb-nav { --portfolio-breadcrumb-space: 20px; }
}
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .portfolio-opening .breadcrumb-nav { --portfolio-breadcrumb-limit: var(--container); --portfolio-breadcrumb-space: 32px; }
}
.portfolio-opening .breadcrumb-list { margin: 0; }
/* Keep the copy close to the project even when the desktop track has spare room. */
.portfolio-opening-copy { display: flex; flex-direction: column; align-items: flex-start; justify-self: end; width: min(100%, 36rem); min-width: 0; padding-block: 12px; text-align: left; }
.portfolio-opening-copy .eyebrow { margin: 0 0 clamp(12px, 2svh, 24px); font-size: .8125rem; }
body.site-white[data-page="portfolio"] .portfolio-opening h1 {
  max-width: 12em;
  margin: 0;
  font-size: clamp(2rem, min(3.5vw, 6.5svh), 4.25rem);
  line-height: 1.08;
  letter-spacing: -.045em;
  text-wrap: balance;
}
body.site-white[data-page="portfolio"] .portfolio-opening h1 > span { color: #176d77 !important; }
body.site-white[data-page="portfolio"] .portfolio-opening-copy p {
  max-width: 38ch;
  margin: clamp(16px, 2.8svh, 28px) 0;
  font-size: clamp(1rem, 1.2vw, 1.1875rem) !important;
  line-height: 1.5 !important;
}
.portfolio-opening-contact { min-height: 48px; max-width: 100%; gap: 16px; padding: 12px 20px; white-space: normal; }
.portfolio-opening svg { display: block; flex: 0 0 auto; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.portfolio-carousel {
  position: relative;
  display: grid;
  grid-template-rows: minmax(auto, 1fr) auto;
  min-width: 0;
  width: 100%;
  height: 100%;
  max-height: min(100%, 42vw, 680px, calc(100svh - var(--breadcrumb-opening-top, 104px) - 150px));
  min-height: 16.25rem;
  gap: 12px;
  container-type: inline-size;
}
.portfolio-project-stage { position: relative; min-height: 0; isolation: isolate; touch-action: pan-y pinch-zoom; }
body.site-white[data-page="portfolio"] .portfolio-project {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(auto, 1fr) auto;
  gap: 18px;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .5s ease, visibility .5s;
}
body.site-white[data-page="portfolio"] .portfolio-project.is-active { opacity: 1; visibility: visible; pointer-events: auto; z-index: 1; transition-property: opacity; }
body.site-white[data-page="portfolio"] .portfolio-project-window {
  display: grid;
  grid-template-rows: 28px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #cddfe2 !important;
  border-radius: 14px;
  background: #f4f8f8;
  box-shadow: 0 16px 48px -24px rgba(32, 59, 74, .3) !important;
}
.portfolio-project-browser { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; background: #f4f8f8; color: #51666d; font-size: 10px; letter-spacing: .08em; }
.portfolio-project-browser > span:first-child { display: flex; gap: 5px; }
.portfolio-project-browser i { width: 5px; height: 5px; border-radius: 50%; background: #438f98; }
.portfolio-project-browser i:nth-child(2) { background: #d8ad65; }
.portfolio-project-browser i:nth-child(3) { background: #b93d35; }
.portfolio-project-live { width: 6px; height: 6px; margin-right: 10px; border-radius: 50%; background: #438f98; }
.portfolio-project-window img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center; background: #fff; user-select: none; -webkit-user-drag: none; }
.portfolio-project-caption { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0; }
.portfolio-project-caption > span:first-child { display: grid; gap: 4px; min-width: 0; }
.portfolio-project-caption small { color: #526773; font-size: .8125rem; line-height: 1.4; }
.portfolio-project-caption strong { font-size: clamp(1rem, 1.55vw, 1.625rem); line-height: 1.2; font-weight: 650; letter-spacing: -.025em; }
body.site-white[data-page="portfolio"] .portfolio-project-open { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; color: #176d77 !important; font-size: .8125rem; font-weight: 650; }
.portfolio-project-open svg { width: 18px; height: 18px; }
.portfolio-carousel-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 44px; }
.portfolio-carousel-count { flex: 0 0 auto; font-size: .875rem; font-variant-numeric: tabular-nums; }
.portfolio-carousel-count strong { font-size: 1.125rem; font-weight: 650; }
.portfolio-carousel-count > span { color: #526773; }
.portfolio-carousel-hint { font-size: .75rem; color: #526773; margin-right: auto; }
.portfolio-carousel-controls { display: none; flex: 0 0 auto; gap: 6px; margin-left: auto; }
.portfolio-carousel.is-enhanced .portfolio-carousel-controls { display: flex; }
body.site-white[data-page="portfolio"] .portfolio-carousel-controls button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #cddfe2 !important;
  border-radius: 50%;
  background: #fff;
  color: #176d77 !important;
  cursor: pointer;
}
.portfolio-carousel-controls [data-portfolio-prev] svg { transform: rotate(180deg); }
.portfolio-carousel-controls [data-portfolio-pause] { border-color: transparent !important; }
.portfolio-carousel-controls [data-portfolio-pause] svg { width: 16px; height: 16px; }
.portfolio-carousel-controls button:disabled { cursor: default; opacity: .5; }
.portfolio-carousel-controls .portfolio-play-icon,
.portfolio-carousel-controls .is-paused .portfolio-pause-icon { display: none; }
.portfolio-carousel-controls .is-paused .portfolio-play-icon { display: block; }
body.site-white[data-page="portfolio"] .portfolio-carousel-controls button:hover { background: #edf5f5; }
body.site-white[data-page="portfolio"] .portfolio-opening-scroll { grid-column: 1 / -1; justify-self: center; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; color: #176d77 !important; font-size: .8125rem; font-weight: 650; text-decoration: none; }
.portfolio-opening-scroll > span { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #cddfe2; border-radius: 50%; }
.portfolio-opening-scroll svg { width: 18px; height: 18px; transform: rotate(90deg); }
.portfolio-opening :is(a, button):focus-visible { outline: 2px solid #176d77; outline-offset: 5px; }
.portfolio-project:hover .portfolio-project-open { text-decoration: underline; text-underline-offset: 4px; }

/* Captions and controls adapt to the actual project width, including split-screen windows. */
@container (max-width: 30rem) {
  body.site-white[data-page="portfolio"] .portfolio-project-open { font-size: 0; gap: 0; }
  .portfolio-project-open svg { width: 22px; height: 22px; }
  .portfolio-carousel-hint { display: none; }
}

/* Stack narrow windows as well as portrait tablets; short wide screens are handled below. */
@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-layout { --portfolio-inline-space: 64px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(auto, 1fr) auto; gap: 16px; width: calc(100% - var(--portfolio-inline-space)); }
  .portfolio-opening-copy { justify-self: start; width: 100%; padding: 0; }
  body.site-white[data-page="portfolio"] .portfolio-opening h1 { max-width: 22em; font-size: clamp(2rem, 4.2vw, 3rem); }
  .portfolio-opening-copy .eyebrow { margin-bottom: 12px; }
  body.site-white[data-page="portfolio"] .portfolio-opening-copy p { max-width: 60ch; margin-block: 14px; }
  .portfolio-carousel { align-self: center; justify-self: center; width: 100%; height: 100%; max-height: min(100%, min(62vw, calc(100svh - var(--breadcrumb-opening-top, 104px) - 325px))); min-height: min(34rem, calc(56.25vw + 80px)); }
}

/* Use an exclusive upper bound: zoom may produce widths between 699 and 700px.
   Phones scale the image into the space left by the title, action and controls. */
@media (width < 700px) {
  body.site-white[data-page="portfolio"] .portfolio-opening { --portfolio-bottom: max(8px, var(--content-safe-area-bottom)); }
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { --portfolio-inline-space: 32px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(auto, 1fr) auto; width: calc(100% - var(--portfolio-inline-space)); gap: clamp(8px, 1.5svh, 14px); }
  .portfolio-opening .breadcrumb-nav { font-size: .75rem; }
  .portfolio-opening-copy { padding: 0; }
  .portfolio-opening-copy .eyebrow { font-size: .6875rem; margin-bottom: 8px; letter-spacing: .08em; }
  body.site-white[data-page="portfolio"] .portfolio-opening h1 { max-width: 18em; font-size: clamp(1.5rem, min(6.5vw, 4.4svh), 2.5rem); line-height: 1.08; }
  body.site-white[data-page="portfolio"] .portfolio-opening-copy p { margin-block: 10px; max-width: 45ch; font-size: .9375rem !important; line-height: 1.4 !important; }
  body.site-white[data-page="portfolio"] .portfolio-opening-contact { min-height: 44px; padding: 10px 14px; font-size: .8125rem !important; }
  .portfolio-carousel { align-self: center; height: 100%; max-height: min(100%, min(78vw, calc(100svh - var(--breadcrumb-opening-top, 104px) - 290px))); min-height: 11.25rem; gap: 4px; }
  .portfolio-project { gap: 10px !important; }
  .portfolio-project-window { grid-template-rows: 20px minmax(0, 1fr) !important; border-radius: 9px !important; }
  .portfolio-project-browser { font-size: 8px; padding-inline: 8px; }
  .portfolio-project-caption { align-items: center; gap: 8px; }
  .portfolio-project-caption > span:first-child { gap: 2px; }
  .portfolio-project-caption small { font-size: .6875rem; }
  .portfolio-project-caption strong { font-size: .9375rem; }
  body.site-white[data-page="portfolio"] .portfolio-project-open { font-size: 0; gap: 0; }
  .portfolio-project-open svg { width: 22px; height: 22px; }
  .portfolio-carousel-hint { display: none; }
  .portfolio-carousel-controls { gap: 2px; }
  body.site-white[data-page="portfolio"] .portfolio-opening-scroll { min-height: 36px; font-size: .75rem; gap: 8px; }
  .portfolio-opening-scroll > span { width: 26px; height: 26px; }
}

/* Narrow landscape phones need scrolling space for a readable, proportional preview. */
@media (width < 700px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { height: auto; }
  .portfolio-carousel { height: calc(56.25vw + 4.5rem); max-height: none; }
}

/* Short landscape viewports keep the copy and project next to each other. */
@media (min-width: 700px) and (max-height: 600px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening { --portfolio-gap: 8px; --portfolio-bottom: max(8px, var(--content-safe-area-bottom)); }
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { --portfolio-inline-space: 40px; width: min(1600px, calc(100% - var(--portfolio-inline-space))); grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(auto, 1fr) auto; row-gap: var(--portfolio-gap); column-gap: 24px; }
  .portfolio-opening .breadcrumb-nav { font-size: .75rem; }
  .portfolio-opening-copy { padding: 0; }
  .portfolio-opening-copy .eyebrow { font-size: .625rem; margin-bottom: 8px; }
  body.site-white[data-page="portfolio"] .portfolio-opening h1 { font-size: clamp(1.375rem, 3.8svh, 2.125rem); }
  body.site-white[data-page="portfolio"] .portfolio-opening-copy p { font-size: .8125rem !important; line-height: 1.35 !important; margin-block: 10px; }
  body.site-white[data-page="portfolio"] .portfolio-opening-contact { min-height: 40px; padding: 8px 12px; font-size: .75rem !important; gap: 10px; }
  .portfolio-carousel { height: 100%; max-height: min(100%, calc(100svh - var(--breadcrumb-opening-top, 104px) - 82px)); min-height: 9.375rem; gap: 0; }
  .portfolio-project { gap: 6px !important; }
  .portfolio-project-window { grid-template-rows: 18px minmax(0, 1fr) !important; border-radius: 8px !important; }
  .portfolio-project-browser { font-size: 8px; }
  .portfolio-project-caption small { font-size: .625rem; }
  .portfolio-project-caption strong { font-size: .875rem; }
  .portfolio-project-caption > span:first-child { gap: 2px; }
  body.site-white[data-page="portfolio"] .portfolio-project-open { font-size: 0; gap: 0; }
  .portfolio-carousel-hint { display: none; }
  .portfolio-carousel-toolbar { min-height: 40px; }
  body.site-white[data-page="portfolio"] .portfolio-carousel-controls button { width: 40px; height: 40px; }
  body.site-white[data-page="portfolio"] .portfolio-opening-scroll { min-height: 30px; font-size: .6875rem; gap: 8px; }
  .portfolio-opening-scroll > span { width: 24px; height: 24px; }
}
/* Keep the introduction visible on compact phones while the preview uses
   the remaining space. */
@media (max-height: 600px) and (width < 700px) and (orientation: portrait) {
  .portfolio-opening-copy p { display: block; }
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { grid-template-rows: auto auto minmax(auto, 1fr) auto; gap: 8px; }
  .portfolio-opening-contact { margin-top: 0; }
  .portfolio-carousel { height: 100%; max-height: min(100%, min(90vw, calc(100svh - var(--breadcrumb-opening-top, 104px) - 194px))); min-height: 10.625rem; }
}
@media (max-height: 540px) and (width < 700px) and (orientation: portrait) {
  .portfolio-opening-copy .eyebrow { display: none; }
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { grid-template-rows: auto auto minmax(auto, 1fr) auto; gap: 4px; }
  body.site-white[data-page="portfolio"] .portfolio-opening-copy p { font-size: .875rem !important; line-height: 1.3 !important; margin-block: 8px; }
  .portfolio-carousel { min-height: 10.625rem; }
  body.site-white[data-page="portfolio"] .portfolio-opening-scroll { min-height: 32px; }
}
@media (min-width: 700px) and (max-height: 360px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { grid-template-rows: auto minmax(auto, 1fr) auto; }
  body.site-white[data-page="portfolio"] .portfolio-opening h1 { font-size: 1.25rem; }
  body.site-white[data-page="portfolio"] .portfolio-opening-copy p { margin-block: 6px; }
  .portfolio-carousel { height: 100%; max-height: min(100%, calc(100svh - var(--breadcrumb-opening-top, 104px) - 46px)); }
}

@media (width < 700px) and (max-height: 480px) and (orientation: portrait) {
  body.site-white[data-page="portfolio"] .portfolio-opening .portfolio-opening-contact { margin-top: 0; }
  body.site-white[data-page="portfolio"] .portfolio-opening .portfolio-opening-scroll { min-height: 24px; }
}

/* The measured header leaves a comfortable eight-pixel gap on short phones. */
@media (max-height: 360px) and (orientation: landscape) {
  html.js-enabled body.site-white[data-page="portfolio"] .portfolio-opening {
    --breadcrumb-opening-top: calc(var(--site-header-clearance, 90px) - 8px);
  }
  body.site-white[data-page="portfolio"] .portfolio-opening .portfolio-opening-scroll { min-height: 24px; }
}
/* On short touch screens the proportional preview yields space to the stable
   bottom safe area. Captions, controls and text retain their original sizes. */
@media (pointer: coarse) and (width < 700px) and (max-height: 600px) and (orientation: portrait),
       (pointer: coarse) and (width < 700px) and (max-height: 360px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-carousel { min-height: 8.5rem; }
}
@media (pointer: coarse) and (width <= 520px) and (max-height: 360px) and (orientation: landscape) {
  body.site-white[data-page="portfolio"] .portfolio-opening.portfolio-opening--devices .portfolio-opening-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  body.site-white[data-page="portfolio"] .portfolio-opening.portfolio-opening--devices .portfolio-opening-copy p { margin-block: 6px; }
  body.site-white[data-page="portfolio"] .portfolio-opening--devices .portfolio-carousel-toolbar { column-gap: 8px; }
}
html:not(.js-enabled) body.site-white[data-page="portfolio"] .portfolio-opening { padding-top: var(--breadcrumb-opening-top, 24px); }
@media (prefers-reduced-motion: reduce) {
  body.site-white[data-page="portfolio"] .portfolio-project { transition: none; }
}
@media print {
  body.site-white[data-page="portfolio"] .portfolio-opening { min-height: 0; padding: 16px 0; }
  body.site-white[data-page="portfolio"] .portfolio-opening-layout { display: block; min-height: 0; height: auto; }
  .portfolio-opening .breadcrumb-nav { width: 100%; max-width: 100%; }
  .portfolio-carousel, .portfolio-opening-scroll { display: none !important; }
}
