/* Editorial layer (2026-10-23). Loaded after base/components/utilities and BEFORE each site's theme.css, so a theme
 * still has the last word. Everything here is expressed in the theme tokens (colours, fonts, radii, card shadows),
 * which is why the ten sites keep their own look on one structure.
 *
 * What it replaces, measured on the live sites that day:
 *  - phone clipping: single-column grids were `1fr` (= minmax(auto, 1fr)), so one `pre` made the column 700-800 px wide
 *    in a 390 px viewport and html/body `overflow-x:hidden` hid the evidence;
 *  - the numbered breadcrumb ("1. Home 2. Tutorials 3. ..."), a 500-word essay above the first card, a tag cloud beside
 *    every article, hover-only copy buttons, links below 4.5:1 on three sites.
 */

/* ---------- foundations ---------- */
:root {
    --color-link: var(--color-primary);
    --color-link-hover: var(--color-primary-hover);
    --rail-width: 15rem;
    --measure: var(--max-width-article, 720px);
    --focus-ring: 2px solid var(--color-link);
}

html { scroll-padding-top: calc(var(--header-height, 64px) + 1rem); }

a { color: var(--color-link); }
a:hover { color: var(--color-link-hover); }

:focus-visible { outline: var(--focus-ring); outline-offset: 2px; border-radius: 2px; }

.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -4rem;
    z-index: 2000;
    padding: 0.6rem 1rem;
    background: var(--color-text);
    color: var(--color-background);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
}
.skip-link:focus { top: 0.75rem; color: var(--color-background); }

.meta-dot { opacity: 0.5; padding: 0 0.15rem; }

/* Comfortable tap targets (the header links, tags and footer links measured 24-34 px tall on a phone). */
.nav-link, .footer-link, .tag-badge, .topic-chip, .share-strip-link, .breadcrumb-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
}
.main-nav { flex-wrap: wrap; }

/* ---------- home ---------- */
.home-hero { padding: 1.5rem 0 1.25rem; max-width: 46rem; }
.home-headline {
    font-size: clamp(1.75rem, 1.15rem + 2.4vw, 2.75rem);
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-wrap: balance;
    margin: 0 0 0.75rem;
}
.home-dek { font-size: 1.125rem; line-height: 1.55; color: var(--color-text-muted); margin: 0; max-width: 40rem; }
.home-intro { max-width: var(--measure); margin-bottom: 2rem; }

.topic-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 2rem; }
.topic-chip {
    padding: 0.2rem 0.95rem;
    border: var(--tag-border, 1px solid var(--color-border));
    border-radius: var(--tag-radius, 999px);
    background: var(--tag-bg, transparent);
    color: var(--color-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}
.topic-chip:hover { color: var(--color-link); border-color: var(--color-link); }

.section-title {
    font-size: 1.125rem;
    letter-spacing: 0.02em;
    margin: 0 0 1.25rem;
}
.latest-articles-heading { margin-top: 0.5rem; }
.home-topics { margin-top: 3rem; }
.home-view-all { margin-top: 2rem; }
.home-view-all-link { font-weight: 600; }

/* ---------- lists and cards ---------- */
.list-page { min-width: 0; }
.list-page .page-title { margin: 0.5rem 0 0.75rem; }

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
    gap: 2rem 1.75rem;
}

