/* The canvas handles taps and drags for the gallery tour. */
#gallery { touch-action: none; }

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  #work-dialog[open] {
    --viewer-top: max(12px, env(safe-area-inset-top));
    --viewer-right: max(12px, env(safe-area-inset-right));
    --viewer-bottom: max(12px, env(safe-area-inset-bottom));
    --viewer-left: max(12px, env(safe-area-inset-left));
    position: fixed;
    inset: var(--viewer-top) var(--viewer-right) var(--viewer-bottom) var(--viewer-left);
    display: flex;
    flex-direction: column;
    width: min(680px, calc(100% - var(--viewer-left) - var(--viewer-right)));
    height: fit-content;
    max-height: calc(100dvh - var(--viewer-top) - var(--viewer-bottom));
    padding: clamp(12px, 4vw, 20px);
    overflow: hidden;
    touch-action: manipulation;
  }

  #work-dialog .dialog-header {
    position: static;
    flex: none;
    margin-bottom: 12px;
  }

  #work-dialog .close-button {
    width: 44px;
    height: 44px;
  }

  #work-dialog .work-layout {
    min-height: 0;
    align-items: start;
    gap: 16px;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0 6px 6px;
  }

  #work-image {
    max-height: min(54dvh, calc(100dvh - var(--viewer-top) - var(--viewer-bottom) - 110px));
  }
}

@media (max-width: 700px) {
  #work-dialog .work-layout { grid-template-columns: minmax(0, 1fr); }
}
