/* ==========================================================================
   LIMM — Clinical Editorial
   publications.css · cover gallery, sticky filter toolbar, year ledger,
                      right-hand year index

   Reuses, and never redefines, the shared furniture:
     tokens.css   palette, type scale, motion, .reveal, .mono, .chip
     layout.css   .shell, .grid12, .ruled/.rule-grid, masthead, footer
     members.css  .people-head (page header), .subnav (sticky bar base),
                  .group__error
   ========================================================================== */

/* The masthead is 60px when compact and the filter toolbar sits under it, so
   anchor jumps (#pub-128, #year-2019) need a deeper scroll offset than the
   global one in tokens.css. Local override, publications page only. */
html { scroll-padding-top: calc(var(--nav-h-compact) + 136px); }

/* Height reserved for the sticky toolbar when parking other sticky rails
   beneath it. Two rows on desktop; the value is only used >=1024. */
:root { --pubbar-h: 118px; }

/* ---- Page header sub-line ------------------------------------------------ */
/* .people-head / .people-head__title come from members.css; only the counted
   sub-line differs — it is three facts, not one sentence. */
.pub-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
}
.pub-sub span { display: inline-flex; align-items: baseline; gap: 0.45em; }
.pub-sub b {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 60;
  font-weight: 500;
  font-size: 1.3em;
  line-height: 1;
  color: var(--ink);
}
.pub-sub i { font-style: normal; color: var(--rule); padding-inline: 2px; }

/* ---- Cover gallery ------------------------------------------------------- */
.covergal {
  border-top: 1px solid var(--ink);
  padding-block: clamp(28px, 3vw, 44px) clamp(36px, 4vw, 60px);
}
.covergal__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}
.covergal__title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72;
  font-weight: 400;
  font-size: var(--text-h3);
  letter-spacing: -0.016em;
}
.covergal__note { color: var(--muted); }
.covergal__note b { color: var(--accent-ink); font-weight: 500; }

.covergal__nudge { display: flex; gap: 8px; }
.covergal__nudge button {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--navy);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.covergal__nudge button:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); background: var(--paper-3); }
.covergal__nudge button:disabled { opacity: 0.32; cursor: default; }
@media (max-width: 767px) { .covergal__nudge { display: none; } }

.covergal__rail {
  display: flex;
  gap: var(--gutter);
  overflow-x: auto;
  padding-block: clamp(22px, 2.4vw, 34px) 10px;
  scroll-snap-type: x proximity;
  scroll-padding-left: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.covergal__rail::-webkit-scrollbar { height: 6px; }
.covergal__rail::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 99px; }

.ctile { flex: 0 0 clamp(158px, 15vw, 206px); scroll-snap-align: start; }
.ctile a { display: block; }
.ctile__frame {
  position: relative;
  aspect-ratio: 451 / 600;
  overflow: hidden;
  background: var(--paper-2);
}
.ctile__frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--dur) var(--ease);
}
.ctile a:hover .ctile__frame img,
.ctile a:focus-visible .ctile__frame img { transform: scale(1.03); }

/* Cover artworks we do not hold: the journal set in Fraunces on paper-2 so the
   client can see that all 20 belong in this gallery. */
.ctile--blank .ctile__frame {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 16px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  background-image: repeating-linear-gradient(
    -45deg, transparent 0 7px, color-mix(in srgb, var(--rule) 46%, transparent) 7px 8px
  );
}
.ctile--blank .ctile__set {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48;
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.18;
  letter-spacing: -0.014em;
  color: var(--ink);
  text-wrap: pretty;
  background: var(--paper-2);
  box-shadow: 0 0 0 6px var(--paper-2);
}
.ctile--blank .ctile__missing {
  color: var(--muted);
  font-size: 0.625rem;
  background: var(--paper-2);
  box-shadow: 0 0 0 5px var(--paper-2);
}
.ctile a:hover .ctile--blank { border-color: var(--ink); }