.article-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-radius: var(--border-radius-lg, 0.75rem);
}
.article-card-image {
    display: block;
    aspect-ratio: 1200 / 630;
    overflow: hidden;
    background: var(--color-border);
}
.article-card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article-card-content { display: flex; flex-direction: column; gap: 0.5rem; padding: var(--card-padding, 1.25rem); min-width: 0; }
.article-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.35rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}
.article-card-category { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem; color: var(--color-link); }
.article-card-title { font-size: 1.2rem; line-height: 1.3; margin: 0; text-wrap: balance; }
.article-card-title a { color: var(--color-text); text-decoration: none; }
.article-card-title a:hover { color: var(--color-link); }
.article-card-excerpt {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* The picture a card shows until the real one exists: the site's own colours, not a rainbow. */
.article-cover-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    color: rgb(255 255 255 / 0.28);
    background: linear-gradient(var(--cover-angle, 135deg), var(--color-primary), color-mix(in srgb, var(--color-primary) 55%, #000));
}

/* The first card of the home page: larger, text and picture side by side where there is room. */
.article-grid-home .article-card-lead { grid-column: 1 / -1; }
@media (min-width: 820px) {
    .article-card-lead { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
    .article-card-lead .article-card-image { aspect-ratio: auto; min-height: 100%; }
    .article-card-lead .article-card-content { justify-content: center; padding: 2rem; gap: 0.75rem; }
    .article-card-lead .article-card-title { font-size: clamp(1.5rem, 1rem + 1.4vw, 2.1rem); line-height: 1.2; }
    .article-card-lead .article-card-excerpt { font-size: 1.05rem; -webkit-line-clamp: 4; }
}

.pagination { margin-top: 2.5rem; flex-wrap: wrap; }

/* ---------- breadcrumb ---------- */
.breadcrumb-nav { margin: 0 0 1rem; }
.breadcrumb-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0 0.1rem;
    overflow: hidden;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}
.breadcrumb-item { display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap; }
.breadcrumb-item:last-child { flex: 1 1 0; min-width: 0; }
.breadcrumb-item + .breadcrumb-item::before { content: "/"; padding: 0 0.45rem 0 0.35rem; opacity: 0.5; }
.breadcrumb-item:last-child > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.breadcrumb-link { color: var(--color-text-muted); text-decoration: none; }
.breadcrumb-link:hover { color: var(--color-link); text-decoration: underline; }

/* ---------- article page ---------- */
.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 3rem;
    max-width: calc(var(--measure) + var(--rail-width) + 3rem);
    margin-inline: auto;
}
.article-detail { grid-column: 1; min-width: 0; margin: 0; max-width: none; }
.article-rail { display: none; }
.related-articles { grid-column: 1 / -1; grid-row: 2; margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--color-border); min-width: 0; }

@media (min-width: 1100px) {
    .article-layout { grid-template-columns: minmax(0, var(--measure)) var(--rail-width); justify-content: center; }
    .article-rail {
        display: block;
        grid-column: 2;
        grid-row: 1;
        align-self: start;
        position: sticky;
        top: calc(var(--header-height, 64px) + 1.5rem);
        max-height: calc(100vh - var(--header-height, 64px) - 3rem);
        overflow-y: auto;
        padding-top: 0.5rem;
        overscroll-behavior: contain;
    }
    .toc-inline { display: none; }
    .related-articles .article-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
}

.article-header { margin-bottom: 1.5rem; }
.article-category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-link);
    text-decoration: none;
    margin-bottom: 0.5rem;
}
.article-category:hover { text-decoration: underline; }
.article-title {
    font-size: clamp(1.75rem, 1.2rem + 2.3vw, 2.6rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 0.85rem;
    text-wrap: balance;
    overflow-wrap: break-word;
}
.article-excerpt { font-size: 1.15rem; line-height: 1.55; color: var(--color-text-muted); margin: 0 0 1.1rem; }
.article-byline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem 0.35rem;
    padding: 0.85rem 0 0;
    border-top: 1px solid var(--color-border);
    font-size: 0.875rem;
    color: var(--color-text-muted);
}
.article-byline-author { font-weight: 600; color: var(--color-text); text-decoration: none; }
.article-byline-author:hover { color: var(--color-link); text-decoration: underline; }

.article-featured-image {
    margin: 1.5rem 0 2rem;
    border-radius: var(--border-radius-lg, 0.75rem);
    overflow: hidden;
    border: 1px solid var(--color-border);
    background: var(--color-border);
}
.article-featured-image img { width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; display: block; }

/* "On this page": a sticky rail on wide screens, a collapsible block above the text on phones. */
.toc-title, .toc-inline > summary {
    margin: 0 0 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--color-border); }
.toc-list li { margin: 0; }
.toc-link {
    display: block;
    padding: 0.35rem 0 0.35rem 0.85rem;
    margin-left: -2px;
    border-left: 2px solid transparent;
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--color-text-muted);
    text-decoration: none;
}
.toc-link:hover { color: var(--color-link); }
.toc-link[aria-current="true"] { color: var(--color-link); border-left-color: var(--color-link); font-weight: 600; }
.toc-inline {
    margin: 0 0 1.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background: var(--color-surface);
}
.toc-inline > summary { cursor: pointer; margin: 0; padding: 0.2rem 0; min-height: 2rem; }
.toc-inline[open] > summary { margin-bottom: 0.6rem; }

