:root {
  color-scheme: light dark;
  --bg: #fdfcfa;
  --surface: #f3f1ec;
  --text: #1c1b19;
  --muted: #66625b;
  --border: #e4e0d8;
  --accent: #9a4a24;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Type scale: every font size on the site is one of these. Fluid from phone to desktop. */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: clamp(1.1875rem, 1.155rem + 0.14vw, 1.25rem);
  --text-lg: clamp(1.375rem, 1.31rem + 0.28vw, 1.5rem);
  --text-xl: clamp(1.625rem, 1.5rem + 0.55vw, 1.875rem);
  --text-2xl: clamp(2.25rem, 1.86rem + 1.7vw, 3rem);

  --leading-tight: 1.12;
  --leading-snug: 1.28;
  --leading-body: 1.6;

  /* Vertical rhythm */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1f1d1a;
    --text: #ece9e3;
    --muted: #a39e94;
    --border: #33302b;
    --accent: #e59a70;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: var(--text-base)/var(--leading-body) var(--sans);
  font-kerning: normal;
  font-optical-sizing: auto;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
ul[class] { list-style: none; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: var(--leading-snug); text-wrap: balance; overflow-wrap: break-word; }
h1 { font-size: var(--text-2xl); line-height: var(--leading-tight); letter-spacing: -0.018em; }
h2 { font-size: var(--text-xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); letter-spacing: -0.005em; }
h4 { font-size: var(--text-md); font-weight: 600; }
p, li, blockquote { text-wrap: pretty; }
time, .meta { font-variant-numeric: tabular-nums; }
button, input, textarea { font-family: var(--sans); line-height: 1.4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 76rem; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 3rem); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 20; background: var(--bg); padding: 0.5rem 1rem; }
.hp { position: absolute; left: -9999px; }

/* Header and footer */
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.75rem 1rem; padding-block: 1.5rem; }
.site-header nav { display: flex; gap: 1.5rem; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: var(--text-sm); padding-block: 0.25rem; border-bottom: 2px solid transparent; }
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current] { color: var(--text); border-color: var(--accent); }
main { flex: 1; padding-block: 2.5rem 4rem; }
.site-footer { border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; padding-block: 1.5rem; }

/* Controls */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: 0 1.25rem;
  background: var(--text); color: var(--bg); border: 1px solid var(--text); border-radius: 999px;
  font: 500 var(--text-sm) var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover { opacity: 0.85; }
.button:disabled { opacity: 0.6; cursor: wait; }
input, textarea { width: 100%; padding: 0.65rem 0.875rem; font-size: var(--text-base); color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 1.25rem; }
.meta { color: var(--muted); font-size: var(--text-sm); }
.page-title { margin-bottom: var(--space-1); }
.lede { color: var(--muted); font-size: var(--text-md); font-family: var(--serif); font-style: italic; margin-bottom: var(--space-4); }

/* Home */
.hero { display: flex; align-items: center; gap: 2rem; margin-bottom: 3rem; }
.role { color: var(--muted); margin-top: var(--space-1); }
.portrait { width: 10rem; height: 10rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.socials { display: flex; gap: 0.25rem; }
.socials a { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; color: var(--muted); }
.socials a:hover { color: var(--text); background: var(--surface); }
.icon { width: 1.25rem; height: 1.25rem; }
.block { margin-top: 4rem; }
.block > h2 { margin-bottom: 1rem; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.block-head a { font-size: var(--text-sm); color: var(--muted); }

/* Notes */
.featured { display: block; text-decoration: none; margin-bottom: 2.5rem; }
.featured-image { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 12px; margin-bottom: 1.25rem; }
.featured h2 { margin-bottom: var(--space-1); }
.featured p, .note-row p, .app-row p { color: var(--muted); margin-bottom: var(--space-1); }
.note-row { display: grid; grid-template-columns: 1fr 9rem; gap: 1.5rem; align-items: center; padding-block: 1.5rem; border-bottom: 1px solid var(--border); text-decoration: none; }
.note-row :is(h2, h3), .card h2, .app-row h2 { font-size: var(--text-lg); letter-spacing: -0.005em; text-wrap: pretty; margin-bottom: var(--space-1); }
.note-row .meta { margin: 0; }
.thumb { width: 9rem; height: 6rem; object-fit: cover; border-radius: 8px; }
.placeholder { display: block; background: var(--surface); }
a:hover h2, a:hover h3 { color: var(--accent); }

/* Article */
.progress { position: fixed; inset: 0 0 auto; height: 3px; background: var(--accent); transform-origin: left; transform: scaleX(0); z-index: 10; }
.article-head { margin-bottom: 2rem; }
.article-head h1 { margin-bottom: var(--space-3); }
.byline { display: flex; align-items: center; gap: 0.75rem; font-size: var(--text-sm); font-weight: 500; }
.byline .meta { font-weight: 400; }
.avatar { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; }
.cover { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 12px; margin-bottom: 2.5rem; }

.prose { font: var(--text-md)/var(--leading-body) var(--serif); overflow-wrap: break-word; hanging-punctuation: first last; }
.prose > * + * { margin-top: 1.1em; }
.prose > :is(h2, h3, h4) { margin-top: 1.8em; }
.prose > :is(h2, h3, h4):first-child { margin-top: 0; }
.prose > :is(h2, h3, h4) + * { margin-top: 0.6em; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35em; }
.prose li::marker { color: var(--muted); }
.prose a { text-decoration-color: var(--accent); text-decoration-thickness: from-font; text-underline-offset: 0.18em; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 1.25rem; color: var(--muted); font-style: italic; }
.prose blockquote > * + * { margin-top: 0.75rem; }
.prose hr { border: 0; text-align: center; margin-block: 2.5rem; }
.prose hr::after { content: '· · ·'; color: var(--muted); letter-spacing: 0.5em; }
.prose pre { overflow-x: auto; padding: 1rem; background: var(--surface); border-radius: 8px; font: var(--text-sm)/1.55 ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; }
.prose code { background: var(--surface); border-radius: 4px; padding: 0.1em 0.3em; font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; font-size: 0.85em; }
.prose pre code { padding: 0; font: inherit; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font: var(--text-sm)/1.5 var(--sans); font-variant-numeric: tabular-nums; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.4rem 0.75rem; text-align: left; }
.prose img { border-radius: 8px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; }
.pager a { padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; font: 500 var(--text-md)/var(--leading-snug) var(--serif); }
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font: 400 var(--text-sm)/1.4 var(--sans); color: var(--muted); margin-bottom: 0.35rem; }
.pager .newer { grid-column: 2; text-align: right; }

/* Courses and apps */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 2rem 1.5rem; }
.card { display: block; text-decoration: none; }
.card-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: 0.875rem; }
.app-row { display: flex; gap: 1.25rem; align-items: center; padding-block: 1.25rem; border-bottom: 1px solid var(--border); text-decoration: none; }
.app-icon { width: 5rem; height: 5rem; border-radius: 22%; object-fit: cover; flex-shrink: 0; }
.app-head { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }
.app-head h1 { font-size: var(--text-xl); }
.app-head .actions { margin-top: 0.75rem; }
.app-head .app-icon { width: 6.5rem; height: 6.5rem; }
.shots { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.75rem; }
.shot { width: 13rem; height: auto; align-self: flex-start; border-radius: 14px; border: 1px solid var(--border); flex-shrink: 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 2.5rem; font-size: var(--text-sm); color: var(--muted); }
.back { margin-bottom: 1.5rem; font-size: var(--text-sm); color: var(--muted); }
.back a { text-decoration: none; }

