/* ═══════════════════════════════════════════════
   annotations.css — Highlights, notes, popups
   ═══════════════════════════════════════════════ */

/* ── INLINE MARKS ── */
.annotated {
  border-bottom: 2px solid var(--blue);
  background: var(--blue-bg);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 1px;
}
.annotated:hover { background: rgba(37,99,235,0.18); }

/* highlight — color set via inline style (data-hl-color) */
.highlighted {
  cursor: pointer;
  border-radius: 2px;
  transition: filter 0.15s;
}
.highlighted:hover { filter: brightness(0.9); }

/* ── ANNOTATION POPUP ── */
.annotation-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 8000;
  display: none;
  align-items: center;
  justify-content: center;
}
.annotation-popup-overlay.visible { display: flex; }

.annotation-popup {
  position: relative;
  background: white;
  border: 1px solid var(--parchment);
  border-radius: var(--radius-md);
  padding: 22px 20px 16px;
  width: 340px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);
  animation: popupIn 0.18s ease both;
}

@keyframes popupIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--ink);
  opacity: 0.28;
  line-height: 1;
  transition: opacity 0.15s;
}
.popup-close:hover { opacity: 0.7; }

.popup-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.38;
  margin-bottom: 9px;
}

.popup-textarea {
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--parchment);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink);
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.popup-textarea:focus { border-color: var(--blue); }

.popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
  align-items: center;
}

.popup-btn {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--parchment);
  background: none;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.popup-btn:hover { background: var(--cream); }
.popup-btn.save {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.popup-btn.save:hover { background: #1d4ed8; }
.popup-btn.delete-btn { color: var(--red); border-color: rgba(192,57,43,0.25); margin-right: auto; }
.popup-btn.delete-btn:hover { background: rgba(192,57,43,0.06); }

/* ── SELECTION TOOLBAR — fixed, appears above selection ── */
.selection-toolbar {
  position: fixed;   /* viewport coords — works with full-screen reader */
  background: #1a1a1a;
  border: 1px solid rgba(200,151,58,0.35);
  border-radius: var(--radius-md);
  padding: 5px 6px;
  display: none;
  gap: 3px;
  z-index: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: popupIn 0.15s ease both;
  white-space: nowrap;
}
.selection-toolbar.visible { display: flex; }

/* little arrow pointing down */
.selection-toolbar::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom: none;
  border-top-color: #1a1a1a;
  pointer-events: none;
}

.sel-btn {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  color: var(--paper);
  background: rgba(245,240,232,0.07);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sel-btn:hover { background: rgba(245,240,232,0.16); }
.sel-btn.blue  { color: #93c5fd; }
.sel-btn.dim   { color: rgba(245,240,232,0.3); padding: 5px 7px; }
.sel-btn.dim:hover { color: var(--paper); }
.sel-hl-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* ── INLINE HIGHLIGHT SPANS (applied by JS) ── */
.annotation-highlight {
  cursor: pointer;
  border-radius: 2px;
  transition: filter 0.15s;
  /* background set via inline style */
}
.annotation-highlight:hover { filter: brightness(0.88); }

/* ── INLINE ANNOTATION/NOTE MARKS ── */
.annotation-mark {
  border-bottom: 2px solid #93c5fd;
  background: rgba(147,197,253,0.15);
  cursor: pointer;
  border-radius: 1px;
  transition: background 0.15s;
}
.annotation-mark:hover { background: rgba(147,197,253,0.28); }

/* ── SEARCH MATCHES ── */
mark.search-match {
  background: rgba(255,200,0,0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
mark.search-match-active {
  background: rgba(255,150,0,0.65);
  outline: 2px solid rgba(200,100,0,0.5);
}

/* ════════════════════════════════════════
   NOTES SIDEBAR
   ════════════════════════════════════════ */

.notes-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--parchment);
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 2;
}
.notes-count {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--gold);
  line-height: 1;
}
.notes-header-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.38;
  flex: 1;
}
.notes-export-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(200,151,58,0.35);
  border-radius: var(--radius-sm);
  background: none;
  padding: 4px 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.notes-export-btn:hover {
  background: rgba(200,151,58,0.1);
  border-color: var(--gold);
}

.notes-list {
  padding: 8px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  display: flex;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px solid var(--parchment);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.note-card:hover {
  border-color: var(--parchment-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.note-card-bar {
  width: 3px;
  flex-shrink: 0;
}
.note-card-body {
  flex: 1;
  padding: 9px 10px 8px;
  min-width: 0;
}
.note-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.note-card-icon {
  font-size: 10px;
  opacity: 0.5;
  flex-shrink: 0;
}
.note-card-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.4;
}
.note-card-page {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink);
  opacity: 0.3;
  margin-left: 2px;
}
.note-card-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.note-card:hover .note-card-actions { opacity: 1; }
.note-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--ink);
  opacity: 0.4;
  padding: 2px 5px;
  border-radius: 3px;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.note-action-btn:hover { opacity: 0.8; background: var(--parchment); }
.note-action-btn.danger:hover { opacity: 1; color: var(--red); background: rgba(192,57,43,0.08); }

.note-card-quote {
  font-family: var(--font-serif);
  font-size: 11px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.note-card-text {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink);
  opacity: 0.72;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-card-empty {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--gold);
  opacity: 0.55;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.no-notes {
  text-align: center;
  padding: 40px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  opacity: 0.4;
  line-height: 1.7;
}
.no-notes-icon {
  font-size: 28px;
  margin-bottom: 12px;
  opacity: 0.25;
}
.no-notes-hint {
  margin-top: 8px;
  font-size: 10px;
  opacity: 0.7;
}

/* ════════════════════════════════════════
   ANNOTATION POPUP — centered modal
   ════════════════════════════════════════ */

.popup-excerpt {
  font-family: var(--font-serif);
  font-size: 12px;
  font-style: italic;
  color: var(--ink);
  opacity: 0.55;
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--parchment);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Scroll-to flash animation */
@keyframes annotFlash {
  0%   { outline: 3px solid rgba(200,151,58,0); }
  20%  { outline: 3px solid rgba(200,151,58,0.8); }
  80%  { outline: 3px solid rgba(200,151,58,0.5); }
  100% { outline: 3px solid rgba(200,151,58,0); }
}
.annot-scroll-flash {
  animation: annotFlash 1.4s ease both;
  border-radius: 2px;
}
