/* The design language of motor.dev (services/motor/web/static/app.css), as sites/amp has it:
   Futura headings, black rules, flat gray shadows, and the Kandinsky palette. Keep the tokens in
   step with app.css. */

:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    /* Geometric display fonts with a system sans fallback. */
    --font-display: Futura, "Futura PT", "Century Gothic", "URW Gothic", "URW Gothic L", var(--font-sans);
    --tracking-caps: 0.08em;
    --color-text: #111;
    --color-muted: #4a4a4a;
    --color-line: #e4e4e4;
    --color-surface: #f2f2f2;
    --color-field: #fff;
    --color-background: #fefefe;
    /* The lightest gray with a contrast of 4.5:1 (WCAG AA) on the background, as app.css's. */
    --color-faint: #757575;
    /* The frame of panels, as in the console (console.css). */
    --color-frame: var(--color-faint);
    /* A solid rule that has to span the page, such as under a table's header, and the hairlines of
       the rotor divider, as on motor.dev's home page. */
    --color-rule: #cfcfcf;

    /* The sizes of the text: a post's prose, the text around it (the frame at the end and the
       footnotes), and the details (bylines and captions). */
    --text-prose: 1.1875rem;
    --text-aside: 1.0625rem;
    --text-detail: 0.9375rem;
    /* The gray shadow of buttons; only buttons are raised. */
    --shadow: 0.25rem 0.25rem 0 var(--color-line);
    /* The shadow inside a text field, as in the console (console.css). */
    --shadow-inset: inset 0.125rem 0.125rem 0 var(--color-line);
    --field-height: 2.5rem;

    /* Kandinsky palette. Contrast ratios: against background, white, and --color-text.
       WCAG AA minimums: 4.5:1 for text; 3:1 for lines, borders, and icons. */
    --color-cobalt: #1c4ba0;         /* 8.1:1, white 8.2:1, text 2.3:1 */
    --color-turquoise: #1a7f86;      /* 4.7:1, white 4.8:1, text 4.0:1 */
    --color-violet: #5b3a8e;         /* 8.5:1, white 8.6:1, text 2.2:1 */
    --color-rose-madder: #b8285f;    /* 5.9:1, white 6.0:1, text 3.2:1 */
    --color-vermilion: #e34234;      /* 4.1:1, white 4.1:1, text 4.6:1 */
    --color-cadmium-yellow: #f2c12e; /* 1.7:1, white 1.7:1, text 11.2:1: only for fills under dark text */
    --color-cadmium-yellow-line: #bc8c00; /* 3.0:1: the yellow for lines and borders */

    /* Links are bold, cobalt, and underlined. Cobalt is only 2.3:1 with --color-text, so the
       underline, not the color, marks a link in a paragraph (WCAG 1.4.1). */
    --color-link: var(--color-cobalt);
    --color-link-hover: #2563d3;
}

html {
    scroll-padding-top: 1.5rem;
    /* Every page keeps space for the scrollbar, so short pages and long pages have the same frame. */
    scrollbar-gutter: stable;
}

body {
    margin: 0 auto;
    max-width: 52rem;
    padding: 1.5rem;
    font-family: var(--font-sans);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-background);
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    /* Futura has no semibold; use medium. */
    font-weight: 500;
    line-height: 1.15;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.35;
}

h2 {
    margin: 2.5rem 0 1rem;
    font-size: 1.75rem;
}

h3 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.125rem;
}

h4 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1rem;
}

/* The first paragraph after the title of a page leads into it. */
main > h1 + p {
    font-size: 1.1875rem;
    line-height: 1.55;
}

li + li {
    margin-top: 0.375rem;
}

a {
    color: var(--color-link);
    font-weight: 600;
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.25em;
    transition: color 150ms ease;
}

a:hover {
    --color-link: var(--color-link-hover);
}

a:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

/* A heading that links to itself keeps the color of the text. */
h2 a,
h3 a {
    color: inherit;
}

/* The logo and the main navigation. */
body > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 3rem;
}

/* Motor's logo, to Motor's site, then a rule and Thoughts, to the blog's home, as the community
   forum's header has them (services/motor/web/static/community.css). Both keep the color of the
   text, without an underline. */
