/* ============================================================
   MODAL - Request Paper / Accessibility
   ============================================================ */

/* Shared scrim for every modal on the site.
   Hidden by default with visibility (not display) so the open state
   can fade in — same pattern as the chat panel and detail modal. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 16, 19, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 110;          /* above the header (60) and search panel (70) */
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* The modal card. Note: unlike the detail modal, THIS one scrolls itself
   (overflow-y: auto) rather than using an inner scroll container.
   That means the close button scrolls with the content — acceptable
   because these modals are short. */
.modal {
  background: var(--paper-bg);
  border-radius: var(--radius-l);
  padding: 30px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-pop);
  position: relative;
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(14px) scale(.98);   /* closed: slightly lower + smaller */
  transition: transform .22s ease;
}

.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
}

/* Wider variant for content-heavy modals (e.g. citation dialog). */
.modal.modal-wide {
  max-width: 560px;
}

/* Close button sits in the corner of the modal, scrolls with content
   (see note on .modal above). */
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink-soft);
  line-height: 1;
}

.modal h3 {
  font-size: 22px;
  color: var(--maroon-950);
  margin-top: 6px;
  font-weight: 700;
}

/* Box at the top of the "Request paper" modal summarising the selected paper. */
.modal-paper-summary {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}

.modal-paper-summary strong {
  display: block;
  font-size: 14.5px;
  color: var(--maroon-900);
  line-height: 1.4;
}

.modal-paper-summary span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.modal-field {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.modal-field input,
.modal-field textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  background: var(--surface);
}

/* Error state applied by JS when validation fails — red border. */
.modal-field input.has-error,
.modal-field textarea.has-error {
  border-color: #C0455B;
}

/* Inline error message slot. min-height reserves space so the modal
   doesn't jump when an error appears. */
.modal-field-error {
  font-size: 11.5px;
  color: #C0455B;
  min-height: 14px;
}

/* Notes textarea can grow vertically but not horizontally. */
.modal-field textarea {
  resize: vertical;
  min-height: 76px;
}

/* Full-width pill-shaped submit button. */
.modal .btn-primary {
  width: 100%;
  margin-top: 20px;
  background: var(--maroon-800);
  color: var(--cream);
  border: none;
  padding: 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14.5px;
}

.modal .btn-primary:hover {
  background: var(--maroon-900);
}

/* Small centred helper text below the primary action. */
.modal-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
}

/* Accessibility feature list inside the a11y modal.
   Rendered as <ul> with a check SVG prefix per item. */
.a11y-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.a11y-list li {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  list-style: none;
}

/* Align the check icon with the first line of the text. */
.a11y-list svg {
  flex: none;
  margin-top: 2px;
  color: var(--maroon-700);
}

/* ---- Citation dialog ---- */
/* Row of pill-shaped tabs (APA / MLA / Chicago / BibTeX…). */
.cite-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 12px;
}

.cite-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.cite-tab:hover {
  border-color: var(--gold);
}

/* Active tab fills with maroon — same treatment as .btn-ghost.is-active. */
.cite-tab.is-active {
  background: var(--maroon-800);
  border-color: var(--maroon-800);
  color: var(--cream);
}

/* Output box for the formatted citation text.
   overflow-wrap: anywhere lets long URLs / DOIs wrap mid-word instead of
   forcing horizontal scroll. Capped height so very long formats scroll. */
.cite-output {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  max-height: 40vh;
  overflow-y: auto;
}

/* When showing a BibTeX / RIS / raw code format, switch to a monospace stack. */
.cite-output.is-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}