/* CourseLens. One bold idea: citations are highlighter marks, and the cited
   slides sit in the margin like an annotated set of notes. Everything else is quiet. */

@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --paper: #f6f7f4;      /* notebook paper */
  --surface: #ffffff;
  --graphite: #1e2a32;   /* text */
  --pencil: #66727c;     /* secondary text (4.9:1 on paper) */
  --rule: #d6dbd3;       /* ruled lines */
  --ink: #2f5f9e;        /* ballpoint blue: links, primary actions */
  --ink-dark: #244a7c;
  --highlight: #f2e35b;  /* highlighter: citations, the selected slide */
  --error: #a3341f;
  --ok: #2e6b3f;
  --ui: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
  --step--1: 0.875rem; --step-0: 1rem; --step-1: 1.25rem; --step-2: 1.6rem; --step-3: 2.1rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--graphite); font: var(--step-0)/1.5 var(--ui); }
a { color: var(--ink); text-underline-offset: 0.15em; }
a:hover { color: var(--ink-dark); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
h1 { font-size: var(--step-3); line-height: 1.15; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: var(--step-1); margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
.muted, .hint, .row-meta { color: var(--pencil); }
.hint { font-size: var(--step--1); margin-top: -0.25rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.booting { padding: 2rem; color: var(--pencil); }

/* Controls */
input, textarea { font: inherit; color: inherit; width: 100%; padding: 0.6rem 0.7rem; border: 1px solid #b9c0b6; border-radius: 6px; background: var(--surface); }
input:focus-visible, textarea:focus-visible { outline: 3px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
button { font: inherit; cursor: pointer; padding: 0.55rem 1rem; border-radius: 6px; border: 1px solid #b9c0b6; background: var(--surface); color: var(--graphite); }
button:hover { border-color: var(--graphite); }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--ink-dark); }
button:disabled { opacity: 0.6; cursor: progress; }
button.link { border: 0; background: none; padding: 0.25rem 0; color: var(--ink); text-decoration: underline; text-underline-offset: 0.15em; }
label { font-weight: 700; display: block; margin-bottom: 0.3rem; }
.field { margin-bottom: 0.25rem; }
.stack > * + * { margin-top: 0.75rem; }
.notice { padding: 0.55rem 0.75rem; border-left: 4px solid var(--rule); background: var(--surface); margin: 0.75rem 0; }
.notice[data-kind="error"] { border-color: var(--error); color: var(--error); }
.notice[data-kind="ok"] { border-color: var(--ok); color: var(--ok); }
.notice[hidden], .notice:empty { display: none; }
.empty { padding: 1.5rem 0; color: var(--pencil); max-width: 52ch; }

/* Sign-in pages: brand on the left, form on the right; stacked on phones */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: 3rem; align-items: center; padding: 3rem clamp(1.25rem, 6vw, 6rem); }
.auth-brand .wordmark { font-size: clamp(2.6rem, 6vw, 4.2rem); font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.auth-brand .tagline { font-family: var(--read); font-size: var(--step-2); line-height: 1.35; max-width: 22ch; }
.auth-card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 2rem; }
.auth-card h1 { font-size: var(--step-2); }
.auth-card button.primary { width: 100%; }

/* App frame */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--rule); background: var(--surface); }
.topbar .wordmark { font-weight: 700; font-size: var(--step-1); color: var(--graphite); text-decoration: none; letter-spacing: -0.02em; }
.who { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }
.role-tag { font-size: var(--step--1); padding: 0.1rem 0.5rem; border: 1px solid var(--rule); border-radius: 999px; }
.page { max-width: 48rem; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem; outline: none; }
.page.wide { max-width: 72rem; }
.crumb { font-size: var(--step--1); margin-bottom: 0.25rem; }

/* My courses */
.rows { list-style: none; margin: 1rem 0 2rem; padding: 0; border-top: 1px solid var(--rule); }
.rows li { border-bottom: 1px solid var(--rule); }
.row-link { display: grid; grid-template-columns: 1fr auto auto; gap: 1.25rem; align-items: baseline; padding: 0.9rem 0.25rem; text-decoration: none; color: var(--graphite); }
.row-link:hover .row-title { text-decoration: underline; }
.row-title { font-weight: 700; font-size: var(--step-1); }
.actions { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: end; }
.inline-form label { grid-column: 1 / -1; }

/* Course header and tabs */
.course-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; justify-content: space-between; }
.join-box { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.join-code { font: 700 var(--step-1)/1 var(--ui); letter-spacing: 0.12em; padding: 0.35rem 0.6rem; background: var(--surface); border: 1px dashed var(--pencil); border-radius: 6px; }
.join-box .notice { margin: 0; padding: 0.2rem 0.5rem; }
.tabs { display: flex; gap: 1.75rem; border-bottom: 1px solid var(--rule); margin: 1.25rem 0 1.5rem; }
.tabs a { padding: 0.6rem 0; text-decoration: none; color: var(--pencil); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--graphite); border-color: var(--graphite); }

