/* Reading and media layout for the seven case studies linked from Works.
   Keep this file mobile-only, including when loaded without the HTML media hint. */
@media screen and (max-width: 860px) {
  .detail-case-page {
    --page-width: min(720px, calc(100vw - 40px));
  }
  .detail-case-page .case-study-main {
    --case-page-width: min(720px, calc(100vw - 40px));
    --case-text-width: 100%;
    --case-media-width: 100%;
  }
  .detail-case-page .case-main {
    width: var(--page-width);
  }
  .detail-case-page :is(.case-header, .case-hero, .model-hero) h1 {
    max-width: 20ch;
    margin-inline: auto;
    font-size: clamp(30px, 7.6vw, 40px);
    line-height: 1.2;
    word-break: normal;
    overflow-wrap: break-word;
    text-wrap: balance;
  }
  .detail-case-page :is(.case-title-cn, .hero-subtitle) {
    max-width: 32ch;
    margin: 20px auto 0;
    font-size: 17px;
    line-height: 1.7;
    text-wrap: pretty;
  }
  .detail-case-page .case-header {
    margin-bottom: 32px;
  }
  .platform-components-case-page .case-study-main {
    --case-page-width: calc(100vw - 40px);
    width: calc(100vw - 40px);
    padding-top: 104px;
  }
  .platform-components-case-page .case-content {
    width: 100%;
  }
  .platform-components-case-page .site-header:has(> .detail-back-control) {
    position: fixed !important;
    inset: 0 0 auto !important;
    width: 100%;
    min-height: 68px !important;
    padding: max(10px, env(safe-area-inset-top)) 20px 10px !important;
  }
  .platform-components-case-page .detail-back-control::after {
    background: rgba(255, 255, 255, .58) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    backdrop-filter: blur(20px) !important;
    box-shadow:
      0 2px 5px rgba(30, 26, 22, .025),
      0 6px 18px rgba(30, 26, 22, .035),
      inset 0 0 0 1px rgba(255, 255, 255, .45) !important;
  }
  .platform-components-case-page .case-carousel-button.prev {
    left: -12px;
  }
  .platform-components-case-page .case-carousel-button.next {
    right: -12px;
  }
  .platform-components-case-page .case-meter > span {
    transform: translateY(-6px);
  }
  .platform-components-case-page .case-results-carousel {
    width: calc(100% + 40px);
    max-width: none;
    margin-left: -20px;
    margin-right: -20px;
    overflow: visible;
  }
  .platform-components-case-page .case-results-carousel > .case-carousel-button {
    display: none;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-track {
    display: flex;
    height: auto !important;
    gap: 16px;
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 0;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-track::-webkit-scrollbar {
    display: none;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide,
  .platform-components-case-page .case-results-carousel .case-delivery-slide:is(.is-active, .is-prev, .is-next) {
    position: relative;
    inset: auto;
    flex: 0 0 calc(100% - 72px);
    width: calc(100% - 72px);
    max-width: none;
    height: auto !important;
    min-height: 0;
    margin: 0;
    opacity: 1 !important;
    visibility: visible;
    pointer-events: auto;
    transform: none !important;
    contain: none;
    transition: none;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide:first-child {
    margin-left: 20px;
    scroll-snap-align: none;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide:nth-child(2) {
    order: 3;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide:nth-child(3) {
    order: 2;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide::after {
    display: none;
  }
  .platform-components-case-page .case-results-carousel .case-delivery-slide img {
    position: static;
    width: 100%;
    height: auto !important;
    min-height: 0;
    object-fit: contain;
    transform: none !important;
  }
  .platform-components-case-page
    .case-delivery-slide.is-active
    .case-delivery-preview-button {
    position: absolute;
    min-width: 88px;
    width: auto;
    height: 36px;
    min-height: 36px;
    padding: 0 12px;
  }
  .platform-components-case-page .case-delivery-preview-button::after {
    content: "";
    position: absolute;
    inset: -6px;
  }

  /* Compact, readable project facts; longer values wrap in their own column. */
  .detail-case-page :is(.project-meta, .aily-case-meta) {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin: 28px 0 24px;
    padding: 4px 0;
  }
  .detail-case-page :is(.project-meta, .aily-case-meta) > div {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    align-items: baseline;
    gap: 12px;
    padding: 12px 0;
    border: 0;
  }
  .detail-case-page :is(.project-meta, .aily-case-meta) > div + div {
    border-top: .5px solid rgba(75, 70, 64, .12);
  }
  .detail-case-page :is(.project-meta, .aily-case-meta) dt {
    margin: 0;
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: .07em;
  }
  .detail-case-page :is(.project-meta, .aily-case-meta) dd {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
  }

  /* Narrative text is distinct from labels, captions and display metrics. */
  .detail-case-page :is(.markdown-format, .case-prose, .model-prose, .plain-list),
  .detail-case-page .markdown-format :is(p, li),
  .detail-case-page .model-prose :is(p, li),
  .detail-case-page :is(.section-heading, .chapter-head, .case-head) > p:not(.eyebrow, .chapter-index) {
    font-size: 16px;
    line-height: 1.85;
  }
  .detail-case-page :is(.section-heading, .case-section-title, .chapter-head, .case-head) h2 {
    font-size: clamp(24px, 5.9vw, 28px);
    line-height: 1.45;
    text-wrap: balance;
  }
  .detail-case-page :is(.markdown-format, .model-prose) h3 {
    line-height: 1.5;
    text-wrap: pretty;
  }
  .detail-case-page :is(.section-heading, .case-section-title, .chapter-head, .case-head) {
    margin-bottom: 24px;
  }
  .detail-case-page .case-section-title p {
    margin: 0;
  }
  .detail-case-page :is(.story-case-format, .case-modules) {
    gap: 64px;
  }
  .detail-case-page :is(.case-section, .model-chapter, .model-stage) {
    scroll-margin-top: 80px;
  }
  .detail-case-page :is(.model-prose, .case-prose) :is(ul, ol) {
    padding-left: 20px;
  }
  .detail-case-page :is(.model-prose, .case-prose) li :is(ul, ol) {
    padding-left: 16px;
  }
  .detail-case-page figcaption {
    font-size: 13px;
    line-height: 1.7;
    overflow-wrap: break-word;
  }
  .detail-case-page .markdown-format figcaption {
    text-align: left;
  }
  .detail-case-page :is(.case-panel, .case-editorial-panel) {
    padding: 22px 18px;
  }
  .detail-case-page .case-panel :is(h3, h4) {
    font-size: 18px;
    line-height: 1.5;
  }

  /* Keep numeric columns compact and leave room for the text that explains them. */
  .detail-case-page .case-table :is(th, td) {
    padding: 14px 10px;
    font-size: 14px;
    line-height: 1.75;
    vertical-align: top;
    overflow-wrap: break-word;
  }
  .case-study-page--lark-app-store .case-panel .case-table th:first-child {
    width: 60%;
  }
  .detail-case-page #delivery > .case-table th:first-child { width: 30%; }
  .detail-case-page #delivery > .case-table th:nth-child(2) { width: 14%; }
  .detail-case-page #delivery > .case-table th:last-child { width: 56%; }
  .platform-components-case-page #delivery > .case-table {
    border-top: 0;
    background-image: linear-gradient(var(--case-module-line), var(--case-module-line));
    background-position: left top;
    background-repeat: no-repeat;
    background-size: 100% 0.5px;
  }
  .platform-components-case-page #delivery > .case-table :is(th, td) {
    border-bottom: 0;
  }
  .platform-components-case-page #delivery > .case-table tr {
    background-image: linear-gradient(var(--case-module-line), var(--case-module-line));
    background-position: left bottom;
    background-repeat: no-repeat;
    background-size: 100% 0.5px;
  }
  .detail-case-page .case-editorial-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
    margin-top: 24px;
    padding-top: 24px;
  }
  .detail-case-page .case-navigation-body {
    height: auto !important; /* The original diagram sets a fixed inline height. */
    min-height: 0;
  }
  .case-study-page--lark-app-store
    .case-navigation-evidence
    .case-architecture-decisions p {
    margin-bottom: 0;
  }
  .case-study-page--lark-app-store
    .markdown-format
    figure.case-before-after-figure.case-breakout-image {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 1462 / 1088;
    margin-top: 24px !important;
    margin-left: 0 !important;
    overflow: hidden;
    transform: none !important;
    pointer-events: none;
  }
  .case-study-page--lark-app-store .case-before-empty {
    position: absolute;
    top: -13.6%;
    left: -18.4%;
    width: 136.8% !important;
    max-width: none;
    transition: none;
  }
  .case-study-page--lark-app-store .case-before-data,
  .case-study-page--lark-app-store .case-before-after-figure:hover .case-before-data {
    display: none !important;
    opacity: 0 !important;
    transition: none !important;
  }
  .detail-case-page [data-horizontal-pan] {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
  }
  .detail-case-page [data-horizontal-pan] > img {
    transform: none !important; /* Native touch scrolling replaces pointer tracking. */
  }
  .case-study-page--lark-app-store .markdown-format figure.case-homepage-preview {
    aspect-ratio: auto !important;
    overflow: visible !important;
  }
  .case-study-page--lark-app-store .case-homepage-preview__viewport {
    height: auto !important;
    max-height: none !important;
    padding-bottom: 0 !important;
    overflow: visible !important;
    overscroll-behavior: auto !important;
    scrollbar-width: none !important;
  }
  .case-study-page--lark-app-store .case-homepage-preview__viewport::-webkit-scrollbar {
    display: none;
  }
  .case-study-page--lark-app-store .case-homepage-preview img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
  }
  .case-study-page--lark-app-store .case-homepage-preview__scrim {
    display: none !important;
  }
  .case-study-page--lark-app-store
    .case-solution-block--visual-upgrade
    .case-solution-visual-copy > h4 {
    display: none;
  }
  .case-study-page--lark-app-store .case-solution-visual-card--compact {
    pointer-events: none;
    cursor: default;
    -webkit-tap-highlight-color: transparent;
  }
  .case-study-page--lark-app-store .case-solution-visual-card--compact :is(figure, img) {
    pointer-events: none;
    user-select: none;
  }
  .case-study-page--lark-app-store .case-solution-visual-card:has(.case-solution-visual-placeholder--video) {
    grid-template-rows: auto auto !important;
    align-content: start;
    gap: 18px;
    padding: 18px;
  }
  .case-study-page--lark-app-store .case-solution-visual-placeholder--video {
    display: block;
    height: auto;
    aspect-ratio: auto;
  }
  .case-study-page--lark-app-store .case-solution-visual-video {
    display: block;
    width: 100%;
    height: auto;
  }
  .detail-case-page :is(.case-solution-visual-card, .homepage-visual-card):has([data-horizontal-pan])
    :is(.case-solution-visual-copy, .homepage-visual-card__copy)::after {
    content: "左右滑动查看完整插画";
    display: block;
    margin-top: 8px;
    color: #817a73;
    font-size: 12px;
    line-height: 1.6;
  }
  .skillhub-case-page .homepage-visual-card--wide:has([data-horizontal-pan])
    .homepage-visual-card__copy::after {
    content: none;
    display: none;
  }
  .detail-case-page .case-breakout-intro { margin-top: 40px !important; }
  .detail-case-page .lark-system-hero .token-dark {
    left: 12px;
    bottom: 12px;
    transform: none;
    padding: 8px 12px;
    min-height: 0;
    font-size: 11px;
    line-height: 1.4;
  }
  .detail-case-page .case-delivery-carousel {
    --case-delivery-slide-height: clamp(320px, 130vw, 520px);
  }
  .detail-case-page .case-delivery-slide img {
    height: 100%;
    min-height: 0;
    object-fit: contain;
    transform: none;
  }
  .platform-components-case-page #delivery .case-delivery-slide img {
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    object-fit: initial;
    object-position: top center;
    transform: none;
  }
  .detail-case-page .case-delivery-slide:is(.is-prev, .is-next) { visibility: hidden; }
  .detail-case-page .case-delivery-preview-button { bottom: 16px; }
  .detail-case-page :is(.case-delivery-page-mask, .case-delivery-page-blur) { display: none; }

  /* Admin: keep the index beside the complete heading, never in a sliver. */
  .admin-case-page .problem-grid article {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .admin-case-page .problem-grid :is(.small-index, h3, p) { grid-column: 1; }
  .admin-case-page :is(.problem-grid, .principle-grid, .solution-copy, .insight-row) p,
  .admin-case-page .decision-list :is(strong, span) {
    font-size: 15px;
    line-height: 1.85;
  }
  .admin-case-page :is(.project-timeline p, .source-note, .research-metrics-note) {
    font-size: 13px;
    line-height: 1.75;
  }

  /* SkillHub: explanatory cards use the same reading scale as the article. */
  .skillhub-case-page :is(.question-grid, .principle-grid, .decision-list, .version-path,
    .editorial-note, .delivery-stages, .risk-definitions, .review-grid, .homepage-visual-card__copy) p {
    font-size: 15px;
    line-height: 1.85;
  }
  .skillhub-case-page .case-section { margin-top: 64px; }
  .skillhub-case-page .chapter { padding-top: 28px; }
  .skillhub-case-page .viewer-zoom-controls {
    grid-template-columns: 44px 64px 44px;
    height: 52px;
  }
  .skillhub-case-page .viewer-zoom-button { width: 44px; height: 44px; }
  .skillhub-case-page .viewer-viewport { inset: 0; }
  .skillhub-case-page .viewer-canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
  }
  .skillhub-case-page .viewer-image {
    width: 100vw;
    height: auto;
    max-width: none;
    max-height: none;
  }
  .platform-components-case-page .case-preview-modal__panel {
    border-right-width: 0;
    border-left-width: 0;
  }
  .platform-components-case-page .case-preview-modal__image {
    width: 100vw;
    max-width: none;
  }

  /* Full-screen image previews open edge-to-edge at 1x on mobile. */
  .admin-case-page .image-preview[open] {
    display: block;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: none;
  }
  .admin-case-page .image-preview-content {
    --image-gesture-scale: 1;
    --image-gesture-x: 0px;
    --image-gesture-y: 0px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: auto;
    max-width: none;
    max-height: none;
    transform: translate(
        calc(-50% + var(--image-gesture-x)),
        calc(-50% + var(--image-gesture-y))
      )
      scale(var(--image-gesture-scale));
    transform-origin: center;
    transition: opacity 240ms ease;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
  }
  .admin-case-page .image-preview.is-open .image-preview-content {
    transform: translate(
        calc(-50% + var(--image-gesture-x)),
        calc(-50% + var(--image-gesture-y))
      )
      scale(var(--image-gesture-scale));
  }

  /* Security: remove oversized chapter gaps and make the entire index row tappable. */
  .account-security-case-page .case-hero { padding-bottom: 8px; }
  .account-security-case-page .case-section { padding-top: 64px; }
  .account-security-case-page .case-conclusion { padding: 80px 0; }
  .account-security-case-page .case-index { margin-top: 28px; padding: 20px 0; }
  .account-security-case-page .case-index ol { grid-template-columns: 1fr; gap: 0; }
  .account-security-case-page .case-index a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.6;
  }
  .account-security-case-page .case-index li + li { border-top: .5px solid var(--line); }
  .account-security-case-page .case-table--delivery th:first-child { width: 44px; }
  .account-security-case-page .case-table--delivery th:nth-child(2) { width: auto; }
  .account-security-case-page .case-table--delivery th:last-child { width: 80px; }
  .account-security-case-page .case-table--delivery th { white-space: nowrap; }
  .account-security-case-page .case-table--delivery td:first-child { white-space: nowrap; }
  .account-security-case-page .case-table--delivery td:last-child { white-space: nowrap; }

  /* Account growth: show the whole image in the article; enlarge it on demand. */
  .account-model-case-page :is(.model-media-viewport, .model-media--panorama) .model-media-button { min-width: 0; }
  .account-model-case-page .model-media-button { position: relative; }
  .account-model-case-page .model-media-button::after {
    content: none;
    display: none;
  }
  .account-model-case-page .model-index ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-model-case-page .model-index a { font-size: 14px; }
  .account-model-case-page .model-stage-label { font-size: 13px; line-height: 1.7; }

  /* Center dense source images and expose touch pan/pinch without visual controls. */
  .account-model-case-page .model-lightbox {
    display: block;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 0;
    touch-action: none;
  }
  .account-model-case-page .model-lightbox[hidden] { display: none; }
  .account-model-case-page .model-lightbox-stage {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    overflow: hidden;
    touch-action: none;
    pointer-events: none;
  }
  .account-model-case-page .model-lightbox-stage img {
    --image-gesture-scale: 1;
    --image-gesture-x: 0px;
    --image-gesture-y: 0px;
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 100vw;
    height: auto;
    max-width: none;
    max-height: none;
    transform: translate(
        calc(-50% + var(--image-gesture-x)),
        calc(-50% + var(--image-gesture-y))
      )
      scale(var(--image-gesture-scale));
    transform-origin: center;
    touch-action: none;
    pointer-events: auto;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
  }
  .account-model-case-page .model-lightbox-caption {
    position: absolute;
    z-index: 1;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    margin: 0;
    pointer-events: none;
  }
  .account-model-case-page .model-lightbox-close { z-index: 3; }
  .account-security-case-page .image-preview[open] {
    display: block;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: none;
  }
  .account-security-case-page .image-preview-content {
    --image-gesture-scale: 1;
    --image-gesture-x: 0px;
    --image-gesture-y: 0px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: auto;
    max-width: none;
    max-height: none;
    transform: translate(
        calc(-50% + var(--image-gesture-x)),
        calc(-50% + var(--image-gesture-y))
      )
      scale(var(--image-gesture-scale));
    transform-origin: center;
    transition: opacity 240ms ease;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
  }
  .account-security-case-page
    .image-preview.is-open
    .image-preview-content {
    transform: translate(
        calc(-50% + var(--image-gesture-x)),
        calc(-50% + var(--image-gesture-y))
      )
      scale(var(--image-gesture-scale));
  }
  .account-security-case-page .image-preview-close {
    z-index: 3;
    border-radius: 50%;
    background: rgba(25, 22, 20, .72);
  }
}

