@charset "UTF-8";

/* iPad/touch fixes only. Load after the existing page styles. */
@media (pointer: coarse) {
  /* Reserve a horizontal swipe for the gallery while retaining page pan and pinch zoom. */
  body .gallery-view {
    touch-action: pan-y pinch-zoom;
  }
}

@media (pointer: coarse) and (max-width: 1366px) {
  /* Keep existing control forms; increase their hit areas on touch devices. */
  body #detail-dialog .dialog-close,
  body #detail-dialog .gallery-nav button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  body #detail-dialog .gallery-nav button {
    flex-basis: 44px;
  }
  body #work .choice {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Keep the generic case viewer's controls in view in both iPad orientations.
   The dedicated photography viewer retains its existing grid and full-frame layout. */
@media (pointer: coarse) and (min-width: 761px) and (max-width: 1366px),
       (pointer: coarse) and (max-width: 1366px) and (max-height: 700px) {
  body:not(.page-photography) #detail-dialog:has(.gallery-view) {
    height: 90dvh;
    max-height: calc(100dvh - 24px);
    overflow: hidden;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) > .dialog-close {
    position: absolute;
    float: none;
    top: 14px;
    right: 14px;
    margin: 0;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) > #dialog-content {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    padding: 28px 32px 20px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > * {
    flex-shrink: 0;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > .eyebrow {
    margin: 0;
    padding-right: 52px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > h2 {
    margin: 8px 0 12px;
    padding-right: 52px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > p:not(.eyebrow):not(.gallery-count) {
    margin: 0;
    padding-right: 52px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-view {
    flex: 1 1 0;
    width: 100%;
    height: auto;
    min-height: 0;
    margin-top: 16px;
    padding: 12px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-view > img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  /* Cropped-source SVGs already preserve their viewBox ratio with xMidYMid meet. */
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-view > svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-nav {
    gap: 12px;
    margin-top: 12px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-nav p {
    flex: 1;
    min-width: 0;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-count {
    margin: 8px 0 0;
  }
}

@media (pointer: coarse) and (max-width: 1366px) and (max-height: 600px) {
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner {
    padding: 18px 24px 14px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > h2 {
    margin: 5px 0 8px;
    font-size: 28px;
    line-height: 1.25;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .dialog-inner > p:not(.eyebrow):not(.gallery-count) {
    font-size: 14px;
    line-height: 1.6;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-view {
    margin-top: 12px;
    padding: 8px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-nav {
    margin-top: 8px;
  }
  body:not(.page-photography) #detail-dialog:has(.gallery-view) .gallery-count {
    margin-top: 4px;
  }
}

/* Balance only the two paragraphs that left a single character on iPad portrait. */
@media (pointer: coarse) and (min-width: 761px) and (max-width: 900px) {
  body.page-technology .tech-hero .hero-intro,
  body.page-technology #tech-stability .section-lead .lead-copy > p {
    text-wrap: balance;
  }
  body.page-technology .tech-hero .hero-intro br {
    display: none;
  }
}