/*
 * tgc: "presidential editorial". A broadsheet look in navy, Old Glory red and newsprint white:
 * Playfair Display headlines, Source Serif 4 text, Libre Franklin labels, and newspaper rules.
 * Layout (from project.md): sticky header bar, footer, and a 1/3 intro + 2/3 content split that stacks
 * on narrow screens.
 */

/* Fonts: self-hosted (the CSP only allows same-origin fonts), latin subset, variable weight. OFL licences
   are next to the files. */

@font-face {
    font-family: "Playfair Display";
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url("fonts/playfair-display.woff2") format("woff2");
}

@font-face {
    font-family: "Source Serif 4";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/source-serif-4.woff2") format("woff2");
}

@font-face {
    font-family: "Source Serif 4";
    font-style: italic;
    font-weight: 400 700;
    font-display: swap;
    src: url("fonts/source-serif-4-italic.woff2") format("woff2");
}

@font-face {
    font-family: "Libre Franklin";
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("fonts/libre-franklin.woff2") format("woff2");
}

:root {
    --ink: #16181d;
    --navy: #0b2545;
    --navy-deep: #071a33;
    --red: #b31942;
    --paper: #fbf9f4;
    --muted: #5b6270;
    --hairline: #d9d4c7;
    --max-width: 72rem;
    --gutter: 1rem;
    --header-height: 3.25rem;

    --display: "Playfair Display", Georgia, "Times New Roman", serif;
    --text: "Source Serif 4", Georgia, "Times New Roman", serif;
    --label: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    /* Anchored headings clear the sticky header */
    scroll-padding-top: calc(var(--header-height) + 1rem);
}

/* A full-height column, so the footer sits at the bottom of short pages */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    font-family: var(--text);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper);
    text-rendering: optimizeLegibility;
}

a {
    color: var(--navy);
    text-decoration-color: color-mix(in srgb, var(--red) 55%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--red);
    text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
}

h1,
h2,
h3,
h4 {
    font-family: var(--display);
    line-height: 1.15;
    color: var(--navy);
    text-wrap: balance;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* Small capitals labels: section headings, datelines */

.label {
    margin: 0 0 1rem;
    padding-top: 0.6rem;
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1.2;
    text-transform: uppercase;
    color: var(--ink);
    border-top: 3px solid var(--ink);
}

.kicker {
    margin: 0 0 0.4rem;
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--red);
}

/* Header bar */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    color: #fff;
    background: var(--navy);
    border-top: 4px solid var(--red);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    min-height: var(--header-height);
}

/* Wraps under the site name on narrow screens rather than overflowing */
.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    padding: 0.4rem 0;
}

.site-name {
    font-family: var(--display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    text-decoration: none;
}

.site-name:hover {
    color: #fff;
}

.site-nav a {
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
}

.site-nav a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-color: var(--red);
    text-decoration-thickness: 2px;
}

.site-nav a:hover {
    color: #fff;
    text-decoration: underline;
    text-decoration-color: var(--red);
    text-decoration-thickness: 2px;
}

/* Nameplate (home page) */

.masthead {
    padding: 2.5rem 0 0;
    text-align: center;
}

.masthead__title {
    margin: 0;
    font-size: clamp(2.4rem, 8vw, 5rem);
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--ink);
}

.masthead__tagline {
    margin: 0.75rem 0 1.25rem;
    font-style: italic;
    font-size: 1.125rem;
    color: var(--muted);
}

.masthead__meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1.5rem;
    margin: 0;
    padding: 0.5rem 0;
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-top: 1px solid var(--ink);
    border-bottom: 4px double var(--ink);
}

/* Two-column page */

.page {
    flex: 1 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
    padding-top: 2.5rem;
    padding-bottom: 4rem;
}

@media (min-width: 48rem) {
    .page {
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        gap: 3rem;
    }

    /* The intro reads as a sidebar column, divided from the news by a rule */
    .intro {
        position: sticky;
        top: calc(var(--header-height) + 2rem);
        align-self: start;
    }

    .content {
        padding-left: 3rem;
        border-left: 1px solid var(--hairline);
    }
}

