/* OKU mobile share accessibility patch. Scope: sharing modals only. */
/* The active context ayah is paper-coloured even in night mode. The selected
   translation therefore needs a dark ink independent of inherited text colour. */
.context-verses .context-verse.is-current .context-verse__tr,
.context-verses .context-verse.is-current .context-verse__translation,
html[data-oku-theme="dark"] .context-verses .context-verse.is-current .context-verse__tr,
html[data-oku-theme="dark"] .context-verses .context-verse.is-current .context-verse__translation {
  color: #171717 !important;
  -webkit-text-fill-color: #171717 !important;
  opacity: 1 !important;
}
@media (max-width: 860px) {
  /* iOS/Safari can otherwise trap the touch gesture on the centred overlay. */
  .native-share,
  .ky-share-dialog,
  .ky-share-sheet {
    min-height: 0 !important;
    max-height: calc(100dvh - 16px) !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .native-share {align-items: start !important; padding-bottom: max(24px,env(safe-area-inset-bottom,0px)) !important;}
  .native-share-panel {max-height: none !important; overflow: visible !important;}
  .ky-share-sheet {height: auto !important;}
}
@media (max-width: 860px) {
  /* Native dialog surfaces: never exceed the visual viewport; scroll within the dialog. */
  dialog.share-dialog,
  dialog.oku-quote-share-dialog,
  dialog.oku-six-share-dialog,
  dialog.oku-electro-share-dialog,
  dialog.oku-video-share-dialog,
  dialog[class*="share-dialog"] {
    box-sizing: border-box !important;
    width: calc(100vw - 20px) !important;
    max-width: 760px !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    margin: auto !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }
  /* Original quote and new hadith use the same sharing shell. */
  .oku-quote-share-dialog .oku-quote-share-dialog__shell {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .oku-quote-share-dialog .oku-quote-share-preview-wrap {
    flex-shrink: 0;
    padding: 18px 18px 8px !important;
    min-height: 0 !important;
  }
  .oku-quote-share-dialog .oku-quote-share-preview {
    width: min(100%, 270px) !important;
    height: auto !important;
    max-height: min(46dvh, 420px) !important;
    object-fit: contain !important;
  }
  .oku-quote-share-dialog .oku-quote-share-side {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    padding: 18px 18px calc(26px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .oku-quote-share-dialog .oku-quote-share-actions,
  .share-dialog .share-actions {
    overflow: visible !important;
    max-height: none !important;
    padding-bottom: 4px;
  }
  .oku-quote-share-dialog .oku-quote-share-dialog__close {
    position: sticky !important;
    top: 10px !important;
    float: right;
  }
  /* Qur'an ayah share sheet and other share dialogs use their own layouts. */
  .share-dialog .share-dialog__layout,
  .share-dialog .share-panel,
  .share-dialog .share-preview-wrap,
  .oku-six-share-dialog > *,
  .oku-electro-share-dialog > * {
    min-height: 0 !important;
    max-height: none !important;
  }
  .share-dialog .share-dialog__layout {
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    height: auto !important;
  }
  .share-dialog .share-preview-wrap {flex: none !important;}
  .share-dialog .share-preview,
  .share-dialog .share-preview-wrap img {
    width: auto !important;
    max-width: 100% !important;
    max-height: min(45dvh,430px) !important;
    object-fit: contain !important;
  }
  .share-dialog .share-panel {
    overflow: visible !important;
    height: auto !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Overlay-based share sheets, including custom master cards. */
  .oku-hadith-overlay,
  .oku-electro-share-overlay,
  .oku-six-share-modal,
  .oku21-share-overlay {
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    align-items: start !important;
    justify-items: center !important;
    padding-top: max(12px,env(safe-area-inset-top,0px)) !important;
    padding-bottom: max(24px,env(safe-area-inset-bottom,0px)) !important;
  }
  .oku-hadith-dialog,
  .oku-electro-share-dialog,
  .oku-six-share-dialog,
  .oku21-share-panel {
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 480px) {
  .oku-quote-share-dialog .oku-quote-share-preview {max-height: 37dvh !important;max-width: 220px !important;}
  .share-dialog .share-preview, .share-dialog .share-preview-wrap img {max-height: 36dvh !important;}
}

/* 2026-11-11 · Previously uncovered book-share overlays.
   On short phones a centred, 94–96vh panel plus overlay padding can put
   the title, close control and final share action outside the scroll range.
   Keep the desktop artwork and independent readers unchanged. */
@media (max-width: 860px) {
  .oku26-share-overlay,
  #oku21-screen .oku78-share {
    box-sizing:border-box !important;
    display:flex !important;
    flex-direction:column !important;
    justify-content:flex-start !important;
    align-items:center !important;
    overflow-x:hidden !important;
    overflow-y:auto !important;
    overscroll-behavior-y:contain;
    -webkit-overflow-scrolling:touch;
    padding:max(12px,env(safe-area-inset-top,0px)) 10px max(24px,env(safe-area-inset-bottom,0px)) !important;
  }
  .oku26-share-panel,
  #oku21-screen .oku78-modal {
    box-sizing:border-box !important;
    flex:0 0 auto !important;
    width:min(100%,650px) !important;
    height:auto !important;
    min-height:0 !important;
    max-height:calc(100dvh - 36px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
    margin:auto !important;
    overflow-x:hidden !important;
    overflow-y:auto !important;
    overscroll-behavior-y:contain;
    -webkit-overflow-scrolling:touch;
  }
  .oku26-share-panel {
    border-radius:22px !important;
    padding:17px 15px 22px !important;
  }
  .oku26-share-panel canvas {
    display:block !important;
    width:auto !important;
    max-width:100% !important;
    max-height:min(38dvh,310px) !important;
    height:auto !important;
    object-fit:contain !important;
  }
  .oku26-share-buttons button {
    min-height:44px !important;
    white-space:normal !important;
    overflow-wrap:anywhere !important;
  }
  #oku21-screen .oku78-modal {
    display:block !important;
    max-width:650px !important;
    padding:12px !important;
    gap:0 !important;
    border-radius:23px !important;
  }
  #oku21-screen .oku78-preview {
    width:100% !important;
    height:auto !important;
    max-height:34dvh !important;
    min-height:0 !important;
    padding:9px !important;
    border-radius:16px !important;
  }
  #oku21-screen .oku78-preview canvas {
    width:auto !important;
    max-width:100% !important;
    height:auto !important;
    max-height:32dvh !important;
    object-fit:contain !important;
  }
  #oku21-screen .oku78-actions {
    width:100% !important;
    box-sizing:border-box !important;
    padding:61px 8px 14px !important;
    gap:9px !important;
  }
  #oku21-screen .oku78-actions button:not(.oku78-close),
  #oku21-screen .oku78-site {
    min-height:46px !important;
    height:auto !important;
    white-space:normal !important;
    overflow-wrap:anywhere !important;
    text-align:left !important;
  }
}
