*, *::before, *::after {
    box-sizing: border-box;
  }

.documents-page {
  max-width: 1250px;
  margin: 0 auto;
}

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }

/* Cards are anchors, so the global link colour and hover underline are overridden. */
.document-card {
  background: var(--bg-color);
  border: 5px solid var(--fg-color);
  color: var(--fg-color);
  text-decoration: none;
  padding: 1rem;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.document-card:hover {
  transform: scale(1.05);
  text-decoration: none;
  color: var(--fg-color);
}

.document-kind {
  color: var(--accent-color);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.document-title {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.15rem;
}

.document-venue {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted-color);
}

.document-card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.document-year {
  font-size: 1.6rem;
  line-height: 1;
  opacity: 0.45;
}

.documents-message {
  border: 5px solid var(--fg-color);
  background: var(--bg-color);
  padding: 1rem;
}

/* ---- single document viewer ---- */

.document-viewer {
  border: 5px solid var(--fg-color);
  background: var(--bg-color);
  padding: 1rem;
}

.document-viewer h1 {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.5rem;
}

.document-viewer-meta {
  margin: 0 0 1rem;
  color: var(--muted-color);
}

/* Stacked pages: the document renders to full length and only the page scrolls. */
.document-pages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.document-page {
  width: 100%;
  height: auto;
  display: block;
  border: 2px solid var(--fg-color);
  /* PDF pages assume white paper; without this they are transparent in dark mode. */
  background: #fff;
}

.document-loading {
  color: var(--muted-color);
}

/* Only used if pdf.js fails to render — the browser's own viewer, as before. */
.document-frame {
  width: 100%;
  height: 80vh;
  border: 2px solid var(--fg-color);
  background: var(--bg-color);
  display: block;
}

.document-viewer-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Pushed right whether or not a kind tag precedes it. */
.document-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.document-action {
  display: flex;
}

/* Same icon treatment as the footer links. */
.document-action svg {
  fill: var(--accent-color);
  display: block;
  transition: transform 0.3s ease;
}

.document-action svg:hover {
  transform: scale(1.2);
}

/* Toggle between a poster and its abstract. Mirrors the Writing page's article
   buttons: the active view is the inverted fill. */
.document-views {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.document-view-button {
  background-color: var(--bg-color);
  color: var(--fg-color);
  border: 2px solid var(--fg-color);
  font: inherit;
  padding: 0.4em 1.2em;
  cursor: pointer;
  transition: background-color 0.2s;
}

.document-view-button:hover {
  color: var(--accent-color);
}

.document-view-button.active-view {
  background-color: var(--fg-color);
  color: var(--bg-color);
  font-weight: bold;
}

/* Already selected: no hover feedback needed. */
.document-view-button.active-view:hover {
  color: var(--bg-color);
}