.ctile figcaption { padding-top: 12px; }
.ctile__journal {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.34;
  color: var(--ink);
  margin-bottom: 5px;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 2px;
  transition: background-size var(--dur) var(--ease);
}
.ctile a:hover .ctile__journal,
.ctile a:focus-visible .ctile__journal { background-size: 100% 2px; }
.ctile__issue { color: var(--muted); display: block; }
.ctile__issue i { font-style: normal; color: var(--accent-ink); }

/* ---- Sticky filter toolbar ----------------------------------------------- */
.pubbar {
  position: sticky;
  top: var(--nav-h-compact);
  z-index: 45;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  /* Chromium leaks the layout width of a <select> past an ancestor scroll
     container, which pushed the document 240px wide at 390. The year select
     now lives in the wrapping top row; this clip is the guard that keeps any
     future toolbar control from re-opening a horizontal scrollbar. `clip`
     rather than `hidden` so the sticky positioning is untouched. */
  overflow-x: clip;
}
.pubbar__inner { padding-block: 12px 12px; display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 10px; }

.pubbar__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-width: 0;
}
.pubbar__row--filters { flex-wrap: nowrap; }
.pubbar__row--filters { overflow-x: auto; scrollbar-width: none; padding-block: 1px; }
.pubbar__row--filters::-webkit-scrollbar { display: none; }

/* Search */
.psearch {
  position: relative;
  flex: 1 1 260px;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-3);
  transition: border-color var(--dur) var(--ease);
}
.psearch:focus-within { border-color: var(--ink); }
.psearch svg { flex: 0 0 auto; color: var(--muted); }
.psearch input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink);
}
.psearch input::placeholder { color: var(--muted); }
.psearch input:focus { outline: none; }
.psearch:focus-within { outline: 2px solid transparent; }
.psearch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Chips — buttons, so they are keyboard operable and announce their state. */
.fchip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 8px 15px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  background: var(--paper-3);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.fchip:hover { color: var(--ink); border-color: var(--ink); }
.fchip b { font-weight: 500; color: var(--muted); transition: color var(--dur) var(--ease); }
.fchip:hover b { color: var(--muted); }
.fchip[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--paper-3));
}
.fchip[aria-pressed="true"] b { color: var(--accent-ink); }

/* Segmented affiliation switch */
.pseg {
  flex: 0 0 auto;
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-3);
}
.pseg button {
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border-left: 1px solid var(--rule);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.pseg button:first-child { border-left: 0; }
.pseg button:hover { color: var(--ink); }
.pseg button[aria-pressed="true"] {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 16%, var(--paper-3));
}

/* Year select */
.pyearsel { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; }
.pyearsel select {
  appearance: none;
  padding: 8px 34px 8px 15px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-3)
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23636B77' stroke-width='1.3'/%3E%3C/svg%3E")
    no-repeat right 14px center;
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.pyearsel select:hover { color: var(--ink); border-color: var(--ink); }
.pyearsel select[data-on="true"] {
  color: var(--ink);
  border-color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 14%, var(--paper-3));
}

/* Counter + clear */
.pcount { margin-left: auto; color: var(--navy); white-space: nowrap; }
.pcount b { color: var(--ink); font-weight: 500; }
.pcount--none b { color: var(--accent-ink); }
.pclear { flex: 0 0 auto; color: var(--muted); }
.pclear:hover { color: var(--ink); }
.pclear[hidden] { display: none !important; }

@media (max-width: 1023px) {
  .pubbar__inner { row-gap: 9px; }
  .psearch { max-width: none; }
  .pcount { margin-left: 0; }
}
@media (max-width: 640px) {
  .psearch { flex-basis: 100%; }
  .pcount { font-size: 0.6875rem; }
}

