/* Article library and reader. Mobile first; no external fonts or images (the CSP allows only this origin). */

:root {
    --art-measure: 42rem; /* rem, not ch: every column (breadcrumbs included) then has the same width */
}

/* Library */

.library-intro {
    max-width: var(--art-measure);
    margin: 8px 0 24px;
}

.library-intro h1 {
    margin: 0 0 12px;
    font-family: var(--font-serif);
    font-size: clamp(30px, 6vw, 42px);
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
}

.library-intro__lede {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 19px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.category-chips ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
}

.chip.is-active {
    border-color: var(--teal);
    background: var(--teal);
    color: var(--on-accent);
    font-weight: 600;
}

.article-grid {
    display: grid;
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
    grid-template-columns: minmax(0, 1fr);
}

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

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

.article-card {
    position: relative;
    height: 100%;
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: 12px;
}

.article-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
}

.article-card__link:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

@media (hover: hover) {
    .article-card {
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .article-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 22px -16px rgba(40, 30, 20, 0.45);
    }
}

.article-card__media {
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    background: linear-gradient(135deg, var(--tint-warm), var(--tint-cool));
}

.article-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    padding: 18px 20px 20px;
}

.article-card__category {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--terracotta);
}

.article-card__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
}

.article-card__description {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
}

.article-card__meta {
    margin: auto 0 0;
    padding-top: 4px;
    font-size: 14px;
    color: var(--ink-soft);
}

/* Fallback shown instead of a missing image: a neutral panel with a plain envelope mark. */
.media-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--tint-warm), var(--tint-cool));
    color: var(--teal);
}

.media-fallback svg {
    width: 30%;
    max-width: 96px;
    min-width: 48px;
    height: auto;
    opacity: 0.85;
}

.empty-state,
.not-found {
    max-width: var(--art-measure);
    margin: 24px 0;
    padding: 28px;
    border: 1px dashed var(--hairline);
    border-radius: 14px;
    text-align: center;
}

.not-found {
    border-style: solid;
    background: var(--card);
}

.empty-state h2,
.not-found h1 {
    margin: 0 0 10px;
    font-family: var(--font-serif);
    font-size: 24px;
    line-height: 1.3;
    color: var(--ink);
}

.not-found h1 {
    font-size: clamp(26px, 5vw, 32px);
}

.empty-state p,
.not-found p {
    margin: 0 0 16px;
    color: var(--ink-soft);
}

.empty-state__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

/* Reader */

.breadcrumbs {
    max-width: var(--art-measure);
    margin: 0 auto 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink-soft);
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li + li::before {
    content: "/";
    margin-right: 8px;
    color: var(--ink-soft);
}

.breadcrumbs li[aria-current] {
    color: var(--ink);
}

.back-link {
    max-width: var(--art-measure);
    margin: 0 auto 8px;
}

.back-link--bottom {
    margin: 32px auto 0;
}

.back-link a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

.article {
    max-width: var(--art-measure);
    margin: 0 auto;
    overflow-wrap: break-word;
}

.article-eyebrow {
    margin: 8px 0 12px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--terracotta);
}

.article h1 {
    margin: 0 0 16px;
    font-family: var(--font-serif);
    font-size: clamp(30px, 6vw, 42px);
    font-weight: 700;
    line-height: 1.18;
    color: var(--ink);
    text-wrap: balance;
}

.article-meta {
    margin: 0 0 24px;
    font-size: 15px;
    color: var(--ink-soft);
}

/* The full picture is shown whole at the width of the reading column, at its own 3:2 shape (no cropping). */
.article-figure {
    margin: 0 0 24px;
    overflow: hidden;
    border-radius: 12px;
}

.article-figure img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

.article-figure .media-fallback {
    height: auto;
    aspect-ratio: 3 / 2;
}

.article-lede {
    margin: 0 0 24px;
    font-family: var(--font-serif);
    font-size: clamp(19px, 2.4vw, 21px);
    line-height: 1.6;
    color: var(--ink-soft);
}

/* Table of contents: open on wide screens, collapsed on phones by articles.js. */
.toc {
    margin: 0 0 32px;
    padding: 6px 18px 14px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--card);
    font-family: var(--font-sans);
}

.toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.toc summary::-webkit-details-marker {
    display: none;
}

.toc summary::after {
    content: "Hide";
    font-size: 14px;
    font-weight: 400;
    color: var(--ink-soft);
}

.toc:not([open]) summary::after {
    content: "Show";
}

.toc ol {
    margin: 0;
    padding-left: 1.2em;
}

.toc li a {
    display: block;
    padding: 11px 0;
    line-height: 22px;
    color: var(--teal);
    font-size: 16px;
    text-decoration: none;
}

.toc li a[aria-current="true"] {
    color: var(--terracotta);
    font-weight: 600;
    text-decoration: underline;
}

/* Body text: about 70 characters per line, 18 px (19 px from 768 px), line height 1.7. */
.prose {
    max-width: var(--art-measure);
    overflow-wrap: break-word;
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--ink);
}

@media (min-width: 768px) {
    .prose {
        font-size: 19px;
    }
}

.prose > :first-child {
    margin-top: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose blockquote {
    margin: 0 0 1.2em;
}

.prose h2 {
    margin: 2em 0 0.6em;
    font-family: var(--font-serif);
    font-size: clamp(22px, 4.6vw, 28px);
    font-weight: 700;
    line-height: 1.25;
    color: var(--ink);
    scroll-margin-top: 16px;
}

.prose h3 {
    margin: 1.6em 0 0.5em;
    font-family: var(--font-serif);
    font-size: clamp(19px, 3.8vw, 22px);
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
    scroll-margin-top: 16px;
}

.prose a {
    color: var(--teal);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.prose ul,
.prose ol {
    padding-left: 1.35em;
}

.prose li + li {
    margin-top: 0.4em;
}

.prose strong {
    font-weight: 700;
}

.prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.prose pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--card);
    font-size: 15px;
    line-height: 1.5;
    white-space: pre;
}

