/* Gistify — one stylesheet.
   Colour carries meaning, so each colour has one job:
     --hl     highlighter: a passage FOUND in the paper (evidence), nothing else
     --ok     verified teal: a check that passed
     --pencil red pencil: a correction, or a claim not supported
   Literata is the reading face (gists, the paper's words); Schibsted Grotesk is the interface. */

:root {
  --paper: #F5F6F2;
  --paper-deep: #ECEEE8;
  --sheet: #FFFFFF;
  --ink: #1C2431;
  --graphite: #5B6472;
  --rule: #D5D9D0;
  --hl: #F3E35A;
  --hl-soft: #F8EEA0;
  --ok: #2E6E62;
  --ok-soft: #DCEAE5;
  --pencil: #B0392B;
  --pencil-soft: #F4DEDA;

  --read: "Literata", Georgia, "Times New Roman", serif;
  --ui: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Type scale, ratio ~1.25 from a 17px reading size (Bringhurst: few sizes, used consistently). */
  --t-xs: 0.8125rem;
  --t-sm: 0.9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.375rem;
  --t-xl: 1.75rem;
  --t-2xl: 2.625rem;

  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.5rem;  --s-6: 2rem;   --s-7: 3rem;    --s-8: 4.5rem;

  --measure: 66ch;
  --radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-md)/1.6 var(--ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: var(--s-6) var(--s-5); }
a { color: var(--ink); text-decoration-color: var(--graphite); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--read); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 var(--s-4); }

.skip { position: absolute; left: -999px; top: 0; background: var(--sheet); padding: var(--s-2) var(--s-3); }
.skip:focus { left: var(--s-3); z-index: 10; }

/* ── Masthead ── */
.masthead {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.wordmark { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; font: 700 var(--t-lg)/1 var(--read); letter-spacing: -0.02em; }
.wordmark-mark { width: 1.35rem; height: 1.35rem; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.wordmark-mark path { stroke: var(--ok); stroke-width: 2.4; }
.masthead-nav { margin-left: auto; display: flex; gap: var(--s-4); align-items: center; font-size: var(--t-sm); }

/* ── Colophon ── */
.colophon { border-top: 1px solid var(--rule); padding: var(--s-5); color: var(--graphite); font-size: var(--t-xs); }
.colophon p { max-width: var(--measure); margin: 0 auto var(--s-1); text-align: center; }
.colophon-cite { font-family: var(--read); }

/* ── Evidence: the highlighter means "found in the paper" ── */
.ev-found { background: linear-gradient(transparent 12%, var(--hl) 12%, var(--hl) 88%, transparent 88%); color: inherit; padding: 0 0.12em; }

/* ── Home ── */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-7); align-items: start; padding: var(--s-6) 0 var(--s-7); }
.hero h1 { font-size: var(--t-2xl); font-weight: 600; max-width: 18ch; }
.lede { font-family: var(--read); font-size: var(--t-lg); line-height: 1.55; color: var(--ink); max-width: 34ch; }

/* The thumb index: the six QDAFI(P) letters as the cut tabs on a reference book's edge.
   The one bold element on the page; everything else stays quiet. */
.index-tabs { list-style: none; margin: 0; padding: 0; border-right: 6px solid var(--ink); }
.index-tabs li {
  display: grid; grid-template-columns: 3.25rem 1fr; column-gap: var(--s-4);
  padding: var(--s-3) var(--s-4) var(--s-3) 0;
  border-bottom: 1px solid var(--rule);
}
.index-tabs li:last-child { border-bottom: 0; }
.tab {
  grid-row: span 2;
  display: flex; align-items: center; justify-content: center;
  font: 700 var(--t-xl)/1 var(--read);
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius) 0 0 var(--radius);
  min-height: 3.25rem;
}
.index-tabs li:nth-child(odd) .tab { background: var(--paper-deep); color: var(--ink); }
.tab-name { font-weight: 600; font-size: var(--t-md); }
.tab-gloss { font-family: var(--read); font-size: var(--t-sm); color: var(--graphite); line-height: 1.45; }

.promise { border-top: 1px solid var(--rule); padding-top: var(--s-5); font-family: var(--read); font-size: var(--t-md); }
.promise p { max-width: var(--measure); }
.soon { color: var(--graphite); font-family: var(--ui); font-size: var(--t-sm); }

