/* Scholar module: citations, references, Google Scholar readiness.
   Only feature-specific rules; colours come from the shared variables so dark mode follows the theme. */

.scholar-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Anchor targets clear the sticky site header. */
#scholar-readiness, #scholar-citations, #references, .scholar-ref { scroll-margin-top: 84px; }

/* Status colours, mixed toward the ink colour so text stays legible on light and dark cards. */
.scholar-cites, .scholar-ready, .scholar-metrics, .scholar-row, .scholar-report, .scholar-bands {
  --scholar-pass: color-mix(in srgb, var(--accent) 78%, var(--ink));
  --scholar-warn: color-mix(in srgb, var(--gold) 62%, var(--ink));
  --scholar-fail: color-mix(in srgb, var(--danger) 85%, var(--ink));
  --scholar-pass-bg: color-mix(in srgb, var(--accent) 13%, var(--card));
  --scholar-warn-bg: color-mix(in srgb, var(--gold) 18%, var(--card));
  --scholar-fail-bg: color-mix(in srgb, var(--danger) 12%, var(--card));
}

/* ---------- Citations card ---------- */
.scholar-cites-total { margin-bottom: .2rem; }
.scholar-cites-total strong { font-size: 1.7rem; }
.scholar-subhead {
  font-family: var(--font-body); font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .4rem;
}
.scholar-citing { list-style: none; display: flex; flex-direction: column; gap: .55rem; font-size: .88rem; line-height: 1.4; }
.scholar-citing li { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.scholar-citing a { overflow-wrap: anywhere; }
.scholar-citing-more { margin-top: .55rem; }
.scholar-citing-more > summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--primary); padding: .2rem 0; }
.scholar-citing-more > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.scholar-citing-more[open] > summary { margin-bottom: .45rem; }
.scholar-more { display: inline-block; margin-top: .6rem; font-size: .85rem; font-weight: 600; }
.scholar-source { margin-top: .9rem; }
.scholar-refresh { margin-top: .6rem; }
.scholar-refresh .btn { width: 100%; }

/* Citations per year */
.scholar-bars-fig { margin: .7rem 0 .2rem; }
.scholar-bars {
  display: flex; align-items: flex-end; gap: 4px; height: 92px;
  border-bottom: 1px solid var(--border); padding-top: 2px;
}
.scholar-bar-col {
  flex: 1 1 0; min-width: 0; height: 100%; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding-bottom: 18px;
}
.scholar-bar { display: block; width: 100%; max-width: 26px; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 0; }
.scholar-bar-col:hover .scholar-bar { background: var(--accent); }
.scholar-bar-n { font-size: .68rem; color: var(--ink-soft); line-height: 1.2; margin-bottom: 2px; white-space: nowrap; }
.scholar-bar-y {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  font-size: .66rem; color: var(--muted); white-space: nowrap; line-height: 16px;
}

