:root {
  color-scheme: light;
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1f1b16;
  --ink-soft: #6b6359;
  --line: #e7e1d6;
  --accent: #9a5b2c;
  --accent-soft: #f2e7da;
  --on-accent: #ffffff;
  --mark-bg: #fbe6c8;
  --code-bg: #2b261f;
  --code-ink: #f3ede2;
  /* callouts: border/label colour + tinted background */
  --quote-line: #b08b5c;    --quote-bg: #fbf6ef;
  --question-line: #2c6e8f; --question-bg: #eef5f8;
  --note-line: #5a6b3f;     --note-bg: #f1f4ea;
  --tip-line: #2f7d5b;      --tip-bg: #ecf5f0;
  --warning-line: #b4632a;  --warning-bg: #fbf0e6;
  --max: 720px;
}

/* Dark theme. The <head> script sets data-theme before paint (no flash),
   defaulting to the OS preference when nothing is stored. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16130f;
  --surface: #1e1a15;
  --ink: #ece5d8;
  --ink-soft: #a99e8d;
  --line: #332d25;
  --accent: #d99a5f;
  --accent-soft: #33281d;
  --on-accent: #1b1611;
  --mark-bg: #6b5220;
  --code-bg: #0f0d0a;
  --code-ink: #e8e0d2;
  --quote-line: #c39b66;    --quote-bg: #241f18;
  --question-line: #6aa8c9; --question-bg: #16212a;
  --note-line: #94a86a;     --note-bg: #1b2016;
  --tip-line: #61b98d;      --tip-bg: #12211a;
  --warning-line: #d98a4e;  --warning-bg: #251a12;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 18px;
}

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

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}
.brand { display: flex; align-items: center; color: var(--ink); }
.brand:hover { text-decoration: none; }
/* Combined mark + "Daily Lesson Notes" wordmark (text is outlined — no font needed) */
.brand-lockup { height: 40px; width: auto; display: block; }
.site-nav { display: flex; gap: 1.1rem; }
.site-nav a { color: var(--ink-soft); font-size: .95rem; white-space: nowrap; }

/* Layout */
.container { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

/* Home hero */
.hero { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 2.4rem;
  line-height: 1.1;
  margin: 0 0 .4rem;
}
.hero-tagline { color: var(--ink-soft); margin: 0; font-size: 1.05rem; }

/* Subscribe page */
.sub-grid { display: grid; gap: 1rem; margin-top: 1.5rem; }
.sub-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
}
.sub-card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.15rem;
  margin: 0 0 .4rem;
}
.sub-card p { margin: 0 0 .6rem; color: var(--ink-soft); font-size: .97rem; }
.sub-card p:last-child { margin-bottom: 0; }
.sub-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.sub-form input {
  flex: 1 1 14rem;
  font: inherit; font-size: .97rem;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.sub-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sub-form button {
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: .6rem 1.1rem;
  border: none; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  cursor: pointer;
}
.sub-form button:hover { filter: brightness(1.08); }
.sub-btn {
  display: inline-block;
  padding: .55rem 1rem;
  border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-size: .95rem; font-weight: 600;
}
.sub-btn:hover { filter: brightness(1.08); text-decoration: none; }
.sub-btn-quiet {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 500; font-size: .85rem;
  word-break: break-all;
}
.sub-soon { font-style: italic; }

/* Search */
.search { margin: 0 0 .5rem; }
.search input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 1rem;
  padding: .7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-meta { margin: .6rem .25rem 0; color: var(--ink-soft); font-size: .85rem; }
.lesson-item-snippet {
  grid-column: 2;
  color: var(--ink-soft);
  font-size: .9rem;
  line-height: 1.5;
  margin-top: .15rem;
}
mark { background: var(--mark-bg); color: inherit; border-radius: 3px; padding: 0 .1em; }

/* Lesson list */
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-item { border-bottom: 1px solid var(--line); }
.lesson-item a {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: .25rem 1rem;
  align-items: baseline;
  padding: 1rem .25rem;
  color: var(--ink);
}
.lesson-item a:hover { text-decoration: none; background: var(--accent-soft); border-radius: 8px; }
.lesson-item time { color: var(--ink-soft); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: .15rem; }
.lesson-item-title { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 1.2rem; }
.lesson-item-sub { grid-column: 2; color: var(--ink-soft); font-size: .95rem; }
.empty { color: var(--ink-soft); padding: 2rem 0; }

/* Lesson page */
.lesson { padding: 1.5rem 0 3rem; }
.lesson-date {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--ink-soft); font-size: .9rem; margin: 0 0 1.25rem;
}
.lesson-date .back { color: var(--ink-soft); }
.lesson-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 0 0 .5rem;
}
.lesson-subtitle { color: var(--ink-soft); font-size: 1.15rem; margin: 0 0 1.5rem; }

