/* CPDB3 prototype. Neutral palette, to be aligned with IGA website branding. */
:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5b6662;
  --line: #dde3e0;
  /* IGA palette: blue #263746, orange #ff9c6c, yellow #f3e4b2 */
  --iga-blue: #263746;
  --iga-orange: #ff9c6c;
  --brand: #b34712;        /* links, text accents: IGA orange deepened for contrast on light bg */
  --btn: #ff9c6c;          /* filled buttons, chips, current page: IGA orange */
  --btn-ink: #263746;      /* IGA blue text on orange (6:1) */
  --brand-ink: #263746;
  --brand-soft: #ffeadf;
  --headline: #b34712;     /* IGA orange deepened for text on light backgrounds (5.5:1); pure orange is 2:1 */
  --accent: #ff9c6c;       /* decorative orange: borders, rules */
  --mark: #f3e4b2;
  --focus: #1a73e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --surface: #1a201e; --text: #e7ece9; --muted: #9aa7a2; --line: #2c3532;
    --bg: #141c23; --surface: #1c2731; --line: #2e3c48;
    --brand: #ff9c6c; --btn: #ff9c6c; --btn-ink: #1c2731; --brand-ink: #1c2731; --brand-soft: #3a2a22; --headline: #ff9c6c; --accent: #ff9c6c; --mark: #5c4f22;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2 { line-height: 1.25; color: var(--headline); }
.result-title, .results-count { color: inherit; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 820px; }
main { min-height: 60vh; outline: none; }

