/* Public course pages (learnfold.app/learn). Same system surfaces, SF Pro,
   and system blue as the landing page and the app. Each course page sets
   --accent to its course color, used only for small marks. */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  /* Tertiary text and the button blue meet 4.5:1 contrast (WCAG 1.4.3). */
  --ink-3: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.14);
  --blue: #0071e3;
  --blue-hover: #0062c4;
  --blue-ink: #0066cc;
  --success: #187a42;
  --blue-wash: #eaf3ff;
  --fill: rgba(120, 120, 128, 0.12);
  --header-bg: rgba(245, 245, 247, 0.82);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 12px 40px -12px rgba(0, 0, 0, 0.16);
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 22px;
  --radius-sm: 14px;
  --accent: #0a84ff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --ink: #f5f5f7;
    --ink-2: #a1a1a6;
    --ink-3: #86868b;
    --line: rgba(255, 255, 255, 0.1);
    --line-2: rgba(255, 255, 255, 0.16);
    --blue-ink: #4da3ff;
    --blue-wash: rgba(10, 132, 255, 0.16);
    --fill: rgba(120, 120, 128, 0.24);
    --success: #30d158;
    --header-bg: rgba(0, 0, 0, 0.72);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 16px 40px -16px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: var(--blue-ink); }
img, svg { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.022em; margin: 0; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
::selection { background: rgba(10, 132, 255, 0.25); }

.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 30;
  padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-shell { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 1.05rem; }
.brand img { border-radius: 7px; }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { color: var(--ink); text-decoration: none; font-size: 0.94rem; font-weight: 500; padding: 8px 12px; border-radius: 999px; }
.site-nav a:hover { background: var(--fill); }
.site-nav .nav-get { background: var(--ink); color: var(--bg); }
.site-nav .nav-get:hover { background: var(--ink); opacity: 0.85; }

/* Shared bits */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.01em;
  margin-bottom: 14px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.lede { color: var(--ink-2); font-size: clamp(1.1rem, 2.2vw, 1.3rem); line-height: 1.45; margin-top: 14px; max-width: 40em; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; padding: 22px 0 0; font-size: 0.9rem; color: var(--ink-3); }
.breadcrumbs a { color: var(--ink-2); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); text-decoration: underline; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  border-radius: 999px; border: 0;
  font-size: 1rem; font-weight: 600; line-height: 1.2; text-align: center;
  text-decoration: none; cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}
