/* ==========================================================================
   Forkner Shorthand Course — mobile-first stylesheet
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2b2620;
  --ink-soft: #5f574c;
  --line: #e6dfd3;
  --accent: #8a4f24;
  --accent-soft: #f3e5d8;
  --accent-ink: #6e3e1b;
  --good: #2e7d4f;
  --good-soft: #e2f2e8;
  --bad: #b03a2e;
  --bad-soft: #f9e4e1;
  --shadow: 0 1px 3px rgba(43, 38, 32, 0.08), 0 4px 16px rgba(43, 38, 32, 0.06);
  --radius: 14px;
  --tabbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1915;
    --surface: #26221d;
    --ink: #ece5da;
    --ink-soft: #b0a696;
    --line: #3a342c;
    --accent: #d99a63;
    --accent-soft: #3a2d20;
    --accent-ink: #e8b98d;
    --good: #6fc493;
    --good-soft: #22352a;
    --bad: #e08578;
    --bad-soft: #3d2723;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  -webkit-text-size-adjust: 100%;
}

/* ---- Typography ------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: 'Avenir Next', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.25;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; margin-top: 1.8em; }
h3 { font-size: 1.05rem; margin-top: 1.4em; }

p { margin: 0 0 1em; }

a { color: var(--accent); }
a:hover { color: var(--accent-ink); }

.cursive {
  font-family: 'Snell Roundhand', 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
  font-size: 1.15em;
}

.kbd, code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

.muted { color: var(--ink-soft); font-size: 0.92em; }

/* ---- Layout ------------------------------------------------------------ */

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 18px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
}