/* ---- List shell: rows + right-hand year index ---------------------------- */
.publist {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  column-gap: var(--gutter);
  align-items: start;
  padding-bottom: clamp(56px, 6vw, 96px);
}
.publist__main { min-width: 0; }
@media (max-width: 1279px) { .publist { grid-template-columns: minmax(0, 1fr); } }

.yearindex {
  position: sticky;
  top: calc(var(--nav-h-compact) + var(--pubbar-h) + 28px);
  padding-top: clamp(40px, 4vw, 64px);
}
@media (max-width: 1279px) { .yearindex { display: none; } }
.yearindex__label {
  display: block;
  color: var(--navy);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 6px;
}
.yearindex__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-family: var(--font-mono);
  font-size: var(--text-meta);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.yearindex__link i { font-style: normal; color: var(--rule); }
.yearindex__link:hover { color: var(--ink); border-bottom-color: var(--ink); }
.yearindex__link:hover i { color: var(--muted); }
.yearindex__link.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.yearindex__link.is-active i { color: var(--accent-ink); }
.yearindex__link[hidden] { display: none !important; }

/* ---- Affiliation band ---------------------------------------------------- */
.affband {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  margin-top: clamp(56px, 6vw, 96px);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
}
.affband:first-child { margin-top: clamp(36px, 3.6vw, 56px); }
.affband__title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96;
  font-weight: 400;
  font-size: clamp(1.5rem, 1.1rem + 1.1vw, 2.125rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
}
.affband__title i { font-style: normal; color: var(--muted); }
.affband__note { color: var(--muted); }
.affband[hidden] { display: none !important; }

/* ---- Year group ---------------------------------------------------------- */
.pyear {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  column-gap: var(--gutter);
  border-top: 1px solid var(--rule);
}
.pyear:first-of-type { border-top: 0; }
.pyear[hidden] { display: none !important; }

.pyear__rail {
  position: sticky;
  top: calc(var(--nav-h-compact) + var(--pubbar-h) + 28px);
  align-self: start;
  padding-block: clamp(26px, 2.6vw, 40px) 24px;
}
.pyear__num {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-weight: 300;
  font-size: clamp(2.5rem, 1.2rem + 2.4vw, 3.75rem);
  line-height: 0.86;
  letter-spacing: -0.038em;
  color: var(--ink);
}
.pyear__count { display: block; margin-top: 12px; color: var(--muted); }
.pyear__count b { color: var(--accent-ink); font-weight: 500; }

