/* ═══════════════════════════════════════════════════════════════════
   blog.css — article typography and blog-only chrome.
   Mirrors the homepage palette: black bg, #3b82f6 accent, cream text.
   The homepage keeps its own inline styles; this file is loaded only
   by pages Eleventy generates under /blog/.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --kh-accent: #3b82f6;
    --kh-cream: #F3F0E6;
    --kh-dim: #9CA3AF;
    --kh-faint: #6b7280;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'DM Sans', system-ui, -apple-system, sans-serif; background: #000; }
::selection { background: var(--kh-accent); color: #fff; }

/* ─── Shared chrome copied from the homepage ─────────────────────── */
.skip-link {
    position: absolute; top: -100%; left: 1rem; z-index: 9999;
    padding: 0.75rem 1.5rem; background: var(--kh-accent); color: #fff;
    border-radius: 0 0 0.5rem 0.5rem; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 0; }

.nav-blur {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.link-underline { position: relative; }
.link-underline::after {
    content: ''; position: absolute; left: 0; bottom: -3px;
    width: 0; height: 1px; background: var(--kh-accent);
    transition: width 0.25s ease;
}
.link-underline:hover::after { width: 100%; }

.mobile-menu { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.mobile-menu.open { max-height: 32rem; }

.reveal {
    opacity: 0; transform: translateY(18px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── Reading progress bar ───────────────────────────────────────── */
.reading-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 2px;
    z-index: 60; background: transparent; pointer-events: none;
}
.reading-progress span {
    display: block; height: 100%; width: 0;
    background: var(--kh-accent);
    transition: width 0.1s linear;
}

/* ═══════════════════════════════════════════════════════════════════
   Article body typography
   ═══════════════════════════════════════════════════════════════════ */
.prose-kh {
    color: #d4d4d8;
    font-size: 1.0625rem;
    line-height: 1.75;
}
@media (min-width: 1024px) {
    .prose-kh { font-size: 1.125rem; line-height: 1.8; }
}

.prose-kh > * + * { margin-top: 1.5rem; }

.prose-kh h2 {
    color: var(--kh-cream);
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.3;
    margin-top: 3rem;
    padding-top: 0.5rem;
    scroll-margin-top: 6rem;
}
.prose-kh h3 {
    color: var(--kh-cream);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 2.25rem;
    scroll-margin-top: 6rem;
}
.prose-kh h4 {
    color: var(--kh-cream);
    font-size: 1.0625rem;
    font-weight: 600;
    margin-top: 1.75rem;
}
@media (min-width: 1024px) {
    .prose-kh h2 { font-size: 1.875rem; }
    .prose-kh h3 { font-size: 1.375rem; }
}

.prose-kh a {
    color: var(--kh-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(59, 130, 246, 0.4);
    transition: text-decoration-color 0.2s ease;
}
.prose-kh a:hover { text-decoration-color: var(--kh-accent); }

.prose-kh strong { color: var(--kh-cream); font-weight: 600; }
.prose-kh em { font-style: italic; }

.prose-kh ul, .prose-kh ol { padding-left: 1.375rem; }
.prose-kh li { margin-top: 0.5rem; }
.prose-kh li::marker { color: var(--kh-accent); }
.prose-kh ul { list-style: disc; }
.prose-kh ol { list-style: decimal; }
.prose-kh li > ul, .prose-kh li > ol { margin-top: 0.5rem; }

.prose-kh blockquote {
    border-left: 2px solid var(--kh-accent);
    padding: 0.25rem 0 0.25rem 1.25rem;
    color: var(--kh-dim);
    font-style: italic;
}
.prose-kh blockquote p + p { margin-top: 1rem; }

.prose-kh img,
.prose-kh video {
    width: 100%;
    height: auto;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.prose-kh figure { margin-top: 2rem; }
.prose-kh figcaption {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--kh-faint);
    text-align: center;
}

.prose-kh code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875em;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 0.3125rem;
    padding: 0.15em 0.4em;
}
.prose-kh pre {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1.25rem;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}
.prose-kh pre code {
    background: none;
    border: none;
    padding: 0;
    color: #d4d4d8;
    font-size: inherit;
}

.prose-kh hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 2.5rem;
}

/* Tables scroll inside their own container rather than dragging the page.
   On phones the wrapper bleeds to the screen edges so a wide table gets the
   full width to work with, and a fade on the right edge signals more content. */
.prose-kh .table-wrap {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}
.prose-kh .table-wrap:focus-visible {
    outline: 2px solid var(--kh-accent);
    outline-offset: 2px;
    border-radius: 0.5rem;
}
.prose-kh table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}
.prose-kh th, .prose-kh td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    text-align: left;
    vertical-align: top;
}
.prose-kh td:first-child { min-width: 8rem; }
.prose-kh th {
    color: var(--kh-cream);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-color: rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .prose-kh .table-wrap {
        margin-inline: -1.5rem;
        padding-inline: 1.5rem;
        /* fade the right edge so it reads as scrollable */
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
                mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    }
    .prose-kh th, .prose-kh td { padding: 0.625rem 0.75rem; }
    .prose-kh table { font-size: 0.875rem; }
}

.prose-kh :focus-visible,
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--kh-accent);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Truncate card descriptions to two lines */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   Mobile
   ═══════════════════════════════════════════════════════════════════ */

/* Nothing should be able to push the page sideways on a phone. */
html, body { max-width: 100%; overflow-x: clip; }

/* Long URLs, product SKUs and unbroken strings wrap instead of overflowing. */
.prose-kh { overflow-wrap: break-word; }
.prose-kh a, .prose-kh code { overflow-wrap: anywhere; }

/* Headings read better with balanced line breaks at narrow widths. */
h1, h2, h3, .prose-kh h2, .prose-kh h3 { text-wrap: balance; }
.prose-kh p { text-wrap: pretty; }

/* Breadcrumb: the post title is long and wraps badly on a phone.
   Home / Blog is enough there - the full trail stays in the schema. */
@media (max-width: 640px) {
    .crumb-current { display: none; }
    .crumb-current-sep { display: none; }
}

@media (max-width: 640px) {
    /* Slightly tighter body copy so lines hold ~50-60 characters */
    .prose-kh { font-size: 1rem; line-height: 1.7; }
    .prose-kh > * + * { margin-top: 1.25rem; }

    .prose-kh h2 { font-size: 1.375rem; margin-top: 2.25rem; }
    .prose-kh h3 { font-size: 1.125rem; margin-top: 1.75rem; }

    /* Code blocks bleed to the edges so there is room for the code itself */
    .prose-kh pre {
        margin-inline: -1.5rem;
        border-radius: 0;
        border-inline: 0;
        padding: 1rem 1.5rem;
        font-size: 0.8125rem;
        -webkit-overflow-scrolling: touch;
    }

    .prose-kh ul, .prose-kh ol { padding-left: 1.125rem; }
    .prose-kh blockquote { padding-left: 1rem; }
}

/* Comfortable thumb targets on touch devices, without changing the look
   on desktop where a cursor is precise. */
@media (hover: none) and (pointer: coarse) {
    .tap-target {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    .prose-kh a { padding-block: 0.15em; }
}

/* Very small phones (iPhone SE and similar) */
@media (max-width: 380px) {
    .prose-kh { font-size: 0.9688rem; }
    .prose-kh h2 { font-size: 1.25rem; }
}
