/*
 * Blog styles, shared by all three sites.
 *
 * This file must stay byte-identical on every site (tests/blog-unit.php checks it).
 * It builds on the variables and the .news-post styles in main.css, so dark mode
 * and high contrast mostly follow from those.
 *
 * Every control outside running text is at least 44 by 44 CSS pixels.
 */

/* Search box, categories and RSS link */
.blog-tools {
    margin-bottom: var(--space-xl);
}

.blog-search {
    margin-bottom: var(--space-lg);
}

.blog-search label {
    display: block;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.blog-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    max-width: 40rem;
}

.blog-search input[type="search"] {
    flex: 1 1 12rem;
    min-width: 0;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font: inherit;
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 2px solid var(--color-text-muted);
    border-radius: var(--border-radius);
}

.blog-search input[aria-invalid="true"] {
    border-color: var(--color-error);
    border-width: 3px;
}

.blog-error {
    margin-top: var(--space-sm);
    margin-bottom: 0;
}

.blog-categories h2 {
    font-size: var(--font-size-lg);
    margin-top: 0;
    margin-bottom: var(--space-sm);
}

.blog-feed {
    margin-top: var(--space-md);
    margin-bottom: 0;
}

/* Lists of link buttons: categories, pagination, sharing */
.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    list-style: none;
    margin: 0;
    padding: 0;
}

.pill-list li {
    margin: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: var(--space-xs) var(--space-md);
    border: 2px solid var(--color-primary);
    border-radius: var(--border-radius);
    color: var(--color-primary);
    background-color: transparent;
    text-decoration: none;
}

.pill:visited {
    color: var(--color-primary);
}

.pill:hover {
    color: var(--color-text-inverse);
    background-color: var(--color-primary);
}

/* The current item differs in weight and underline too, not just in color */
.pill[aria-current],
.pill[aria-current]:visited {
    color: var(--color-text-inverse);
    background-color: var(--color-primary);
    font-weight: 700;
    text-decoration: underline;
}

/* A section of the navigation is marked the same way as the page itself */
.nav-list a[aria-current="true"] {
    font-weight: 700;
    border-bottom: 3px solid var(--color-text-inverse);
}

/* Links outside running text are comfortable targets too */
.breadcrumb a,
.blog-feed a,
.post-card h3 a,
.post-categories a,
.post-address a,
.post-nav a {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: var(--space-lg);
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    margin: 0;
}

.breadcrumb li + li::before {
    content: "/";
    content: "/" / "";
    margin-inline: var(--space-sm);
    color: var(--color-text-muted);
}

.breadcrumb [aria-current="page"] {
    font-weight: 700;
}

/* Posts */
.post-card h3 {
    font-size: var(--font-size-xl);
    margin-top: 0;
    margin-bottom: var(--space-xs);
}

.post-card > :last-child {
    margin-bottom: 0;
}

.post-card .news-date,
.post-header .news-date {
    margin-bottom: var(--space-sm);
}

.post-categories,
.post-source {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.news-post h1 {
    margin-top: 0;
    margin-bottom: var(--space-sm);
    overflow-wrap: anywhere;
}

.post-header {
    margin-bottom: var(--space-lg);
}

.post-body h2 {
    font-size: var(--font-size-xl);
    margin-top: var(--space-xl);
}

.post-body .news-notes h2 {
    font-size: var(--font-size-lg);
    margin-top: 0;
}

.post-body kbd,
.post-body code {
    overflow-wrap: anywhere;
}

.post-body kbd {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    background-color: var(--color-bg);
    border: 1px solid var(--color-text-muted);
    border-radius: var(--border-radius);
}

.post-body code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

/* Sharing, and the links to other posts */
.post-share,
.post-nav,
.pagination {
    margin-block: var(--space-xl);
}

.post-share h2 {
    font-size: var(--font-size-xl);
    margin-top: 0;
}

.post-address {
    overflow-wrap: anywhere;
}

.post-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-nav li {
    margin-bottom: var(--space-sm);
}

/* High contrast: stronger edges */
@media (prefers-contrast: more), (prefers-contrast: high) {
    .blog-search input[type="search"] {
        border-color: var(--color-text);
    }

    .pill {
        border-width: 3px;
    }
}

/* Windows High Contrast and other forced colors: keep the current item visible */
@media (forced-colors: active) {
    .pill[aria-current] {
        border-width: 4px;
    }
}

/* Print: only the post itself */
@media print {
    .blog-tools,
    .breadcrumb,
    .pagination,
    .post-share,
    .post-nav {
        display: none;
    }
}