@media (max-width: 1023px) {
  .pyear { grid-template-columns: minmax(0, 1fr); }
  .pyear__rail {
    position: sticky;
    top: calc(var(--nav-h-compact) + 1px);
    z-index: 20;
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding-block: 16px 12px;
    border-bottom: 1px solid var(--rule);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .pyear__num { font-size: 2rem; }
  .pyear__count { margin-top: 0; }
}

/* ---- Ledger row ---------------------------------------------------------- */
.pyear__rows { display: block; }

.prow {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 250px 74px;
  column-gap: var(--gutter);
  align-items: start;
  padding-block: clamp(22px, 2.2vw, 32px);
  border-bottom: 1px solid var(--rule-soft);
  transition: background var(--dur) var(--ease);
}
.prow[hidden] { display: none !important; }
.prow:hover { background: color-mix(in srgb, var(--paper-2) 52%, transparent); }
.prow:last-child { border-bottom: 0; }
/* The anchored row is marked, not flashed — a 2px accent bar on the left. */
.prow:target {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.prow__n { color: var(--muted); padding-top: 0.4em; font-variant-numeric: tabular-nums; }
.prow--cover .prow__n { color: var(--accent-ink); }

.prow__title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48;
  font-weight: 400;
  font-size: clamp(1.0625rem, 0.98rem + 0.34vw, 1.3125rem);
  line-height: 1.26;
  letter-spacing: -0.012em;
  text-wrap: pretty;
  margin-bottom: 9px;
}
.prow__authors {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}
.prow__authors b { color: var(--ink); font-weight: 600; }

.prow__meta { display: flex; flex-direction: column; align-items: flex-start; gap: 11px; padding-top: 0.35em; }
.prow__src { color: var(--navy); text-transform: none; letter-spacing: 0.03em; line-height: 1.5; }
.prow__src i { font-style: normal; color: var(--muted); white-space: nowrap; }
.prow__badges { display: flex; flex-wrap: wrap; gap: 5px; }
.prow__badges .chip { padding: 3px 8px; font-size: 0.625rem; letter-spacing: 0.05em; }
.chip--flag { border-color: var(--navy); color: var(--navy); }
.chip--pending { border-style: dashed; }
/* IF ≥ 10 and JCR top-10% — the two badges that are the point of the row. */
.prow__badges .chip--major {
  background: var(--navy);
  color: var(--paper);
  border-color: var(--navy);
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
}

.prow__doi {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 5px 12px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.prow__doi:hover { background: var(--ink); color: var(--paper); }

.prow__cover { display: block; align-self: start; margin-top: 0.35em; }
.prow__cover img {
  width: 100%;
  aspect-ratio: 451 / 600;
  object-fit: cover;
  background: var(--paper-2);
  border: 1px solid var(--rule-soft);
  transition: transform var(--dur) var(--ease);
}
.prow__cover:hover img { transform: scale(1.04); }

@media (max-width: 1279px) {
  .prow { grid-template-columns: 52px minmax(0, 1fr) 220px 64px; }
}
@media (max-width: 1023px) {
  .prow {
    grid-template-columns: 46px minmax(0, 1fr) 62px;
    row-gap: 14px;
  }
  .prow__meta { grid-column: 2 / 4; padding-top: 0; }
  .prow__cover { grid-column: 3; grid-row: 1; }
}
@media (max-width: 560px) {
  .prow { grid-template-columns: 34px minmax(0, 1fr) 54px; column-gap: 14px; }
  .prow__authors { font-size: 0.75rem; }
  .prow__badges .chip { font-size: 0.5625rem; padding: 2px 7px; }
}

/* ---- Empty state --------------------------------------------------------- */
.pempty {
  padding-block: clamp(56px, 7vw, 104px);
  border-top: 1px solid var(--rule);
  text-align: center;
}
.pempty[hidden] { display: none !important; }
.pempty__title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96;
  font-weight: 300;
  font-size: var(--text-h3);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.pempty p { color: var(--muted); margin-bottom: 22px; }

/* ---- Closing callout ----------------------------------------------------- */
.pubfoot {
  background: var(--paper-2);
  border-top: 1px solid var(--rule);
  padding-block: clamp(56px, 6vw, 96px);
}
.pubfoot__inner { align-items: end; row-gap: 30px; }
.pubfoot__body { grid-column: 1 / 8; }
.pubfoot__label { display: block; color: var(--navy); margin-bottom: 18px; }
.pubfoot__title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-weight: 300;
  font-size: clamp(2rem, 1.1rem + 2.8vw, 3.5rem);
  line-height: 1.03;
  letter-spacing: -0.026em;
}
.pubfoot__title b {
  font-weight: 500;
  font-style: italic;
  color: var(--accent-ink);
  font-variation-settings: "opsz" 144, "SOFT" 40, "WONK" 1;
}
.pubfoot__aside { grid-column: 9 / 13; }
.pubfoot__note {
  color: var(--muted);
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  text-transform: none;
  letter-spacing: 0.02em;
  line-height: 1.62;
}
.pubfoot__note b { color: var(--navy); font-weight: 500; }
@media (max-width: 1023px) {
  .pubfoot__body { grid-column: 1 / 7; }
  .pubfoot__aside { grid-column: 1 / 7; }
}
@media (max-width: 640px) {
  .pubfoot__body, .pubfoot__aside { grid-column: 1 / 5; }
}
