/* Evolving Notebook — clean neutral styling only.
   Final aesthetic is deferred to a dedicated later session; keep this legible, don't polish. */

* { box-sizing: border-box; }

:root {
  --bg: #fafaf8;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e2e2dd;
  --card-bg: #ffffff;
  --accent: #2563eb;
  --rule: #d7d7d0;          /* Cornell rules / summary lines */
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem 1.25rem 4rem; }

/* Header: breadcrumbs left, Table of Contents button right */
.site-header {
  border-bottom: 1px solid var(--line); background: var(--card-bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
}
.crumbs { padding: 0.7rem 0; font-size: 0.9rem; }
.crumbs span { color: var(--muted); margin: 0 0.35rem; }
.crumbs strong { color: var(--ink); }
.toc-link {
  flex: 0 0 auto; font-size: 0.85rem; padding: 0.3rem 0.9rem; margin-left: 1rem;
  border: 1px solid var(--line); border-radius: 7px; color: var(--ink); white-space: nowrap;
}
.toc-link:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

/* Landing */
.landing { background: #fdfdfb; }
.landing-main {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 2rem;
}
.landing-main h1 { font-size: 2.4rem; font-weight: 650; margin: 0 0 0.5rem; }
.landing-sub { color: var(--muted); margin: 0 0 2rem; }
.enter-btn {
  display: inline-block; padding: 0.7rem 2.4rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card-bg); color: var(--ink);
  font-size: 1.05rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.enter-btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

/* Semester grid: ~4 across desktop, ~2 across mobile, left-to-right wrap */
.semester-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 720px) {
  .semester-grid { grid-template-columns: repeat(2, 1fr); }
}
.semester-card {
  display: block; padding: 1.1rem 1rem; background: var(--card-bg);
  border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.semester-card:hover { text-decoration: none; border-color: var(--accent); }
.semester-card h2 { font-size: 1.05rem; margin: 0 0 0.3rem; }
.semester-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* Lock banner / badge */
.lock-badge {
  display: inline-block; margin-top: 0.5rem; font-size: 0.78rem; color: #92400e;
  background: #fef3c7; border: 1px solid #fcd34d; border-radius: 6px; padding: 0.1rem 0.5rem;
}
.lock-banner {
  margin: 0 0 1rem; padding: 0.6rem 0.9rem; font-size: 0.9rem;
  background: #fef3c7; border: 1px solid #fcd34d; border-radius: 8px; color: #92400e;
}

/* ---------- Table of Contents (page 1 of the notebook, fully open) ---------- */
.toc { display: flex; flex-direction: column; gap: 1.4rem; }
.toc-class {
  background: var(--card-bg); border: 1px solid var(--line);
  border-left: 6px solid var(--accent); border-radius: 10px;
  padding: 1rem 1.4rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.toc-class-name {
  font-size: 1.25rem; margin: 0 0 0.4rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.class-dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; flex: 0 0 auto; }
.toc-section h3 {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 1rem 0 0.3rem;
}
.toc-line {
  display: flex; align-items: baseline; gap: 0.5rem;
  padding: 0.22rem 0; color: var(--ink);
}
.toc-line:hover { text-decoration: none; }
.toc-line:hover .toc-title { color: var(--accent); text-decoration: underline; }
.toc-title { flex: 0 1 auto; }
.toc-dots {
  flex: 1 1 auto; min-width: 2rem;
  border-bottom: 2px dotted var(--rule);
  transform: translateY(-0.28em);
}
.toc-page { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); font-size: 0.9rem; font-style: italic; margin: 0.2rem 0; }

/* ---------- notebook pager: prev bottom-left, next bottom-right, TOC middle ---------- */
.nb-pager {
  display: flex; align-items: center; gap: 0.8rem;
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line);
}
.pager-side { flex: 1 1 0; display: flex; }
.pager-left { justify-content: flex-start; }
.pager-right { justify-content: flex-end; }
.pager-mid {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
}
.pager-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.pager-btn { max-width: 100%; }
.pager-btn .pager-label {
  display: inline-block; max-width: 16rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.pager-toc { font-size: 0.8rem; padding: 0.25rem 0.8rem; }
@media (max-width: 720px) {
  .pager-btn .pager-label { max-width: 5.5rem; }
}

/* Content pages (notes, sources) */
.page-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; margin: 0 0 0.25rem; }
.page-head h1 { margin: 0; }
.meta-line { color: var(--muted); font-size: 0.85rem; margin: 0 0 1rem; }
.tag-chip {
  display: inline-block; font-size: 0.75rem; background: #eef2ff; color: #3730a3;
  border-radius: 999px; padding: 0.05rem 0.6rem; margin-right: 0.3rem;
}
.note-body { background: var(--card-bg); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.5rem; }
.note-body img, .note-body svg { max-width: 100%; height: auto; }
.note-body table { border-collapse: collapse; }
.note-body th, .note-body td { border: 1px solid var(--line); padding: 0.3rem 0.6rem; }
.note-body code { background: #f3f4f0; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }
.note-body pre code { display: block; padding: 0.8rem; overflow-x: auto; }
.note-body blockquote { margin: 0.8rem 0; padding: 0.1rem 1rem; border-left: 3px solid var(--line); color: var(--muted); }

/* ---------- Cornell note layout ----------
   Each ### section = a row: cue column left (heading + open space to write),
   notes right; ruled Summary block at the bottom. Deliberately spaced out
   so printed pages leave room for handwriting. */
.cornell { padding: 0; overflow: hidden; }
.cornell-intro { padding: 1.1rem 1.5rem 0.4rem; }
.cornell-row {
  display: grid;
  grid-template-columns: minmax(140px, 26%) 1fr;
  border-top: 1px solid var(--rule);
}
.cornell-intro + .cornell-row, .cornell-row:first-child { border-top: none; }
.cornell-cue {
  border-right: 2px solid var(--rule);
  padding: 1.1rem 0.9rem 2.6rem;         /* extra bottom space = writing room */
}
.cue-heading { font-weight: 650; font-size: 0.95rem; line-height: 1.4; }
.cornell-notes {
  padding: 1.1rem 1.5rem 1.6rem;
  line-height: 1.9;                       /* spaced out for annotation */
}
.cornell-notes p { margin: 0.5rem 0 1rem; }
.cornell-notes li { margin: 0.45rem 0; }
.cornell-notes ul, .cornell-notes ol { padding-left: 1.4rem; }
.cornell-summary {
  border-top: 2px solid var(--rule);
  padding: 1rem 1.5rem 1.4rem;
}
.summary-label {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 0.9rem;
}
.summary-line { border-bottom: 1px solid var(--rule); height: 2.1rem; }
@media (max-width: 640px) {
  .cornell-row { grid-template-columns: 1fr; }
  .cornell-cue { border-right: none; border-bottom: 1px dashed var(--rule); padding-bottom: 0.8rem; }
}

.toolbar { display: flex; gap: 0.6rem; margin: 0.8rem 0 1rem; flex-wrap: wrap; }
.btn {
  cursor: pointer; padding: 0.4rem 1rem; font-size: 0.9rem;
  border: 1px solid var(--line); border-radius: 7px; background: var(--card-bg); color: var(--ink);
  display: inline-block;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Cross-topic reference term + modal */
.xref {
  color: var(--accent); border-bottom: 1px dashed var(--accent); cursor: pointer;
}
.xref-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.xref-modal {
  width: min(340px, 85vw); aspect-ratio: 1 / 1; background: var(--card-bg);
  border-radius: 12px; padding: 1.25rem; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  display: flex; flex-direction: column; overflow: auto;
}
.xref-modal h3 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.xref-modal p { margin: 0 0 auto; font-size: 0.92rem; }
.xref-modal .xref-actions { margin-top: 1rem; display: flex; justify-content: space-between; align-items: center; }

/* Flashcard viewer */
.fc-stage { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.fc-card {
  width: min(640px, 92vw); min-height: min(340px, 55vh);
  background: var(--card-bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07); cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 2rem; font-size: 1.4rem; user-select: none;
  position: relative;
}
.fc-card .fc-side-label {
  position: absolute; top: 0.6rem; left: 0.9rem; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.fc-card.back { background: #f6f8ff; }
.fc-counter { color: var(--muted); font-size: 0.9rem; }
.fc-controls { display: flex; gap: 0.6rem; }

/* Quiz */
.quiz-list { list-style: none; padding: 0; margin: 0; }
.quiz-q { background: var(--card-bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1.1rem; margin: 0 0 0.8rem; }
.quiz-q .q-prompt { font-weight: 600; margin: 0 0 0.4rem; }
.quiz-q ol { list-style: upper-alpha; margin: 0; padding-left: 1.6rem; }
.quiz-q ol li { margin: 0.15rem 0; }
.short-line { color: var(--muted); font-style: italic; }
.key-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.key-table td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.9rem; vertical-align: top; }
.key-table td.key-n { width: 3rem; font-weight: 600; text-align: left; }

.error-box {
  background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b;
  border-radius: 8px; padding: 0.8rem 1rem; margin: 1rem 0;
}

/* Flashcard print sheet is screen-hidden; print.css reveals it */
.fc-print { display: none; }
