/* ============================================================
   Archive Trust — citation.css
   Styles for click-to-cite UI:
     - .at-cite-modal       — the citation dialog
     - .at-cite-popover     — selection popover in the transcript
     - .at-cite-cue-btn     — per-cue citation button
     - .at-cite-row-btn     — track-row citation button
   ============================================================ */

/* ── Modal overlay ─────────────────────────────────────────── */
.at-cite-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.at-cite-modal[hidden] { display: none; }

.at-cite-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(2px);
}

[data-theme="dark"] .at-cite-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

body.at-cite-modal-open {
  overflow: hidden;
}

/* ── Modal panel ───────────────────────────────────────────── */
.at-cite-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  padding: 28px 32px 24px;
  font-family: var(--ff-body);
  color: var(--ink);
  animation: at-cite-in 180ms ease-out;
}

@keyframes at-cite-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 540px) {
  .at-cite-panel {
    padding: 20px 18px 18px;
    max-height: calc(100vh - 24px);
  }
}

/* ── Modal header ──────────────────────────────────────────── */
.at-cite-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.at-cite-head h2 {
  font-family: var(--ff-serif);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
}

.at-cite-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, border-color 120ms;
}

.at-cite-close-btn svg { width: 14px; height: 14px; }

.at-cite-close-btn:hover {
  color: var(--ink);
  border-color: var(--rule);
}

/* ── Recording meta header inside modal ────────────────────── */
.at-cite-meta {
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--paper-warm);
  border-left: 2px solid var(--gold);
}

.at-cite-meta__title {
  font-family: var(--ff-serif);
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 500;
  color: var(--ink);
}

.at-cite-meta__sub {
  margin-top: 4px;
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.at-cite-meta__tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.at-cite-tag {
  display: inline-block;
  padding: 3px 9px;
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
}

.at-cite-tag--quote {
  font-family: var(--ff-body);
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Style toggle ──────────────────────────────────────────── */
.at-cite-styles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
}

.at-cite-style-btn {
  padding: 7px 12px;
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 120ms, background 120ms, border-color 120ms;
}

.at-cite-style-btn:hover {
  color: var(--ink);
  background: var(--paper-warm);
}

.at-cite-style-btn.active {
  color: var(--ink);
  background: var(--paper-mid);
  border-color: var(--rule-dark);
}

/* ── Citation preview ──────────────────────────────────────── */
.at-cite-preview-label {
  display: block;
  font-family: var(--ff-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.at-cite-preview {
  padding: 16px 18px;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  font-family: var(--ff-body);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
  min-height: 80px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.at-cite-preview a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.at-cite-preview em {
  font-style: italic;
}

/* ── Actions ───────────────────────────────────────────────── */
.at-cite-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.at-cite-copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}

.at-cite-copy svg { width: 14px; height: 14px; }

.at-cite-copy:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.at-cite-copy--ok {
  background: var(--gold);
  border-color: var(--gold);
}

.at-cite-copy--err {
  background: var(--crimson);
  border-color: var(--crimson);
}

.at-cite-exports {
  display: flex;
  align-items: center;
  gap: 6px;
}

.at-cite-export-btn {
  padding: 9px 13px;
  background: transparent;
  border: 1px solid var(--rule-dark);
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.at-cite-export-btn:hover {
  color: var(--ink);
  border-color: var(--ink-muted);
  background: var(--paper-warm);
}

/* ── Selection popover (transcript) ────────────────────────── */
.at-cite-popover {
  position: absolute;
  z-index: 9998;
  background: var(--ink);
  color: var(--paper);
  padding: 0;
  border: 1px solid var(--ink);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
  animation: at-cite-pop-in 140ms ease-out;
}

[data-theme="dark"] .at-cite-popover {
  background: var(--paper-mid);
  color: var(--ink);
  border-color: var(--rule-dark);
}

.at-cite-popover[hidden] { display: none; }

@keyframes at-cite-pop-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Little arrow */
.at-cite-popover::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--ink);
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
[data-theme="dark"] .at-cite-popover::after {
  background: var(--paper-mid);
  border-color: var(--rule-dark);
}

.at-cite-popover--below::after {
  bottom: auto;
  top: -6px;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
}
[data-theme="dark"] .at-cite-popover--below::after {
  border-color: var(--rule-dark);
}

.at-cite-popover__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: transparent;
  border: 0;
  color: inherit;
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.at-cite-popover__btn svg {
  width: 14px;
  height: 14px;
  color: var(--gold-light);
}

[data-theme="dark"] .at-cite-popover__btn svg {
  color: var(--gold);
}

.at-cite-popover__btn:hover {
  color: var(--gold-light);
}

/* ── Per-cue cite button (transcript panel) ───────────────── */
.at-vtt-cue {
  position: relative;
}

.at-cite-cue-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms, color 120ms, border-color 120ms, background 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
}

.at-cite-cue-btn svg {
  width: 13px;
  height: 13px;
}

.at-vtt-cue:hover  .at-cite-cue-btn,
.at-vtt-cue:focus-within .at-cite-cue-btn,
.at-vtt-cue.active .at-cite-cue-btn {
  opacity: 1;
}

.at-cite-cue-btn:hover {
  color: var(--gold);
  border-color: var(--rule);
  background: var(--paper);
}

[data-theme="dark"] .at-cite-cue-btn:hover {
  background: var(--paper-mid);
}

/* Always visible on touch — no hover.
   Was opacity: 0.55 (faint, ambiguous on phones). Touch users can't hover
   to discover it, so make it fully visible by default. */
@media (hover: none) {
  .at-cite-cue-btn { opacity: 1; }
}

/* Keep cue text from running under the button */
.at-vtt-cue .at-vtt-text {
  padding-right: 30px;
}

/* ── Track-row "Cite" button ──────────────────────────────── */
/* Matches the bookmark star: no border, icon-only, fades in on row hover */
.at-cite-row-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms;
}

.at-cite-row-btn svg {
  width: 14px;
  height: 14px;
}

.at-cite-row-btn:hover {
  color: var(--gold);
}

/* On the curated tracklist rows, fade in on hover only */
.curated-track-table .at-cite-row-btn {
  opacity: 0;
}
.curated-track-table tr:hover .at-cite-row-btn,
.curated-track-table tr:focus-within .at-cite-row-btn,
.curated-track-table tr.ct-playing .at-cite-row-btn {
  opacity: 1;
}

/* Touch: row cite buttons fully visible (no hover to reveal them) */
@media (hover: none) {
  .curated-track-table .at-cite-row-btn { opacity: 1; }
}

/* On the main playlist table, sit in its own column cell */
.playlist-table .col-cite {
  width: 36px;
  text-align: center;
}

.playlist-table .at-cite-row-btn {
  opacity: 0;
}
.playlist-table tr:hover .at-cite-row-btn,
.playlist-table tr:focus-within .at-cite-row-btn,
.playlist-table tr.pt-playing .at-cite-row-btn {
  opacity: 1;
}

/* Touch: row cite buttons fully visible (no hover to reveal them) */
@media (hover: none) {
  .playlist-table .at-cite-row-btn { opacity: 1; }
}

/* ── "Cite recording" button on the player bar ─────────────── */
/* The bar-level cite button now uses pill styling defined in
   css/style.css under "Pill-style toggles (Transcript, Cite)".
   Behaviour-specific tweaks (e.g. flash-on-copy) can be added here
   if needed; visual style edits should go to style.css. */

