/* ============================================================
   /resources/ — the AI-for-research directory.
   Page-local styles on the shared tokens in /styles.css: paper
   cards with soft depth, pill controls, lime only for a pressed
   filter (docs/design.md: accent marks selected states, nothing
   decorative). Every card is in the HTML; resources.js adds the
   search, filters, section peeks and the jump bar's current mark.
   ============================================================ */

/* Role colours, from the ecosystem figure in Valency's talks (co-scientists
   violet, reviewers vermilion, labs teal), darkened until the ink and
   monogram text clear AA on their tints. Page-local: they mark which kind of
   system a card is, nothing else on the site. */
.page-resources {
  --rc-co: #5546d6;
  --rc-co-tint: #ecebfc;
  --rc-rev: #bf3a2b;
  --rc-rev-tint: #fce9e4;
  --rc-lab: #0a7566;
  --rc-lab-tint: #dcf2ed;
}

.rc-role--co { --rc-role: var(--rc-co); --rc-role-tint: var(--rc-co-tint); }
.rc-role--rev { --rc-role: var(--rc-rev); --rc-role-tint: var(--rc-rev-tint); }
.rc-role--lab { --rc-role: var(--rc-lab); --rc-role-tint: var(--rc-lab-tint); }

.rc-heart {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  vertical-align: -0.1em;
  color: var(--rc-rev);
}

/* A directory, not a landing page: a compact head, so the search box sits
   above the fold on a laptop. The site's editorial hero (6.3vw display type)
   is for marketing pages; here it pushed the search past 720px. */
.rc-hero {
  padding: clamp(24px, 3vw, 40px) var(--container-x) 16px;
}

.rc-hero .chip { margin-bottom: 10px; }

.rc-hero__title {
  font-family: var(--sans);
  font-size: clamp(26px, 2.5vw, 34px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.rc-hero__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 48px;
  margin-top: 10px;
}

.rc-hero__sub {
  flex: 1 1 36rem;
  max-width: 78ch;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.55;
  text-wrap: pretty;
}

.rc-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

/* This page's actions are a size down from the site's 52px pills: they
   sit beside the search and the cards, not alone in a hero. */
.page-resources .btn-pill {
  gap: 7px;
  padding: 9px 18px;
  font-size: 14px;
}

.page-resources .btn-pill__icon {
  width: 15px;
  height: 15px;
}

.rc-textlink {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.rc-textlink:hover { text-decoration-thickness: 2px; }

/* ----- Without resources.js ----- */
/* The head script sets .rc-js and drops it again if resources.js never
   initialises, so a blocked or failed script leaves the plain directory:
   no search to type into, no empty jump bar, every section open. */
html:not(.rc-js) .rc-finder,
html:not(.rc-js) .rc-jump { display: none; }

/* ----- Finder: search and filter chips ----- */
.rc-finder {
  padding: 6px var(--container-x) 18px;
}

.rc-finder__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.rc-search {
  display: flex;
  align-items: center;
  flex: 0 1 640px;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px 0 14px;
  border-radius: 8px;
  background: var(--paper-alt);
  box-shadow: inset 0 0 0 1px var(--line);
}

.rc-search:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.rc-search__icon {
  flex: none;
  width: 17px;
  height: 17px;
  color: var(--ink-muted);
}

.rc-search input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 15px/1.4 var(--sans);
}

.rc-search input:focus { outline: none; }
.rc-search input::placeholder { color: var(--placeholder); }
/* The field clears through our own "Clear search and filters" control. */
.rc-search input::-webkit-search-cancel-button { display: none; }

.rc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 12px;
}

.rc-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rc-filter-label {
  margin-right: 4px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.rc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 11px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--paper-alt);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: 500 13px/1.2 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.rc-chip:hover { box-shadow: inset 0 0 0 1px var(--ink); }

.rc-chip[aria-pressed="true"] {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.rc-chip__n {
  color: var(--ink-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.rc-chip[aria-pressed="true"] .rc-chip__n { color: var(--ink); }

.rc-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  color: var(--ink-muted);
  font-size: 14px;
}

/* A section's colour, beside its name in the jump bar and its heading. */
.rc-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rc-role);
}