/* Sample letters are set like paper: a slightly warm sheet with a hairline edge, not an italic quote. */
.prose blockquote {
    padding: 1.25em 1.6em;
    border: 1px solid var(--hairline);
    border-radius: 6px;
    background: var(--letter);
    box-shadow: 0 10px 18px -16px rgba(60, 40, 20, 0.5);
    color: var(--ink);
}

.prose blockquote p {
    margin: 0 0 0.9em;
}

.prose blockquote p:last-child {
    margin: 0;
}

/* Wide tables scroll sideways inside the article instead of pushing the page wider than the screen. */
.prose table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
}

.prose th,
.prose td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--hairline);
    text-align: left;
    vertical-align: top;
}

.prose th {
    font-weight: 600;
}

.prose hr {
    width: 40%;
    margin: 2.4em auto;
    border: 0;
    border-top: 1px solid var(--hairline);
}

.article-cta {
    margin: 48px 0 40px;
    padding: 28px 24px;
    border: 1px solid var(--hairline);
    border-radius: 14px;
    background: var(--card);
    text-align: center;
}

.article-cta h2 {
    margin: 0 0 8px;
    font-family: var(--font-serif);
    font-size: 24px;
    line-height: 1.3;
    color: var(--ink);
}

.article-cta p {
    max-width: 40ch;
    margin: 0 auto 18px;
    color: var(--ink-soft);
}

.prev-next {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    margin: 0 0 16px;
}

.prev-next__link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 44px;
    padding: 12px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}

/* The next card mirrors the previous one: thumbnail on the right, text right-aligned. */
.prev-next__link--next {
    flex-direction: row-reverse;
    text-align: right;
}

.prev-next__media {
    flex: 0 0 120px;
    width: 120px;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 8px;
}

.prev-next__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prev-next__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.prev-next__label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
}

.prev-next__title {
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.35;
}

@media (max-width: 575.98px) {
    .prev-next {
        grid-template-columns: minmax(0, 1fr);
    }

    .prev-next__link--next {
        flex-direction: row;
        text-align: left;
    }
}

.related {
    max-width: 1040px;
    margin: 48px auto 0;
}

.related h2 {
    margin: 0 0 20px;
    font-family: var(--font-serif);
    font-size: 26px;
    line-height: 1.3;
    text-align: left;
    color: var(--ink);
}

/* Reading progress, sticky call to action and back-to-top sit above the content. */
.reading-progress {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1040;
    height: 4px;
    pointer-events: none;
}

.reading-progress__bar {
    height: 100%;
    background: var(--terracotta);
    transform: scaleX(0);
    transform-origin: 0 50%;
}

.back-to-top {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 1030;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    background: var(--card);
    box-shadow: 0 4px 14px rgba(91, 60, 30, 0.18);
    color: var(--teal);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.back-to-top.is-hidden {
    display: none;
}

.cta-sticky {
    display: none;
}

@media (min-width: 1024px) {
    .cta-sticky {
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 1030;
        display: block;
    }

    .cta-sticky a {
        display: inline-flex;
        align-items: center;
        min-height: 48px;
        padding: 0 22px;
        border-radius: 12px;
        background: var(--terracotta);
        box-shadow: 0 3px 0 var(--terracotta-deep), 0 10px 22px -12px rgba(154, 69, 36, 0.8);
        color: var(--on-accent);
        font-size: 16px;
        font-weight: 600;
        text-decoration: none;
    }
}

/* Home page: the three newest articles as small horizontal cards under the idea cards. */
.explore-articles {
    margin: 48px 0 0;
    padding: 28px 24px;
    border: 1px solid var(--hairline);
    border-radius: 14px;
    background: var(--card);
    color: var(--ink);
    font-family: var(--font-sans);
}

.explore-articles h2 {
    margin: 0 0 16px;
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    color: var(--ink);
}

.explore-articles__list {
    display: grid;
    gap: 12px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {
    .explore-articles__list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    .explore-articles__list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.explore-card {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 10px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
}

.explore-card:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

/* 120 px wide, 3:2 high, beside the category, title and reading time. */
.explore-card__media {
    flex: 0 0 120px;
    width: 120px;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: 8px;
}

.explore-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.explore-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.explore-card__category {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--terracotta);
}

.explore-card__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
}

.explore-card__meta {
    font-size: 14px;
    color: var(--ink-soft);
}

.explore-articles__all {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--teal);
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
    .article-card,
    .article-card__link,
    .chip,
    .button {
        transition: none !important;
    }

    .article-card:hover {
        transform: none;
    }
}

/* Print: the article only, no navigation, chrome or call to action. */
@media print {
    header,
    footer,
    nav,
    .skip-link,
    .reading-progress,
    .cta-sticky,
    .back-to-top,
    .toc,
    .article-cta,
    .prev-next,
    .related,
    .back-link,
    .breadcrumbs,
    .article-figure {
        display: none !important;
    }

    body:has(.articles-theme) {
        background: #fff !important;
        color: #000 !important;
    }

    .articles-theme {
        padding: 0;
    }

    .prose,
    .article-lede,
    .article h1 {
        color: #000;
    }

    .prose {
        font-size: 12pt;
        line-height: 1.5;
    }

    .prose a {
        color: #000;
        text-decoration: underline;
    }

    .prose blockquote {
        background: none;
        border-color: #999;
        box-shadow: none;
    }
}