.home {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.home a {
    color: var(--color-text);
    font: 500 1.75rem/1 var(--font-display);
    text-decoration-line: none;
}

.home a:hover {
    opacity: 0.7;
}

.home svg {
    display: block;
    width: auto;
    height: 1.75rem;
}

.divider {
    width: 1px;
    height: 1.75rem;
    background: var(--color-text);
    opacity: 0.3;
}

body > header ul {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

body > header li + li {
    margin-top: 0;
}

body > header nav a {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 500;
    white-space: nowrap;
}

/* The link of the page that is open is black, without an underline. */
body > header nav a[aria-current="page"],
body > footer a[aria-current="page"] {
    color: var(--color-text);
    text-decoration-line: none;
}

/* The copyright line and the footer links. */
body > footer {
    margin-top: 3rem;
    color: var(--color-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 1.25rem;
}

body > footer ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

body > footer li + li {
    margin-top: 0;
}

body > footer a {
    font-weight: 500;
}

/* Code: mono text, and a block of code on the gray surface with a black rule at the left. */
code {
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

pre {
    margin: 0.75rem 0 1.25rem;
    padding: 0.875rem 1rem;
    overflow-x: auto;
    border-left: 4px solid var(--color-text);
    background: var(--color-surface);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.55;
}

pre code {
    font-size: inherit;
}

/* A quotation or a note: the text on the gray surface, with a turquoise rule at the left. */
blockquote {
    margin: 1.25rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--color-turquoise);
    background: var(--color-surface);
}

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

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

table {
    width: 100%;
    margin: 0 0 1rem;
    border-collapse: collapse;
}

/* A wide table scrolls on its own, so the page doesn't scroll sideways. */
@media (max-width: 40rem) {
    table {
        display: block;
        overflow-x: auto;
    }
}

th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-line);
    text-align: left;
    vertical-align: baseline;
}

th {
    border-bottom: 1px solid var(--color-rule);
    font: 500 0.75rem var(--font-display);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--color-muted);
}

hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--color-rule);
}

img {
    max-width: 100%;
}

/* The divider between the parts of a page, as on motor.dev's home page (app.css's
   .product-divider): the rotor of the logo between two hairlines that fade at their ends. */
.rotor-divider {
    width: calc(100% / 3);
    margin: 2.5rem auto;
    opacity: 0.7;
}

.rotor-divider svg {
    display: block;
    width: 100%;
    height: auto;
    mask-image: linear-gradient(to right, transparent, #000 30%, #000 70%, transparent);
}

.rotor-divider .rule {
    stroke: var(--color-rule);
    stroke-width: 1;
}

.rotor-divider .rotor {
    fill: var(--color-cobalt);
}

.rotor-divider .hub {
    fill: var(--color-background);
}

/* The rotor turns clockwise, slowly, as a prayer wheel does. Its color goes once around the
   palette in hue order, and each color stays a while before the next. Yellow is the yellow for
   lines, because the fill yellow is too faint on the background. divider.js speeds up both while
   the pointer is over a divider. */
@media (prefers-reduced-motion: no-preference) {
    .rotor-divider .turn {
        transform-box: view-box;
        transform-origin: 120px 12px;
        animation: rotor_turn 16s linear infinite;
    }

    .rotor-divider .rotor {
        animation: rotor_colors 36s ease-in-out infinite;
    }
}

@keyframes rotor_turn {
    to { transform: rotate(1turn); }
}

@keyframes rotor_colors {
    0%, 8%    { fill: var(--color-cobalt); }
    17%, 25%  { fill: var(--color-violet); }
    33%, 42%  { fill: var(--color-rose-madder); }
    50%, 58%  { fill: var(--color-vermilion); }
    67%, 75%  { fill: var(--color-cadmium-yellow-line); }
    83%, 92%  { fill: var(--color-turquoise); }
    100%      { fill: var(--color-cobalt); }
}

/* An empty state is text, without a frame. */
.empty {
    margin: 0;
}

/* The list of posts, with a rotor divider between two posts, and no rule before the first. */
.posts {
    margin: 0;
    padding: 0;
    list-style: none;
}

.posts > li + li {
    margin-top: 0;
}

.posts article {
    padding: 0;
}

.posts h2 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

/* A title keeps the heading's weight: Futura's bold is too heavy at this size. */
.posts h2 a {
    font-weight: inherit;
    text-decoration-line: none;
}

.posts h2 a:hover {
    text-decoration-line: underline;
}

.posts article > p:last-child {
    margin: 0;
}

/* The authors, the date, and the reading time of a post. */
.byline {
    margin: 0 0 0.75rem;
    color: var(--color-muted);
    font-size: var(--text-detail);
}

.byline a {
    color: var(--color-text);
}

.draft {
    margin-left: 0.5rem;
    padding: 0.125rem 0.5rem;
    background: var(--color-cadmium-yellow);
    color: var(--color-text);
    font: 500 0.75rem var(--font-display);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
}

/* A post: the title and the byline, a divider, and the text. */

.post > header h1 {
    margin: 0 0 0.75rem;
}

.post > header p {
    margin: 0;
}

.updated {
    color: var(--color-muted);
    font-size: var(--text-detail);
}

.post .content {
    font-size: var(--text-prose);
    line-height: 1.65;
}

.post .content h2,
.post .content h3,
.post .content h4 {
    line-height: 1.25;
}

.post .content code {
    font-size: 0.875em;
}

.post .content pre {
    font-size: 0.875rem;
}

.post .content pre code {
    font-size: inherit;
}

.post .content img {
    display: block;
    height: auto;
    margin: 1.5rem 0;
    border: 2px solid var(--color-text);
}

.post .content figure {
    margin: 1.5rem 0;
}

.post .content figcaption {
    color: var(--color-muted);
    font-family: var(--font-sans);
    font-size: var(--text-detail);
}

/* The footnotes, after their divider (the rule that goldmark puts first is one). */
.footnotes {
    font-size: var(--text-aside);
}

/* The frame at the end of a post and of the index: the standard text (standard.md) and the form
   that subscribes. A gray frame, as the console's panels have (console.css's
   --color-frame): black frames and shadows are for buttons. Its text is one size. */
.closing {
    margin-top: 3rem;
    padding: 1.25rem 1.5rem;
    border: 2px solid var(--color-frame);
    font-size: var(--text-aside);
}

.post + .closing {
    margin-top: 2.5rem;
}

.standard > :first-child,
.subscribe > :first-child {
    margin-top: 0;
}

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

/* The form, after the standard text and a soft rule. */
.standard + .subscribe {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-line);
}

