/* Articles section. Design tokens come from style.css, which the layout always
   loads first: black background, glass cards, 20px radius, Inter. */

:root {
    --article-link-color: #0a84ff;
}

.articles-page,
.article-page {
    width: 100%;
    min-width: 0;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.articles-page__header {
    max-width: 720px;
    margin: 32px auto 28px;
    text-align: center;
}

.articles-page__header h1 {
    margin: 0 0 12px;
    font-size: clamp(1.9rem, 5vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.articles-page__header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.6;
}

/* One column on a phone, two on a tablet, three on a desktop — no media query. */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.article-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-card);
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    overflow: hidden;
    transition: var(--transition-smooth);
}

@media (hover: hover) and (pointer: fine) {
    .article-card:hover {
        transform: translateY(-4px);
        border-color: var(--border-color-hover);
    }
}

/* A reader who asked the system for less movement gets the colour change and
   none of the lift; the rest of the site already honours this. */
@media (prefers-reduced-motion: reduce) {
    .article-card {
        transition: none;
    }

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

.article-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* A fixed ratio so the grid cannot jump while covers load. */
.article-card__cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.article-card__body {
    padding: 18px 18px 20px;
}

.article-card__title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    line-height: 1.3;
    font-weight: 600;
}

.article-card__excerpt {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.article-card__date {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.articles-empty {
    margin: 48px auto;
    text-align: center;
    color: var(--text-secondary);
}

.articles-pagination {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.articles-pagination a,
.articles-pagination span {
    min-height: 44px;
    min-width: 44px;
}

.article-card__link:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 3px;
    border-radius: 6px;
}

/* ---- Article page: built for reading, not for scanning ---- */

/* One column for everything made of words. The body has always centred its
   text inside the 860px shell, so a full-width heading started 94px to the left
   of the paragraph under it — the page read as if the title had slipped. The
   shell now carries the same track, and only the cover and the body keep the
   full width: the cover because a picture wider than the text looks deliberate,
   the body because its own grid is what lets figures break out. */
.article {
    /* One length, not 56ch: the ch unit follows the font size, and the body
       sets a larger one — the same "56ch" came out 565px in the header and
       671px in the text, so the two never lined up. */
    --article-measure: 42rem;

    max-width: 860px;
    margin: 0 auto;
    display: grid;
    grid-template-columns:
        [full-start] 1fr
        [text-start] minmax(0, var(--article-measure))
        [text-end] 1fr
        [full-end];
}

.article > * {
    grid-column: text;
}

.article__cover,
.article__body {
    grid-column: full;
}

.article__breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 20px 0 8px;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.article__breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
}

.article__breadcrumbs a:hover {
    color: var(--text-primary);
}

.article__header {
    margin: 12px 0 24px;
}

.article__title {
    margin: 0 0 14px;
    font-size: clamp(1.9rem, 5vw, 3rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 700;
    text-wrap: balance;
}

.article__excerpt {
    margin: 0 0 16px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

.article__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.article__cover {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 28px;
}

/* The measured comfortable line is 60-75 characters, and 42rem lands near 68 at
   the body's own font size. Figures and code break out to the full 860px on a
   desktop. */
.article__body {
    display: grid;
    grid-template-columns:
        [full-start] 1fr
        [text-start] minmax(0, var(--article-measure))
        [text-end] 1fr
        [full-end];
    font-size: clamp(1.0625rem, 0.5vw + 1rem, 1.1875rem);
    line-height: 1.75;
}

.article__body > * {
    grid-column: text;
    margin: 0;
}

.article__body > * + * {
    margin-top: 1.25em;
}

/* Proximity: twice the space above a subheading as below it, so the heading
   reads as part of the section it introduces. */
.article__body > h2,
.article__body > h3 {
    margin-top: 2em;
    margin-bottom: -0.5em;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.article__body > h2 {
    font-size: 1.5rem;
}

.article__body > h3 {
    font-size: 1.2rem;
}

.article__body a {
    /* Not --accent-blue: #0071e3 measures 4.47:1 on the site's black, just
       under the 4.5:1 WCAG AA asks for body text. This is the same blue one
       step lighter — 5.76:1 — which is what dark surfaces want anyway. */
    color: var(--article-link-color);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.article__body a:hover {
    text-decoration-thickness: 2px;
}

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

.article__body li + li {
    margin-top: 0.5em;
}

/* No italic: it reads noticeably worse in Cyrillic. */
.article__body blockquote {
    padding-left: 18px;
    border-left: 3px solid var(--accent-blue);
    color: var(--text-secondary);
}

.article__body figure {
    grid-column: full;
    margin-top: 2em;
}

.article__body figure img,
.article__body > img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 16px;
}

.article__body figcaption {
    margin-top: 10px;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    text-align: center;
}

/* The element scrolls, never the page. */
/* A table is the widest thing a body can hold, so it breaks out of the reading
   column and scrolls inside itself rather than pushing the page sideways. */
.article__body table {
    grid-column: full;
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.5;
}

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

.article__body th {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.article__body tbody tr:last-child td {
    border-bottom: 0;
}

.article__body pre {
    grid-column: full;
    overflow-x: auto;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    line-height: 1.5;
}

.article__body code {
    font-size: 0.92em;
}

/* Evergreen shopping-Sunday calendar. It is server-rendered so the dates are
   useful to readers and search engines even when JavaScript is unavailable. */
.article__body > .shopping-sundays-calendar {
    grid-column: full;
    width: 100%;
    max-width: 800px;
    justify-self: center;
}

.shopping-sundays-calendar {
    margin-top: 2em;
    padding: clamp(20px, 4vw, 30px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background:
        radial-gradient(circle at 100% 0, rgba(10, 132, 255, 0.12), transparent 42%),
        var(--bg-card);
}

.shopping-sundays-calendar__inner {
    width: 100%;
    max-width: var(--article-measure);
    margin: 0 auto;
}

.shopping-sundays-calendar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.shopping-sundays-calendar__header h2 {
    margin: 0 0 6px;
    font-size: clamp(1.3rem, 3vw, 1.65rem);
    line-height: 1.25;
    text-wrap: balance;
}

.shopping-sundays-calendar__header p,
.shopping-sundays-calendar__source {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.shopping-sundays-calendar__next {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    padding: 8px 12px;
    border: 1px solid rgba(48, 209, 88, 0.25);
    border-radius: 999px;
    background: rgba(48, 209, 88, 0.09);
    color: #30d158 !important;
    font-weight: 600;
}

.shopping-sundays-calendar__next > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.article__body .shopping-sundays-calendar__dates {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.shopping-sundays-calendar__dates li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.shopping-sundays-calendar__dates time {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
}

.shopping-sundays-calendar__dates li > span {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    color: #30d158;
    background: rgba(48, 209, 88, 0.1);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.shopping-sundays-calendar__dates .is-passed time {
    color: var(--text-tertiary);
}

.shopping-sundays-calendar__dates .is-passed > span {
    color: var(--text-tertiary);
    background: rgba(255, 255, 255, 0.055);
}

.shopping-sundays-calendar__dates .is-today {
    border-color: rgba(48, 209, 88, 0.28);
}

.shopping-sundays-calendar__source {
    margin-top: 16px;
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

@media (max-width: 767px) {
    .shopping-sundays-calendar__header {
        flex-direction: column;
    }
}

.article__body a:focus-visible,
.article__breadcrumbs a:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 3px;
    border-radius: 6px;
}

.article-more {
    max-width: 860px;
    margin: 56px auto 40px;
}

.article-more__title {
    margin: 0 0 20px;
    font-size: 1.3rem;
    font-weight: 600;
}

.article__draft-badge {
    padding: 2px 10px;
    border: 1px solid rgba(255, 159, 10, 0.35);
    border-radius: 20px;
    color: var(--warning-orange);
    font-weight: 600;
}

/* ---- Closing questions: a list you can scan, not a wall you must read ---- */

.article-faq {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 36px 0 8px;
}

.article-faq__item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    transition: border-color 0.2s ease;
}

.article-faq__item:hover {
    border-color: var(--border-color-hover);
}

.article-faq__item summary {
    /* The whole row is the target, and 56px clears the 44px finger minimum
       with room to spare on a phone. */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 56px;
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    list-style: none;
}

/* Safari draws its own triangle and ignores list-style. */
.article-faq__item summary::-webkit-details-marker {
    display: none;
}

.article-faq__item summary::after {
    content: '';
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    margin-right: 4px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform 0.2s ease;
}

.article-faq__item[open] summary::after {
    transform: rotate(-135deg) translate(-2px, -2px);
}

.article-faq__item summary:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
    border-radius: 14px;
}

.article-faq__answer {
    padding: 0 18px 16px;
    color: var(--text-secondary);
    line-height: 1.65;
}

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

.article-faq__answer > :last-child {
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .article-faq {
        gap: 8px;
        margin-top: 28px;
    }

    .article-faq__item summary {
        padding: 13px 15px;
        font-size: 0.98rem;
    }

    .article-faq__answer {
        padding: 0 15px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .article-faq__item,
    .article-faq__item summary::after {
        transition: none;
    }
}