.brand {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand .flourish { color: var(--accent); }

.desktop-nav { display: none; }

main { padding: 22px 0 40px; }

/* ---- Bottom tab bar (mobile) ------------------------------------------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.68rem;
  text-decoration: none;
  color: var(--ink-soft);
}

.tabbar a .ico { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

/* ---- Cards & sections --------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}

.hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 20px;
  margin-bottom: 20px;
}

.hero h1 { margin-bottom: 0.3em; }
.hero p.lede { font-size: 1.05rem; color: var(--ink-soft); margin-bottom: 1.2em; }

.btn {
  display: inline-block;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  transition: filter 0.15s ease;
}

.btn:hover { filter: brightness(1.08); color: #fff; }

.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn.small { padding: 8px 16px; font-size: 0.85rem; }

/* ---- Lesson list -------------------------------------------------------- */

.lesson-list { list-style: none; margin: 0; padding: 0; }

.lesson-list li { margin-bottom: 10px; }

.lesson-link {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}

.lesson-link:hover { transform: translateY(-1px); color: var(--ink); }

.lesson-num {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lesson-link.done .lesson-num { background: var(--good-soft); color: var(--good); }

.lesson-link .titles { flex: 1; min-width: 0; }
.lesson-link .titles strong { display: block; font-family: 'Avenir Next', 'Segoe UI', sans-serif; }
.lesson-link .titles span { font-size: 0.85rem; color: var(--ink-soft); }
.lesson-link .check { flex: none; color: var(--good); font-size: 1.2rem; visibility: hidden; }
.lesson-link.done .check { visibility: visible; }

.progress-summary {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ---- Tables -------------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin: 0 0 1em; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ---- Shorthand symbol figures --------------------------------------------- */

.sym {
  display: inline-block;
  vertical-align: middle;
}

.sym svg {
  display: block;
  height: 44px;
  width: auto;
}

.sym svg .stroke {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sym svg .stroke.accent { stroke: var(--accent); }
.sym svg .dot { fill: var(--ink); }
.sym svg .dot.accent { fill: var(--accent); }
.sym svg .baseline { stroke: var(--line); stroke-width: 2; stroke-dasharray: 3 4; }

.sym-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.sym-row:last-child { border-bottom: none; }
.sym-row .sym { flex: none; width: 84px; text-align: center; }
.sym-row .desc { flex: 1; min-width: 0; font-size: 0.95rem; }
.sym-row .desc strong { font-family: 'Avenir Next', 'Segoe UI', sans-serif; }

/* ---- Example blocks ------------------------------------------------------- */

.example {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 1em;
  font-size: 1rem;
}

.example .arrow { color: var(--accent); font-weight: bold; padding: 0 6px; }

.shw {
  font-family: 'Snell Roundhand', 'Segoe Script', 'Bradley Hand', cursive;
  font-size: 1.2em;
  color: var(--accent-ink);
  white-space: nowrap;
}

.callout {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  margin: 0 0 1em;
  font-size: 0.95rem;
}

.callout.note { border-left-color: var(--ink-soft); color: var(--ink-soft); }

/* ---- Quiz ------------------------------------------------------------------ */

.quiz { margin-top: 8px; }

.quiz .q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.quiz .q p.prompt { font-weight: 600; font-family: 'Avenir Next', 'Segoe UI', sans-serif; font-size: 0.98rem; }

.quiz .opts { display: flex; flex-direction: column; gap: 8px; }

.quiz .opt {
  text-align: left;
  font: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
}

.quiz .opt:hover { border-color: var(--accent); }
.quiz .opt.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 600; }
.quiz .opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.quiz .opt:disabled { cursor: default; }

.quiz .explain {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  display: none;
}

.quiz .q.answered .explain { display: block; }

.quiz-score {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-weight: 600;
  margin-top: 4px;
}

/* ---- Pen-and-paper drills ---------------------------------------------------- */

.drill { margin-top: 8px; }

.drill-note {
  font-size: 0.92rem;
  color: var(--ink-soft);
  border-left: 4px solid var(--accent);
  padding: 2px 0 2px 12px;
  margin: 0 0 14px;
}

.drill-set {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.drill-set h3 { margin-top: 0; }
.drill-set .how { margin-bottom: 12px; font-size: 0.9rem; }

.prompt-list { margin: 0 0 14px; padding-left: 1.5em; }
.prompt-list li { margin-bottom: 7px; }

.passage-prompt {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 12px;
}

.plabel {
  display: block;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.passage-prompt .ptext { font-style: italic; }

.key-toggle { display: inline-block; }

.drill-key {
  display: none;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.drill-key.open { display: block; }

.drill-key h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

.answer-list { margin: 0; padding-left: 1.5em; }
.answer-list li { margin-bottom: 7px; }

.drill-key .why { display: block; font-size: 0.85rem; }

.passage-answer {
  border-left: 3px solid var(--line);
  padding-left: 12px;
  margin-bottom: 12px;
}

.passage-answer .atext {
  display: block;
  font-family: 'Snell Roundhand', 'Segoe Script', 'Bradley Hand', cursive;
  font-size: 1.15em;
  color: var(--accent-ink);
  line-height: 1.9;
}

.drill-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }

/* ---- Lesson footer nav ------------------------------------------------------ */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.complete-btn { width: 100%; text-align: center; margin-top: 14px; }
.complete-btn.done { background: var(--good); }

/* ---- Flashcards --------------------------------------------------------------- */

.deck-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.chip {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.flashcard {
  perspective: 1000px;
  height: 240px;
  margin-bottom: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.flashcard .inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s;
  transform-style: preserve-3d;
}

.flashcard.flipped .inner { transform: rotateY(180deg); }

.flashcard .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.flashcard .face.back { transform: rotateY(180deg); background: var(--accent-soft); }

.flashcard .face .big { font-size: 1.5rem; font-weight: 600; font-family: 'Avenir Next', 'Segoe UI', sans-serif; }
.flashcard .face .sym svg { height: 64px; }
.flashcard .face .hint { font-size: 0.8rem; color: var(--ink-soft); }

.fc-controls { display: flex; gap: 10px; }
.fc-controls .btn { flex: 1; text-align: center; }
.fc-controls .again { background: var(--bad); }
.fc-controls .knew { background: var(--good); }

.fc-meta {
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 10px;
}

/* ---- Reference sheet ------------------------------------------------------------ */

.ref-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

@media print {
  .site-header, .tabbar, .no-print { display: none !important; }
  body { padding-bottom: 0; background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---- Desktop ---------------------------------------------------------------------- */

@media (min-width: 760px) {
  body { font-size: 18px; padding-bottom: 0; }

  .tabbar { display: none; }

  .desktop-nav {
    display: flex;
    gap: 4px;
  }

  .desktop-nav a {
    font-family: 'Avenir Next', 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--ink-soft);
    padding: 8px 14px;
    border-radius: 999px;
  }

  .desktop-nav a:hover { color: var(--accent); background: var(--accent-soft); }
  .desktop-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }

  .wrap { max-width: 860px; padding: 0 28px; }

  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.45rem; }

  .hero { padding: 44px 40px; }

  main { padding: 34px 0 70px; }

  .ref-grid { grid-template-columns: 1fr 1fr; }

  .complete-btn { width: auto; }

  .flashcard { height: 280px; }
}

@media (min-width: 1100px) {
  .wrap { max-width: 960px; }
}
