/* ==========================================================================
   Article and writing-index styles. Loaded only by /writing/ pages.
   The home page is a showcase; these pages are for reading, so the 3D scene
   stays off and the type does the work.
   ========================================================================== */

body.reading {
    background:
        radial-gradient(70% 45% at 70% -5%, rgba(247, 147, 26, 0.10), transparent 70%),
        var(--ink);
    background-attachment: fixed;
}

/* Reading progress, pinned under the header */
.read-progress {
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top));
    left: 0; right: 0;
    height: 2px;
    z-index: 49;
    background: transparent;
    pointer-events: none;
}
.read-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--btc), #ffc071);
    box-shadow: 0 0 12px rgba(247, 147, 26, 0.6);
    transition: width .1s linear;
}

/* ----- Shared page furniture ---------------------------------------------- */
.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: var(--step--1);
    color: var(--faint);
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--btc); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--btc);
    background: var(--btc-soft);
    border: 1px solid rgba(247, 147, 26, 0.3);
    border-radius: 999px;
    padding: 3px 11px;
}
.chip-quiet { color: var(--faint); background: transparent; border-color: var(--line-strong); }

/* ----- Writing index ------------------------------------------------------ */
.index-head {
    padding: calc(var(--header-h) + clamp(48px, 8vw, 88px)) 0 clamp(28px, 5vw, 48px);
    border-bottom: 1px solid var(--line);
}
.index-head h1 {
    margin-top: 18px;
    font-size: clamp(2.5rem, 7vw, 4rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1;
}
.index-lede {
    margin-top: 18px;
    max-width: 56ch;
    font-size: var(--step-1);
    color: var(--muted);
    text-wrap: pretty;
}

.post-list { padding: clamp(28px, 5vw, 48px) 0 0; }
.post-card {
    padding: clamp(24px, 4vw, 36px) 0;
    border-bottom: 1px solid var(--line);
}
.post-card:first-child { padding-top: 8px; }
.post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: var(--step--1);
    color: var(--faint);
}
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.post-card h2 {
    margin-top: 10px;
    font-size: clamp(1.375rem, 3vw, 1.875rem);
    font-weight: 600;
    line-height: 1.22;
    letter-spacing: -0.015em;
    max-width: 36ch;
    text-wrap: balance;
}
.post-card h2 a { text-decoration: none; }
.post-card h2 a::after {
    /* whole card is clickable without nesting interactive elements */
    content: '';
    position: absolute;
    inset: 0;
}
.post-card { position: relative; transition: border-color .2s; }
.post-card:hover h2 a { color: var(--btc); }
.post-card:hover .post-more { color: var(--btc); }
.post-sum {
    margin-top: 12px;
    max-width: 68ch;
    color: var(--muted);
    text-wrap: pretty;
}
.post-card .chips { margin-top: 18px; }
.post-more {
    display: inline-block;
    margin-top: 18px;
    font-family: var(--mono);
    font-size: var(--step--1);
    color: var(--faint);
    transition: color .2s;
}
.post-more::after { content: ' \2192'; }

.subscribe {
    margin: clamp(40px, 7vw, 72px) 0 clamp(56px, 9vw, 96px);
    padding: clamp(24px, 4vw, 36px);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--btc);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--ink-raised), var(--ink));
}
.subscribe h2 { font-size: var(--step-2); font-weight: 600; }
.subscribe p { margin-top: 10px; max-width: 60ch; color: var(--muted); }
.subscribe .btn { margin-top: 18px; }

/* ----- Article page ------------------------------------------------------- */
.article-head {
    padding: calc(var(--header-h) + clamp(40px, 7vw, 72px)) 0 clamp(28px, 5vw, 44px);
    border-bottom: 1px solid var(--line);
}
/* Header text lines up with the prose column below it, not centred */
.article-head-inner > * { max-width: 760px; }
.article-head h1 {
    margin-top: 18px;
    font-size: clamp(2rem, 5.2vw, 3.25rem);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.028em;
    text-wrap: balance;
}
.article-lede {
    margin-top: 20px;
    font-size: var(--step-1);
    line-height: 1.6;
    color: var(--muted);
    max-width: 62ch;
    text-wrap: pretty;
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    margin-top: 24px;
    font-family: var(--mono);
    font-size: var(--step--1);
    color: var(--faint);
}
.article-meta .byline { color: var(--paper); }
.article-meta .read-time { color: var(--btc); }
.article-head .chips { margin-top: 18px; }

