/* Blog hub, category pages and articles (#514).
 *
 * Loaded after seo-page.css on blog pages only. The hub is a card grid with
 * category chips that are plain links; an article adds a cover, an
 * "On this page" list, step screenshots, wide comparison tables and a task band.
 */

/* ── Listing: hub and category pages ────────────────────────────── */

.seo-article.blog-listing {
    max-width: 1120px;
}

.seo-breadcrumbs:has(+ .blog-listing) {
    max-width: 1120px;
}

.blog-listing .seo-header {
    max-width: 74ch;
}

.blog-chips {
    display: flex;
    gap: 8px;
    margin: 0 0 24px;
    padding: 2px 0 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.blog-chips::-webkit-scrollbar {
    display: none;
}

.seo-article a.blog-chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-pill);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.seo-article a.blog-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.seo-article a.blog-chip[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft-tint);
}

.seo-article h2.blog-grid-heading {
    margin-top: 32px;
}

.seo-article .blog-grid {
    list-style: none;
    margin: 16px 0 8px;
    padding: 0;
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr;
}

.seo-article .blog-card {
    position: relative;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface-card);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.seo-article .blog-card:hover {
    border-color: var(--accent-soft-edge);
    box-shadow: var(--shadow-card-hover);
}

.blog-card-cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid var(--border-solid);
}

.blog-card-body {
    padding: 16px 18px 20px;
}

.seo-article p.blog-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin: 0 0 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.blog-card-category {
    display: inline-flex;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft-tint);
    border: 1px solid var(--accent-soft-edge);
    color: var(--text-primary);
    font-weight: 600;
}

.seo-article h3.blog-card-title {
    margin: 0 0 8px;
    font-size: 1.12rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.seo-article .blog-card-title a {
    color: var(--text-primary);
    text-decoration: none;
    touch-action: manipulation;
}

/* The whole card is the target, without nesting interactive elements. */
.seo-article .blog-card-title a::after {
    content: "";
    position: absolute;
    inset: 0;
}

.seo-article p.blog-card-summary {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Article ────────────────────────────────────────────────────── */

.blog-cover {
    margin: 0 0 28px;
}

.blog-cover img,
.seo-shot img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-lg);
}

.blog-cover figcaption,
.seo-shot figcaption {
    margin-top: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.blog-toc {
    margin: 0 0 32px;
    padding: 0 18px;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-lg);
    background: var(--surface-card);
}

.blog-toc summary {
    display: flex;
    align-items: center;
    min-height: 48px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    touch-action: manipulation;
}

.seo-article .blog-toc ol {
    margin: 0 0 16px;
    padding-inline-start: 1.3em;
}

.seo-article .blog-toc li {
    margin-bottom: 2px;
    font-size: 0.95rem;
}

.seo-article .blog-toc a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    text-decoration: none;
}

.seo-shot {
    margin: 14px 0 6px;
}

/* Phone screenshots stay phone-sized next to the text. */
.seo-shot img.is-portrait {
    max-width: 320px;
}

.blog-task {
    margin: 48px 0 8px;
    padding: 24px;
    border: 1px solid var(--accent-soft-edge);
    border-radius: var(--radius-lg);
    background: var(--accent-soft-tint);
}

.seo-article .blog-task h2 {
    margin: 0 0 8px;
    font-size: clamp(1.3rem, 3vw, 1.6rem);
}

.seo-article .blog-task p {
    margin: 0 0 16px;
    color: var(--text-primary);
}

/* ── Comparison tables ──────────────────────────────────────────── */

.seo-compare-wrap {
    margin: 20px 0 26px;
}

.seo-compare {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    line-height: 1.5;
}

.seo-compare caption {
    caption-side: top;
    text-align: start;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding-bottom: 10px;
}

.seo-compare th,
.seo-compare td {
    padding: 10px 12px 10px 0;
    border-top: 1px solid var(--bg-border);
    text-align: start;
    vertical-align: top;
}

.seo-compare thead th {
    border-top: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.seo-compare tbody th {
    color: var(--text-primary);
    font-weight: 700;
}

.seo-compare td {
    color: var(--text-muted);
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (min-width: 640px) {
    .seo-article .blog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .seo-article .blog-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Wide screens: the comparison tables get the full container, and
   "On this page" moves into a sticky column beside the article. */
@media (min-width: 1200px) {
    .seo-article.blog-post {
        max-width: calc(74ch + 300px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) 252px;
        column-gap: 48px;
    }

    .seo-breadcrumbs:has(+ .blog-post) {
        max-width: calc(74ch + 300px);
    }

    .blog-post > * {
        grid-column: 1;
    }

    .blog-post > .blog-toc {
        grid-column: 2;
        grid-row: 1 / span 60;
        align-self: start;
        position: sticky;
        /* Below the sticky site header: the 74 px nav row plus the section row. */
        top: 160px;
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
        overflow-y: auto;
    }
}

@media (max-width: 760px) {
    .seo-compare thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .seo-compare,
    .seo-compare tbody,
    .seo-compare tr,
    .seo-compare th,
    .seo-compare td {
        display: block;
        width: auto;
    }

    .seo-compare tr {
        padding: 12px 0;
        border-top: 1px solid var(--bg-border);
    }

    .seo-compare th,
    .seo-compare td {
        border-top: 0;
        padding: 2px 0;
    }

    .seo-compare tbody th {
        font-size: 1rem;
        padding-bottom: 6px;
    }

    .seo-compare td::before {
        content: attr(data-label) ": ";
        color: var(--text-primary);
        font-weight: 600;
    }
}

@media (max-width: 640px) {
    .blog-task {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .seo-article a.blog-chip,
    .seo-article .blog-card {
        transition: none;
    }
}
