/* Loaded after landing.css, which sets the layer order and the colour tokens. */
@layer components {
    .articles,
    .article {
        padding-bottom: 4rem;
    }

    .articles a,
    .article a {
        color: inherit;
        text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
        text-underline-offset: 0.15em;
    }

    .articles a:hover,
    .article a:hover {
        text-decoration-color: currentColor;
    }

    .articles__title,
    .article__title {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
        letter-spacing: -0.02em;
        line-height: 1.1;
        text-wrap: balance;
    }

    .articles__title {
        padding-top: 1.5rem;
    }

    .articles__empty {
        margin-top: 2rem;
        color: var(--color-muted);
    }

    .articles__list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
        gap: 1.5rem;
        margin: 2rem 0 0;
        padding: 0;
        list-style: none;
    }

    /* The whole card is the link, through the title's link stretched over it. */
    .article-card {
        position: relative;
        overflow: hidden;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        background: color-mix(in srgb, var(--color-background) 85%, transparent);

        &:hover {
            border-color: var(--color-muted);
        }

        &:has(a:focus-visible) {
            outline: 3px solid var(--color-accent);
            outline-offset: 2px;
        }
    }

    .article-card__image {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
        object-fit: cover;
    }

    .article-card__title {
        padding: 1rem 1rem 0;
        font-size: 1.25rem;
        line-height: 1.3;

        a {
            text-decoration: none;

            &::after {
                content: "";
                position: absolute;
                inset: 0;
            }

            &:focus-visible {
                outline: none;
            }
        }
    }

    .article-card__description {
        padding: 0.5rem 1rem 1rem;
        color: var(--color-muted);
        font-size: 0.9375rem;
    }

    .article {
        max-width: 42rem;
        padding-top: 1.5rem;
    }

    .article__back {
        margin-bottom: 0.75rem;
        color: var(--color-muted);
        font-size: 0.9375rem;

        &::before {
            content: "← ";
        }
    }

    .article__updated {
        margin-top: 0.5rem;
        color: var(--color-muted);
        font-size: 0.9375rem;
    }

    .article__lede {
        margin-top: 1.25rem;
        font-size: 1.1875rem;
    }

    .article__image {
        width: 100%;
        height: auto;
        max-height: 22rem;
        margin-block: 1.75rem;
        border-radius: var(--radius);
        object-fit: cover;
    }

    .article__body {
        > * + * {
            margin-top: 1rem;
        }

        h2,
        h3,
        h4 {
            letter-spacing: -0.01em;
            line-height: 1.25;
        }

        h2 {
            margin-top: 2.5rem;
            font-size: 1.5rem;
        }

        h3 {
            margin-top: 2rem;
            font-size: 1.25rem;
        }

        h4 {
            margin-top: 1.5rem;
            font-size: 1.0625rem;
        }

        ul,
        ol {
            padding-left: 1.25rem;
        }

        li + li,
        li > ul {
            margin-top: 0.25rem;
        }
    }
}