/* Ask */
.ask { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; align-items: start; max-width: 48rem; }
.ask textarea { resize: vertical; min-height: 3.2rem; }
.ask button { height: 3.2rem; padding: 0 1.4rem; }
.result { display: grid; grid-template-columns: minmax(0, 68ch) minmax(14rem, 19rem); gap: 2.5rem; margin-top: 2rem; align-items: start; }
.answer { font: var(--step-0)/1.75 var(--read); font-size: 1.075rem; white-space: pre-wrap; }
.answer.small { font-size: var(--step-0); }
.answer-status { font-size: var(--step--1); margin-top: 1rem; }

/* The memorable element: highlighter citations, lit together with their slide */
.cite { font: 700 0.8em/1 var(--ui); color: var(--graphite); border: 0; padding: 0.15em 0.35em; margin: 0 0.1em; border-radius: 3px;
  background: linear-gradient(100deg, transparent 2%, color-mix(in srgb, var(--highlight) 75%, transparent) 6%, var(--highlight) 50%, color-mix(in srgb, var(--highlight) 80%, transparent) 94%, transparent 98%);
  vertical-align: 0.1em; cursor: pointer; }
.cite.lit, .cite:hover { background: var(--graphite); color: var(--highlight); }

.margin { border-left: 1px solid var(--rule); padding-left: 1.25rem; position: sticky; top: 1rem; }
.margin-title { font-size: var(--step-0); color: var(--pencil); font-weight: 700; }
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.sources li { position: relative; padding: 0.4rem; border-radius: 6px; border: 2px solid transparent; transition: border-color 120ms ease, background-color 120ms ease, opacity 120ms ease; }
.sources li.lit { border-color: var(--highlight); background: color-mix(in srgb, var(--highlight) 22%, var(--surface)); }
.sources img, .thumb-missing { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
.thumb-missing { display: grid; place-items: center; color: var(--pencil); font-size: var(--step--1); }
.src-n { position: absolute; top: -0.5rem; left: -0.5rem; min-width: 1.6rem; height: 1.6rem; display: grid; place-items: center; font-weight: 700; font-size: var(--step--1); background: var(--highlight); color: var(--graphite); border-radius: 999px; padding: 0 0.35rem; }
.src-title { font-weight: 700; font-size: var(--step--1); margin: 0.4rem 0 0; overflow-wrap: anywhere; }
.src-page { font-size: var(--step--1); margin: 0; }

/* History */
.history { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.history li { border-bottom: 1px solid var(--rule); }
.history summary { display: flex; justify-content: space-between; gap: 1rem; padding: 0.9rem 0.25rem; cursor: pointer; }
.history .q { font-weight: 700; }
.history .answer { padding: 0 0.25rem 1rem; max-width: 68ch; }

/* Documents */
.uploader { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem 0.75rem; align-items: end; padding: 1.25rem; border: 1px dashed #b9c0b6; border-radius: 8px; background: var(--surface); margin-bottom: 1.25rem; max-width: 48rem; }
.uploader label, .uploader .hint, .uploader progress { grid-column: 1 / -1; }
.uploader input[type="file"] { padding: 0.45rem; }
.uploader progress { width: 100%; accent-color: var(--ink); }
.docs { width: 100%; border-collapse: collapse; }
.docs th, .docs td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.docs th { font-size: var(--step--1); color: var(--pencil); }
.status { font-weight: 700; }
.status-ready { color: var(--ok); }
.status-failed { color: var(--error); }
.status-pending, .status-processing { color: var(--pencil); }
.doc-error { display: block; font-size: var(--step--1); color: var(--error); }
.doc-note { display: block; font-size: var(--step--1); color: var(--pencil); font-weight: 400; }
.other-slides { margin-top: 1.25rem; }
.other-slides summary { cursor: pointer; }
.other-slides .sources li { opacity: 0.7; }
.other-slides .hint { margin: 0.25rem 0 0.75rem; }

/* Phones and narrow windows */
@media (max-width: 52rem) {
  .auth { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 2rem; align-items: start; align-content: start; }
  .result { grid-template-columns: 1fr; }
  .margin { position: static; border-left: 0; border-top: 1px solid var(--rule); padding: 1.25rem 0 0; }
  .sources { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
  .row-link { grid-template-columns: 1fr auto; }
  .row-link .row-meta:last-child { display: none; }
  .docs th:nth-child(2), .docs td:nth-child(2) { display: none; }
}
@media (max-width: 30rem) {
  .who .muted { display: none; } /* the email crowds the bar on phones; Sign out stays */
  .topbar { padding: 0.7rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