/* Header / footer */
/* Header stays dark in both themes: the IGA logo is the white (negative) version. */
.site-header { background: var(--iga-blue); color: #fff; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 76px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: #fff; font-weight: 600; font-size: 1.05rem; }
.brand-logo { display: block; height: 56px; width: auto; }
.brand-text { padding-left: .9rem; border-left: 1px solid rgba(255,255,255,.35); line-height: 1.2; }
.site-header :focus-visible { outline-color: #fff; }
.status { display: inline-flex; align-items: center; gap: .45rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; border: 1px solid currentColor; border-radius: 999px; padding: .15rem .65rem; white-space: nowrap; }
.status .dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.status-live { color: #5fd38d; }
.status-live .dot { box-shadow: 0 0 0 0 rgba(95,211,141,.6); animation: pulse 2s infinite; }
.status-demo { color: var(--iga-orange); }
.status-offline { color: #ff8a8a; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(95,211,141,.6); } 70% { box-shadow: 0 0 0 .4rem rgba(95,211,141,0); } 100% { box-shadow: 0 0 0 0 rgba(95,211,141,0); } }
@media (prefers-reduced-motion: reduce) { .status-live .dot { animation: none; } }
@media (max-width: 480px) { .brand-logo { height: 44px; } .brand-text { font-size: .9rem; } }
.site-footer { text-align: center; margin-top: 4rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; padding: 1.5rem 0; }
.site-footer p { margin: .25rem 0; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid transparent; padding: .6rem 1.1rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn-primary { background: var(--btn); color: var(--btn-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--brand); }
.btn-small { padding: .35rem .75rem; font-size: .875rem; }
.fs { font-weight: 400; opacity: .85; }
input[type=search], input[type=text], input[type=number], select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:hover, select:hover { border-color: var(--muted); }
select { width: auto; padding-right: 1.8rem; }
label { font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }

/* Search box */
.searchbox { display: flex; gap: .5rem; }
.searchbox input { font-size: 1.1rem; padding: .75rem 1rem; border-width: 2px; border-color: var(--btn); }
.searchbox .btn { padding: .75rem 1.4rem; font-size: 1rem; }
.advanced { margin-top: .75rem; }
.advanced summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .9rem; width: max-content; }
.adv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; margin-top: .75rem; }
.field label { display: block; margin-bottom: .25rem; color: var(--muted); }
.field select { width: 100%; }

/* Home */
.hero { background: var(--iga-blue); color: #fff; padding: 2.5rem 0 3rem; border-top: 1px solid rgba(255,255,255,.12); }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 .4rem; color: var(--iga-orange); }
.lede { color: #d5dde4; font-size: 1.1rem; margin: 0 0 1.5rem; }
.hero .searchbox input { border-color: var(--iga-orange); background: #fff; color: #1c2321; }
.hero .searchbox .btn-primary { background: var(--iga-orange); color: var(--iga-blue); }
.hero .hint { color: #b9c5cf; }
.hero .advanced summary { color: var(--iga-orange); }
.hero .field label { color: #d5dde4; }
.hero :focus-visible { outline-color: #fff; }
.home-browse h2 { font-size: 1.1rem; margin-top: 2rem; }
.conf-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem;  grid-auto-rows: 1fr; }
.conf-tiles li { display: flex; }
.conf-tiles li > a { flex: 1; }
.conf-tiles a { display: flex; flex-direction: column; gap: .1rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.conf-tiles a { border-top: 3px solid var(--accent) !important; }
.conf-tiles a:hover { border-color: var(--brand); }
.conf-tiles strong { color: var(--brand); }
.conf-tiles .featured a { background: var(--iga-blue); border-color: var(--iga-blue); color: #fff; }
.conf-tiles .featured a:hover { border-color: var(--iga-orange); }
.conf-tiles .featured strong { color: var(--iga-orange); }
.conf-tiles .featured .muted { color: #c9d3db; }
.conf-tiles .flag { align-self: flex-start; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; background: var(--iga-orange); color: var(--iga-blue); border-radius: 999px; padding: .05rem .5rem; margin-bottom: .3rem; }
.conf-tiles span { font-size: .875rem; }
.chip { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .2rem .7rem; margin: 0 .35rem .4rem 0; text-decoration: none; font-size: .875rem; }
.chip:hover { text-decoration: underline; }

/* Results layout */
.results-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5rem 2rem; padding-top: 1.5rem; grid-template-areas: "top top" "filters results"; }
.results-top { grid-area: top; max-width: 820px; }
.filters { grid-area: filters; align-self: start; position: sticky; top: 1rem; }
.results { grid-area: results; }
.filters-head { display: flex; justify-content: space-between; align-items: baseline; }
.filters-head h2 { font-size: 1rem; margin: 0 0 .5rem; }
.filters-head a { font-size: .85rem; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: .75rem 0 1rem; }
legend { font-weight: 700; font-size: .9rem; padding: 0; margin-bottom: .4rem; float: left; width: 100%; }
legend + * { clear: both; }
.conf-list { max-height: 320px; overflow: auto; padding-right: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--btn); margin: 0; }
.check .count { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.year-range { display: flex; align-items: center; gap: .4rem; }
.year-range label { flex: 1; }
.apply { width: 100%; justify-content: center; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; border-bottom: 1px solid var(--line); padding-bottom: .75rem; }
.results-count { font-size: 1rem; font-weight: 400; margin: 0; }
.sorters { display: flex; flex-wrap: wrap; gap: .75rem; }
.sorters label { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.sorters select { padding: .35rem 1.6rem .35rem .5rem; }
.is-disabled { opacity: .5; }
.active-filters { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.active-filters a { display: inline-block; background: var(--btn); color: var(--btn-ink); padding: .2rem .65rem; border-radius: 999px; font-size: .85rem; text-decoration: none; }
/* Papers-per-year chart: one series, IGA orange, bars are links */
.yearchart { margin: 1rem 0 .25rem; }
.yearchart figcaption { font-size: .85rem; font-weight: 600; margin-bottom: .4rem; }
.yearchart figcaption .muted { font-weight: 400; }
.yc-plot { position: relative; height: 72px; border-bottom: 1px solid var(--line); }
.yc-max { position: absolute; top: -2px; left: 0; font-size: .7rem; line-height: 1; }
.yc-bars { list-style: none; margin: 0; padding: 0 0 0 1.75rem; height: 100%; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 2px; align-items: end; }
.yc-bars li { height: 100%; position: relative; }
.yc-bars a { display: flex; align-items: flex-end; height: 100%; text-decoration: none; }
.yc-bars .bar { display: block; width: 100%; background: var(--btn); border-radius: 4px 4px 0 0; min-height: 2px; }
.yc-bars a.out .bar { background: var(--line); }
.yc-bars a:hover .bar, .yc-bars a:focus-visible .bar { background: var(--brand); }
.yc-bars a.current .bar { background: var(--brand); }
.yc-bars .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--text); color: var(--bg); font-size: .75rem; padding: .15rem .45rem; border-radius: 4px; z-index: 2; pointer-events: none; }
.yc-bars a:hover .tip, .yc-bars a:focus-visible .tip { display: block; }
.yc-axis { display: flex; justify-content: space-between; font-size: .75rem; padding: .2rem 0 0 1.75rem; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.result-title { font-size: 1.1rem; margin: 0 0 .25rem; font-weight: 650; }
.result-title a { text-decoration: none; }
.result-title a:hover { text-decoration: underline; }
.result-meta { margin: 0 0 .4rem; font-size: .9rem; }
.result-meta .authors { color: var(--text); }
.sep { color: var(--muted); margin: 0 .3rem; }
.result-excerpt { margin: 0 0 .6rem; color: var(--muted); font-size: .93rem; }
.result-actions { display: flex; gap: .5rem; align-items: center; margin: 0; }
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: 1rem; }
.pager { display: flex; flex-wrap: wrap; gap: .3rem; margin: 1.5rem 0; align-items: center; }
.pager a, .pager span { min-width: 2.4rem; text-align: center; padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); }
.pager [aria-current] { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); font-weight: 700; }
.pager .gap { border: 0; background: none; }

/* Paper page */
.paper { padding-top: 1.25rem; }
.crumbs { font-size: .9rem; margin-bottom: 1rem; }
.eyebrow { color: var(--muted); font-weight: 600; font-size: .9rem; margin: 0; text-transform: uppercase; letter-spacing: .03em; }
.paper h1 { font-size: clamp(1.5rem, 3.2vw, 2rem); margin: .3rem 0 .5rem; }
.paper-authors { font-size: 1.05rem; margin: 0 0 1.25rem; }
.paper-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.paper h2 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }
.abstract p { margin: 0 0 .9rem; }
.meta { display: grid; grid-template-columns: 160px 1fr; gap: .4rem 1rem; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.cite blockquote { margin: 0 0 .6rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; font-size: .95rem; }
.cite-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.related ul { padding-left: 1.1rem; }
.related li { margin-bottom: .35rem; }
.empty-page { padding: 3rem 16px; }
.debug { background: var(--surface); border: 1px solid var(--line); padding: 1rem; overflow: auto; }

.filter-panel > summary { display: none; }
@media (max-width: 800px) {
  .filter-panel > summary { display: block; cursor: pointer; color: var(--brand); font-weight: 600; padding-bottom: .75rem; }
  .filters-head h2 { display: none; }
  .results-layout { grid-template-columns: 1fr; grid-template-areas: "top" "filters" "results"; }
  .filters { position: static; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 0; }
  .filters-head { justify-content: flex-end; }
  .conf-list { max-height: 180px; }
  .adv-grid { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; }
  .meta dt { margin-top: .4rem; font-size: .85rem; }
}
@media (max-width: 480px) {
  .searchbox { flex-direction: column; }
  .searchbox .btn { justify-content: center; }
}
@media print {
  .site-header, .site-footer, .paper-actions, .crumbs, .cite button { display: none; }
}
select option:disabled { color: #a3a9ad; }

/* Collections (home) and session filter */
.collections { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.collections a { display: flex; flex-direction: column; gap: .1rem; height: 100%; box-sizing: border-box; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--iga-orange); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.collections a:hover { border-color: var(--brand); border-left-color: var(--iga-orange); }
.collections strong { color: var(--brand); }
.collections span { font-size: .875rem; }
.session-facet .hint { margin: .4rem 0 0; font-size: .8rem; }
a.session-link { text-decoration: none; }
a.session-link:hover { text-decoration: underline; }
.check input[type=radio], .check input[type=checkbox] { flex-shrink: 0; }
