/* ============================================================
   Dialog Overlay CSS — shared by layout editor + comic viewer
   ============================================================ */

/* ── Overlay layer container ── */
.dialog-overlay-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
}
.dialog-overlay-layer.interactive {
  pointer-events: auto;
}

/* ── Dialog box base ── */
.dialog-box-overlay {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
  font-size: 0.85rem;
  line-height: 1.3;
  word-wrap: break-word;
  box-sizing: border-box;
  pointer-events: auto;
  transition: box-shadow 0.15s;
}

/* ── SVG shape layer inside dialog boxes ── */
.dialog-box-overlay .dialog-shape-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

/* ── SVG shape styling ── */
.dialog-box-overlay svg { pointer-events: none; overflow: visible; }
.dialog-box-overlay svg path { transition: fill 0.15s; }
.dialog-box-overlay.selected svg path { filter: drop-shadow(0 0 3px rgba(13,110,253,0.5)); }
.tail-base-handle { cursor: grab; pointer-events: auto; }
.tail-base-handle.snapped { fill: #4CAF50; r: 7; }

/* ── Style-specific overrides ── */
.dialog-box-overlay.style-whisper {
  /* Whisper dashing is now applied to SVG stroke-dasharray */
}
.dialog-box-overlay.style-no_box {
  background: transparent !important;
  text-shadow: 0 0 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.6);
}

/* ── Tail / pointer — SVG-based ── */
.dialog-box-overlay .tail-svg {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}
.dialog-box-overlay .dialog-shape-svg .tail-handle,
.dialog-box-overlay .tail-svg .tail-handle {
  pointer-events: auto;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
}
.dialog-box-overlay.selected .dialog-shape-svg .tail-handle,
.dialog-box-overlay.selected .tail-svg .tail-handle,
.dialog-box-overlay:hover .dialog-shape-svg .tail-handle,
.dialog-box-overlay:hover .tail-svg .tail-handle {
  opacity: 0.7;
}
.dialog-box-overlay .dialog-shape-svg .tail-handle:active,
.dialog-box-overlay .tail-svg .tail-handle:active {
  cursor: grabbing;
  opacity: 1;
}

/* ── Text content overlay ── */
.dialog-box-overlay .dialog-text-content {
  position: relative;
  z-index: 1;
}

/* ── HTML tail handles (tip + midway/bulge) ── */
.tail-tip-handle, .tail-mid-handle, .tail-base-handle {
  opacity: 0;
  transition: opacity 0.15s, transform 0.1s;
}
.dialog-box-overlay.selected .tail-tip-handle,
.dialog-box-overlay.selected .tail-mid-handle,
.dialog-box-overlay.selected .tail-base-handle,
.dialog-box-overlay:hover .tail-tip-handle,
.dialog-box-overlay:hover .tail-mid-handle,
.dialog-box-overlay:hover .tail-base-handle {
  opacity: 0.8;
}
.tail-tip-handle:hover, .tail-mid-handle:hover, .tail-base-handle:hover {
  opacity: 1 !important;
  transform: scale(1.3);
}
.tail-tip-handle:active, .tail-mid-handle:active, .tail-base-handle:active {
  cursor: grabbing !important;
  opacity: 1 !important;
}

/* ── Interactive editor states ── */
.dialog-box-overlay.draggable { cursor: grab; }
.dialog-box-overlay.dragging  { cursor: grabbing; opacity: 0.8; z-index: 100; }
.dialog-box-overlay.selected  {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}
.dialog-box-overlay:focus-visible {
  outline: 2px solid var(--color-accent-blue);
  outline-offset: 1px;
}

.dialog-box-overlay .resize-handle {
  position: absolute;
  top: 0; right: -4px; bottom: 0; width: 8px;
  cursor: ew-resize;
  background: transparent;
}
.dialog-box-overlay.selected .resize-handle {
  background: rgba(13, 110, 253, 0.3);
  border-radius: 0 4px 4px 0;
}

/* ── Page decoration layer ── */
.decoration-overlay-layer {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}
.decoration-overlay-layer.interactive {
  pointer-events: auto;
}
.decoration-item {
  position: absolute;
  pointer-events: none;
}
.decoration-item.decoration-editable {
  pointer-events: auto;
  cursor: grab;
}
.decoration-item.decoration-editable:hover {
  outline: 2px dashed rgba(13, 110, 253, 0.6);
  outline-offset: 2px;
  box-shadow: 0 0 8px rgba(13, 110, 253, 0.2);
}

/* ── Decoration corner resize handles ── */
.dec-corner-handle {
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.1s;
}
.dec-corner-handle:hover {
  opacity: 1;
  transform: scale(1.3);
}
.dec-corner-handle:active {
  cursor: grabbing !important;
  opacity: 1;
}

/* ── Layout Side Panel (always visible) ── */
#layout-side-panel {
  width: 240px;
  min-width: 240px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--color-bg-secondary);
  border-left: 1px solid var(--color-border-default);
  border-radius: 0 6px 6px 0;
}

/* ── Decoration drag sources ── */
.dec-drag-source {
  cursor: grab;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
}
.dec-drag-source:active {
  cursor: grabbing;
}

/* ── Drop target highlight on canvas ── */
#layout-canvas-container.dec-drop-active {
  outline: 2px dashed rgba(13, 110, 253, 0.4);
  outline-offset: -2px;
}

/* ── Reader spread navigation arrows ── */
.reader-nav-arrow {
  position: absolute;
  top: 33%;            /* vertically centred in the middle third */
  height: 33%;
  width: 56px;         /* matches the gutter padding (60px - 4px breathing room) */
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  z-index: 10;
  user-select: none;
  border-radius: 4px;
}
.reader-nav-arrow:hover {
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.05);
}
.reader-nav-arrow:active {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
}
.reader-nav-arrow.d-none { display: none !important; }
.reader-nav-prev { left: 0; }
.reader-nav-next { right: 0; }

/* ── Continue to next episode link — bottom third of right gutter ── */
.reader-continue-link {
  position: absolute;
  top: 66%;
  height: 33%;
  right: 0;
  width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
}
.reader-continue-link:hover {
  background: rgba(255, 255, 255, 0.05);
}
.reader-continue-link a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  font-size: var(--text-xs);
  line-height: 1.3;
  text-align: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transition: color 0.2s ease;
}
.reader-continue-link a:hover {
  color: rgba(255, 255, 255, 0.9);
}

/* ── Mobile responsive ─────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .dialog-box-overlay {
    font-size: 0.85rem;
    max-width: 90vw;
  }
  .reader-nav-arrow {
    width: 40px;
  }
  .reader-continue-link {
    width: 40px;
  }
  #layout-side-panel {
    width: 100%;
    min-width: unset;
    max-height: 220px;
    border-left: none;
    border-top: 1px solid var(--color-border-default);
  }
}