.rc-section__title .rc-dot {
  align-self: center;
  width: 11px;
  height: 11px;
}

/* ----- Jump bar: the three sections, pinned under the site header ----- */
/* resources.js fills the links; the bar's height is reserved so the page
   does not shift when they arrive. */
.rc-jump {
  min-height: 43px;
  position: sticky;
  top: var(--rc-header, var(--header-h));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px var(--container-x);
  background: rgba(248, 244, 239, 0.92);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(28, 22, 16, 0.06);
}

.rc-jump__links {
  display: flex;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  overflow-x: auto;
  border-radius: var(--radius-pill);
  background: rgba(28, 22, 16, 0.06);
  scrollbar-width: none;
}

.rc-jump__links::-webkit-scrollbar { display: none; }

.rc-jump__links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}

.rc-jump__links a:hover,
.rc-jump__links a[aria-current="true"] {
  background: var(--paper-alt);
  color: var(--ink);
}

.rc-jump__links a[hidden] { display: none; }
.rc-jump__links .rc-dot { width: 8px; height: 8px; }

.rc-jump__n {
  color: var(--ink-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.rc-clear {
  min-height: 32px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 14px/1 var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.rc-clear[hidden] { display: none; }

/* ----- Sections ----- */
.rc-sections {
  padding: 0 var(--container-x);
}

.rc-section {
  padding-top: 28px;
  /* On top of the page's scroll-padding-top (the header): resources.js sets the
     jump bar's height plus a little air. */
  scroll-margin-top: var(--rc-sticky, 59px);
}

.rc-section[hidden] { display: none; }

.rc-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  margin-bottom: 14px;
}

.rc-section__heading { flex: 1 1 32rem; min-width: 0; }

.rc-section__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  font-family: var(--sans);
  font-size: clamp(21px, 1.8vw, 25px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.rc-section__count {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.rc-section__sub {
  margin-top: 4px;
  max-width: 100ch;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.5;
}

.rc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--ink);
  color: var(--ink);
  font: 600 13px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}

.rc-toggle:hover { background: var(--paper-alt); }
.rc-toggle[hidden] { display: none; }

.rc-chev {
  width: 13px;
  height: 13px;
  transition: transform 200ms ease;
}

[aria-expanded="true"] > .rc-chev { transform: rotate(180deg); }

/* ----- Peek: a collapsed section shows its first row and half of the
   next (two cards and half of a third in one column), fading out under
   a "Show all" pill. resources.js measures the real rows; the fallback
   heights keep the first paint close. The wrapper's padding gives the
   cards' shadows room inside the clip. ----- */
.rc-peek {
  position: relative;
  margin: -6px -16px 0;
  padding: 6px 16px 24px;
}

.rc-js .rc-peek.is-collapsed {
  max-height: var(--rc-peek-h, 280px);
  overflow: hidden;
}

.rc-js .rc-peek.is-collapsed::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 140px;
  background: linear-gradient(to bottom, rgba(248, 244, 239, 0), var(--paper) 82%);
  pointer-events: none;
}

.rc-more {
  position: absolute;
  inset: auto 0 14px;
  z-index: 1;
  display: flex;
  justify-content: center;
}

.rc-more[hidden] { display: none; }

.rc-more .btn-pill {
  background: var(--paper-alt);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink), var(--shadow-soft);
}

.rc-more .btn-pill:hover {
  box-shadow: inset 0 0 0 1px var(--ink), var(--shadow-hover);
}

/* ----- Cards ----- */
.rc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--paper-alt);
  box-shadow: var(--shadow-soft);
  transition: transform 200ms cubic-bezier(0, 0, 0.2, 1), box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
}

.rc-card[hidden] { display: none; }

.rc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* The name is the card's one link; it stretches over the whole card, so
   the focus ring is drawn on the card. */
.rc-card:has(.rc-card__link:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.rc-card__head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 15px;
  align-items: center;
  column-gap: 11px;
}

.rc-card__tile {
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(28, 22, 16, 0.08);
}