.article-body-wrap {
    display: grid;
    grid-template-columns: minmax(0, 760px) 220px;
    gap: 56px;
    align-items: start;
    padding-top: clamp(32px, 5vw, 56px);
}

/* Table of contents */
.toc {
    order: 2;
    position: sticky;
    top: calc(var(--header-h) + 32px);
    padding-left: 20px;
    border-left: 1px solid var(--line);
}
.toc-title {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}
.toc ol { margin-top: 12px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
    display: block;
    padding: 6px 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -20px;
    padding-left: 18px;
    transition: color .15s, border-color .15s;
}
.toc a:hover { color: var(--paper); }
.toc a.is-current { color: var(--btc); border-left-color: var(--btc); }

/* Prose */
.article-prose { order: 1; font-size: 1.0625rem; line-height: 1.72; }
.article-prose > * + * { margin-top: 1.25em; }
.article-prose p { color: #C6CBD4; max-width: 68ch; }
.article-prose h2 {
    margin-top: 2.2em;
    font-size: clamp(1.375rem, 2.6vw, 1.75rem);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--paper);
    scroll-margin-top: calc(var(--header-h) + 24px);
}
.article-prose h2::before {
    content: '';
    display: block;
    width: 28px;
    height: 2px;
    background: var(--btc);
    margin-bottom: 16px;
}
.article-prose h3 {
    margin-top: 1.9em;
    font-size: var(--step-1);
    font-weight: 600;
    color: var(--paper);
}
.article-prose ul { display: grid; gap: 10px; max-width: 68ch; }
.article-prose li { position: relative; padding-left: 22px; color: #C6CBD4; }
.article-prose ul > li::before {
    content: '';
    position: absolute;
    left: 2px; top: 0.72em;
    width: 8px; height: 1px;
    background: var(--btc);
    opacity: .8;
}
.article-prose strong { color: var(--paper); font-weight: 600; }

.callout {
    margin-top: 1.5em;
    padding: 20px 22px;
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--btc);
    border-radius: var(--radius);
    background: var(--ink-raised);
}
.callout-title {
    font-weight: 600;
    color: var(--btc) !important;
    margin-bottom: 12px;
}
.callout ul { gap: 8px; }
.callout li { font-size: 0.9375rem; }

/* Figures. Dark screenshots sit directly on the page; light ones get a pale
   mount so they read as a quoted document rather than a hole in the page. */
.fig { margin-top: 2em; }
.fig picture { display: block; }
.fig img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius);
}
.fig-dark img { border: 1px solid var(--line-strong); }
.fig-light picture {
    padding: 14px;
    border-radius: var(--radius);
    background: #E9E6E0;
    border: 1px solid var(--line-strong);
}
.fig-light img { border-radius: 3px; }
.fig figcaption {
    margin-top: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--faint);
    max-width: 68ch;
}
.fig figcaption a { color: var(--muted); }
.fig figcaption a:hover { color: var(--btc); }

.source-line {
    font-size: 0.875rem !important;
    color: var(--faint) !important;
    padding-left: 14px;
    border-left: 2px solid var(--line-strong);
}
.source-line a { color: var(--muted); }
.source-line a:hover { color: var(--btc); }

.series-tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--btc);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.article-prose table {
    width: 100%;
    min-width: 440px;
    border-collapse: collapse;
    font-size: 0.9375rem;
}
.article-prose thead th {
    text-align: left;
    padding: 10px 14px 10px 0;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    border-bottom: 1px solid var(--line-strong);
}
.article-prose tbody th {
    text-align: left;
    padding: 14px 20px 14px 0;
    color: var(--btc);
    font-weight: 600;
    vertical-align: top;
    white-space: nowrap;
}
.article-prose tbody td {
    padding: 14px 0;
    color: #C6CBD4;
    vertical-align: top;
}
.article-prose tbody tr + tr th,
.article-prose tbody tr + tr td { border-top: 1px solid var(--line); }