.lesson-body { font-size: 1.075rem; }
.lesson-body h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.5rem; margin: 2rem 0 .6rem; }
.lesson-body h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.2rem; margin: 1.6rem 0 .5rem; }
.lesson-body h4 { font-weight: 600; font-size: 1.02rem; letter-spacing: .01em; margin: 1.4rem 0 .4rem; color: var(--accent); }
.lesson-body p { margin: 0 0 1.1rem; }
.lesson-body ul, .lesson-body ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.lesson-body li { margin-bottom: .35rem; }
.lesson-body img { max-width: 100%; height: auto; border-radius: 10px; margin: 1rem 0; }
.lesson-body blockquote {
  margin: 1.4rem 0;
  padding: .4rem 0 .4rem 1.2rem;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}
.lesson-body code {
  background: var(--accent-soft);
  padding: .12em .4em;
  border-radius: 5px;
  font-size: .9em;
}
.lesson-body pre {
  background: var(--code-bg); color: var(--code-ink);
  padding: 1rem 1.2rem; border-radius: 10px; overflow-x: auto;
}
.lesson-body pre code { background: none; padding: 0; }
.lesson-body hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

/* Tables */
.lesson-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: .97rem;
}
.lesson-body th, .lesson-body td {
  text-align: left;
  vertical-align: top;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--line);
}
.lesson-body thead th {
  background: var(--accent-soft);
  font-weight: 600;
  border-bottom: 2px solid var(--line);
}
.lesson-body tbody tr:last-child td { border-bottom: none; }

/* Callouts (converted from admonitions) */
.lesson-body .callout {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  color: var(--ink);
  font-style: normal;
}
.lesson-body .callout > :first-child { margin-top: 0; }
.lesson-body .callout > :last-child { margin-bottom: 0; }
.lesson-body .callout strong:first-child {
  display: block;
  font-size: .78rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.lesson-body .callout-quote {
  border-left-color: var(--quote-line);
  background: var(--quote-bg);
  font-style: italic;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.5;
}
.lesson-body .callout-question { border-left-color: var(--question-line); background: var(--question-bg); }
.lesson-body .callout-question strong:first-child { color: var(--question-line); }
.lesson-body .callout-note { border-left-color: var(--note-line); background: var(--note-bg); }
.lesson-body .callout-note strong:first-child { color: var(--note-line); }
.lesson-body .callout-tip { border-left-color: var(--tip-line); background: var(--tip-bg); }
.lesson-body .callout-tip strong:first-child { color: var(--tip-line); }
.lesson-body .callout-warning { border-left-color: var(--warning-line); background: var(--warning-bg); }
.lesson-body .callout-warning strong:first-child { color: var(--warning-line); }

/* Pager */
.lesson-pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
  font-size: .95rem;
}
.lesson-pager .next { margin-left: auto; text-align: right; }

/* Footer */
.site-footer {
  max-width: var(--max); margin: 2rem auto 0; padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .9rem;
}
.site-footer p { margin: 0; }
.site-footer-credit { margin-top: .35rem !important; font-size: .85rem; }
.site-footer-credit a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; }
.site-footer-credit a:hover { color: var(--accent); }

@media (max-width: 540px) {
  body { font-size: 17px; }
  /* lockup is ~4.9:1 — shrink it so it doesn't crowd the nav on phones */
  .brand-lockup { height: 30px; }
  .site-nav { gap: .8rem; }
  .site-header { padding-left: 1rem; padding-right: 1rem; }
  .hero h1 { font-size: 2rem; }
  .lesson-item a { grid-template-columns: 1fr; }
  .lesson-item time { padding-top: 0; }
  .lesson-item-sub, .lesson-item-snippet { grid-column: 1; }
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink-soft);
  cursor: pointer; line-height: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
/* show the icon for the theme you'd switch TO */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }

/* Swap the header lockup for the reversed one in dark mode */
.brand-lockup-dark { display: none; }
:root[data-theme="dark"] .brand-lockup-light { display: none; }
:root[data-theme="dark"] .brand-lockup-dark { display: block; }

/* Lesson audio player */
.lesson-audio {
  margin: 0 0 1.75rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.lesson-audio-label {
  font-size: .9rem; font-weight: 600; color: var(--ink);
  margin-bottom: .55rem;
}
.lesson-audio-label span { font-weight: 400; color: var(--ink-soft); }
.lesson-audio audio { width: 100%; height: 40px; display: block; }
