/* site/assets/annotations.css
   Comments overlay — anonymous annotations on the live site.
   Design tokens are inherited from the page (--accent, --surface, etc).
*/

/* Persistent annotation highlights are rendered as <mark> elements wrapping
   the quoted text. Sits inline with the text (no overlay layer), so the
   highlight is clearly attached to the words it comments on. */
mark.df-anno-mark {
  background-color: rgba(146, 100, 13, 0.22);
  border-bottom: 2px solid var(--amber, #92640d);
  color: inherit;
  cursor: pointer;
  padding: 0 0.05em;
  transition: background-color 0.15s;
}
mark.df-anno-mark:hover,
mark.df-anno-mark:active {
  background-color: rgba(146, 100, 13, 0.4);
}

/* Pulse used when a side-panel item is tapped — flashes the matching
   <mark> so the user can see exactly which passage the comment is on. */
mark.df-anno-mark.df-anno-pulse {
  animation: df-anno-pulse 1.4s ease-out;
}
@keyframes df-anno-pulse {
  0%, 100% { background-color: rgba(146, 100, 13, 0.22); }
  20%      { background-color: rgba(146, 100, 13, 0.7); }
  60%      { background-color: rgba(146, 100, 13, 0.4); }
}

/* Mobile: stronger fill and thicker underline for sunlight legibility. */
@media (max-width: 768px) {
  mark.df-anno-mark {
    background-color: rgba(146, 100, 13, 0.3);
    border-bottom-width: 3px;
  }
  mark.df-anno-mark:active {
    background-color: rgba(146, 100, 13, 0.5);
  }
}

/* Recogito's overlay layer (used only during live selection while creating
   a comment) — keep it visible briefly so the user sees feedback, but it's
   replaced by our <mark> the moment the comment is posted. */
.r6o-span-highlight-layer .r6o-annotation {
  background-color: rgba(146, 100, 13, 0.28) !important;
}

/* Hide recogito's stock popup — we render our own. */
.r6o-popup,
.r6o-editor {
  display: none !important;
}

/* ---- FAB (toggle) ---- */
.df-anno-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  font-size: 1.25rem;
}
.df-anno-fab:hover { background: #15273f; }
.df-anno-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.df-anno-fab svg { display: block; }
.df-anno-fab-count {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  background: var(--amber, #92640d);
  color: var(--surface);
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- Side panel ---- */
.df-anno-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.2s ease-out;
  z-index: 999;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.df-anno-panel.open { transform: translateX(0); }

/* Match the page nav's bottom-border position so the rule appears continuous.
   Page: body padding-top 3rem + nav text line-height + nav padding-bottom 0.875rem.
   Panel: padding-top 3rem + content (matched line-height) + padding-bottom 0.875rem. */
.df-anno-header {
  padding: 3rem 1.25rem 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--bg);
}
.df-anno-header strong {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  /* Match the nav link's total box height (4 + 22.4 + 4 + 1.5 = 31.9px) so
     the panel header's bottom-border lands at the same y as the nav's. */
  padding: 0.25rem 0;
  border-bottom: 1.5px solid transparent;
  line-height: 22.4px;
}
.df-anno-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 0.25rem;
}
.df-anno-close:hover { color: var(--text); }

.df-anno-list {
  overflow-y: auto;
  flex: 1;
  padding: 2.5rem 0 1rem;
}

.df-anno-empty {
  padding: 1.5rem 1.25rem;
  color: var(--text-3);
  font-size: 0.8125rem;
  line-height: 1.55;
}

/* ---- Threads ---- */
.df-anno-thread {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.df-anno-thread.df-anno-flash {
  background: var(--amber-bg, #fef8ec);
}

.df-anno-quote {
  font-family: var(--display);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-2);
  background: var(--bg);
  border-left: 2px solid var(--amber, #92640d);
  padding: 0.4rem 0.625rem;
  margin: 0 0 0.625rem;
  cursor: pointer;
  font-style: italic;
}
.df-anno-quote:hover { background: var(--amber-bg, #fef8ec); }

.df-anno-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 0.25rem;
}
.df-anno-name {
  font-weight: 600;
  color: var(--text-2);
}
.df-anno-time::before { content: "·"; margin-right: 0.5rem; color: var(--text-3); }

.df-anno-body {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.df-anno-reply {
  margin: 0.625rem 0 0 0.875rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
}

.df-anno-reply-toggle {
  margin-top: 0.5rem;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  font-family: inherit;
}
.df-anno-reply-toggle:hover { text-decoration: underline; }

.df-anno-reply-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ---- Popup (new comment near selection) ---- */
.df-anno-popup {
  position: absolute;
  z-index: 1001;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong, #c5bda9);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

/* Mobile: pin the popup to the bottom of the viewport so the on-screen
   keyboard doesn't push the submit button below the fold. */
.df-anno-popup-mobile {
  position: fixed;
  top: auto !important;
  left: 0 !important;
  right: 0;
  bottom: 0;
  width: 100%;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
}

/* Shared form controls */
.df-anno-popup textarea,
.df-anno-popup input,
.df-anno-reply-form textarea,
.df-anno-reply-form input {
  font: inherit;
  font-family: var(--sans);
  font-size: 0.8125rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.df-anno-popup textarea:focus,
.df-anno-popup input:focus,
.df-anno-reply-form textarea:focus,
.df-anno-reply-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.df-anno-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.df-anno-submit,
.df-anno-cancel {
  font: inherit;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.df-anno-submit {
  background: var(--accent);
  color: var(--surface);
}
.df-anno-submit:hover { background: #15273f; }
.df-anno-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.df-anno-cancel {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.df-anno-cancel:hover { background: var(--bg); }

/* When panel is open on desktop, push content slightly so highlights aren't
   covered by the panel. (Skip on small screens — panel covers content.) */
@media (min-width: 1024px) {
  body.df-anno-panel-open {
    margin-right: 380px;
  }
}