/* On narrow screens the intro comes first, so the posts follow it */
.intro__text {
    font-size: 1rem;
    color: var(--muted);
}

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

.intro__text h2,
.intro__text h3 {
    font-size: 1.25rem;
    color: var(--ink);
}

/* The author card under the introduction: portrait left, role, name and bio right */
.author-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 3px solid var(--ink);
}

.author-card__image {
    flex: none;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--hairline);
}

.author-card__text p {
    margin: 0;
}

.author-card__role {
    margin-bottom: 0.3rem !important;
    font-family: var(--label);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--red);
}

.author-card__name {
    font-family: var(--display);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.author-card__bio {
    margin-top: 0.4rem !important;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--muted);
}

/* Post list */

.post-summary {
    display: flow-root;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--hairline);
}

.post-summary:first-of-type {
    padding-top: 0.25rem;
}

.post-summary__title {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.post-summary__title a {
    color: inherit;
    text-decoration: none;
}

.post-summary__title a:hover {
    color: var(--red);
}

.post-summary__intro {
    color: #33373f;
}

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

.post-summary__intro > :last-child {
    margin-bottom: 0.5rem;
}

.post-summary__image {
    display: block;
    float: right;
    width: 36%;
    margin: 0.3rem 0 0.75rem 1.25rem;
}

.post-summary__image img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* The newest post leads, with a large headline and its picture across the column */
.post-summary--lead {
    padding-bottom: 2rem;
    border-bottom: 3px double var(--ink);
}

.post-summary--lead .post-summary__title {
    font-size: clamp(1.9rem, 4.5vw, 2.6rem);
    font-weight: 800;
}

.post-summary--lead .post-summary__intro {
    font-size: 1.15rem;
}

.post-summary--lead .post-summary__image {
    float: none;
    width: auto;
    margin: 0 0 1rem;
}

.post-summary--lead .post-summary__image img {
    aspect-ratio: auto;
}

@media (max-width: 30rem) {
    .post-summary__image {
        float: none;
        width: auto;
        margin: 0 0 0.75rem;
    }
}

.read-more-line {
    margin: 0;
}

.read-more {
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
}

.read-more:hover {
    text-decoration: underline;
}

.empty {
    font-style: italic;
    color: var(--muted);
}

/* Newer/older links below the post list; the page number stays centred whichever links there are */
.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    font-family: var(--label);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-top: 3px solid var(--ink);
}

.pagination__link[rel="prev"] {
    grid-column: 1;
    justify-self: start;
}

.pagination__status {
    grid-column: 2;
    color: var(--muted);
}

.pagination__link[rel="next"] {
    grid-column: 3;
    justify-self: end;
    text-align: right;
}

.pagination__link {
    font-weight: 700;
    text-decoration: none;
}

.pagination__link:hover {
    text-decoration: underline;
}


/* Post page */

.article {
    max-width: 42rem;
}

.article__header {
    margin-bottom: 1.75rem;
}

.article__title {
    margin: 0 0 1rem;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.article__standfirst {
    margin: 0;
    padding-bottom: 1.25rem;
    font-size: 1.25rem;
    line-height: 1.5;
    color: var(--muted);
    border-bottom: 1px solid var(--hairline);
}

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

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

.featured-image {
    display: block;
    width: 100%;
    margin: 0 0 2rem;
}

.article__body {
    font-size: 1.125rem;
    line-height: 1.75;
}

/* A drop cap on the opening paragraph */
.article__body > p:first-child::first-letter {
    float: left;
    margin: 0.08em 0.1em 0 0;
    font-family: var(--display);
    font-size: 3.6em;
    font-weight: 700;
    line-height: 0.8;
    color: var(--red);
}

.article__body h2 {
    margin: 2.25rem 0 0.75rem;
    font-size: 1.6rem;
}

.article__body h3 {
    margin: 2rem 0 0.5rem;
    font-size: 1.3rem;
}

.article__body h4 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.1rem;
}