@media (max-width: 52rem) {
  .hero { grid-template-columns: 1fr; gap: var(--s-6); }
  .hero h1 { font-size: var(--t-xl); }
  main { padding: var(--s-5) var(--s-4); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Masthead (signed in) and the sign-in card ── */
.masthead-who { color: var(--graphite); }
.masthead-nav a[aria-current="page"] { font-weight: 600; text-decoration: none; }
.masthead-nav form.inline { margin: 0; }
.auth-card { max-width: 24rem; margin: var(--s-7) auto; }
.auth-form { display: flex; flex-direction: column; gap: var(--s-4); }
.auth-form label { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--t-sm); font-weight: 500; }
.auth-error { color: var(--pencil); background: var(--pencil-soft); padding: var(--s-2) var(--s-3); border-radius: var(--radius); }
.auth-lede, .auth-alt { font-size: var(--t-sm); color: var(--graphite); }
.auth-hint { font-weight: 400; color: var(--graphite); }

/* ── Account and People ── */
.account { max-width: 40rem; }
.account-wide { max-width: 64rem; }
.account-msg { background: var(--ok-soft); color: var(--ok); padding: var(--s-2) var(--s-3); border-radius: var(--radius); font-size: var(--t-sm); }
.account-part { border-top: 1px solid var(--rule); padding: var(--s-5) 0; }
.account-part h2 { font-size: var(--t-lg); }
.account-row { display: flex; gap: var(--s-3); }
.account-row .field { flex: 1; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--s-3); align-items: end; }
.account-grid label { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--t-sm); font-weight: 500; }
.account-note { font-size: var(--t-sm); color: var(--graphite); }
.account-danger h2 { color: var(--pencil); }
.people { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.people th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--rule); padding: var(--s-2); }
.people td { border-bottom: 1px solid var(--rule); padding: var(--s-2); vertical-align: top; }
.people .num { text-align: right; font-variant-numeric: tabular-nums; }
.people-off td { color: var(--graphite); }
.people-flags { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
@media (max-width: 52rem) { .account-grid { grid-template-columns: 1fr; } }

/* ── Zotero ── */
.zot-lede { font-family: var(--read); font-size: var(--t-md); max-width: var(--measure); }
.zot-steps { padding-left: 1.25rem; font-size: var(--t-sm); line-height: 1.6; }
.zot-steps li + li { margin-top: var(--s-2); }
.zot-mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.zot-add { display: flex; flex-direction: column; gap: var(--s-3); align-items: flex-start; }
.zot-add label { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--t-sm); font-weight: 500; }
.zot-cols { width: 100%; }
.zot-tree { border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s-2) 0; margin: 0; max-height: 22rem; overflow: auto; background: var(--sheet); }
.zot-col { display: block; padding: var(--s-1) var(--s-3); font-size: var(--t-sm); cursor: pointer; }
.zot-col:hover { background: var(--paper); }
.zot-source { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--rule); }
.zot-source:last-child { border-bottom: 0; }
.zot-source-state { margin: var(--s-1) 0 0; font-size: var(--t-sm); color: var(--graphite); display: flex; gap: var(--s-2); align-items: baseline; }
.zot-source-do { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); }
.zot-source-do form { margin: 0; }
.zot-fail { color: var(--pencil); }
.zot-credit { margin-top: var(--s-6); font-size: var(--t-xs); color: var(--graphite); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lit-zot { font-size: var(--t-xs); color: var(--ok); font-weight: 600; }

.token-new { background: var(--ok-soft); border-radius: var(--radius); padding: var(--s-3); margin: var(--s-3) 0; }
.token-new p { margin: 0 0 var(--s-2); font-size: var(--t-sm); }
.token-value { width: 100%; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.token-list { list-style: none; padding: 0; margin: var(--s-3) 0; }
.token-list li { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--rule); font-size: var(--t-sm); }
.token-list form { margin: 0; }

.auth-buttons { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.auth-buttons .btn { text-decoration: none; }
.masthead-cta { text-decoration: none; }
.home-cta { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-5); }
.home-cta .btn { text-decoration: none; }

/* ── Deep search ── */
.srch-form { display: flex; flex-direction: column; gap: var(--s-3); }
.srch-form textarea { font-family: var(--read); font-size: var(--t-md); line-height: 1.5; resize: vertical; }
.srch-sources { display: flex; flex-direction: column; gap: var(--s-2); }
.srch-source { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-3); align-items: baseline; font-size: var(--t-sm); padding: var(--s-2) var(--s-3); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); }
.srch-source-off { color: var(--graphite); }
.srch-list { list-style: none; padding: 0; margin: 0; }
.srch-list li { padding: var(--s-2) 0; border-bottom: 1px solid var(--rule); font-size: var(--t-sm); display: flex; flex-direction: column; gap: 2px; }
.srch-show { max-width: 62rem; }
.srch-goal { font-size: var(--t-xl); font-weight: 500; line-height: 1.3; max-width: 40ch; }
.srch-count { font-size: var(--t-sm); color: var(--graphite); }
.srch-summary { border-left: 3px solid var(--paper-deep); padding-left: var(--s-3); margin: var(--s-3) 0 var(--s-4); }
.srch-summary summary { cursor: pointer; font-size: var(--t-sm); font-weight: 600; }
.srch-quote { font-family: var(--read); font-size: var(--t-md); line-height: 1.55; margin: var(--s-2) 0 0; white-space: pre-wrap; max-width: 70ch; }
.srch-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.srch-table th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--rule); padding: var(--s-2); }
.srch-table td { border-bottom: 1px solid var(--rule); padding: var(--s-2); vertical-align: top; }
.srch-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.srch-title { font-family: var(--read); font-size: var(--t-md); line-height: 1.35; }
.srch-title a { text-decoration: none; }
.srch-title a:hover { text-decoration: underline; }
.srch-why { margin: 4px 0 0; color: var(--ink); }
.srch-why-who { font-weight: 600; color: var(--graphite); }
.srch-nuance { color: var(--graphite); font-style: italic; }
.srch-foot { margin-top: var(--s-5); font-size: var(--t-sm); color: var(--graphite); }
