/* HED - History of Education Database
   Direction "Catalogo" (6 Sep 2026): utilitarian and dense, IBM Plex Sans
   with IBM Plex Mono for labels and figures, cobalt as the only accent,
   sharp corners, the search box as the only framed element on the home.
   Type scale (11 Sep 2026): ten sizes, nothing in between. 12 is reserved
   for uppercase tracked labels; running text never goes below 13. Mono only
   for figures, ids, sigla and labels; names and prose always in Sans. */

/* ========== TOKENS ========== */
:root {
  --ink: #0b0f19;
  --text: #1d2939;
  --text-2: #344054;
  --text-3: #667085;      /* lowest contrast used for text (4.7:1 on white) */
  --line: #d0d5dd;
  --line-soft: #e4e7ec;
  --bg: #ffffff;
  --bg-bar: #f2f4f7;
  --accent: #2f5fd0;
  --accent-ink: #1f44a3;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --warn-ink: #78350f;
  --err-bg: #fef2f2;
  --err-ink: #991b1b;
  --ok-ink: #047857;
  --mono: 'IBM Plex Mono', Consolas, 'Courier New', monospace;
  --sans: 'IBM Plex Sans', 'Segoe UI', Helvetica, Arial, sans-serif;
  --topbar-h: 56px;
  --fs-12: 12px;   /* uppercase tracked labels only */
  --fs-13: 13px;   /* mono secondary, notes */
  --fs-14: 14px;   /* nav, filters, tables, buttons */
  --fs-15: 15px;   /* body */
  --fs-16: 16px;   /* result titles, lead, inputs */
  --fs-18: 18px;   /* reading column */
  --fs-20: 20px;   /* section headings */
  --fs-24: 24px;   /* page titles */
  --fs-28: 28px;   /* record title */
  --fs-34: 34px;   /* home headline */
}