.article__body img {
    display: block;
    margin: 2rem 0;
}

.article__body blockquote {
    margin: 2rem 0;
    padding: 0.25rem 0 0.25rem 1.25rem;
    font-family: var(--display);
    font-size: 1.35rem;
    font-style: italic;
    line-height: 1.45;
    color: var(--navy);
    border-left: 4px solid var(--red);
}

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

.article__body blockquote > :last-child {
    margin-bottom: 0;
}

.article__body hr {
    width: 6rem;
    margin: 2.5rem auto;
    border: 0;
    border-top: 3px double var(--ink);
}

.article__body pre,
.article__body code {
    font-size: 0.9em;
}

.article__body pre {
    overflow-x: auto;
    padding: 1rem;
    background: #f1ede3;
}

.article__body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.article__body th,
.article__body td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--hairline);
}

.article__body th {
    font-family: var(--label);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--ink);
}

.sources {
    margin-top: 3rem;
}

.sources__list {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.95rem;
}

.sources__list li {
    margin-bottom: 0.4rem;
}

.sources__list li::marker {
    font-family: var(--label);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--red);
}

.sources__list a {
    overflow-wrap: anywhere;
}

.back-link {
    margin-top: 2.5rem;
    font-family: var(--label);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.back-link a {
    text-decoration: none;
}

/* Updates (post.html.twig): cards appended after the post, oldest first, never mixed into it */

.updates {
    max-width: 42rem;
    margin-top: 3.5rem;
}

.update-card {
    margin: 0 0 1.25rem;
    padding: 1.25rem 1.5rem 1.5rem;
    background: #fff;
    border: 1px solid var(--hairline);
    border-top: 4px solid var(--red);
    box-shadow: 0 1px 2px rgba(7, 26, 51, 0.06);
}

.update-card__kicker {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.update-card__body {
    font-size: 1.0625rem;
    line-height: 1.7;
}

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

.update-card__body > :last-child {
    margin-bottom: 0;
}

.update-card__body h2,
.update-card__body h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.25rem;
}

.update-card__body img {
    display: block;
    margin: 1.25rem 0;
}

.update-card__body blockquote {
    margin: 1.25rem 0;
    padding-left: 1rem;
    font-style: italic;
    color: var(--navy);
    border-left: 3px solid var(--red);
}

.update-card__sources {
    margin-top: 1.25rem;
}

.update-card__sources-heading {
    margin-bottom: 0.6rem;
    padding-top: 0.5rem;
    font-size: 0.7rem;
    border-top-width: 1px;
}

/* Preview with drafts only: a strip above the header, and a yellow tag on each draft */
.preview-banner {
    margin: 0;
    padding: 0.5rem var(--gutter);
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
    color: var(--ink);
    background: #ffd84d;
}

.kicker__draft {
    padding: 0.1em 0.45em;
    color: var(--ink);
    background: #ffd84d;
}

/* A pinned post in the home page's list: a solid red tag */
.kicker__pinned {
    padding: 0.1em 0.45em;
    color: #fff;
    background: var(--red);
}

/* The "Updated" date in a post's dateline jumps to the updates */
.kicker__link {
    color: inherit;
    text-decoration-color: currentColor;
}

/* Share strip (share.html.twig) */

.share {
    margin-top: 3rem;
}

.share__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.share__list li[hidden] {
    display: none;
}

.share__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    color: var(--navy);
    background: transparent;
    border: 1px solid var(--navy);
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.share__link:hover,
.share__link:focus-visible {
    color: #fff;
    background: var(--navy);
}

.share__icon {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.share__status {
    margin: 0.6rem 0 0;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.share__status:empty {
    display: none;
}

/* Footer */

.site-footer {
    position: relative;
    /* Keeps the statue's z-index: -1 inside the footer, above its background */
    isolation: isolate;
    overflow: hidden;
    padding: 2.5rem 0 2rem;
    color: #c9d2de;
    background: var(--navy-deep);
    border-top: 4px solid var(--red);
}

/* A faint Statue of Liberty rising from the bottom edge, in line with the content's right edge.
   assets/liberty.png is cut out of "Sl-shadow.jpg" by Pascual De Ruvo (public domain, via Wikimedia Commons):
   white where the backlit statue is, transparent sky. */
.site-footer::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("liberty.png") right max(var(--gutter), calc(50% - 34rem)) bottom / auto 94% no-repeat;
    opacity: 0.09;
    pointer-events: none;
}

.site-footer__inner {
    text-align: center;
}

.site-footer p {
    margin: 0.25rem 0;
}

/* The US flag (assets/flag.svg), above the site name */
.site-footer__flag {
    display: block;
    width: 95px;
    height: auto;
    margin: 0 auto 1rem;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 4px 12px rgba(0, 0, 0, 0.35);
}

.site-footer__name {
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
}

.site-footer__tagline {
    font-style: italic;
}

/* The navigation pages again, as a centred row */
.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1.5rem;
    margin: 1.25rem 0 0;
    padding: 0;
    font-family: var(--label);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    list-style: none;
    text-transform: uppercase;
}

.footer-nav a {
    text-decoration: none;
}

.footer-nav a:hover,
.footer-nav a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-color: var(--red);
}