/* ---------- prose ---------- */
.prose { font-size: var(--font-size-base); line-height: 1.75; overflow-wrap: break-word; min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.15rem; }
.prose h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 1.75rem); line-height: 1.25; margin: 2.75rem 0 0.9rem; scroll-margin-top: 5rem; text-wrap: balance; }
.prose h3 { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem); line-height: 1.3; margin: 2rem 0 0.6rem; scroll-margin-top: 5rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.4rem; }
.prose li > p { margin-bottom: 0.5rem; }
.prose a { color: var(--color-link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.prose a:hover { color: var(--color-link-hover); text-decoration-thickness: 2px; }
.prose img { max-width: 100%; height: auto; }

/* Inline code may be a long identifier: it wraps rather than widening the page. */
.prose :not(pre) > code {
    padding: 0.12em 0.38em;
    border-radius: 0.3rem;
    background: color-mix(in srgb, var(--color-text) 8%, transparent);
    font-size: 0.88em;
    overflow-wrap: anywhere;
}

.prose blockquote { font-style: normal; }

/* Tables scroll in their own box (the presenter wraps them). */
.table-scroll { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--color-border); border-radius: var(--border-radius); max-width: 100%; }
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 32rem; font-size: 0.9375rem; line-height: 1.5; }
.table-scroll th, .table-scroll td { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.table-scroll th { background: var(--color-surface); font-weight: 700; white-space: nowrap; }
.table-scroll tr:last-child td { border-bottom: 0; }
.prose .comparison-table { margin: 0; border: 0; }

/* Key takeaways and callouts. */
.prose .article-tldr {
    margin: 0 0 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-link);
    border-radius: var(--border-radius);
    background: var(--color-surface);
}
.prose .article-tldr h2 {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.prose .article-tldr ul { margin: 0; padding-left: 1.2rem; }
.prose .article-tldr li { margin: 0.35rem 0; line-height: 1.55; }
.prose .article-callout { margin: 1.5rem 0; padding: 0.85rem 1.1rem; border: 1px solid var(--color-border); border-left-width: 4px; border-radius: var(--border-radius); background: var(--color-surface); }
.prose .article-callout > :last-child { margin-bottom: 0; }

/* ---------- code ---------- */
.prose .code-block { position: relative; margin: 1.5rem 0; border-radius: var(--border-radius-lg, 0.6rem); background: var(--code-bg); color: var(--code-text); }
.prose .code-block pre {
    margin: 0;
    padding: 1rem 1.1rem;
    background: transparent;
    color: inherit;
    border-radius: inherit;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    tab-size: 4;
    -webkit-overflow-scrolling: touch;
}
.prose .code-block pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; color: inherit; }
.prose .code-block[data-lang] pre { padding-top: 2.4rem; }
.prose .code-block[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0.6rem;
    left: 1.1rem;
    font: 700 0.6875rem/1 var(--font-family-sans);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}