@media screen and (min-width: 375px) and (max-width: 600px) {
  .detail-case-page .case-kpi-grid,
  .detail-case-page .aily-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-case-page .case-kpi-card { padding: 20px 16px; }
  .detail-case-page .case-kpi-card strong { font-size: 30px; }
  .detail-case-page .case-kpi-card p { font-size: 14px; line-height: 1.7; }
  .detail-case-page .aily-result-grid article {
    padding: 22px 16px;
    border-right: 0;
    border-bottom: .5px solid rgba(75, 70, 64, .12);
  }
  .detail-case-page .aily-result-grid article:nth-child(odd) { border-right: .5px solid rgba(75, 70, 64, .12); }
  .detail-case-page .aily-result-grid article:nth-last-child(-n + 2) { border-bottom: 0; }
  .detail-case-page .aily-result-grid strong { font-size: 32px; }
  .detail-case-page .aily-result-grid p { font-size: 13px; line-height: 1.7; }
}

@media screen and (max-width: 600px) {
  .skillhub-case-page .question-grid { grid-template-columns: 1fr; gap: 20px; }
  .skillhub-case-page .question-grid h3 { margin-bottom: 10px; }
  .account-security-case-page .case-media-grid--login { grid-template-columns: 1fr; }
  .account-security-case-page .case-2fa-rate {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 12px;
  }
  .account-security-case-page .case-2fa-rate strong { font-size: clamp(32px, 9vw, 44px); }
  .account-security-case-page .case-2fa-rate small { font-size: 16px; }
}