/* ---------- Readiness checklist ---------- */
.scholar-ready-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: .6rem; }
.scholar-ready-head h3 { margin: 0; }
.scholar-score {
  flex-shrink: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1;
  min-width: 2.6em; text-align: center; padding: .35em .5em; border-radius: 999px;
}
.scholar-score--ready { background: var(--scholar-pass-bg); color: var(--scholar-pass); }
.scholar-score--almost { background: var(--scholar-warn-bg); color: var(--scholar-warn); }
.scholar-score--needs { background: var(--scholar-fail-bg); color: var(--scholar-fail); }
.scholar-meter { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: .6rem; }
.scholar-meter span { display: block; height: 100%; border-radius: inherit; }
.scholar-meter--ready span { background: var(--accent); }
.scholar-meter--almost span { background: var(--gold); }
.scholar-meter--needs span { background: var(--danger); }
.scholar-checks { list-style: none; margin: .7rem 0 0; display: flex; flex-direction: column; gap: 2px; }
.scholar-check { font-size: .88rem; border-radius: 6px; }
.scholar-check summary, .scholar-check-row {
  display: flex; align-items: flex-start; gap: 8px; padding: .4rem .45rem; border-radius: 6px; line-height: 1.35;
}
.scholar-check summary { cursor: pointer; list-style: none; }
.scholar-check summary::-webkit-details-marker { display: none; }
.scholar-check summary:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.scholar-check summary:focus-visible, .scholar-passed summary:focus-visible, .scholar-refs-more summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.scholar-check-label { flex: 1; min-width: 0; font-weight: 600; color: var(--ink); }
.scholar-check--pass .scholar-check-label { font-weight: 500; color: var(--ink-soft); }
.scholar-check-icon {
  flex-shrink: 0; width: 1.25rem; height: 1.25rem; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: .72rem; font-weight: 800; margin-top: .05rem;
}
.scholar-check--fail .scholar-check-icon { background: var(--scholar-fail-bg); color: var(--scholar-fail); }
.scholar-check--warn .scholar-check-icon { background: var(--scholar-warn-bg); color: var(--scholar-warn); }
.scholar-check--pass .scholar-check-icon { background: var(--scholar-pass-bg); color: var(--scholar-pass); }
.scholar-check details[open] { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.scholar-check details p { padding: 0 .5rem .45rem 2.15rem; color: var(--ink-soft); font-size: .84rem; line-height: 1.45; }
.scholar-fix strong { color: var(--ink); }
.scholar-passed { margin-top: .6rem; }
.scholar-passed > summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--primary); padding: .25rem 0; }
.scholar-passed .scholar-checks { margin-top: .3rem; }
.scholar-ready-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: .9rem; }
.scholar-guidelines { font-size: .85rem; }

/* ---------- References ---------- */
.scholar-ref-list { padding-left: 2.1em; display: flex; flex-direction: column; gap: .45rem; font-size: .92rem; color: var(--ink-soft); }
.scholar-ref { padding-left: .25em; line-height: 1.5; overflow-wrap: anywhere; }
.scholar-ref::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.scholar-ref:target { background: color-mix(in srgb, var(--gold) 16%, transparent); border-radius: 4px; }
.scholar-ref-title { color: var(--ink); }
.scholar-ref-doi { overflow-wrap: anywhere; }
.scholar-ref-chip {
  display: inline-block; font-size: .7rem; font-weight: 700; line-height: 1.5; padding: .05em .55em; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, var(--card)); color: color-mix(in srgb, var(--accent) 78%, var(--ink));
  vertical-align: .1em; white-space: nowrap;
}
.scholar-refs-more { margin-top: .5rem; }
.scholar-refs-more > summary { cursor: pointer; font-weight: 600; color: var(--primary); font-size: .92rem; padding: .3rem 0; }
.scholar-refs-more[open] > summary { margin-bottom: .45rem; }

/* Deposit form section. The theme styles .form-section; these zero-specificity
   fallbacks only replace the browser's fieldset defaults where it does not. */
:where(.scholar-refs-section) { border: 0; padding: 0; margin: 1.2rem 0 0; min-width: 0; }
:where(.scholar-refs-section > legend) { font-weight: 600; padding: 0; margin-bottom: .3rem; }
:where(.scholar-refs-section .section-intro) { margin: 0 0 .6rem; font-size: .88rem; color: var(--muted); }
.scholar-refs-field .field-label { font-weight: 600; font-size: .92rem; color: var(--ink); }
.scholar-refs-field p { margin: 0; }
.scholar-refs-field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.5; }
.scholar-refs-count:empty { display: none; }
.scholar-refs-count { font-weight: 600; }
.scholar-refs-count.is-over { color: var(--danger); }

