/* ─────────────────────────────────────────────────────────────
   Blog typography
   One scale for the index and the article: 32/24 title, then
   24 / 20 / 18 headings over 16px body, with 14px for the small
   print (meta, captions, code).
   ───────────────────────────────────────────────────────────── */

/* The reading column is narrower than the site shell — 600px keeps a
   16px line near 70 characters. */
.blog-header, .post-body { max-width: 600px; }

.blog-header { margin: 40px 0 32px; }
.blog-header h1 { font-size: clamp(24px, 4.5vw, 32px); line-height: 1.2; letter-spacing: -0.025em; text-wrap: balance; }
.blog-header p { margin-top: 16px; }

/* ── The index: search, layout toggle, list ──────────────── */

.blog-tools {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0 24px;
}

.blog-tools__search {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-tertiary);
}

.blog-tools__search svg { width: 20px; height: 20px; flex-shrink: 0; }

.blog-tools__search input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    /* 16px minimum — iOS zooms the viewport on focus below this */
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.blog-tools__search input::placeholder { color: var(--text-tertiary); }
.blog-tools__search:focus-within { color: var(--text-secondary); }

/* Desktop: the row opens the site's "/" search dialog instead. */
.blog-tools__trigger {
    flex: 0 1 auto;
    height: 40px;
    margin-left: -8px;
    padding: 0 8px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.15s ease-out, background-color 0.15s ease-out;
}
.blog-tools__trigger[hidden] { display: none; }
.blog-tools__trigger:hover { color: var(--text-secondary); background: var(--control); }
.blog-tools__trigger:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.blog-tools__trigger kbd {
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 5px;
    background: var(--control);
    color: var(--text-tertiary);
    font: inherit;
    font-size: 12px;
    line-height: 18px;
}

.blog-tools__views { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }

.blog-tools__view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0.6;
    transition: color 0.15s ease-out, opacity 0.15s ease-out, background-color 0.15s ease-out;
}

.blog-tools__view svg { width: 20px; height: 20px; }
.blog-tools__view:hover { opacity: 1; background: var(--control); }
.blog-tools__view[aria-pressed="true"] { color: var(--text-primary); opacity: 1; }
.blog-tools__view:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.blog-list { margin: 0 0 96px; }
.blog-list > li[hidden] { display: none; }
.blog-list a { display: block; }
.blog-list h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.012em; text-wrap: balance; }
.blog-list p { margin-top: 12px; color: var(--text-secondary); font-size: 16px; line-height: 1.6; }
.blog-list__year, .blog-list__day { display: none; }
.blog-empty { margin: 8px 0 96px; color: var(--text-tertiary); font-size: 16px; }

/* Expanded: title, date, then the excerpt — one entry per breath. */
.blog-list:not([data-view="compact"]) { display: grid; gap: 48px; }
.blog-list:not([data-view="compact"]) a:hover h2 { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--border-strong); }
.blog-list:not([data-view="compact"]) .blog-list__date { margin-top: 6px; }

/* Compact: year · title · day, ruled like a ledger. */
.blog-list[data-view="compact"] { display: flex; flex-direction: column; }
.blog-list[data-view="compact"] > li:not([hidden]) ~ li:not([hidden]) { border-top: 1px solid var(--border); }
.blog-list[data-view="compact"] a {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 16px;
    padding: 14px 0;
}
.blog-list[data-view="compact"] h2 {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: -0.005em;
    text-wrap: pretty;
    transition: color 0.15s ease-out;
}
.blog-list[data-view="compact"] :is(.blog-list__year, .blog-list__day) {
    display: block;
    color: var(--text-tertiary);
    font-size: 16px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}
.blog-list[data-view="compact"] :is(.blog-list__date, p) { display: none; }
.blog-list[data-view="compact"]:has(a:hover) h2 { color: var(--text-tertiary); }
.blog-list[data-view="compact"] a:hover h2 { color: var(--text-primary); }

@media (max-width: 479px) {
    .blog-list[data-view="compact"] a { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; }
}

.blog-list__date, .post-meta { display: block; margin-top: 12px; color: var(--text-tertiary); font-size: 14px; line-height: 1.5; }

.post-body { color: var(--text-primary); font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; text-wrap: pretty; }
.post-body > * + * { margin-top: 24px; }
/* One scale, each step a little tighter than the one below it: the
   article's headings run Heading 1 → Heading 3 regardless of the element
   they render as. */
.post-body :is(h2, h3, h4) { margin-top: 40px; text-wrap: balance; }
.post-body .post-h1 { font-size: 24px; line-height: 1.25; letter-spacing: -0.015em; }
.post-body .post-h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.012em; }
.post-body .post-h3 { font-size: 18px; line-height: 1.4; letter-spacing: -0.01em; }
/* A heading belongs to the text under it, not between the two blocks. */
.post-body :is(h2, h3, h4) + * { margin-top: 12px; }
/* Suisse ships Regular and Medium here, so bold is Medium — asking for 700
   only gets a browser-smeared fake. */
