/* One photographic scale: Arnau's 30rem portrait, shared by the entire portfolio. */
:root { --project-image-width:30rem;--project-image-ratio:4/5;--project-gallery-gap:clamp(1.25rem,2.2vw,2.5rem); }

/* A contained opening: the title and one complete image share the first row. */
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main {
  display:grid;grid-template-columns:repeat(12,minmax(0,1fr));column-gap:var(--project-gallery-gap);
  padding-top:clamp(1.5rem,3vw,3rem);width:100%;margin:0;overflow:clip;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > section { grid-column:1/-1;min-width:0; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-hero {
  grid-column:1/span 6;grid-row:1;display:flex;flex-direction:column;justify-content:center;
  align-self:center;padding:2rem 0 2rem var(--gutter);min-width:0;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-hero h1 {
  font-size:clamp(2.8rem,5.4vw,6.2rem);line-height:1.01;letter-spacing:-.055em;
  margin:1.75rem 0;padding:0;overflow-wrap:anywhere;max-width:100%;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-hero h1 span { text-align:left; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-kicker { display:block;margin:0;max-width:30rem; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-lead { display:block;margin:0; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-lead p { max-width:30rem;font-size:clamp(1.0625rem,1.5vw,1.4rem);line-height:1.5; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-cover {
  grid-column:7/-1;grid-row:1;justify-self:center;align-self:center;display:block;
  width:min(var(--project-image-width),calc(100% - var(--gutter)));height:auto;min-height:0;
  aspect-ratio:var(--project-image-ratio);margin:0;padding:0;overflow:hidden;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-cover > img {
  display:block;width:100%;height:100%;max-width:100%;max-height:none;min-height:0;
  aspect-ratio:var(--project-image-ratio);object-fit:contain;object-position:center;
  margin:0;padding:0;transform:none;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:not(:has(> .case-cover)) > .case-hero { grid-column:1/-1;max-width:65rem; }

/* Rows of one, two or three equal frames; incomplete rows stay centred. */
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-gallery {
  display:flex;flex-wrap:wrap;justify-content:center;align-items:start;
  gap:var(--project-gallery-gap);width:calc(100% - 2 * var(--gutter));
  max-width:calc(3 * var(--project-image-width) + 2 * var(--project-gallery-gap));
  margin:0 auto var(--space-section,5rem);padding:0;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery > :is(figure,.bbsw-gallery-text) {
  flex:0 1 calc((100% - 2 * var(--project-gallery-gap)) / 3);width:100%;
  max-width:var(--project-image-width);min-width:0;grid-column:auto;
  align-self:start;justify-self:auto;display:block;margin:0;padding:0!important;background:transparent;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery .bbsw-media-frame { display:block;width:100%;margin:0; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-gallery :is(img,video) {
  display:block;width:100%;height:auto;min-height:0;max-width:100%;max-height:none;
  aspect-ratio:var(--project-image-ratio);object-fit:contain;object-position:center;
  padding:0;margin:0;background:transparent;transform:none;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery figcaption {
  display:block;width:100%;padding:.8rem 0 0;margin:0;font-size:.9375rem;line-height:1.45;overflow-wrap:anywhere;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery > .bbsw-gallery-text {
  align-self:center;padding:clamp(1rem,2vw,2rem)!important;box-sizing:border-box;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .bbsw-gallery-text h3 { font-size:clamp(1.6rem,2.1vw,2.3rem);line-height:1.12; }
body.editorial-case:not([data-bbsw-layout="custom"]) .bbsw-gallery-text p { font-size:1rem;line-height:1.6; }

/* Keep the existing story, with editorial alignment on the same three-column grid. */
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-story {
  display:block;width:calc(100% - 2 * var(--gutter));
  max-width:calc(3 * var(--project-image-width) + 2 * var(--project-gallery-gap));
  padding:0;margin:clamp(3rem,5vw,5rem) auto;
}
body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy { display:grid;grid-template-columns:1fr 2fr;gap:1.5rem var(--project-gallery-gap);max-width:none; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy > h2 { grid-column:1;grid-row:1/span 2;font-size:clamp(1.75rem,2.4vw,2.6rem);line-height:1.15;margin:0; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy > p { grid-column:2;max-width:46rem;margin:0;font-size:1.0625rem;line-height:1.65; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy > .case-facts { grid-column:2;margin:0;padding-top:1.5rem; }
body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-film { grid-column:1/-1;width:calc(100% - 2 * var(--gutter));max-width:calc(2 * var(--project-image-width) + var(--project-gallery-gap));margin:0 auto var(--space-section,5rem); }

/* With one or two gallery pieces, the story completes the row beside them. */
@media(min-width:1101px) {
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) > .case-story {
    grid-column:1/span 4;grid-row:2;align-self:center;width:auto;margin:4rem 0 4rem var(--gutter);
  }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) .case-story-copy { display:block; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) .case-story-copy > p { margin-top:1.5rem; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) .case-facts { display:block;margin-top:1.5rem; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) .case-fact { padding-bottom:.8rem; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) > .case-gallery {
    grid-column:5/-1;grid-row:2;align-self:center;width:calc(100% - var(--gutter));margin:4rem var(--gutter) 4rem 0;
  }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main:has(.case-gallery > :first-child):not(:has(.case-film,.case-gallery > :nth-child(3))) > .case-gallery > :is(figure,.bbsw-gallery-text) { flex-basis:calc((100% - var(--project-gallery-gap)) / 2); }
}

/* Project selection uses the same portrait frame for any chosen cover. */
body .work-selector .work-track { --card-width:min(var(--project-image-width),calc((100vw - 2 * var(--gutter) - 2 * var(--card-gap)) / 3)); }
body .work-selector .work-card-image { height:auto;max-width:var(--project-image-width);aspect-ratio:var(--project-image-ratio);background:transparent; }
body .work-selector .work-card-link .work-card-image img { width:100%;height:100%;object-fit:contain;object-position:center;padding:0;transform:none; }
body .work-selector .work-card-link:hover img { transform:none; }
body .project-index .project-index-intro { gap:clamp(1.25rem,3vh,2rem); }
body .project-index .project-index-intro h2 { font-size:clamp(2.5rem,4vw,4rem);margin:0; }
body .project-index .index-preview { position:relative;inset:auto;flex:0 1 auto;min-height:0;width:min(100%,var(--project-image-width),max(8rem,calc((100dvh - 27rem) * .8)));height:auto;aspect-ratio:var(--project-image-ratio);max-height:none;transform:none;box-shadow:none; }
body .project-index .index-preview img { width:100%;height:100%;object-fit:contain;object-position:center;padding:0;transform:none; }

@media(max-width:1100px) {
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery > :is(figure,.bbsw-gallery-text) { flex-basis:calc((100% - var(--project-gallery-gap)) / 2); }
  body .work-selector .work-track { --card-width:min(var(--project-image-width),calc((100vw - 2 * var(--gutter) - var(--card-gap)) / 2)); }
}
@media(max-width:700px) {
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main { display:block;padding-top:0; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-hero { padding:2.5rem var(--gutter) 2rem; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-hero h1 { font-size:clamp(2.5rem,10vw,4rem); }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-main > .case-cover { width:min(var(--project-image-width),calc(100% - 2 * var(--gutter)));margin-inline:auto; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-gallery > :is(figure,.bbsw-gallery-text) { flex-basis:100%; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy { display:block; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy > p { margin-top:1.4rem; }
  body.editorial-case:not([data-bbsw-layout="custom"]) .case-story-copy > .case-facts { margin-top:1.25rem; }
  body .work-selector .work-track { --card-width:min(var(--project-image-width),calc(100vw - 2 * var(--gutter))); }
}
