/*
 * Magazine: /magazine/, topic pages /magazine/{topic}/ and the topic tag/bar on single posts.
 * Loaded only on category archives and single posts (marpet_mag_enqueue_assets()).
 */

.mag,
.single-post .entry {
    --mag-green: #3d8f68;
    --mag-green-dark: #2b6e4e;
    --mag-mint: #e8f6ef;
    --mag-mint-hover: #d6efe2;
    --mag-line: #cfe7da;
    --mag-text: #1c2b26;
    --mag-muted: #5b6b65;
    --mag-navy: #1f3a4d;
    --mag-radius: 18px;
}

.mag {
    color: var(--mag-text);
}

.mag a {
    color: inherit;
}

/* style.css sets an explicit font-size on every a/p/div, so nested text does not inherit */
.mag-head__text p,
.mag-card__link,
.mag-section__title a,
.mag-topics__link,
.mag-box__list a {
    font-size: inherit;
}

/* Visually hidden, still read by screen readers */
.mag-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Breadcrumbs ---------- */

/* style.css hides breadcrumbs below 1200px; the magazine spec shows them on every screen size */
.mag .breadcrumbs,
.single-post .entry .breadcrumbs {
    display: block;
}

/* ---------- Head ---------- */

.mag .mag-head {
    margin-bottom: 32px;
}

.mag .mag-head__title,
.entry.mag h1 {
    max-width: none;
    margin: 0 0 12px;
    font-size: 40px;
    line-height: 1.2;
}

.mag-head__text {
    max-width: 760px;
    font-size: 18px;
    line-height: 1.6;
    color: var(--mag-muted);
}

.mag-head__text p {
    margin: 0 0 10px;
}

.mag-head__text a {
    color: var(--mag-green-dark);
    text-decoration: underline;
}

/* ---------- Sections ---------- */

.mag-section {
    margin-bottom: 48px;
}

.mag-section__title {
    margin: 0 0 20px;
    font-size: 26px;
    line-height: 1.3;
}

.mag ul.mag-grid,
.mag ul.mag-featured,
.mag-topics__list,
.mag-box__list,
.mag-pagination ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Topic section head on /magazine/: linked H2 and "all articles" */
.mag-section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.mag-section__head .mag-section__title {
    margin: 0;
}

.mag-section__title a {
    text-decoration: none;
}

.mag-section__title a:hover,
.mag-section__title a:focus-visible {
    color: var(--mag-green-dark);
}

.mag .mag-section__more {
    flex-shrink: 0;
    font-size: 15px;
    font-weight: bold;
    color: var(--mag-green-dark);
    text-decoration: none;
    white-space: nowrap;
}

.mag .mag-section__more:after {
    content: " \2190";
}

.mag .mag-section__more:hover,
.mag .mag-section__more:focus-visible {
    text-decoration: underline;
}

/* ---------- Featured posts (/magazine/) ---------- */

/* Lead card on the right (RTL), two compact cards stacked next to it */
.mag-featured {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
    /* The third row takes the rest of the lead card height, so the compact cards stay on top */
    grid-template-rows: auto auto 1fr;
    gap: 20px;
    align-items: start;
}

.mag-card--featured {
    grid-row: 1 / span 3;
}

.mag-card--featured .mag-card__title {
    font-size: 26px;
    line-height: 1.3;
}

.mag-card--featured .mag-card__body {
    padding: 20px 24px 24px;
}

/* Compact card: image on the right, tag and title on the left */
.mag-featured .mag-card--compact {
    flex-direction: row;
    min-height: 140px;
}

.mag-card--compact .mag-card__media {
    flex: 0 0 38%;
    aspect-ratio: auto;
}

.mag-card--compact .mag-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 14px 16px;
}

.mag-card--compact .mag-card__title {
    margin: 8px 0 0;
    font-size: 17px;
}

.mag-card--section .mag-card__title,
.mag-card--grid .mag-card__title {
    font-size: 18px;
}

.mag-card--section .mag-card__title {
    margin-top: 0;
}

.mag-card--grid .mag-card__title {
    margin-bottom: 0;
}

/* ---------- Topic bar ---------- */

.mag-topics {
    margin: 0 0 28px;
}

.mag-topics__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mag-topics__link {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--mag-line);
    border-radius: 999px;
    background: #fff;
    font-size: 15px;
    line-height: 1.4;
    color: var(--mag-text);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .2s ease, border-color .2s ease;
}