.site-footer__small {
    margin-top: 1.25rem !important;
    font-family: var(--label);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-footer a,
.site-footer .link-button {
    color: #fff;
}

.site-footer a:hover {
    color: #fff;
    text-decoration-color: currentColor;
}

/* Cookie consent banner (only rendered when the site has a Google tag) */

.cookie-consent {
    position: fixed;
    right: var(--gutter);
    bottom: var(--gutter);
    left: var(--gutter);
    z-index: 20;
    max-width: 40rem;
    margin: 0 auto;
    padding: 1.25rem;
    background: var(--paper);
    border: 1px solid var(--ink);
    border-top: 4px solid var(--red);
    box-shadow: 0 0.75rem 2rem rgba(7, 26, 51, 0.25);
}

.cookie-consent[hidden] {
    display: none;
}

.cookie-consent p {
    margin: 0 0 1rem;
}

.cookie-consent__actions {
    display: flex;
    gap: 0.5rem;
}

/* Equal prominence for both choices, so rejecting is as easy as accepting */
.cookie-consent button {
    min-width: 6rem;
    padding: 0.55rem 1.25rem;
    font-family: var(--label);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
    background: var(--navy);
    border: 1px solid var(--navy);
    cursor: pointer;
}

.cookie-consent button:hover {
    background: var(--navy-deep);
}

.link-button {
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--navy);
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
}

/* Utilities */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

@media print {
    .site-header,
    .share,
    .back-link,
    .cookie-consent {
        display: none;
    }

    .site-header {
        position: static;
    }

    body {
        background: #fff;
    }
}

/* A post's entry type and status (pills.html.twig), and the date its research is current to */
.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.pill {
    padding: 0.2em 0.7em;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--label);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.5;
    text-transform: uppercase;
}

.pill--type {
    color: var(--navy);
    border-color: var(--navy);
}

.pill--delivered { color: #fff; background: #1d6b3a; }
.pill--partly-delivered { color: #1d5b33; background: #d6eedc; }
.pill--in-progress { color: var(--navy); background: #dce6f5; }
.pill--stalled { color: #5c4300; background: #ffe7a8; }
.pill--abandoned { color: #3f444d; background: #e4e1d9; }
.pill--broken { color: #fff; background: var(--red); }
.pill--too-early { color: var(--muted); border-color: var(--hairline); }

.as-of {
    margin: 0 0 1rem;
    font-family: var(--label);
    font-size: 0.8rem;
    color: var(--muted);
}