/* ---------- Listings and dashboard ---------- */
.scholar-li-cites { margin-top: .35em; font-size: .82rem; font-weight: 600; color: var(--primary); }
.scholar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: .35rem; }
.scholar-row-cites { font-size: .8rem; font-weight: 600; color: var(--primary); }
.scholar-badge {
  display: inline-flex; align-items: center; gap: .3em; font-size: .74rem; font-weight: 700; line-height: 1.2;
  padding: .22em .65em; border-radius: 999px; white-space: nowrap; border: 1px solid transparent;
}
a.scholar-badge:hover { text-decoration: none; border-color: currentColor; }
.scholar-badge--ready { background: var(--scholar-pass-bg); color: var(--scholar-pass); }
.scholar-badge--almost { background: var(--scholar-warn-bg); color: var(--scholar-warn); }
.scholar-badge--needs { background: var(--scholar-fail-bg); color: var(--scholar-fail); }

.scholar-metrics { margin-bottom: 1.2rem; }
.scholar-metrics-main { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: end; }
.scholar-metrics-title { font-size: 1.1rem; margin: 0 0 .6rem; }
.scholar-metrics-table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.scholar-metrics-table th, .scholar-metrics-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.scholar-metrics-table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: right; }
.scholar-metrics-table tbody th { text-align: left; font-weight: 600; color: var(--ink-soft); }
.scholar-metrics-table td { text-align: right; font-weight: 700; color: var(--ink); }
.scholar-metrics-table tr:last-child th, .scholar-metrics-table tr:last-child td { border-bottom: none; }
.scholar-metrics-table abbr { text-decoration: none; border-bottom: 1px dotted var(--muted); cursor: help; }
.scholar-metrics-chart .scholar-bars { height: 120px; }
.scholar-metrics-chart .scholar-bars-fig { margin: 0; }
.scholar-metrics-foot { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.scholar-bands { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }

/* ---------- Admin ---------- */
.scholar-admin-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 1.4rem; }
.scholar-admin-cta-title { font-size: 1.05rem; margin: 0 0 .2rem; }
.scholar-report .section-head form { margin: 0; }
/* Layout of the shared .stat-card component; the cards themselves are styled by the theme. */
.scholar-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 1rem 0; }
.scholar-stats > a.stat-card { text-decoration: none; }
.scholar-stats > a.stat-card:hover, .scholar-stats > a.stat-card[aria-current="true"] { border-color: var(--primary); }
.scholar-stats > a.stat-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.scholar-stat--ready .stat-value { color: var(--scholar-pass); }
.scholar-stat--almost .stat-value { color: var(--scholar-warn); }
.scholar-stat--needs .stat-value { color: var(--scholar-fail); }
.scholar-h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.scholar-filters { margin-top: 1.4rem; }
.scholar-filters input[type="search"] { flex: 2 1 220px; }
.scholar-filters select { flex: 1 1 150px; }
.scholar-table td { font-size: .88rem; }
.scholar-td-title { min-width: 260px; }
.scholar-td-title a { font-weight: 600; }
.scholar-td-cites { white-space: nowrap; }
.scholar-issue-list { list-style: none; display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.scholar-issue { font-size: .82rem; line-height: 1.35; }
.scholar-issue span[aria-hidden] { display: inline-block; width: 1em; font-weight: 800; }
.scholar-issue--fail { color: var(--scholar-fail); }
.scholar-issue--warn { color: var(--scholar-warn); }

/* ---------- Most cited ---------- */
.scholar-rank { list-style: none; counter-reset: scholar-rank; }
.scholar-rank > li { counter-increment: scholar-rank; position: relative; padding-left: 72px; }
.scholar-rank > li::before {
  content: counter(scholar-rank); position: absolute; left: 20px; top: 18px; width: 36px; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--muted);
}
.scholar-rank-cites { margin-top: .4em; font-size: .9rem; color: var(--primary); }

@media (max-width: 860px) {
  .scholar-metrics-main { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 520px) {
  .scholar-rank > li { padding-left: 52px; }
  .scholar-rank > li::before { left: 10px; width: 30px; font-size: 1.1rem; }
  .scholar-admin-cta .btn { width: 100%; }
  .scholar-bar-n { font-size: .6rem; }
}