.mag-topics__link:hover,
.mag-topics__link:focus-visible {
    border-color: var(--mag-green);
}

.mag-topics__link.is-current {
    border-color: var(--mag-green);
    background: var(--mag-green);
    color: #fff;
    font-weight: bold;
}

/* ---------- Article cards ---------- */

.mag-grid {
    display: grid;
    gap: 24px;
}

.mag-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mag-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mag-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--mag-radius);
    background: var(--mag-mint);
    transition: background-color .2s ease;
}

.mag-card:hover,
.mag-card:focus-within {
    background: var(--mag-mint-hover);
}

.mag-card__media {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--mag-line);
}

.mag-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}

.mag-card:hover .mag-card__img {
    transform: scale(1.04);
}

.mag-card__body {
    padding: 16px 20px 20px;
}

.mag-card__title {
    margin: 10px 0 8px;
    font-size: 20px;
    line-height: 1.35;
}

/* The title link covers the whole card; the topic tag sits above it */
.mag-card__link {
    text-decoration: none;
}

.mag-card__link:after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.mag-card__link:focus-visible {
    outline: none;
}

.mag-card:focus-within {
    outline: 2px solid var(--mag-green-dark);
    outline-offset: 2px;
}

.mag-card__excerpt {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 15px;
    line-height: 1.5;
    color: var(--mag-muted);
}

.mag-card .mag-tag {
    position: relative;
    z-index: 2;
}

/* ---------- Topic tag (cards and single post) ---------- */

.mag-tag {
    display: inline-block;
    padding: 3px 12px;
    border: 1px solid var(--mag-line);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    line-height: 1.5;
    color: var(--mag-green-dark);
    text-decoration: none;
}

.mag-tag:hover,
.mag-tag:focus-visible {
    border-color: var(--mag-green);
}

.single-post .bubble .mag-tag {
    margin-bottom: 10px;
    font-size: 14px;
}

/* ---------- Pagination ---------- */

.mag-pagination {
    margin-top: 32px;
}

.mag-pagination ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.mag-pagination .page-numbers {
    display: inline-block;
    min-width: 40px;
    padding: 8px 12px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--mag-mint);
    text-align: center;
    text-decoration: none;
    font-size: 15px;
}

.mag-pagination a.page-numbers:hover,
.mag-pagination a.page-numbers:focus-visible {
    background: var(--mag-mint-hover);
}

.mag-pagination .page-numbers.current {
    background: var(--mag-green);
    color: #fff;
    font-weight: bold;
}

.mag-pagination .page-numbers.dots {
    background: transparent;
}

/* ---------- Call to action ---------- */

.mag-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-radius: var(--mag-radius);
    background: var(--mag-navy);
    color: #fff;
}

.mag-cta--strip {
    margin: 8px 0 60px;
    padding: 28px 36px;
}

/* style.css sets a color on every div, so the white text is set explicitly */
.mag .mag-cta__title,
.mag .mag-cta__subtitle {
    color: #fff;
}

.mag-cta__title {
    font-size: 24px;
    font-weight: bold;
    line-height: 1.3;
}

.mag-cta__subtitle {
    margin-top: 6px;
    font-size: 16px;
    opacity: .85;
}

.mag .mag-cta__button {
    flex-shrink: 0;
    display: inline-block;
    padding: 12px 28px;
    border-radius: 999px;
    background: #a1d1ab;
    color: var(--mag-navy);
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    transition: background-color .2s ease;
}

.mag .mag-cta__button:hover,
.mag .mag-cta__button:focus-visible {
    background: #c3e5ca;
}

.mag-cta--box {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px;
}

.mag-cta--box .mag-cta__title {
    font-size: 20px;
}

/* ---------- Topic page layout ---------- */

.mag-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 40px;
    align-items: start;
    margin-bottom: 60px;
}

.mag-layout__aside {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 130px; /* below the fixed site header */
}

/*
 * style.css gives body "overflow-x: hidden", which turns body into a scroll
 * container that never scrolls, so position: sticky never engages.
 * "clip" still cuts horizontal overflow but is not a scroll container.
 */
@supports (overflow: clip) {
    body.category {
        overflow-x: clip;
    }
}

.mag-box {
    padding: 20px 22px;
    border: 1px solid var(--mag-line);
    border-radius: var(--mag-radius);
    background: #fff;
}

.mag-box__title {
    margin: 0 0 10px;
    font-size: 20px;
}

.mag-box__list li + li {
    border-top: 1px solid var(--mag-line);
}

