/* pu.nielsveck.com — tokens and type follow DESIGN.md in the repo root. */
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/fraunces-latin-opsz-normal.woff2) format("woff2");
}

:root {
  --bg: #FAF7F2; --bg-raised: #FFFFFF; --ink: #1B1917; --ink-soft: #5E5852;
  --line: #E6DFD5; --accent: #B4531F; --accent-ink: #FFFFFF; --warn: #9A3412; --tint: #F3EDE4;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151311; --bg-raised: #1D1A17; --ink: #EFEAE3; --ink-soft: #A79F95;
    --line: #2C2823; --accent: #E08A5A; --accent-ink: #151311; --warn: #F0A274; --tint: #25211D;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 "Inter", system-ui, sans-serif; }
@media (min-width: 768px) { body { font-size: 17px; } }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: var(--mono); font-size: .9em; background: var(--tint); padding: 1px 5px; border-radius: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }

/* Header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 56px; }
.kicker, .label, .fine, .meta, .step {
  font-family: var(--mono); font-size: 13px; letter-spacing: .06em; color: var(--ink-soft);
}
.kicker { text-transform: uppercase; text-decoration: none; margin: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { text-decoration: none; padding: 10px 12px; border-radius: 999px; font-weight: 500; font-size: 15px; }
.nav a.on { background: var(--tint); }

h1, h2 { font-family: "Fraunces", Georgia, serif; font-weight: 560; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
.lead { color: var(--ink-soft); margin: 8px 0 0; max-width: 68ch; }
.label { text-transform: uppercase; margin: 24px 0 8px; }
.fine { font-size: 12px; letter-spacing: .02em; margin: 8px 0; }

#view { padding-top: 24px; padding-bottom: 64px; outline: none; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  display: block; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 16px; margin-bottom: 16px;
}
@media (min-width: 768px) { .card { padding: 24px; } }

/* Buttons and pills */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 15px/1 "Inter", system-ui, sans-serif; min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; transition: border-color .15s, background-color .15s;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { border-color: transparent; color: var(--ink-soft); }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn.wide { width: 100%; margin-top: 20px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font: 500 14px/1 "Inter", system-ui, sans-serif; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; min-height: 40px; padding: 0 16px; cursor: pointer;
}
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs { margin-bottom: 16px; }

/* Forms */
label { display: block; margin: 14px 0 6px; font-weight: 500; font-size: .95em; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; min-height: 44px;
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 180px; min-width: 0; }
.row > div.narrow { flex: 0 1 110px; }
.row.end { margin-top: 12px; }
.row.end input { flex: 1 1 260px; }

/* Overview */
.search { margin-bottom: 24px; }
.search input { font-size: 1.05em; min-height: 52px; border-radius: 999px; padding: 0 20px; background: var(--bg-raised); }
.course { margin-bottom: 40px; }
.course .lead { margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ch-card, .hit { text-decoration: none; margin: 0; display: grid; gap: 4px; transition: border-color .15s; }
.ch-card:hover, .hit:hover { border-color: var(--accent); box-shadow: 0 8px 24px -16px rgb(0 0 0 / .25); }
.ch-card b, .hit b { font-weight: 600; line-height: 1.35; }
.ch-card .focus, .hit .snippet { color: var(--ink-soft); font-size: .92em; line-height: 1.45; }
.hits { display: grid; gap: 12px; }
.empty { padding: 32px 0; color: var(--ink-soft); }

/* Chapter text */
.sec h2 { font-size: 1.15rem; }
/* long source URLs must wrap, or the page scrolls sideways on phones */
.sec, .prose, .snippet { overflow-wrap: anywhere; }
.md-table td, .md-table th { overflow-wrap: normal; }
.sec p, .prose p { margin: 0 0 12px; max-width: 75ch; }
.md-h { font-family: "Inter", system-ui, sans-serif; font-size: 1.02em; font-weight: 700; margin: 22px 0 6px; }
.md-h:first-child { margin-top: 0; }
.md-ul { margin: 4px 0 14px; padding-left: 20px; max-width: 75ch; }
.md-ul li { margin-bottom: 4px; }
.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
.md-table { border-collapse: collapse; width: 100%; font-size: .9em; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md-table th { background: var(--tint); font-weight: 600; }
.md-fig { margin: 16px 0 20px; }
.md-fig img { display: block; max-width: 100%; max-height: 560px; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.md-fig figcaption { font-size: .85em; color: var(--ink-soft); text-align: center; margin-top: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.prevnext { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.prevnext .btn { white-space: normal; text-align: left; line-height: 1.3; padding: 10px 16px; }

/* Presentation: full screen, dark */
body.slides-open { overflow: hidden; }
.slides { position: fixed; inset: 0; background: #14110F; color: #EFEAE3; z-index: 50; display: flex; flex-direction: column; }
.slide { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 5vh 7vw; max-width: 1400px; margin: 0 auto; width: 100%; overflow-y: auto; }
.slide h2 { font-size: clamp(24px, 4vw, 46px); margin: 0 0 24px; color: #fff; }
.slide .md-ul { font-size: clamp(17px, 2.3vw, 28px); line-height: 1.5; max-width: none; }
.slide p { font-size: clamp(16px, 2vw, 24px); }
.slide .md-fig img { max-height: 60vh; border: none; }
.slide .md-fig figcaption { color: #CFC6BB; }
.slide .md-table { font-size: clamp(13px, 1.7vw, 20px); color: #fff; }
.slide .md-table th { background: #2A2521; }
.slide .md-table th, .slide .md-table td { border-color: #4A423B; }
.slide-notes { font-size: 15px; color: #CFC6BB; border-top: 1px solid #4A423B; margin-top: 20px; padding-top: 10px; display: none; }
.slides.notes .slide-notes { display: block; }
.slides-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: #221E1A; font-size: 13px; color: #CFC6BB; }
.slides-bar button { background: #3A332D; color: #fff; border: 0; border-radius: 6px; min-height: 36px; padding: 0 12px; margin-left: 6px; cursor: pointer; font: inherit; }
.slides-bar button:hover { background: #4A423B; }

/* Editor */
.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.editor textarea { font-family: var(--mono); font-size: 13px; line-height: 1.5; min-height: 160px; resize: vertical; }
.editor textarea.big { min-height: 520px; }
.ed-tabs { margin: 4px 0 8px; }
.ed-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.preview { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
.slide-mini { padding: 12px; margin-bottom: 8px; }
.rev { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); padding: 6px 0; }
#e_state { color: var(--warn); }

/* Admin / account */
.users input:not([type="checkbox"]), .users select { min-height: 36px; padding: 4px 8px; }
.nowrap { white-space: nowrap; }
.notice { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--tint); }
.narrow-card { max-width: 520px; }
.narrow-card .btn { margin-top: 18px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 10px; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--warn); color: #fff; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; margin: 0; }
.login-card h1 { margin: 6px 0 12px; }
.status.err { color: var(--warn); margin: 0 0 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .top, .view-head .actions, .prevnext, .tabs { display: none !important; }
  .card { border: none; padding: 0; }
}