.post-body strong { font-weight: 500; }
.post-body a { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.post-body a:hover { text-decoration-color: currentColor; }
.post-body .post-underline { text-decoration: underline; text-underline-offset: 3px; }
.post-body code { padding: 2px 6px; border-radius: var(--r-sm); background: var(--control); font-family: var(--font-mono); font-size: 14px; }
.post-body ul, .post-body ol { padding-left: 24px; }
.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }
.post-body li + li { margin-top: 8px; }
.post-body figure { margin-inline: 0; }
.post-body img { width: 100%; height: auto; border-radius: var(--r-sm); }
.post-body figcaption { margin-top: 8px; color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.post-body blockquote { margin-inline: 0; padding-left: 24px; border-left: 2px solid var(--border-strong); color: var(--text-secondary); font-size: 18px; line-height: 1.6; }
.post-body hr { border: 0; border-top: 1px solid var(--border-strong); margin-block: 32px; }
.blog-retry { margin-top: 12px; padding: 8px 12px; background: var(--control); color: var(--text-primary); border: 0; border-radius: var(--r-sm); font: inherit; cursor: pointer; }

/* ── The invitation at the end of an article ─────────────── */

/* A quiet signature signs off the article before the subscription form. */
.post-signature {
    width: 86px;
    height: 54px;
    margin-top: 48px;
    color: var(--text-tertiary);
}

.post-signature--waiting {
    visibility: hidden;
}

.subscribe {
    max-width: 600px;
    margin: 32px 0 0;
}

.subscribe__mail {
    display: block;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.subscribe__lead {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.subscribe__note {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
}

.subscribe__form {
    width: 300px;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: transparent;
    transition: border-color 0.15s ease-out;
}

.subscribe__form:focus-within {
    border-color: var(--text-tertiary);
}

.subscribe__field {
    flex: 1;
    min-width: 0;
}

.subscribe__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.subscribe__field input {
    display: block;
    width: 100%;
    height: 36px;
    border: 0;
    padding: 0;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    /* 16px minimum — iOS zooms the viewport on focus below this */
    font-size: 16px;
}

.subscribe__field input::placeholder {
    color: var(--text-tertiary);
}

.subscribe__form button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--control);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.15s ease-out, color 0.15s ease-out, opacity 0.15s ease-out;
}

.subscribe__form button svg {
    width: 20px;
    height: 20px;
}

.subscribe__form button:not(:disabled) {
    background: var(--text-primary);
    color: var(--raised);
}

.subscribe__form button:not(:disabled):hover {
    opacity: 0.85;
}

.subscribe__form button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Bait for bots, never shown to a person or a screen reader. */
.subscribe__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.subscribe__fine {
    margin-top: 12px;
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1.5;
}

.subscribe__status:not(:empty) {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Read next ───────────────────────────────────────────── */

/* The same closing move the case studies make, in the article's column. */
#read-next:empty {
    display: none;
}

#read-next {
    max-width: 600px;
    margin-top: 40px;
}

#read-next a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 0;
}

.read-next__label {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

.read-next__name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.012em;
    text-wrap: balance;
}

.read-next__name svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    transition: translate 0.15s ease-out;
}

#read-next a:hover .read-next__name {
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: var(--border-strong);
}

#read-next a:hover svg {
    translate: 2px 0;
}

@media (prefers-reduced-motion: reduce) {
    .read-next__name svg {
        transition: none;
    }
}

/* Clear the sticky header pill when jumping from the contents */
.blog-header,
.post-body [id] { scroll-margin-top: 88px; }

/* ── Contents on phones and tablets ──────────────────────────
   A progress ring in the lower-left corner, dimmed until touched, so the
   index is one tap away without covering the text. Hidden wherever the
   margin index (.page-toc) is shown. */

.toc-pill {
    position: fixed;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

@media (min-width: 1180px) and (hover: hover) and (pointer: fine) {
    .toc-pill { display: none; }
}

.toc-pill__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgb(from var(--raised) r g b / 0.72);
    box-shadow: var(--tray-shadow);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.55;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.2s ease-out, scale 0.15s ease-out;
}

.toc-pill__button:active { scale: 0.94; }
.toc-pill.is-open .toc-pill__button,
.toc-pill__button:focus-visible { opacity: 1; }

.toc-pill__button svg { width: 22px; height: 22px; rotate: -90deg; }
.toc-pill__button circle { fill: none; stroke-width: 2.5; }
.toc-pill__track { stroke: var(--border-strong); }
.toc-pill__progress { stroke: currentColor; stroke-linecap: round; }

.toc-pill__panel {
    width: min(300px, calc(100vw - 32px));
    max-height: min(60vh, 420px);
    overflow-y: auto;
    padding: 6px;
    border-radius: var(--r-xl);
    background: var(--raised);
    box-shadow: var(--popover-shadow);
    transform-origin: bottom left;
    animation: toc-pill-in 0.18s cubic-bezier(0.2, 0, 0, 1);
}

.toc-pill__panel[hidden] { display: none; }

@keyframes toc-pill-in {
    from { opacity: 0; scale: 0.96; translate: 0 6px; }
}

.toc-pill__list a {
    position: relative;
    display: block;
    padding: 10px 12px 10px 30px;
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.35;
}

.toc-pill__list a::before {
    content: '';
    position: absolute;
    left: 13px;
    top: calc(10px + 0.675em - 3px);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
}

.toc-pill__sub a { padding-left: 42px; }
.toc-pill__sub a::before { left: 25px; }

.toc-pill__list a[aria-current] {
    background: var(--control);
    color: var(--text-primary);
    font-weight: 500;
}

.toc-pill__list a[aria-current]::before { opacity: 1; }

html:has(.toc-pill) { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html:has(.toc-pill) { scroll-behavior: auto; }
    .toc-pill__panel { animation: none; }
}

@media print {
    .toc-pill { display: none; }
}
