/* Keep the original recording pixels, proportions and contour masks.
   Size the visible phone bounds, rather than the surrounding recording canvas. */
.case-spacegrid{--spacegrid-section-min-height:max(0px,calc((100vh - var(--sticky-header-height,var(--header-height,0px))) * .7));--spacegrid-frame-height:95vh;--spacegrid-frame-padding:var(--case-section-gap)}
.case-spacegrid .spacegrid-animation-section{--recording-phone-height:max(240px,calc(var(--spacegrid-frame-height) - 2 * var(--spacegrid-frame-padding) - var(--spacegrid-frame-border,0px)))}
@supports(height:100dvh){.case-spacegrid{--spacegrid-section-min-height:max(0px,calc((100dvh - var(--sticky-header-height,var(--header-height,0px))) * .7));--spacegrid-frame-height:95dvh}}
.case-spacegrid .spacegrid-animation-section>.feature-layout{height:auto;min-height:0;align-items:start}
.case-spacegrid .spacegrid-animation-section>.feature-layout>.case-cell{min-width:0;min-height:0}
.case-spacegrid .case-body figure.spacegrid-recording-figure{display:flex;align-items:flex-start;justify-content:center;height:auto;min-height:0;max-height:none;padding:0;margin:0;background:transparent}
.case-spacegrid .spacegrid-recording-figure picture{position:relative;display:block;flex:none;max-width:100%;overflow:hidden}
/* Inspo phone: x=100..704, y=84..1313 inside the 800 × 1399 canvas. */
.case-spacegrid [data-recording="inspo"] picture{width:min(100%,calc(var(--recording-phone-height) * 604 / 1229));aspect-ratio:604 / 1229}
/* View in Room: x=84..1316, y=98..703 inside the 1402 × 800 canvas. */
.case-spacegrid [data-recording="room"] picture{width:min(100%,calc(var(--recording-phone-height) * 1232 / 605));aspect-ratio:1232 / 605}
.case-spacegrid .case-body figure.spacegrid-recording-figure img{position:absolute;display:block;min-width:0;min-height:0;max-width:none;max-height:none;margin:0;object-fit:fill;border-radius:0;mask-position:0 0;mask-size:100% 100%;mask-repeat:no-repeat;-webkit-mask-position:0 0;-webkit-mask-size:100% 100%;-webkit-mask-repeat:no-repeat}
.case-spacegrid .case-body figure.spacegrid-recording-figure .spacegrid-recording-inspo{width:calc(100% * 800 / 604);height:calc(100% * 1399 / 1229);left:calc(-100% * 100 / 604);top:calc(-100% * 84 / 1229);mask-image:url('/assets/projects/spacegrid-inspo-mask.svg');-webkit-mask-image:url('/assets/projects/spacegrid-inspo-mask.svg')}
.case-spacegrid .case-body figure.spacegrid-recording-figure .spacegrid-recording-room{width:calc(100% * 1402 / 1232);height:calc(100% * 800 / 605);left:calc(-100% * 84 / 1232);top:calc(-100% * 98 / 605);mask-image:url('/assets/projects/spacegrid-room-mask.svg');-webkit-mask-image:url('/assets/projects/spacegrid-room-mask.svg')}
/* Content-led sections share the case-study spacing rhythm. Visuals are capped to the viewport. */
.case-spacegrid .case-body>:is(#development,#designs){padding-block:0}
.case-spacegrid .spacegrid-frame{display:flex;flex-direction:column;justify-content:center;min-height:var(--spacegrid-section-min-height);padding-block:var(--spacegrid-frame-padding);margin:0}
.case-spacegrid .spacegrid-frame-content{display:flex;flex-direction:column;gap:32px;width:100%;min-width:0}
.case-spacegrid .spacegrid-frame-content>.chapter-row{margin:0}
.case-spacegrid .case-body figure.spacegrid-frame-media{flex:none;width:100%;height:var(--frame-media-height,calc(var(--spacegrid-frame-height) - 2 * var(--spacegrid-frame-padding)));min-height:0;margin:0}
.case-spacegrid .spacegrid-animation-section>.feature-layout{width:100%;align-items:start}
.case-spacegrid .spacegrid-room-section>.feature-layout>.case-cell:first-child{grid-column:span 4}
.case-spacegrid .spacegrid-room-section>.feature-layout>.case-cell:last-child{grid-column:span 8}
.case-spacegrid .case-body .spacegrid-room-section figure.spacegrid-recording-figure{box-sizing:border-box;padding-left:64px;justify-content:center}
@media(max-width:650px){
 .case-spacegrid{--spacegrid-frame-padding:var(--case-section-gap)}
 .case-spacegrid .spacegrid-room-section>.feature-layout>.case-cell{grid-column:1/-1}
 .case-spacegrid .case-body .spacegrid-room-section figure.spacegrid-recording-figure{padding-left:24px}
 .case-spacegrid .spacegrid-animation-section>.feature-layout{row-gap:32px}
 .case-spacegrid .spacegrid-animation-section{--recording-phone-height:max(240px,min(65dvh,620px))}
}

.case-spacegrid .case-body .spacegrid-frame{margin:0}
.case-spacegrid .case-body figure.spacegrid-frame-media>a{width:100%;height:100%;min-height:0;display:flex;align-items:center;justify-content:center}
.case-spacegrid .case-body figure.spacegrid-frame-media img{width:100%;height:100%;max-height:none;object-fit:contain}

/* One shared rule at each section boundary; existing adjacent rules are reused. */
.case-spacegrid .case-body>:is(#development,#designs){border-bottom:0}
.case-spacegrid .spacegrid-frame{--spacegrid-frame-border:1px;box-sizing:border-box;border-bottom:1px solid var(--line)}
/* Designs is one chapter: no internal dividers. Next project closes the chapter. */
.case-spacegrid #designs>.spacegrid-frame{--spacegrid-frame-border:0px;border-bottom:0}

/* Related content frames share an 80px gap; viewport minimum belongs to the chapter. */
.case-spacegrid .case-body>:is(#development,#designs)>.spacegrid-frame:has(+.spacegrid-frame){padding-bottom:40px}
.case-spacegrid .case-body>:is(#development,#designs)>.spacegrid-frame+.spacegrid-frame{padding-top:40px}
.case-spacegrid .case-body>:is(#development,#designs)>.spacegrid-frame{min-height:0}
.case-spacegrid .case-body>:is(#development,#designs){min-height:var(--spacegrid-section-min-height)}

/* Research questions and supporting evidence belong to one Development chapter. */
.case-spacegrid #development>.spacegrid-frame:has(+.spacegrid-frame){border-bottom:0;--spacegrid-frame-border:0px}