/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--sans); font-size: var(--fs-15); line-height: 1.5;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: var(--fs-13); }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.small { font-size: var(--fs-13); }
.oa { color: var(--ok-ink); }
.dot { color: #c4c9d2; margin: 0 6px; }
.link-btn { color: var(--accent); padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.link-btn:hover { color: var(--accent-ink); }
.filter-key { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1.5px solid var(--ink); background: var(--bg);
  font-size: var(--fs-14); font-weight: 600; color: var(--ink); line-height: 1.2;
}
.action-btn:hover { background: var(--bg-bar); text-decoration: none; }
.action-btn:disabled { opacity: 0.4; cursor: default; }
.action-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.action-btn.primary:hover { background: var(--accent-ink); }
.action-btn.disabled { opacity: 0.4; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ========== TOP BAR ========== */
.topbar {
  display: flex; align-items: center; gap: 24px;
  height: var(--topbar-h); padding: 0 40px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: var(--ink); color: #fff;
  font-family: var(--mono); font-size: var(--fs-13); font-weight: 500;
}
.brand-name { font-weight: 600; font-size: var(--fs-15); }
.brand-tag { font-family: var(--mono); font-size: var(--fs-13); color: var(--text-3); }
/* Sezione attiva del progetto: oggi il catalogo delle riviste, domani altri cataloghi. */
.brand-section { font-family: var(--mono); font-size: var(--fs-13); color: var(--text-2); padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; }
.site-nav { display: flex; gap: 24px; margin-left: auto; }
.nav-item { font-size: var(--fs-14); color: var(--text-2); }
.nav-item:hover { color: var(--ink); text-decoration: none; }
.nav-item.active { color: var(--ink); font-weight: 600; }
.menu-btn { display: none; margin-left: auto; width: 40px; height: 40px; color: var(--ink); border: 1px solid var(--line); background: var(--bg); align-items: center; justify-content: center; }

/* Slim progress line under the top bar while a search is in flight */
.loading-bar { position: fixed; top: var(--topbar-h); left: 0; right: 0; height: 3px; background: var(--accent); z-index: 60; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }

/* ========== HOMEPAGE ========== */
.homepage { display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.home-column {
  display: flex; flex-direction: column; align-items: center; gap: 26px;
  width: 760px; max-width: 100%; margin: auto; padding: 60px 20px 40px; text-align: center;
}
.home-stats { color: var(--text-3); min-height: 18px; }
.home-title { font-size: var(--fs-34); font-weight: 600; line-height: 1.18; letter-spacing: -0.6px; text-wrap: balance; }
.home-sub { font-size: var(--fs-16); color: var(--text-2); max-width: 620px; text-wrap: balance; margin-top: -12px; }
.search-form { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.search-box {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 54px;
  padding: 0 8px 0 16px; border: 1.5px solid var(--ink); background: var(--bg);
}
.search-box:focus-within { box-shadow: 0 0 0 3px rgba(47, 95, 208, 0.18); }
.search-icon { color: var(--text-3); flex-shrink: 0; }
.search-input { flex-grow: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: var(--fs-16); color: var(--ink); }
.search-input::placeholder { color: #98a2b3; }
.search-submit { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: var(--accent); color: #fff; flex-shrink: 0; }
.search-submit:hover { background: var(--accent-ink); }
.filter-panel { display: flex; align-items: baseline; justify-content: center; gap: 22px; flex-wrap: wrap; font-size: var(--fs-14); color: var(--text-2); }
.filter-inline { display: inline-flex; align-items: baseline; gap: 6px; }
.filter-select {
  border: none; border-bottom: 1px solid #98a2b3; background: transparent; padding: 0 2px 1px;
  font-size: var(--fs-14); color: var(--ink); max-width: 190px; text-overflow: ellipsis;
}
.filter-select:focus { border-bottom-color: var(--accent); outline: none; }
.filter-year { width: 58px; border: none; border-bottom: 1px solid #98a2b3; background: transparent; padding: 0 2px 1px; text-align: center; color: var(--ink); font-size: var(--fs-14); -moz-appearance: textfield; }
.filter-year::-webkit-outer-spin-button, .filter-year::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.filter-year:focus { border-bottom-color: var(--accent); outline: none; }
.filter-sep { color: var(--text-3); }
.filter-panel.active .filter-select, .filter-panel.active .filter-year { border-bottom-color: var(--accent); }
.examples { display: flex; align-items: baseline; justify-content: center; gap: 8px 16px; flex-wrap: wrap; max-width: 640px; font-size: var(--fs-14); }
.example-chips { display: contents; }
.example-chip { color: var(--accent); }
.home-footer {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 40px 18px; border-top: 1px solid var(--line-soft); color: var(--text-3);
}

/* ========== RESULTS PAGE ========== */
.results-page { display: none; min-height: calc(100vh - var(--topbar-h)); }
.results-page.active { display: flex; flex-direction: column; }
.results-topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 40px; border-bottom: 1px solid var(--line-soft);
}
.results-search { display: flex; align-items: center; gap: 10px; flex: 1 1 360px; max-width: 720px; height: 40px; padding: 0 12px; border: 1.5px solid var(--ink); background: var(--bg); color: var(--text-3); }
.results-search-input { flex-grow: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: var(--fs-15); color: var(--ink); }
.topbar-count { color: var(--text-2); white-space: nowrap; }
.mode-banner {
  margin: 12px 40px 0; padding: 10px 14px;
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: var(--warn-ink); font-size: var(--fs-14); line-height: 1.5;
}
.mode-banner-detail { display: block; }
.results-error { margin: 12px 40px 0; padding: 10px 14px; background: var(--err-bg); border: 1px solid #fca5a5; color: var(--err-ink); font-size: var(--fs-14); }
.results-error .link-btn { margin-left: 8px; color: var(--err-ink); }

.results-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; padding: 20px 40px 40px; flex-grow: 1; align-items: start; }
.results-body.detail-open { grid-template-columns: minmax(0, 1fr); }
.results-body.detail-open .filters-panel, .results-body.detail-open .results-panel { display: none; }

/* Filter column */
.filters-panel { display: flex; flex-direction: column; gap: 18px; font-size: var(--fs-14); color: var(--text-2); position: sticky; top: calc(var(--topbar-h) + 16px); }
.fp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fp-title { font-weight: 600; color: var(--ink); }
.fp-dist { color: var(--text-3); }
.fp-group { display: flex; flex-direction: column; gap: 2px; }
.fp-group .filter-key { margin-bottom: 4px; }
.fp-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: 100%; padding: 4px 4px; margin: 0 -4px; text-align: left; color: var(--text-2);
}
.fp-row:hover { background: var(--bg-bar); }
.fp-row.selected { color: var(--accent-ink); font-weight: 600; }
.fp-row.static { cursor: default; }
.fp-row.static:hover { background: none; }
.fp-more { padding: 4px; }
.overview-filters { color: var(--ink); }
.overview-note { color: var(--text-3); font-size: var(--fs-13); line-height: 1.5; }
.overview-note strong { color: var(--text); }

/* Results list */
.results-panel { min-width: 0; }
.results-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) 120px; gap: 12px; padding: 6px 0 8px; border-bottom: 1.5px solid var(--ink); color: var(--text-3); text-transform: uppercase; font-size: var(--fs-12); letter-spacing: 0.04em; }
.results-head-via { text-align: right; }
.paper-card { display: grid; grid-template-columns: 36px minmax(0, 1fr) 120px; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.paper-number { color: var(--text-3); padding-top: 3px; }
.paper-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.paper-title { font-size: var(--fs-16); font-weight: 600; line-height: 1.35; color: var(--accent-ink); }
.paper-meta-info { color: var(--text-3); line-height: 1.6; display: flex; flex-wrap: wrap; align-items: baseline; }
.paper-meta-info a { color: var(--accent); }
.paper-sigla { color: var(--text-2); font-weight: 500; }
.paper-authors { font-family: var(--sans); font-size: var(--fs-14); color: var(--text-2); }
.paper-excerpt {
  font-size: var(--fs-15); line-height: 1.55; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.paper-excerpt.muted { color: var(--text-3); font-style: italic; }
.paper-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.paper-via { color: var(--text-3); text-align: right; line-height: 1.6; font-size: var(--fs-12); }
.save-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: var(--text-3); border: 1px solid transparent; }
.save-btn:hover { color: var(--ink); border-color: var(--line); }
.save-btn.saved { color: var(--accent); }
.results-empty { padding: 30px 0; color: var(--text-2); line-height: 1.6; max-width: 520px; }
.results-empty p + p { margin-top: 8px; }
#papers-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px 0 24px; }
.footer-error { width: 100%; color: var(--err-ink); font-size: var(--fs-13); }
.window-end { color: var(--text-2); font-size: var(--fs-14); line-height: 1.6; }

/* ========== RECORD DETAIL (wide reading column) ========== */
.paper-detail-panel { display: none; }
.paper-detail-panel.active { display: block; }
.paper-detail-topbar { max-width: 760px; margin: 0 auto 18px; }
.paper-detail-content { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.paper-detail-title { font-size: var(--fs-28); font-weight: 600; line-height: 1.25; letter-spacing: -0.4px; color: var(--ink); }
.paper-detail-meta { color: var(--text-3); display: flex; flex-wrap: wrap; align-items: baseline; }
.paper-detail-journal { font-size: var(--fs-15); color: var(--text-2); line-height: 1.6; }
.detail-authors { color: var(--ink); font-weight: 500; }
.paper-detail-abstract { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-18); line-height: 1.6; color: var(--text); }
.paper-detail-abstract h3 { margin-top: 10px; }
.detail-alt-title { font-size: var(--fs-15); color: var(--text-2); }
.detail-keywords { font-size: var(--fs-15); color: var(--text-2); }
.paper-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 16px; border-bottom: 1px solid var(--line-soft); }
.paper-actions .save-btn { width: auto; height: auto; }

/* ========== HISTORY, LIBRARY, COVERAGE ========== */
.page { display: none; min-height: calc(100vh - var(--topbar-h)); }
.page.active { display: block; }
.page-column { max-width: 760px; margin: 0 auto; padding: 32px 20px 48px; display: flex; flex-direction: column; gap: 18px; }
.page-column.wide { max-width: 1120px; }
.page-header h1 { font-size: var(--fs-24); font-weight: 600; letter-spacing: -0.3px; color: var(--ink); }
.page-note { font-size: var(--fs-14); color: var(--text-3); margin-top: 4px; }
.page-empty { color: var(--text-3); padding: 24px 0; }
/* Guided empty state: what this space is for, and the one action that fills it */
.empty { display: flex; flex-direction: column; gap: 6px; max-width: 520px; padding: 28px 0; }
.empty-title { font-size: var(--fs-16); font-weight: 600; color: var(--ink); }
.empty-text { color: var(--text-2); line-height: 1.6; }
.empty-action { margin-top: 6px; }
.empty-action a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.history-search { width: 100%; max-width: 480px; height: 40px; padding: 0 12px; border: 1px solid var(--line); font-size: var(--fs-16); }
.history-search:focus { border-color: var(--accent); outline: none; }
.history-thread-list { display: flex; flex-direction: column; }
.history-thread { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; text-align: left; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.history-thread:hover { background: var(--bg-bar); }
.history-thread-title { font-size: var(--fs-15); font-weight: 600; color: var(--ink); }
.history-thread-meta { color: var(--text-3); }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-3); }
.library-actions { display: flex; gap: 8px; }
.library-table, .coverage-table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.library-table th, .coverage-table th {
  text-align: left; padding: 8px 10px; font-family: var(--mono); font-size: var(--fs-12); font-weight: 500;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1.5px solid var(--ink);
}
.library-table td, .coverage-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--text-2); }
.coverage-table th.num, .coverage-table td.num { text-align: right; white-space: nowrap; }
.coverage-table.narrow { max-width: 520px; }
.library-paper-title { color: var(--accent-ink); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.coverage-lead { font-size: var(--fs-16); line-height: 1.6; color: var(--text); max-width: 820px; }
.coverage-h2 { font-size: var(--fs-20); font-weight: 600; margin-top: 14px; color: var(--ink); }
.coverage-list { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); max-width: 820px; }
.coverage-page p { max-width: 820px; color: var(--text-2); line-height: 1.6; }

/* ========== CITE MODAL ========== */
.cite-modal-overlay { position: fixed; inset: 0; background: rgba(11, 15, 25, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.cite-modal { background: var(--bg); width: min(560px, calc(100vw - 40px)); border: 1.5px solid var(--ink); }
.cite-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-weight: 600; }
.cite-modal-close { font-size: 22px; line-height: 1; color: var(--text-3); }
.cite-modal-close:hover { color: var(--ink); }
.cite-modal-tabs { display: flex; gap: 6px; padding: 12px 16px 0; }
.cite-tab { padding: 4px 12px; border: 1px solid var(--line); font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.cite-tab.active { border-color: var(--accent); color: var(--accent); }
.cite-modal-text { margin: 12px 16px; padding: 12px; background: var(--bg-bar); white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow-y: auto; line-height: 1.5; }
.cite-modal-footer { display: flex; justify-content: flex-end; padding: 0 16px 14px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .results-body { grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 900px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .brand-tag { display: none; }
  .menu-btn { display: inline-flex; }
  .site-nav { display: none; position: absolute; top: var(--topbar-h); left: 0; right: 0; flex-direction: column; gap: 0; background: var(--bg); border-bottom: 1px solid var(--line); }
  .site-nav.open { display: flex; }
  .site-nav .nav-item { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-16); }
  .home-column { padding: 40px 16px 32px; gap: 22px; }
  .home-title { font-size: var(--fs-28); letter-spacing: -0.4px; }
  .search-input, .filter-select, .filter-year, .results-search-input, .history-search { font-size: var(--fs-16); }
  .filter-year { width: 64px; }
  .home-footer { padding: 14px 16px 18px; }
  .results-topbar { padding: 10px 16px; gap: 10px; }
  .mode-banner, .results-error { margin: 12px 16px 0; }
  .results-body { display: flex; flex-direction: column; padding: 16px 16px 32px; gap: 20px; }
  .filters-panel { order: 2; position: static; border-top: 1px solid var(--line); padding-top: 16px; }
  .results-head { display: none; }
  .paper-card { grid-template-columns: 28px minmax(0, 1fr); }
  .paper-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; }
  .paper-via { text-align: left; }
  .library-table thead { display: none; }
  .library-table, .library-table tbody, .library-table tr, .library-table td { display: block; width: 100%; }
  .library-table tr { border: 1px solid var(--line); padding: 8px 12px; margin-bottom: 10px; }
  .library-table td { padding: 3px 0; border: none; }
  .library-table td[data-label]::before { content: attr(data-label) ': '; color: var(--text-3); font-size: var(--fs-13); }
  .library-table td[data-label="Title"]::before { content: ''; }
  .page-column { padding: 24px 16px 40px; }
}