.rc-card__tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* No logo: the monogram, in the colours of the card's section. It is drawn
   from an attribute, so the letters stay out of the page's text. */
.rc-card__tile--mono::before { content: attr(data-mono); }

.rc-card__tile--mono {
  background: var(--rc-role-tint);
  box-shadow: none;
  color: var(--rc-role);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.rc-card__link {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.rc-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.rc-card__link:focus-visible { outline: none; }

.rc-card__org {
  grid-column: 2;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rc-card__ext {
  grid-column: 3;
  grid-row: 1 / span 2;
  width: 15px;
  height: 15px;
  color: var(--ink-muted);
  /* The hover nudge (a transform) lifts the arrow above the card's stretched
     link; clicks pass through to the link. */
  pointer-events: none;
  transition: color 150ms ease, transform 200ms cubic-bezier(0, 0, 0.2, 1);
}

.rc-card:hover .rc-card__ext {
  color: var(--ink);
  transform: translate(2px, -2px);
}

.rc-card__tagline {
  flex: 1;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.5;
  text-wrap: pretty;
}

.rc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rc-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(28, 22, 16, 0.06);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.rc-tag svg {
  flex: none;
  width: 12px;
  height: 12px;
}

.rc-tag__lic {
  color: var(--ink-muted);
  font-weight: 400;
}

.rc-tag--field {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-muted);
}

/* ----- Empty result, closing card, fine print ----- */
.rc-empty {
  margin-top: 48px;
  padding: 48px 24px;
  border-radius: var(--radius);
  background: var(--paper-alt);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.rc-empty[hidden] { display: none; }

.rc-empty h2 {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.rc-empty p {
  margin: 8px auto 20px;
  max-width: 46ch;
  color: var(--ink-muted);
}

.rc-close {
  padding: 48px var(--container-x) var(--section-py);
}

@media (min-width: 1024px) {
  .rc-close { padding-bottom: var(--section-py-lg); }
}

.rc-publish {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 40px;
  padding: clamp(22px, 2.4vw, 30px);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-soft);
}

.rc-publish h2 {
  font-family: var(--sans);
  font-size: clamp(20px, 1.8vw, 24px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.rc-publish p {
  margin-top: 6px;
  max-width: 60ch;
  color: rgba(248, 244, 239, 0.75);
  font-size: 15px;
  line-height: 1.5;
}

.rc-publish :focus-visible { outline-color: var(--paper); }

.rc-notes {
  margin-top: 20px;
  max-width: 82ch;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.6;
}

.rc-notes p + p { margin-top: 8px; }

.rc-notes a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ----- Narrow screens ----- */
@media (max-width: 767px) {
  /* Roomier for touch, still compact: 36px clears WCAG 2.2's 24px target
     minimum and keeps the first cards on a phone's first screen. */
  .rc-chip,
  .rc-jump__links a,
  .rc-clear { min-height: 36px; }

  /* Each filter row scrolls sideways instead of stacking six lines deep. */
  .rc-filters { gap: 12px; }

  .rc-filter-group {
    flex-wrap: nowrap;
    width: calc(100% + 2 * var(--container-x));
    margin-inline: calc(-1 * var(--container-x));
    padding-inline: var(--container-x);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .rc-filter-group::-webkit-scrollbar { display: none; }

  /* The heading takes the row here, so a collapsed section opens from its
     fade alone; "Show fewer" appears once the reader has opened it. */
  .rc-toggle[aria-expanded="false"] { display: none; }
  .rc-section { padding-top: 28px; }
  .rc-hero__sub { font-size: 14px; }
  /* On a phone the section names say enough; the cards come first. */
  .rc-section__sub { display: none; }
  .rc-section__heading { flex-basis: 100%; }
  .rc-js .rc-peek.is-collapsed { max-height: var(--rc-peek-h, 440px); }
  .rc-grid { gap: 14px; }
  .rc-card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .rc-card,
  .rc-card__ext,
  .rc-chev { transition: none; }

  .rc-card:hover,
  .rc-card:hover .rc-card__ext { transform: none; }
}