.subscribe h2 {
    margin: 0 0 0.25rem;
    font-size: var(--text-aside);
}

.subscribe p {
    margin: 0 0 0.75rem;
    color: var(--color-muted);
}

.subscribe-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* A text field as the console's: set in, with its shadow inside the border, and the height of the
   button beside it (console.css). */
.subscribe input[type="email"] {
    box-sizing: border-box;
    flex: 1 1 16rem;
    min-width: 0;
    height: var(--field-height);
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--color-muted);
    border-radius: 0;
    background: var(--color-field);
    box-shadow: var(--shadow-inset);
    color: var(--color-text);
    font: inherit;
}

.subscribe input[type="email"]:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

.subscribe ::placeholder {
    color: var(--color-faint);
}

/* The button of motor.dev (app.css's .button), the height of a field. */
.button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--field-height);
    padding: 0 1.25rem;
    border: 2px solid var(--color-text);
    background: var(--color-background);
    box-shadow: var(--shadow);
    color: var(--color-text);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: var(--text-aside);
    font-weight: 500;
    line-height: 1.25;
    transition: background-color 150ms ease;
}

.button:hover {
    background: var(--color-surface);
}

.button:active {
    box-shadow: none;
    transform: translate(0.25rem, 0.25rem);
}

.button:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

/* The field for bots, out of sight and out of the order of focus. */
.trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Text for screen readers only. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* The archives: the posts of each year, with their dates. */
.year h2 {
    margin: 2.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-rule);
}

.archive {
    margin: 0;
    padding: 0;
    list-style: none;
}

.archive li {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-line);
}

.archive li + li {
    margin-top: 0;
}

.archive time {
    color: var(--color-muted);
}

@media (max-width: 40rem) {
    .archive li {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

/* The authors page, and the header of an author's page. */
.authors {
    margin: 2rem 0 0;
    padding: 0;
    list-style: none;
}

.authors > li {
    padding: 1.25rem 0;
    border-top: 1px solid var(--color-rule);
}

.authors > li + li {
    margin-top: 0;
}

.authors h2 {
    margin: 0 0 0.25rem;
}

.authors p,
.author .role {
    margin: 0;
    color: var(--color-muted);
}

header.author {
    margin-bottom: 1rem;
}

header.author h1 {
    margin-bottom: 0.25rem;
}

.bio {
    margin-top: 1rem;
}

@media (max-width: 40rem) {
    body {
        padding: 1rem;
    }

    body > header {
        flex-wrap: wrap;
        margin-bottom: 2rem;
    }

    body > header ul {
        gap: 1rem;
    }

    /* The divider is wider, so that its rotor stays the size it has on a computer. */
    .rotor-divider {
        width: 60%;
    }

    /* The logo is smaller, so that Archives stays on its line. */
    .home {
        gap: 0.625rem;
    }

    .home a {
        font-size: 1.375rem;
    }

    .home svg,
    .divider {
        height: 1.375rem;
    }

    h1 {
        font-size: 2rem;
    }

    .posts h2 {
        font-size: 1.5rem;
    }

    .post .content {
        font-size: 1.125rem;
    }
}