.prose .copy-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.45rem;
    min-height: 1.9rem;
    padding: 0.2rem 0.65rem;
    font: 600 0.75rem var(--font-family-sans);
    color: var(--code-text);
    background: rgb(255 255 255 / 0.1);
    border: 1px solid rgb(255 255 255 / 0.22);
    border-radius: 0.4rem;
    cursor: pointer;
    opacity: 0.9;
    transition: background 0.15s;
}
.prose .copy-btn:hover { background: rgb(255 255 255 / 0.2); opacity: 1; }
.prose .copy-btn.copied { background: #15803d; border-color: #15803d; color: #fff; }

/* Syntax colours (Prism token classes), chosen for the dark code backgrounds every theme uses. */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8e99ab; font-style: italic; }
.token.punctuation { opacity: 0.8; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #ffa07a; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #98e0ac; }
.token.operator, .token.entity, .token.url, .token.variable { color: #e6e6e6; }
.token.atrule, .token.attr-value, .token.keyword { color: #a5c8ff; }
.token.function, .token.class-name { color: #f4d27f; }
.token.regex, .token.important { color: #ffd86b; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* Difficulty: quiet text with a coloured dot, readable on every theme (the pills hard-coded dark text on a light tint,
   which is unreadable on the two dark themes). */
.difficulty-badge, .difficulty-beginner, .difficulty-intermediate, .difficulty-advanced {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.1rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.difficulty-badge::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.difficulty-beginner::before { background: #22a55b; }
.difficulty-intermediate::before { background: #e0a800; }
.difficulty-advanced::before { background: #e5484d; }

/* ---------- end of article ---------- */
.article-tags { margin: 2.25rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.share-strip { margin-top: 1.25rem; }
.article-changelog { margin-top: 1.5rem; }

.newsletter-inline { margin: 2.25rem 0 0; padding: 1.25rem 1.4rem; border: 1px solid var(--color-border); border-radius: var(--border-radius-lg, 0.6rem); background: var(--color-surface); }
.newsletter-title { font-weight: 700; margin: 0 0 0.25rem; font-family: var(--font-family-heading); font-size: 1.05rem; }

.author-box {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin: 2rem 0 0;
    padding: 1.25rem 0 0;
    border-top: 1px solid var(--color-border);
}
.author-monogram, .author-box-avatar {
    flex: 0 0 3.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
}
.author-monogram {
    display: grid;
    place-items: center;
    font: 700 1.1rem/1 var(--font-family-heading);
    letter-spacing: 0.02em;
    color: var(--color-surface);
    background: var(--color-primary);
}
.author-box-avatar { object-fit: cover; }
.author-box-body { min-width: 0; }
.author-box-label { display: block; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
.author-box-name { font-weight: 700; color: var(--color-text); text-decoration: none; }
.author-box-name:hover { color: var(--color-link); text-decoration: underline; }
.author-box-text { margin: 0.35rem 0 0.5rem; font-size: 0.9375rem; line-height: 1.55; color: var(--color-text-muted); }
.author-box-links { margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.875rem; }

/* ---------- footer ---------- */
.footer-inner {
    grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
    grid-template-areas:
        "brand   col1 col2"
        "news    col1 col2"
        "copy    copy copy";
    gap: 1.5rem 2.5rem;
    align-items: start;
}
.footer-brand { grid-area: brand; }
.footer-newsletter { grid-area: news; }
.footer-inner > .footer-column:nth-of-type(1) { grid-area: col1; }
.footer-inner > .footer-column:nth-of-type(2) { grid-area: col2; }
.footer-inner > .footer-copy { grid-area: copy; padding-top: 1rem; border-top: 1px solid color-mix(in srgb, var(--footer-text) 25%, transparent); }
.footer-heading { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--footer-accent); margin-bottom: 0.25rem; }
/* The footer's links used the PAGE's muted text colour on the footer's own (usually dark) background: 3:1 and lower. */
.site-footer .footer-link { color: var(--footer-text); }
.site-footer .footer-link:hover { color: var(--footer-accent); }
.site-footer .footer-link-button { font-size: 0.875rem; }
.site-footer .newsletter-title { color: var(--footer-accent); }
.site-footer .newsletter-blurb { color: var(--footer-text); }
.footer-links { gap: 0.1rem; }
.footer-link:hover { text-decoration: underline; }

/* ---------- consent bar: a strip, not a card over the text ---------- */
@media (max-width: 560px) {
    .ac-consent { padding: 0; }
    .ac-consent-inner { border-radius: var(--border-radius-lg, 12px) var(--border-radius-lg, 12px) 0 0; padding: 0.85rem 1rem; gap: 0.6rem; }
    .ac-consent-title { font-size: 0.95rem; margin-bottom: 0.1rem; }
    .ac-consent-body { font-size: 0.8125rem; line-height: 1.4; }
    .ac-btn { min-height: 44px; padding: 0.5rem 0.75rem; }
}

/* ---------- phones ---------- */
@media (max-width: 768px) {
    .home-hero { padding-top: 0.75rem; }
    .article-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
    .article-card-content { padding: 1rem; }
    .footer-inner {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "brand" "news" "col1" "col2" "copy";
        text-align: left;
    }
    .footer-links { align-items: flex-start; }
    .article-title { font-size: 1.6rem; }
    .prose { font-size: max(1rem, var(--font-size-base)); }
    .prose h2 { margin-top: 2.25rem; }
    .author-box { flex-direction: row; text-align: left; align-items: flex-start; }
    .table-scroll table { min-width: 28rem; }
}

@media print {
    .site-header, .site-footer, .article-rail, .toc-inline, .share-strip, .newsletter-signup, .related-articles, .ac-consent, .copy-btn, .skip-link { display: none !important; }
    .article-layout { display: block; }
    .prose .code-block pre { white-space: pre-wrap; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