.button:active { transform: scale(0.98); }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-hover); }
.button-secondary { background: var(--blue-wash); color: var(--blue-ink); }
.button-secondary:hover { filter: brightness(0.97); }
.button-ghost { background: transparent; color: var(--blue-ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.button-ghost:hover { background: var(--fill); }

/* Course page */
.course-hero { padding: 26px 0 30px; max-width: 820px; }
.course-hero h1, .catalog-hero h1 { font-size: clamp(2.3rem, 6vw, 3.9rem); line-height: 1.04; font-weight: 750; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }

.course-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 36px; align-items: start; }
.course-aside { position: sticky; top: 80px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.facts > div { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.facts h2 { font-size: 1.05rem; margin-bottom: 8px; }
.facts p { color: var(--ink-2); }

.outline { margin-top: 40px; }
.outline > h2, .next-up h2, .related h2 { font-size: 1.6rem; margin-bottom: 16px; }
.chapters { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.chapter { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chapter-head { padding: 20px 22px 14px; }
.chapter-number { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
.chapter-head h3 { font-size: 1.2rem; }
.chapter-head p { color: var(--ink-2); font-size: 0.95rem; margin-top: 5px; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li { border-top: 1px solid var(--line); }
.lesson-list a { display: flex; align-items: flex-start; gap: 14px; padding: 14px 22px; color: inherit; text-decoration: none; }
.lesson-list a:hover { background: var(--fill); }
.lesson-number {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; margin-top: 1px;
  font-size: 0.85rem; font-weight: 650; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.lesson-text { flex: 1; min-width: 0; }
.lesson-title { display: block; font-weight: 600; }
.lesson-summary { display: block; color: var(--ink-2); font-size: 0.92rem; margin-top: 2px; }
.lesson-time { flex: none; color: var(--ink-3); font-size: 0.85rem; margin-top: 3px; }

.next-up { margin-top: 40px; }
.next-up p { color: var(--ink-2); }
.next-up ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 14px 0 0; }
.next-up li { background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 8px 14px; font-size: 0.93rem; }

/* App panel */
.app-panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; position: relative; overflow: hidden;
}
.app-panel::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}
.app-panel h2 { font-size: 1.35rem; margin-bottom: 8px; }
.app-panel > p { color: var(--ink-2); font-size: 0.97rem; }
.app-actions { display: grid; gap: 10px; margin: 20px 0 14px; }
.app-actions .button { width: 100%; }
.app-panel-note { font-size: 0.85rem !important; color: var(--ink-3) !important; line-height: 1.45; }
.app-panel-note strong { color: var(--ink-2); }
.app-panel-get { margin-top: 14px !important; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.93rem; }
.app-panel-get a { font-weight: 600; text-decoration: none; }

/* Course cards */
.related { margin: 56px 0 24px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.course-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; color: inherit; text-decoration: none; position: relative; overflow: hidden;
  transition: transform 0.15s ease;
}
.course-card:hover { transform: translateY(-2px); }
.course-card-accent { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--accent) 55%, white), var(--accent)); margin-bottom: 8px; }
.course-card-meta { font-size: 0.8rem; font-weight: 600; color: var(--ink-3); }
.course-card-title { font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1.2; letter-spacing: -0.015em; }
.course-card-subtitle { color: var(--ink-2); font-size: 0.93rem; }

/* Catalog */
.catalog-hero { padding: 40px 0 34px; max-width: 820px; }
.catalog-own { margin: 48px 0 24px; padding: 32px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.catalog-own h2 { font-size: 1.6rem; }
.catalog-own p { color: var(--ink-2); margin: 8px 0 20px; }

/* Start a course on a question */
.ask-card { max-width: 640px; margin: 40px auto 0; padding: 36px 32px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.ask-card h1 { font-size: clamp(1.9rem, 4.6vw, 2.6rem); line-height: 1.1; font-weight: 750; }
.ask-question { margin: 18px 0 0; padding: 14px 18px; border-left: 3px solid var(--blue); background: var(--blue-wash); border-radius: 0 12px 12px 0; font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.ask-form { margin-top: 24px; }
.ask-form label { display: block; font-weight: 600; margin-bottom: 8px; }
.ask-form-row { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; background: var(--bg); color: var(--ink); font: inherit; }
.ask-phone, .ask-desktop { margin-top: 24px; }
.ask-phone .app-store-badge { display: inline-block; line-height: 0; margin-top: 8px; }
.ask-phone .app-store-badge img { height: 50px; width: auto; }
.ask-note { font-size: 0.92rem; color: var(--ink-2); margin-top: 14px !important; }
.ask-note:empty { display: none; }
[data-ask-status], [data-ask-copy-status] { color: var(--success); font-weight: 600; }
.ask-desktop > p { color: var(--ink-2); }
.ask-qr { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.ask-qr .qr { width: 132px; margin: 0; flex: none; }
.ask-qr p { color: var(--ink-3); font-size: 0.9rem; }
.ask-again { margin-top: 20px !important; font-weight: 600; }
.ask-again a { text-decoration: none; }
.ask-next { max-width: 640px; margin: 32px auto 24px; }
.ask-next h2 { font-size: 1.35rem; }
.ask-next ol { padding-left: 1.3em; margin-top: 12px; }
.ask-next li + li { margin-top: 8px; }
.ask-next li { color: var(--ink-2); }
.ask-next strong { color: var(--ink); }
.ask-fine { color: var(--ink-3); font-size: 0.9rem; margin-top: 16px !important; }
@media (max-width: 640px) {
  .ask-card { margin-top: 20px; padding: 26px 20px; }
  .ask-form-row { flex-direction: column; }
}

/* Lesson page */
.lesson-shell { max-width: 760px; }
.lesson-header { padding: 22px 0 8px; }
.lesson-header h1 { font-size: clamp(2.1rem, 5.4vw, 3.2rem); line-height: 1.06; font-weight: 750; }
.lesson-meta { color: var(--ink-3); font-size: 0.9rem; margin-top: 14px !important; }

.prose { font-size: 1.1rem; line-height: 1.68; padding-top: 10px; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: 1.55rem; line-height: 1.2; margin-top: 2em; }
.prose h3 { font-size: 1.25rem; margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose blockquote { margin-left: 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--fill); padding: 0.1em 0.35em; border-radius: 6px; }
.prose pre { background: var(--card); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 16px 18px; overflow-x: auto; font-size: 0.92rem; line-height: 1.5; }
.prose pre code { background: none; padding: 0; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.97rem; }
.prose th, .prose td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 650; }
.prose tr:last-child td { border-bottom: 0; }

.viz { margin: 1.6em 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 14px 12px; }
.viz-frame { display: block; width: 100%; border: 0; min-height: 120px; color-scheme: normal; }
.viz figcaption { font-size: 0.82rem; color: var(--ink-3); text-align: center; padding-top: 4px; }

.app-tip {
  display: block; font-size: 0.97rem; line-height: 1.5;
  background: var(--blue-wash); color: var(--ink); border-radius: var(--radius-sm); padding: 14px 16px;
}
.app-tip strong { display: block; color: var(--blue-ink); font-size: 0.82rem; margin-bottom: 3px; }
.app-tip a { font-weight: 600; text-decoration: none; }

.rabbit-holes { margin-top: 40px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.rabbit-holes h2 { font-size: 1.4rem; }
.rabbit-holes > p { color: var(--ink-2); margin-top: 6px; }
.rabbit-holes ul { list-style: none; padding: 0; margin: 16px 0 20px; display: grid; gap: 8px; }
.rabbit-holes li { padding: 12px 14px 12px 40px; border-radius: var(--radius-sm); background: var(--fill); position: relative; font-weight: 500; }
.rabbit-holes li::before { content: "?"; position: absolute; left: 14px; top: 11px; font-weight: 700; color: var(--accent); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 40px 0 28px; }
.pager a { display: block; background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: var(--ink); font-weight: 600; line-height: 1.3; }
.pager a span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
.pager-next { text-align: right; grid-column: 2; }
.lesson-shell .app-panel { margin-bottom: 40px; }

.continue-bar {
  position: fixed; left: 12px; right: 12px; z-index: 15;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px;
  background: var(--header-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  transform: translateY(160%); transition: transform 0.25s ease;
}
.continue-bar.visible { transform: none; }
.continue-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.continue-bar-text strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-bar-text span { font-size: 0.8rem; color: var(--ink-2); }
.continue-bar .button { min-height: 42px; padding: 10px 18px; font-size: 0.95rem; }
.continue-bar-close {
  flex: none; width: 36px; height: 36px; margin-left: -4px; border: 0; border-radius: 50%;
  background: var(--fill); color: var(--ink-2); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.is-other .continue-bar, .continue-bar[hidden] { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 30px 0 calc(40px + env(safe-area-inset-bottom)); margin-top: 40px; }
.footer-grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; color: var(--ink-2); font-size: 0.92rem; }
.footer-grid div { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-grid div a { color: var(--ink-2); text-decoration: none; }
.footer-grid div a:hover { color: var(--ink); }

/* Download sheet */
.get-app-sheet {
  width: min(440px, calc(100% - 24px)); max-height: calc(100% - 24px);
  border: 0; border-radius: 28px; padding: 30px 26px 26px;
  background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.get-app-sheet:focus, .get-app-sheet:focus-visible, .get-app-sheet h2:focus, #lesson-title:focus { outline: none; }
.sheet-open-again[hidden] { display: none; }
.sheet-open-again a { font-weight: 600; text-decoration: none; }
.get-app-sheet::backdrop { background: rgba(0, 0, 0, 0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet-close-form { position: absolute; top: 12px; right: 12px; margin: 0; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--fill); color: var(--ink-2); font-size: 1.3rem; line-height: 1;
}
.sheet-mark { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px; }
.get-app-sheet h2 { font-size: 1.45rem; }
.sheet-lede { color: var(--ink-2); margin-top: 8px !important; }
.sheet-steps { text-align: left; margin: 20px 0 18px; padding-left: 1.3em; display: grid; gap: 8px; font-size: 0.97rem; }
.sheet-steps em { font-style: normal; font-weight: 600; }
.no-course .sheet-steps, .no-course [data-copy-status] { display: none; }
.get-app-sheet .app-store-badge { display: inline-block; line-height: 0; margin: 4px auto 0; }
.get-app-sheet .app-store-badge img { height: 50px; width: auto; }
.badge-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  .badge-light { display: none !important; }
  .badge-dark { display: block !important; }
}
.sheet-note { font-size: 0.85rem; color: var(--ink-3); margin-top: 12px !important; }
.sheet-note:empty { display: none; }
[data-copy-status], [data-desktop-copy-status] { color: var(--success); font-weight: 600; }
.course-link-copy { display: flex; gap: 8px; margin: 14px 0 4px; }
.course-link-copy input {
  flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 0.85rem;
}
.course-link-copy .button { min-height: 42px; padding: 8px 16px; font-size: 0.93rem; }
.qr { width: 196px; margin: 22px auto 14px; padding: 10px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.sheet-desktop p { color: var(--ink-2); font-size: 0.95rem; }
.text-link { display: inline-block; margin-top: 12px; font-weight: 600; text-decoration: none; }
.is-ios .sheet-desktop, .is-other .sheet-phone { display: none; }

@media (max-width: 900px) {
  .course-layout { grid-template-columns: 1fr; gap: 28px; }
  .course-aside { position: static; }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 32px); }
  .facts { grid-template-columns: 1fr; }
  .hero-actions .button { flex: 1 1 100%; }
  .lesson-list a { padding: 13px 18px; }
  .lesson-time { display: none; }
  .chapter-head { padding: 18px 18px 12px; }
  .prose { font-size: 1.06rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .site-nav a:not(.nav-get) { padding: 8px 8px; }
  .get-app-sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 28px 28px 0 0;
    padding-bottom: calc(26px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .button, .course-card, .continue-bar { transition: none; }
}

/* Five related courses fit in one row on a wide screen. */
.related .course-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
