/* PHASE A3 — shared Viewer containment for tablet landscape and larger tablets. */
@media (min-width: 768px) and (max-width: 1200px) {
  body[data-page="case-study"] {
    /* Shared safe-space budget for the Viewer title, controls and dialog padding. */
    --viewer-tablet-ui-space: 150px;
  }

  body[data-page="case-study"] .content-viewer-dialog {
    width: calc(100vw - 40px);
    height: min(calc(100vh - 40px), 760px);
    height: min(calc(100dvh - 40px), 760px);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    box-sizing: border-box;
    overflow: hidden;
  }

  body[data-page="case-study"] .content-viewer-layout {
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    height: auto;
    overflow: hidden;
  }

  body[data-page="case-study"] .content-viewer-media-area,
  body[data-page="case-study"] .content-viewer-details,
  body[data-page="case-study"] .content-viewer-rail {
    min-width: 0;
    min-height: 0;
    max-height: 100%;
  }

  body[data-page="case-study"] .content-viewer-media-area {
    overflow: hidden;
    align-items: center;
    justify-content: center;
  }

  body[data-page="case-study"] .content-viewer-details {
    align-self: start;
    overflow-y: auto;
  }

  body[data-page="case-study"] .content-viewer-rail {
    overflow: hidden;
  }

  body[data-page="case-study"] .content-viewer-thumbnails {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
  }

  body[data-page="case-study"] .content-viewer-media-frame {
    height: min(470px, calc(100vh - var(--viewer-tablet-ui-space)));
    height: min(470px, calc(100dvh - var(--viewer-tablet-ui-space)));
    max-height: min(470px, calc(100vh - var(--viewer-tablet-ui-space)));
    max-height: min(470px, calc(100dvh - var(--viewer-tablet-ui-space)));
    flex: 0 1 auto;
  }

  body[data-page="case-study"] .content-viewer-layout.is-image-gallery {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-details,
  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-media-area,
  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-rail {
    min-height: 0;
    max-height: 100%;
  }

  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-details {
    overflow-y: auto;
  }

  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-media-area {
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  body[data-page="case-study"] .content-viewer-layout.is-image-gallery .content-viewer-rail {
    overflow: hidden;
  }

  /* Case03 type 11 is a 1080×2400 long image, not a fixed 9:16 frame. */
  body[data-page="case-study"][data-case-study="multi-brand-content"] .content-viewer-media-frame[data-viewer-type="10"],
  body[data-page="case-study"][data-case-study="multi-brand-content"] .content-viewer-media-frame[data-viewer-type="11"] {
    aspect-ratio: auto;
  }

  body[data-page="case-study"][data-case-study="multi-brand-content"] .content-viewer-media-frame[data-viewer-type="10"] .content-viewer-image,
  body[data-page="case-study"][data-case-study="multi-brand-content"] .content-viewer-media-frame[data-viewer-type="11"] .content-viewer-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
  }
}
