/* Canvas viewer — full-bleed deep-zoom stage with a slide-in comment panel. */
:root {
  --under: #d6283b;   /* underage  (red)  */
  --adult: #1f50d0;   /* adult     (blue) */
  --family: #8c1d2e;  /* family / incest  */
  --panelw: 380px;
}

body {
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;           /* the stage owns the viewport */
  height: 100vh;
}

.cv { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* header */
.cv-head {
  flex: 0 0 auto;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid #ececec;
  background: var(--bg);
  z-index: 6;
}
.cv-head .wordmark { font-size: 1.35rem; margin: 0; }
.cv-head .wordmark a { color: inherit; text-decoration: none; }
.cv-sub { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.3; }

/* stage */
.cv-stage-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
/* OpenSeadragon forces position:relative on its container, so size it explicitly. */
#osd { position: absolute; inset: 0; width: 100%; height: 100%; background: #fafafa; }
#osd .openseadragon-canvas:focus { outline: none; }
#dot-overlay { position: absolute; inset: 0; pointer-events: none; }

/* floating tools (zoom) */
.cv-tools {
  position: absolute; left: 14px; bottom: 14px; z-index: 7;
  display: flex; flex-direction: column; gap: 8px;
}
.cv-tools button {
  width: 42px; height: 42px; font-size: 1.25rem; line-height: 1;
  border: 1px solid #d9d9d9; border-radius: 10px; background: #fff; color: var(--fg);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.cv-tools button:hover { border-color: var(--fg); }

/* comment panel */
.cv-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panelw); max-width: 92vw;
  background: #fff; border-left: 1px solid #ececec; z-index: 8;
  box-shadow: -8px 0 30px rgba(0,0,0,0.10);
  transform: translateX(100%); transition: transform 0.26s ease;
  display: flex; flex-direction: column;
}
.cv-panel.open { transform: translateX(0); }
.cv-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 10px;
}
.cv-cat {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
}
.cv-cat .sw { width: 11px; height: 11px; border-radius: 50%; }
.cv-cat.origin { color: #111; } .cv-cat.origin .sw { background: #111; }
.cv-pos { font-size: 0.78rem; letter-spacing: 0.03em; color: var(--muted); font-variant-numeric: tabular-nums; }
.cv-close {
  border: none; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 0 4px;
}
.cv-close:hover { color: var(--fg); }
.cv-body { padding: 4px 18px 18px; overflow-y: auto; }
.cv-text { font-size: 1.05rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-text .redacted { color: #b8b8b8; font-style: italic; }
.cv-nav { display: flex; gap: 8px; padding: 12px 18px 18px; border-top: 1px solid #f0f0f0; }
.cv-nav button {
  flex: 1; font: inherit; font-size: 0.85rem; padding: 10px; cursor: pointer;
  border: 1px solid #d9d9d9; border-radius: 9px; background: #fff; color: var(--fg);
}
.cv-nav button:hover { border-color: var(--fg); }
.cv-note {
  margin: 0 18px 18px; font-size: 0.8rem; line-height: 1.5; color: var(--muted);
}

/* loading splash */
.cv-loading {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,0.9); color: var(--muted);
  font-size: 0.95rem; transition: opacity 0.3s ease;
}
.cv-loading.hide { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  .cv-sub { display: none; }
  .cv-panel {
    width: 100%; max-width: 100%; top: auto; height: 62vh;
    border-left: none; border-top: 1px solid #ececec; border-radius: 16px 16px 0 0;
    transform: translateY(100%); box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
  }
  .cv-panel.open { transform: translateY(0); }
  .cv-tools { bottom: 10px; left: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .cv-panel { transition: none; }
}
