/*
 * The news page (index.html) and the share page: masthead, the edition layout
 * (player and topic navigation next to the news), topics shown one at a time,
 * articles and the political spectrum of the sources.
 */

/* Masthead */

.masthead {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: clamp(2.5rem, 7vw, 5rem) var(--page-gutter) clamp(2rem, 5vw, 3.5rem);
}

.masthead-date {
    margin: 0 0 1.25rem;
    color: var(--color-muted);
    font-size: 0.9375rem;
}

.masthead-title {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(2.25rem, 1.2rem + 3.6vw, 3.5rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.masthead-title em {
    color: var(--color-accent);
    font-style: normal;
}

.masthead-claim {
    display: block;
    color: var(--color-muted);
}

/* Edition: sticky rail (player + section navigation) next to the news */

.edition {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    align-items: start;
    gap: var(--rail-gap);
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 var(--page-gutter) clamp(4rem, 8vw, 7rem);
}

.edition-rail {
    position: sticky;
    top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.toc-list {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    color: var(--color-muted);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: color 150ms ease;
}

.toc-link:hover,
.toc-link[aria-current="true"] {
    color: var(--color-ink);
}

.toc-time {
    font-size: 0.8125rem;
}

.toc-link.is-playing .toc-time {
    color: var(--color-accent);
}

/* Compact play/pause next to the section tabs, shown on small screens once playback started. */
.toc-play {
    display: none;
    place-items: center;
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-on-accent);
    cursor: pointer;
}

.toc-play .icon {
    width: 0.875rem;
    height: 0.875rem;
}

/*
 * Small screens: the rail dissolves (display: contents) so the player sits in the flow
 * and the topic tabs can stick right below the (sticky) site header.
 */
@media (max-width: 59.99rem) {
    .edition {
        display: block;
    }

    .edition-rail {
        display: contents;
    }

    .edition-toc {
        position: sticky;
        top: calc(var(--header-height) + 1px); /* below the header and its border */
        z-index: var(--layer-sticky);
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin: 1.5rem calc(-1 * var(--page-gutter)) 2.5rem;
        padding-left: var(--page-gutter);
        border-bottom: 1px solid var(--color-rule);
        background: var(--color-bg);
    }

    .toc-list {
        display: flex;
        gap: 1.25rem;
        padding-right: var(--page-gutter);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .toc-list::-webkit-scrollbar {
        display: none;
    }

    .toc-link {
        align-items: center;
        min-height: 3rem;
        padding: 0;
        border-bottom: 2px solid transparent;
        white-space: nowrap;
    }

    .toc-link[aria-current="true"] {
        border-bottom-color: var(--color-accent);
    }

    .toc-time {
        display: none;
    }

    body[data-audio] .toc-play {
        display: grid;
    }
}

/* Topics */

.topic {
    scroll-margin-top: 1.5rem;
}

/* main.js shows one topic at a time; without JavaScript all topics are listed one below the other. */
.topic:not([hidden]) + .topic:not([hidden]) {
    margin-top: 5rem;
}

.topic-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    padding-top: 1rem;
    border-top: 2px solid var(--color-ink);
}

.topic-heading {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.topic-title {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.topic-actions {
    display: flex;
    gap: 0.5rem;
}

.ai-label {
    display: inline-flex;
    align-items: center;
    height: 1.375rem;
    padding: 0 0.375rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
    color: var(--color-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

@media (max-width: 59.99rem) {
    .topic {
        /* Clears the sticky header and topic tabs when a topic is scrolled into view. */
        scroll-margin-top: calc(var(--header-height) + 4.25rem);
    }
}

/* Articles */

.article {
    padding: 2.25rem 0;
    border-bottom: 1px solid var(--color-rule);
}

.article:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.article-title {
    margin: 0 0 0.75rem;
    color: var(--color-ink);
    font-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.article-body {
    max-width: 38rem;
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.65;
    text-wrap: pretty;
    hyphens: auto;
}

/* Sources and spectrum sit in fixed columns, so they line up from article to article. */
.article-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 18rem);
    gap: 1.25rem 3rem;
    max-width: 38rem;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

@media (max-width: 35.99rem) {
    .article-meta {
        grid-template-columns: minmax(0, 1fr);
    }
}

.meta-label {
    margin: 0 0 0.375rem;
    color: var(--color-muted);
    font-size: 0.8125rem;
}

.meta-label strong {
    color: var(--color-text);
    font-weight: 600;
}

.source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.source-list a {
    color: var(--color-text);
    text-decoration-color: var(--color-rule);
}

.source-list a:hover {
    color: var(--color-accent);
    text-decoration-color: currentColor;
}

/* Political spectrum of the sources, 0 (left) to 100 (right), set via --score */

.spectrum {
    --spectrum-left: #d4574e;
    --spectrum-center: #8f8a82;
    --spectrum-right: #4b8bd6;
}

.spectrum-help {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline dotted;
    text-underline-offset: 0.25em;
    cursor: help;
}

.spectrum-help:hover {
    color: var(--color-ink);
}

.spectrum-scale {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--color-muted);
    font-size: 0.75rem;
}

.spectrum-track {
    position: relative;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--spectrum-left), var(--spectrum-center), var(--spectrum-right));
}

/* The centre tick */
.spectrum-track::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 50%;
    width: 1px;
    height: 10px;
    background: var(--color-muted);
}

.spectrum-marker {
    position: absolute;
    top: 50%;
    left: calc(var(--score) * 1%);
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--color-ink);
    box-shadow: 0 0 0 3px var(--color-bg);
    transform: translate(-50%, -50%);
}

/* Explanation of the spectrum score, a native popover shared by all articles */

.explainer {
    width: min(28rem, calc(100vw - 2rem));
    margin: auto;
    padding: 1.25rem 1.5rem 1.5rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.explainer::backdrop {
    background: rgb(0 0 0 / 0.45);
}

.explainer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.explainer-title {
    margin: 0.5rem 0 0;
    color: var(--color-ink);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
}

.explainer-header .icon-button {
    margin: -0.25rem -0.75rem 0 0;
}

.explainer p {
    margin: 0.75rem 0 0;
}

/* Share page: one topic with its own player */

.shared .masthead,
.shared-entry {
    max-width: 50rem;
}

.shared-entry {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    margin: 0 auto;
    padding: 0 var(--page-gutter) 6rem;
}
