  @font-face {
    font-family: 'Caprasimo';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('caprasimo.ttf') format('truetype');
  }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/SourceSerif4-Regular.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: italic; font-weight: 400; font-display: swap; src: url('fonts/SourceSerif4-It.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/SourceSerif4-Semibold.woff2') format('woff2'); }

  :root {
    --paper: #f8f7f1;
    --surface: #fffefa;
    --ink: #2a3b33;
    --muted: #66736b;
    --line: #dfe4da;
    --green: #4f7d66;
    --green-soft: #eaf0e5;
    --accent: #d2673f;
    --accent-soft: #f9ece2;
    --display: 'Caprasimo', 'Cooper Black', 'Cooper Std', Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --sans: -apple-system, system-ui, "Segoe UI", Inter, sans-serif;
  --serif: 'Source Serif 4', 'Iowan Old Style', 'Charter', 'Palatino', Georgia, 'Times New Roman', serif;
  }
  * { box-sizing: border-box; }
  b, strong { font-weight: 600; }
  html { color-scheme: light; }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 19px/1.6 var(--serif);
    -webkit-font-smoothing: antialiased;
  }
  main { max-width: 680px; margin: 0 auto; padding: 48px 16px 64px; }

  header { margin-bottom: 32px; display: flex; align-items: center; gap: 20px; }
  .logo { flex: none; width: 96px; height: auto; }
  @media (max-width: 480px) { header { gap: 14px; } .logo { width: 64px; } }
  h1 {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(40px, 9vw, 64px);
    line-height: 1.02;
    letter-spacing: -0.01em;
    margin: 0 0 10px;
    color: var(--green);
  }
  h1 span { color: var(--accent); }
  .intro { font-size: 21px; color: var(--ink); margin: 0; max-width: 34em; }

  h2 {
    font-family: var(--display);
    font-weight: 400;
    font-size: 15px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 12px;
  }

  .list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
  .card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 20px 16px;
    text-decoration: none;
    color: inherit;
    transition: transform .12s ease, border-color .12s ease, background .12s ease;
  }
  a.card:hover, a.card:focus-visible { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); outline: none; }
  .card h3 {
    font-family: var(--display);
    font-weight: 400;
    font-size: 26px;
    line-height: 1.1;
    margin: 0 0 6px;
    color: var(--green);
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  }
  a.card h3::after { content: "→"; color: var(--accent); font-family: var(--sans); font-size: 20px; }
  .card p { margin: 0; color: var(--ink); }
  .card p + p { margin-top: 8px; }
  .card .url { display: block; margin-top: 8px; font-family: var(--sans); font-size: 14px; color: var(--muted); }

  /* icon cards: the icon sits beside the title only; the copy runs full width */
  .card .head { display: flex; align-items: center; gap: 14px; margin: 0 0 10px; }
  .card .head h3 { margin: 0; }
  .thumb.icon { flex: none; width: 56px; height: 56px; border-radius: 14px; }

  /* hero card: the picture fills the card, text sits on a white fade at the left.
     With a second picture (has-dark) the card crossfades to it on hover and the text goes light. */
  .card.hero {
    position: relative; overflow: hidden; isolation: isolate;
    border-radius: 0; border-color: var(--line);
    min-height: 280px; padding: 24px 24px 22px;
    background: #fff;
    display: flex; flex-direction: column; justify-content: flex-end;
    transition: border-color .45s ease, color .45s ease;
  }
  .card.hero::before, .card.hero::after {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background-repeat: no-repeat; background-size: auto, cover;
    transition: opacity .45s ease;
  }
  .card.hero::before {
    background-image: linear-gradient(90deg, rgba(255,255,255,.97) 0%, rgba(255,255,255,.93) 38%, rgba(255,255,255,.55) 58%, rgba(255,255,255,0) 78%), var(--hero);
    background-position: 0 0, var(--focus, 50% 50%);
  }
  .card.hero::after {
    opacity: 0;
    background-color: #000;
    background-image: linear-gradient(90deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.85) 38%, rgba(0,0,0,.45) 58%, rgba(0,0,0,0) 78%), var(--hero-dark, none);
    background-position: 0 0, var(--focus-dark, 50% 50%);
  }
  .card.hero h3, .card.hero p, .card.hero .url { max-width: 58%; }
  .card.hero h3 { color: var(--ink); transition: color .45s ease; }
  .card.hero p, .card.hero .url { transition: color .45s ease; }
  a.card.hero:hover, a.card.hero:focus-visible { background-color: #fff; transform: none; border-color: var(--ink); }
  a.card.hero.has-dark:hover, a.card.hero.has-dark:focus-visible { border-color: #000; }
  a.card.hero.has-dark:hover::after, a.card.hero.has-dark:focus-visible::after { opacity: 1; }
  a.card.hero.has-dark:hover h3, a.card.hero.has-dark:focus-visible h3 { color: #fff; }
  a.card.hero.has-dark:hover p, a.card.hero.has-dark:focus-visible p { color: #f1efe7; }
  a.card.hero.has-dark:hover .url, a.card.hero.has-dark:focus-visible .url { color: #b9c2b8; }
  a.card.hero.has-dark:hover h3::after, a.card.hero.has-dark:focus-visible h3::after { color: #ff5c8a; }
  @media (max-width: 560px) {
    .card.hero { min-height: 240px; }
    .card.hero::before { background-image: linear-gradient(90deg, rgba(255,255,255,.96) 0%, rgba(255,255,255,.9) 55%, rgba(255,255,255,.4) 85%, rgba(255,255,255,.1) 100%), var(--hero); }
    .card.hero::after { background-image: linear-gradient(90deg, rgba(0,0,0,.9) 0%, rgba(0,0,0,.82) 55%, rgba(0,0,0,.35) 85%, rgba(0,0,0,.1) 100%), var(--hero-dark, none); }
    .card.hero h3, .card.hero p, .card.hero .url { max-width: 80%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .card.hero, .card.hero::before, .card.hero::after, .card.hero h3, .card.hero p, .card.hero .url { transition: none; }
  }

  footer { margin-top: 40px; color: var(--muted); font-size: 16px; }
  footer a { color: var(--green); }

/* ---- tabs on the front page ------------------------------------------ */
.tabs { display: flex; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.tabs button {
  font-family: var(--display); font-weight: 400; font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--green); background: var(--green-soft); border-color: var(--line); }
.tabs button:hover { color: var(--green); }
.tab-panel[hidden] { display: none; }
.tab-panel > p.lead { margin: 0 0 14px; color: var(--muted); }
.card .date { display: block; margin-top: 8px; font-family: var(--sans); font-size: 14px; color: var(--muted); }

/* ---- a post page ------------------------------------------------------ */
.post { font-size: 20px; line-height: 1.6; }
.post-top { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.post-top img { width: 44px; height: auto; }
.post-top a { font-family: var(--display); font-size: 18px; color: var(--green); text-decoration: none; }
.post-top a span { color: var(--accent); }
.post h1 { font-size: clamp(34px, 7vw, 52px); margin-bottom: 8px; }
.post .meta { margin: 0 0 28px; color: var(--muted); font-size: 16px; font-family: var(--sans); }
.post .lead { font-size: 23px; line-height: 1.5; color: var(--ink); margin: 0 0 24px; }
.post h2 {
  font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; letter-spacing: 0; text-transform: none;
  color: var(--green); margin: 44px 0 10px;
}
.post h3 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.15; color: var(--ink); margin: 28px 0 8px; }
.post p { margin: 0 0 14px; }
.post ul, .post ol { margin: 0 0 14px; padding-left: 22px; }
.post li { margin: 4px 0; }
.post a { color: var(--green); text-decoration-color: var(--line); text-underline-offset: 3px; }
.post a:hover { text-decoration-color: var(--green); }
.post code { font-family: var(--mono); font-size: .92em; background: var(--green-soft); padding: 2px 5px; border-radius: 5px; }
.post pre {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.55; tab-size: 2;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin: 0 0 18px; overflow-x: auto;
}
.post pre code { background: transparent; padding: 0; font-size: inherit; }
.post pre .lang { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.post blockquote { margin: 0 0 16px; padding: 10px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.post blockquote p:last-child { margin: 0; }
.post hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.post figure { margin: 6px 0 22px; }
.post figure img { display: block; max-width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.post figure.wide img { width: 100%; }
.post figcaption { margin-top: 8px; font-family: var(--sans); font-size: 14px; color: var(--muted); }
.post figure.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: start; }
.post figure.gallery img { width: 100%; }
.post figure.gallery figcaption { grid-column: 1 / -1; }
.post .tip { font-size: 18px; background: var(--green-soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; }
.post .tip p:last-child { margin: 0; }
.post-foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 16px; }
/* a lone portrait screenshot stays phone-sized; "wide:" pictures fill the column */
.post figure:not(.gallery):not(.wide):not(.phone-fig) img { max-height: 680px; width: auto; max-width: 100%; }

/* ---- the schematic diagram in a post ---------------------------------- */
.post figure.diagram { margin: 10px 0 18px; padding: 14px 8px 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.post figure.diagram svg { display: block; width: 100%; height: auto; }
.dg-arrow { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.dg-out { stroke: var(--green); }
.dg-in { stroke: var(--accent); stroke-dasharray: 1 9; stroke-width: 4.5; }
.dg-fill-out { fill: var(--green); }
.dg-fill-in { fill: var(--accent); }
.dg-tile { fill: #fff; stroke: var(--line); stroke-width: 1.5; }
.dg-name { font-family: var(--display); font-size: 24px; fill: var(--ink); text-anchor: middle; }
.dg-label { font-family: var(--sans); font-size: 17px; font-weight: 600; fill: var(--ink); }
.dg-num { font-family: var(--sans); font-size: 14px; font-weight: 700; fill: #fff; text-anchor: middle; }
.dg-badge-out { fill: var(--green); }
.dg-badge-in { fill: var(--accent); }
.dg-note { font-family: var(--serif); font-style: italic; font-size: 18px; fill: var(--muted); text-anchor: middle; }
.post figure.diagram .dg-tall { display: none; }
@media (max-width: 560px) {
  .post figure.diagram .dg-wide { display: none; }
  .post figure.diagram .dg-tall { display: block; max-width: 360px; margin: 0 auto; }
}

/* ---- a phone screenshot beside its paragraph ---------------------------- */
.post .with-phone { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 28px; align-items: start; margin: 0 0 22px; }
.post .with-phone-text > p:last-child { margin-bottom: 0; }
.post .phone-fig { margin: 4px 0 22px; }
.post .with-phone .phone-fig { margin: 4px 0 0; }
.phone { position: relative; display: block; width: 180px; padding: 0; margin: 0 auto; border: 0; background: none; cursor: zoom-in; border-radius: 27px; transition: transform .15s ease; }
.phone:hover { transform: translateY(-2px); }
.phone:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.post .phone img, .lightbox .phone img {
  position: absolute; left: 4.444%; top: 2.151%; width: 91.111%; height: 95.699%;
  object-fit: cover; object-position: top; border-radius: 10.6% / 5.1%; border: 0; background: #000; max-height: none;
}
.phone-frame { position: relative; display: block; width: 100%; height: auto; }
.phone-body { fill: #1d2622; }
.phone-edge { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 1.5; }
.post .phone-fig figcaption { max-width: 180px; margin: 10px auto 0; font-size: 13.5px; line-height: 1.45; }
@media (max-width: 560px) {
  .post .with-phone { grid-template-columns: 1fr; gap: 16px; }
}

/* ---- the large view --------------------------------------------------- */
.lightbox { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; overflow: visible; cursor: zoom-out; }
.lightbox::backdrop { background: rgba(20, 28, 24, .82); }
.lightbox .phone { width: min(86vw, calc(90vh * 180 / 372)); cursor: zoom-out; transform: none; }

/* ---- table of contents in a post --------------------------------------- */
.post .toc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px 14px; margin: 0 0 30px; font-size: 17px; }
.post .toc-title { font-family: var(--display); font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.post .toc ol { margin: 0; padding-left: 22px; }
.post .toc > ol { padding-left: 20px; }
.post .toc li { margin: 3px 0; }
.post .toc ol ol { padding-left: 18px; margin: 2px 0 6px; font-size: 16px; }
.post .toc a { color: var(--ink); text-decoration: none; }
.post .toc a:hover { color: var(--green); text-decoration: underline; }

/* An interactive demo embedded in a post (demos/*.html, sized by demos/embed.js). */
.post iframe.demo { display: block; width: 100%; height: 640px; border: 0; margin: 18px 0 28px; background: transparent; }

/* The RSS link under the posts. */
.feed { margin: 18px 0 0; font-size: 15px; color: var(--muted); }
.feed a { color: var(--green); }