/* Layout: pages use the full width; running text stays at a comfortable measure. */
.reading > :not(article, .progress), .reading article > * { max-width: 39.5rem; margin-inline: auto; }
.reading article > .cover { max-width: 60rem; }
.index .subscribe { margin-top: var(--space-5); }
@media (max-width: 63.99rem) {
  .home > * { max-width: 39.5rem; margin-inline: auto; }
}

@media (min-width: 64rem) {
  .home { display: grid; grid-template-columns: 19rem minmax(0, 40rem); justify-content: space-between; align-content: start; column-gap: var(--space-5); }
  .home > * { grid-column: 2; }
  .home > .hero { grid-column: 1; grid-row: 1 / span 3; align-self: start; position: sticky; top: var(--space-4); flex-direction: column; align-items: flex-start; margin: 0; }
  .home .portrait { width: 14rem; height: 14rem; }
  .home > .block:first-of-type { margin-top: var(--space-5); }
}

@media (min-width: 48rem) {
  .featured { display: grid; grid-template-columns: 3fr 2fr; grid-template-rows: auto auto 1fr; column-gap: var(--space-4); align-items: start; margin-bottom: var(--space-5); }
  .featured-image { grid-row: 1 / span 3; margin: 0; aspect-ratio: 16 / 10; }
  .index .note-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: var(--space-5) var(--space-4); }
  .index .note-row { display: flex; flex-direction: column-reverse; justify-content: flex-end; align-items: stretch; gap: var(--space-2); height: 100%; padding: 0; border: 0; }
  .index .thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; }
  .app-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr)); column-gap: var(--space-4); }
}

/* Subscribe and contact */
.subscribe { margin-top: 4rem; padding: 2rem 1.5rem; background: var(--surface); border-radius: 16px; text-align: center; }
.subscribe h2 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.subscribe-form { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.subscribe-form input[type="email"] { width: min(100%, 18rem); border-radius: 999px; }
.form-status { width: 100%; font-size: var(--text-sm); color: var(--muted); }
.form-status:empty { display: none; }
.form-human { width: 100%; }
.form-status.ok { color: light-dark(#166534, #86efac); }
.form-status.error { color: light-dark(#991b1b, #fca5a5); }

dialog { margin: auto; width: min(32rem, calc(100% - 2rem)); padding: 1.75rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 16px; }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
dialog form { display: grid; gap: 1rem; }
dialog label { display: grid; gap: 0.35rem; font-size: var(--text-sm); font-weight: 500; }
dialog textarea { resize: vertical; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.dialog-close { width: 2.75rem; height: 2.75rem; font-size: 1.5rem; line-height: 1; background: none; border: 0; border-radius: 50%; color: var(--muted); cursor: pointer; }
body:has(dialog[open]) { overflow: hidden; }
.message { text-align: center; padding-block: 4rem; }
.message p { margin-top: 1rem; }

@media (max-width: 36rem) {
  .hero { flex-direction: column; text-align: center; }
  .hero .actions { justify-content: center; }
  .portrait { width: 8rem; height: 8rem; }
  .note-row { grid-template-columns: 1fr 5rem; gap: 1rem; }
  .note-row p:not(.meta) { display: none; }
  .thumb { width: 5rem; height: 5rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .newer { grid-column: 1; }
  .app-head { align-items: flex-start; gap: 1rem; }
  .app-head .app-icon { width: 4.5rem; height: 4.5rem; }
}
