/* v19 input + margin patch
   Native finger scrolling, full-width pen hit surface, and safe controls. */

/* Let the browser own vertical finger scrolling for momentum/inertia. */
.smart-ink-page,
.smart-ink-page.freehand-ink-mode,
.smart-ink-page.freehand-ink-mode .verse-block,
.smart-ink-page.freehand-ink-mode .verse-text,
.smart-ink-page.freehand-ink-mode .above-note {
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior-y: auto !important;
}

.reader {
  overscroll-behavior-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* The handwriting canvas is the real pen hit surface across the ENTIRE page,
   including the right journaling rail beside Bookmark / Sticky note / Precepts. */
.smart-ink-page.freehand-ink-mode > .ink-canvas.handwriting-ink-canvas {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  z-index: 30 !important;
  pointer-events: auto !important;
  touch-action: pan-y pinch-zoom !important;
  cursor: crosshair !important;
}

/* Highlighter storage canvas never needs to win hit-testing. */
.smart-ink-page > .ink-canvas.local-highlight-canvas {
  pointer-events: none !important;
}

/* Once a real pen stroke begins, stop browser panning until the pen lifts. */
.smart-ink-page.freehand-ink-mode.pen-contact > .ink-canvas.handwriting-ink-canvas,
.smart-ink-page.freehand-ink-mode.pen-contact {
  touch-action: none !important;
  overscroll-behavior: contain !important;
}

/* Keep controls above the active handwriting layer. */
.smart-ink-page .verse-actions,
.smart-ink-page.freehand-ink-mode .verse-actions,
.smart-ink-page .sticky-editor,
.smart-ink-page.freehand-ink-mode .sticky-editor,
.smart-ink-page .bible-image-controls {
  position: relative !important;
  z-index: 140 !important;
  pointer-events: auto !important;
}

.smart-ink-page .verse-actions > div,
.smart-ink-page .verse-actions button,
.smart-ink-page .verse-actions button *,
.smart-ink-page .sticky-editor button,
.smart-ink-page .sticky-editor textarea,
.smart-ink-page .bible-image-controls button {
  position: relative !important;
  z-index: 141 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

/* The right rail remains visually blank and writable rather than becoming a dead zone. */
@media screen and (min-width: 721px) {
  .smart-ink-page.freehand-ink-mode .verse-block::after {
    pointer-events: none !important;
  }
}

/* Text-entry mode behaves normally. */
.smart-ink-page.text-entry-mode > .ink-canvas.handwriting-ink-canvas {
  pointer-events: none !important;
}

.pen-style-buttons button {
  touch-action: manipulation !important;
}

html, .reader, .journal-panel {
  scrollbar-gutter: stable;
}

/* v20 — let handwriting START in the blank strip beside the verse action buttons.
   The action row itself must not become a full-width invisible hit blocker.
   Only the actual buttons are interactive; the gap and helper text fall through to the ink canvas. */
.smart-ink-page.freehand-ink-mode .verse-actions,
.smart-ink-page.freehand-active .verse-actions {
  pointer-events: none !important;
}

.smart-ink-page.freehand-ink-mode .verse-actions > div,
.smart-ink-page.freehand-active .verse-actions > div,
.smart-ink-page.freehand-ink-mode .verse-actions > span,
.smart-ink-page.freehand-active .verse-actions > span {
  pointer-events: none !important;
}

.smart-ink-page.freehand-ink-mode .verse-actions button,
.smart-ink-page.freehand-ink-mode .verse-actions button *,
.smart-ink-page.freehand-active .verse-actions button,
.smart-ink-page.freehand-active .verse-actions button * {
  pointer-events: auto !important;
}

/* v21 — annotation anchoring + navigation stability.
   Canvas layers must never participate in browser scroll anchoring. */
.smart-ink-page > .ink-canvas {
  overflow-anchor: none !important;
  contain: paint !important;
}

/* Keep the scripture page itself as the stable scroll anchor while transient
   overlay/canvas dimensions settle after a cross-reference navigation. */
.smart-ink-page {
  overflow-anchor: auto;
}

/* v22 — stable annotation geometry.
   The canvas must follow the page's content box, never the page scrollHeight.
   scrollHeight can include an absolutely-positioned canvas and create a resize loop. */
.smart-ink-page {
  overflow-anchor: none !important;
}
.smart-ink-page > .ink-canvas {
  box-sizing: border-box !important;
  max-width: 100% !important;
  max-height: 100% !important;
}
