/* ============================================================
   AREA ICON BADGE (self-contained SVG icon set)
   ============================================================ */
/* Small inline badge that sits next to a paper's area/topic label. */
.area-icon {
  width: 15px;
  height: 15px;
  flex: none;            /* don't let it shrink inside a flex pill */
  display: inline-block;
}

.area-icon svg {
  width: 100%;
  height: 100%;
}

/* ============================================================
   TOOLBAR - result count, sort, active filter chips
   ============================================================ */
/* Row above the grid: "N results" on the left, sort dropdown on the right. */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;       /* stack on narrow screens */
  margin-bottom: 20px;
}

.results-count {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 500;
}

.results-count strong {
  color: var(--maroon-900);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Pill-shaped sort dropdown with a custom caret.
   The caret is an inline SVG data URI so no extra request or icon font is needed;
   `padding-right: 30px` reserves space so text never runs under it. */
.sort-select {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 9px 30px 9px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  background: var(--surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M1 1l4 4 4-4" stroke="%236B5257" stroke-width="1.5" fill="none"/></svg>') no-repeat right 12px center;
  appearance: none;      /* hides the OS-drawn arrow */
  color: var(--ink);
}

/* Row of removable chips summarising active filters. */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

/* display:flex above would otherwise override the hidden attribute. */
.active-filters[hidden] {
  display: none;
}

/* Single filter chip: "Year: 2020" + a small × button. */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 13px;   /* less right padding so the × sits close to the edge */
  border-radius: 999px;
  background: var(--cream);
  border: 1px solid var(--line);
  color: var(--maroon-800);
  font-size: 12.5px;
  font-weight: 600;
}

/* The × remove button inside a chip. */
.filter-chip button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(110, 26, 40, .1);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--maroon-800);
  font-size: 13px;
  line-height: 1;
  flex: none;
}

.filter-chip button:hover {
  background: var(--maroon-800);
  color: var(--cream);
}

/* "Clear all" link shown after the chips. */
.filter-chip-clear {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: underline;
  padding: 6px 4px;
}

.filter-chip-clear:hover {
  color: var(--maroon-800);
}

/* ============================================================
   PAPER CARD (compact / browse view)
   ============================================================ */
/* Two-column grid on wider screens. */
.paper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}

@media (max-width:760px) {
  .paper-grid {
    grid-template-columns: 1fr;
  }
}

.paper-card {
  position: relative;    /* anchor for the absolutely-positioned .marga-badge */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Small "Marga Institute" logo badge pinned to the card's top-right corner. */
.marga-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: url("../site_logo/marga-logo.jpg") center/cover no-repeat;
}

.marga-badge::after {
  display: none;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.paper-card h3 {
  font-size: 18px;
  line-height: 1.35;
  color: var(--maroon-950);
  font-weight: 700;
}

/* Reserve space so the title doesn't run under the corner badge. */
.paper-card.has-badge h3 {
  padding-right: 44px;
}

/* Title is a <button> (so the whole title is clickable and focusable)
   but we strip the default button look so it reads as text. */
.paper-card h3 button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.paper-card h3 button:hover {
  color: var(--maroon-700);
  text-decoration: underline;
}

/* Author line — clamp to 2 lines so cards stay a consistent height.
   -webkit-line-clamp is the standardised-but-prefixed multi-line clamp. */
.paper-authors {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Generic meta pill (year, field, etc.). */
.pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--paper-bg);
  border: 1px solid var(--line);
  color: var(--maroon-800);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Status pill variants — colour-coded by data-status attribute set in the HTML. */
.pill-status[data-status="published"] {
  background: var(--status-published-bg);
  border-color: transparent;
  color: var(--status-published);
}

.pill-status[data-status="unpublished"] {
  background: var(--status-unpublished-bg);
  border-color: transparent;
  color: var(--status-unpublished);
}

.pill-status[data-status="presentation"] {
  background: var(--status-presentation-bg);
  border-color: transparent;
  color: var(--status-presentation);
}

.pill-status[data-status="report"] {
  background: var(--status-report-bg);
  border-color: transparent;
  color: var(--status-report);
}

.paper-desc {
  font-size: 13.8px;
  line-height: 1.65;
  color: var(--ink-soft);
}

/* "Read more" toggle inside the card. */
.read-more {
  background: none;
  border: none;
  color: var(--maroon-800);
  font-weight: 700;
  font-size: 13.5px;
  padding: 0;
  margin-top: -4px;                /* pull up slightly to tighten the paragraph gap */
  align-self: flex-start;
}

.read-more:hover {
  text-decoration: underline;
}

/* Bottom action row inside a card (save / cite / request).
   `margin-top: auto` pushes this row to the bottom, so all cards in a grid
   row line up even when their descriptions differ in length. */
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
  margin-top: auto;
}

.card-actions .spacer {
  flex: 1;
}

/* Round gold "request paper" button. */
.request-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--maroon-950);
  transition: background .15s;
  flex: none;
}

.request-btn:hover {
  background: var(--gold-light);
}

.save-btn svg {
  transition: fill .15s;
}

/* Saved state: dark maroon background + filled bookmark icon
   (the SVG's fill becomes currentColor, i.e. the cream text color). */
.save-btn.is-saved {
  background: var(--maroon-800);
  border-color: var(--maroon-800);
  color: var(--cream);
}

.save-btn.is-saved svg {
  fill: currentColor;
}

/* Placeholder cards shown while paper.json is loading. */
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Shimmer block used inside the skeleton card.
   The wide gradient is animated left-to-right to fake a loading sweep. */
.sk {
  background: linear-gradient(90deg, var(--line) 25%, #f1e9d8 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: skShimmer 1.4s ease infinite;
  border-radius: 6px;
}

@keyframes skShimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: 0 0;
  }
}

/* Shape hints that mirror the real card's proportions. */
.sk-title {
  height: 20px;
  width: 85%;
}

.sk-line {
  height: 12px;
  width: 60%;
}

.sk-pill {
  height: 22px;
  width: 64px;
  border-radius: 99px;
}

.sk-body {
  height: 12px;
}

/* Slightly shorter lines on the 2nd and 3rd body rows for a natural look. */
.sk-body:nth-child(2) {
  width: 92%;
}

.sk-body:nth-child(3) {
  width: 75%;
}

/* Shared wrapper for the two "nothing to show" messages (no results / error). */
.empty-state,
.error-state {
  grid-column: 1/-1;   /* span the whole grid so it centres nicely */
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.empty-state svg,
.error-state svg {
  color: var(--maroon-700);
  opacity: .55;
}

.empty-state h3,
.error-state h3 {
  font-size: 19px;
  color: var(--maroon-900);
  font-weight: 700;
}

.empty-state p,
.error-state p {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 420px;
  line-height: 1.6;
}

/* Inline code snippet used in the error copy (e.g. the failing file name). */
.error-state code {
  background: var(--paper-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12.5px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 36px;
}

/* display:flex above would otherwise override the hidden attribute. */
.load-more-wrap[hidden] {
  display: none;
}

/* Note shown after the result count when a search was auto-corrected or loosened. */
.results-note {
  color: var(--ink-soft);
  font-size: .92em;
}

/* Banner with a clear way out of the saved-papers view. */
.saved-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 16px;
  /* Fallback radius (10px) in case --radius-m is missing — handy if this
     stylesheet gets loaded in isolation. */
  border-radius: var(--radius-m, 10px);
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
}

/* display:flex above would otherwise override the hidden attribute. */
.saved-banner[hidden] {
  display: none;
}