/* ============================================================
   PAPER DETAIL MODAL
   ============================================================ */

/* Full-screen dark scrim that centres the modal.
   Hidden by default with visibility (not display) so the open state
   can fade in smoothly — the same trick used for the chat panel. */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 16, 19, .55);
  backdrop-filter: blur(3px);        /* blur the page behind for focus */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;                     /* keeps the modal off the screen edges on mobile */
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s;
}

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

/* The modal card itself.
   Position: relative + overflow: hidden lets the close button be absolutely
   positioned and keeps all scrolling *inside* .detail-modal-scroll below,
   so the close button never scrolls out of view. */
.detail-modal {
  background: var(--paper-bg);
  border-radius: var(--radius-l);
  width: 100%;
  max-width: 920px;
  max-height: 88vh;                  /* never fill the whole screen — gives the page a sliver of context */
  box-shadow: var(--shadow-pop);
  position: relative;
  overflow: hidden;
  transform: translateY(14px) scale(.98);   /* closed: slightly lower + smaller */
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
}

/* Open state animates the modal up to full size. */
.detail-overlay.is-open .detail-modal {
  transform: translateY(0) scale(1);
}

/* The actual scroll container — the modal card itself doesn't scroll,
   so the close button stays pinned at the top-right while the content scrolls. */
.detail-modal-scroll {
  overflow-y: auto;
  padding: 30px;
}

@media (max-width:640px) {
  .detail-modal-scroll {
    padding: 22px;
  }
}

/* Close button pinned to the top-right corner of the modal,
   above the scrolling area thanks to z-index. */
.detail-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 20px;
  color: var(--ink-soft);
  line-height: 1;
  z-index: 2;
}

.detail-modal-close:hover {
  color: var(--maroon-800);
  border-color: var(--maroon-700);
}

/* Two-column body: main content on the left, sidebar on the right.
   align-items: start stops the sidebar from stretching to match the content height. */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 26px;
  align-items: start;
  margin-top: 8px;
}

/* Stack into one column on narrow screens. */
@media (max-width:760px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

/* Heading row; padding-right reserves room so the close button doesn't overlap the title. */
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-right: 36px;
}

.detail-head h3 {
  font-size: 22px;
  line-height: 1.32;
  color: var(--maroon-950);
  font-weight: 700;
}

.detail-authors {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.detail-ref {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* Section sub-headings inside the body ("Abstract", "Methodology", etc.):
   small uppercase sans-serif labels in brand maroon. */
.detail-body h4 {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--maroon-800);
  margin: 22px 0 10px;
}

/* Slightly more breathing room above the very first sub-heading. */
.detail-body h4:first-of-type {
  margin-top: 24px;
}

.detail-body p {
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--ink-soft);
}

/* Adjacent-paragraph spacing — avoids the top-margin collapse quirk. */
.detail-body p+p {
  margin-top: 12px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* Right-side box with "Recent papers" links. */
.detail-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px;
}

.detail-sidebar h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--maroon-800);
  margin-bottom: 10px;
}

/* A single "recent paper" row — a <button> so it's keyboard-clickable,
   but styled to read like plain text. */
.recent-item {
  display: block;
  width: 100%;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.4;
  background: none;
  border: none;
  cursor: pointer;
}

/* Drop the separator on the last row so the sidebar doesn't end with a dangling line. */
.recent-item:last-child {
  border-bottom: none;
}

.recent-item:hover {
  color: var(--maroon-800);
}

/* Author/date second line — single-line ellipsis if the text is too long. */
.recent-item span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 400;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  font-size: 12.5px;
  color: var(--ink-soft);
}