.pending-note {
    padding: 20px 22px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
}
.pending-title { color: var(--paper) !important; font-weight: 600; margin-bottom: 8px; }
.pending-note p { font-size: 0.9375rem; }

/* ----- Engagement block --------------------------------------------------- */
.engage {
    margin-top: clamp(48px, 7vw, 80px);
    padding-top: clamp(32px, 5vw, 48px);
    border-top: 1px solid var(--line);
}
.engage-title { font-size: var(--step-2); font-weight: 600; }
.engage-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.engage-card {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--ink-raised);
    display: flex;
    flex-direction: column;
}
.engage-card h3 { font-size: var(--step-1); font-weight: 600; }
.engage-card p { margin-top: 8px; color: var(--muted); font-size: 0.9375rem; }
.engage-card .btn { margin-top: auto; align-self: flex-start; }
.engage-card > p + .btn { margin-top: 18px; }

.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--ink-sunk);
    color: var(--paper);
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.share-btn:hover { border-color: var(--btc); color: var(--btc); }
.share-btn svg {
    width: 16px; height: 16px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}
.share-btn.is-copied { border-color: var(--ok); color: var(--ok); }

.btn-sm { min-height: 40px; padding: 0 16px; font-size: 0.9375rem; }

.respond {
    margin-top: 16px;
    padding: clamp(20px, 4vw, 28px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--ink-raised);
}
.respond h3 { font-size: var(--step-1); font-weight: 600; }
.respond > p { margin-top: 8px; color: var(--muted); font-size: 0.9375rem; }
.respond-form { margin-top: 20px; display: grid; gap: 16px; }
.respond-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.respond-form .btn { justify-self: start; }

/* ----- Previous / next ---------------------------------------------------- */
.pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: clamp(40px, 6vw, 64px) 0 clamp(56px, 9vw, 96px);
}
.pager-item {
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    transition: border-color .15s;
}
.pager-item:hover { border-color: var(--btc); }
.pager-item:hover .pager-title { color: var(--btc); }
.pager-next { text-align: right; grid-column: 2; }
.pager-dir {
    display: block;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
}
.pager-title {
    display: block;
    margin-top: 8px;
    font-weight: 600;
    line-height: 1.35;
    transition: color .15s;
}

/* ----- Responsive --------------------------------------------------------- */
@media (max-width: 1000px) {
    .article-body-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .toc {
        order: 0;
        position: static;
        margin-bottom: 32px;
        padding: 16px 18px;
        border-left: 0;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--ink-raised);
    }
    .toc ol { display: flex; flex-wrap: wrap; gap: 4px 18px; }
    .toc a { margin-left: 0; padding-left: 0; border-left: 0; }
    .toc a.is-current { border-left: 0; }
}

@media (max-width: 620px) {
    /* Stack the table into labelled blocks rather than scroll it sideways */
    .table-wrap { overflow-x: visible; }
    .article-prose table { min-width: 0; display: block; }
    .article-prose thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .article-prose tbody, .article-prose tbody tr { display: block; }
    .article-prose tbody tr { padding: 14px 0; }
    .article-prose tbody tr + tr { border-top: 1px solid var(--line); }
    .article-prose tbody th,
    .article-prose tbody td { display: block; padding: 0; border: 0; white-space: normal; }
    .article-prose tbody td { margin-top: 6px; }
}

@media (max-width: 720px) {
    .engage-grid { grid-template-columns: minmax(0, 1fr); }
    .respond-row { grid-template-columns: minmax(0, 1fr); }
    .pager { grid-template-columns: minmax(0, 1fr); }
    .pager-next { grid-column: 1; text-align: left; }
    .article-prose { font-size: 1rem; }
    .respond-form .btn { justify-self: stretch; }
}

@media print {
    .read-progress, .toc, .engage, .pager, .crumbs, .subscribe, .post-more { display: none !important; }
    .article-head { padding-top: 0; border-bottom: 1px solid #ccc; }
    .article-prose { font-size: 11pt; }
    .article-prose p, .article-prose li { color: #111; }
    .callout { border: 1px solid #ccc; background: none; }
}