.mag-box__list {
    font-size: 16px;
}

.mag-box__list a {
    display: block;
    padding: 9px 0;
    text-decoration: none;
    color: var(--mag-green-dark);
}

.mag-box__list a:hover,
.mag-box__list a:focus-visible {
    text-decoration: underline;
}

.mag-empty {
    padding: 28px;
    border-radius: var(--mag-radius);
    background: var(--mag-mint);
    font-size: 18px;
}

/*
 * Single post, desktop: style.css lifts the title bubble 60px above
 * .top-section (top: -60px), so the topic bar needs that much extra room.
 */
@media (min-width: 1200px) {
    .single-post .entry .mag-topics {
        margin-bottom: 92px;
    }
}

/* ---------- Tablet ---------- */

@media (max-width: 1199px) {
    .mag-featured {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    }

    .mag-layout {
        grid-template-columns: minmax(0, 1fr) 260px;
        gap: 28px;
    }
}

/* ---------- Mobile ---------- */

@media (max-width: 767.98px) {
    .mag .breadcrumbs,
    .single-post .entry .breadcrumbs {
        padding-bottom: 16px;
    }

    .mag .mag-head__title,
    .entry.mag h1 {
        font-size: 30px;
    }

    .mag-head__text {
        font-size: 16px;
    }

    .mag-section__title {
        font-size: 22px;
    }

    /* Featured: the lead card only */
    .mag-featured {
        grid-template-columns: minmax(0, 1fr);
    }

    .mag-featured .mag-card--compact {
        display: none;
    }

    .mag-card--featured .mag-card__title {
        font-size: 21px;
    }

    .mag-card--featured .mag-card__body {
        padding: 16px 18px 20px;
    }

    .mag-card--featured .mag-card__excerpt {
        display: none;
    }

    /* Topic sections: 2 posts, horizontal cards, title only */
    .mag-grid--section .mag-card:nth-child(n+3) {
        display: none;
    }

    .mag-grid--section .mag-card {
        flex-direction: row;
        min-height: 110px;
    }

    .mag-grid--section .mag-card__media {
        flex: 0 0 38%;
        aspect-ratio: auto;
    }

    .mag-grid--section .mag-card__body {
        display: flex;
        align-items: center;
        padding: 12px 14px;
    }

    .mag-grid--section .mag-card__title {
        margin: 0;
        font-size: 16px;
    }

    .mag-grid--section .mag-card__excerpt {
        display: none;
    }

    .mag-section__head .mag-section__title {
        font-size: 22px;
    }

    .mag .mag-section__more {
        font-size: 14px;
    }

    /* Horizontal scroll instead of wrapping */
    .mag-topics {
        margin-left: -20px;
        margin-right: -20px;
    }

    .mag-topics__list {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 20px 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .mag-topics__list::-webkit-scrollbar {
        display: none;
    }

    .mag-grid--3,
    .mag-grid--2 {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .mag-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .mag-layout__aside {
        position: static;
    }

    .mag-cta--strip {
        flex-direction: column;
        align-items: flex-start;
        padding: 22px;
    }

    .mag-cta__title {
        font-size: 20px;
    }
}

/*
 * Single post, mobile markup (wp_is_mobile()): the title bubble comes first,
 * then one line of breadcrumbs and the topic bar, then the post image.
 */
.single-post .top-section .bubble:has(+ .mag-post-nav) {
    padding-bottom: 30px;
}

.single-post .top-section .mag-post-nav {
    padding-top: 14px;
}

.single-post .top-section .mag-post-nav + .b-lazy {
    margin-top: 0;
}

.single-post .entry .mag-post-nav .breadcrumbs {
    padding: 0 0 10px;
}

.single-post .entry .mag-post-nav #breadcrumbs,
.single-post .entry .mag-post-nav #breadcrumbs a,
.single-post .entry .mag-post-nav #breadcrumbs span {
    font-size: 12px;
    line-height: 1.5;
}

/* One line; a long post title ends with "..." */
.single-post .entry .mag-post-nav #breadcrumbs {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.single-post .entry .mag-post-nav .mag-topics {
    margin: 0 0 18px;
}

.single-post .entry .mag-post-nav .mag-topics__list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 20px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.single-post .entry .mag-post-nav .mag-topics__list::-webkit-scrollbar {
    display: none;
}

.single-post .entry .mag-post-nav .mag-topics__link {
    padding: 5px 12px;
    font-size: 12.5px;
}
