/*
 * Marketing shell.
 *
 * Structure and behaviour shared by the landing page and every subpage under
 * /content/. Themes supply values only.
 *
 * RULE: no raw colour, font family or container width in this file. Every such
 * value resolves through a --m-* token declared by the active theme. A raw hex
 * here is a bug — it is invisible until a second theme exists.
 *
 * See docs/dev/marketing-design-system.md.
 */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    overflow-x: hidden;
    background: var(--m-surface);
    color: var(--m-ink);
    font-family: var(--m-font-body);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

:focus-visible {
    outline: 3px solid var(--m-highlight);
    outline-offset: 4px;
}

.material-symbols-outlined {
    font-variation-settings: "FILL" 0, "wght" 550, "GRAD" 0, "opsz" 24;
    vertical-align: middle;
}

.container {
    width: min(calc(100% - 2rem), var(--m-content-width));
    margin: 0 auto;
}

.skip-link {
    position: fixed;
    z-index: 20;
    top: -5rem;
    left: 1rem;
    padding: 0.7rem 0.9rem;
    background: var(--m-ink);
    color: var(--m-surface-raised);
    border-radius: 0 0 var(--m-radius-sm) var(--m-radius-sm);
}
.skip-link:focus { top: 0; }

/* --- Header ------------------------------------------------------------- */

.site-header { position: relative; z-index: 10; background: var(--m-surface-alt); }
.site-header__inner {
    min-height: 4.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--m-ink);
    font-size: 0.95rem;
    font-weight: 750;
    letter-spacing: 0.015em;
}
.brand__mark { color: var(--m-accent); font-size: 1.7rem; }

.header-nav {
    display: none;
    align-items: center;
    gap: 1.75rem;
    color: var(--m-ink-muted);
    font-size: 0.875rem;
    font-weight: 550;
}
.header-nav a { position: relative; padding: 0.35rem 0; }
.header-nav a::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0.08rem;
    left: 0;
    height: 1px;
    background: var(--m-accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 190ms ease;
}
.header-nav a:hover { color: var(--m-ink); }
.header-nav a:hover::after { transform: scaleX(1); transform-origin: left; }
.header-nav a[aria-current="page"] { color: var(--m-ink); }
.header-nav a[aria-current="page"]::after { transform: scaleX(1); }

.header-actions { display: flex; align-items: center; gap: 0.45rem; }

/* --- Language switcher -------------------------------------------------- */

.m-lang-switch { display: inline-flex; align-items: center; gap: 0.15rem; }

.m-lang-switch__item {
    padding: 0.25rem 0.5rem;
    border-radius: var(--m-radius-sm);
    color: var(--m-ink-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

a.m-lang-switch__item:hover { color: var(--m-ink); background: var(--m-surface-sunken); }
.m-lang-switch__item.is-current { color: var(--m-ink); background: var(--m-surface-sunken); }

/* A language with no live counterpart stays visible but inert: a reader should
   be able to see that a translation is missing rather than guess. */
.m-lang-switch__item.is-missing { opacity: 0.45; cursor: not-allowed; }

/* --- Buttons ------------------------------------------------------------ */

.button {
    min-height: 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--m-radius);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.005em;
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease,
                color 180ms ease, border-color 180ms ease;
}
.button--primary {
    background: var(--m-accent);
    color: var(--m-accent-contrast);
    box-shadow: 0 0.55rem 0 var(--m-accent-deep);
}
.button--primary:hover {
    background: var(--m-accent-deep);
    box-shadow: 0 0.3rem 0 var(--m-accent-deep);
    transform: translateY(0.25rem);
}
.button--secondary {
    border-color: var(--m-ink);
    background: transparent;
    color: var(--m-ink);
}
.button--secondary:hover {
    background: var(--m-surface-raised);
    transform: translateY(-0.14rem) rotate(-1deg);
    box-shadow: 0 0.45rem 0 var(--m-surface-sunken);
}
.button__icon { font-size: 1.1rem; transition: transform 180ms ease; }
.button:hover .button__icon { transform: translateX(0.18rem); }

.header-actions .button--secondary { display: none; }

/* --- Section rhythm ----------------------------------------------------- */

.section { padding: clamp(5rem, 10vw, 9rem) 0; }

.section-kicker {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    color: var(--m-accent);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.section-kicker::before { content: ""; width: 1.6rem; height: 1px; background: currentColor; }

.section-heading {
    max-width: 42rem;
    margin: 1rem 0 0;
    font-family: var(--m-font-display);
    font-size: clamp(2.65rem, 5vw, 4.85rem);
    font-weight: 400;
    line-height: 0.98;
    text-wrap: balance;
}

.section-intro {
    max-width: 35rem;
    margin: 1.2rem 0 0;
    color: var(--m-ink-muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
    padding: 2rem 0 max(2rem, env(safe-area-inset-bottom));
    background: var(--m-surface);
    border-top: 1px solid var(--m-line);
}
.footer__inner {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    color: var(--m-ink-muted);
    font-size: 0.875rem;
}
.footer__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--m-ink);
    font-weight: 800;
}
.footer__brand .material-symbols-outlined { color: var(--m-accent); }
.footer__links { display: flex; flex-wrap: wrap; gap: 1rem 1.35rem; }
.footer__links a:hover { color: var(--m-accent); }

/* --- Reveal ------------------------------------------------------------- */

.js .reveal {
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity 650ms ease, transform 650ms cubic-bezier(.2, .8, .2, 1);
}
.js .reveal.is-visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 80ms; }
.reveal-delay-2 { transition-delay: 160ms; }

/* --- Content pages ------------------------------------------------------

   Every /content/ page and article renders through .m-article + .m-prose. This
   is the whole subpage vocabulary: themes contribute tokens, not layout, so a
   new theme gets readable articles with no extra CSS.

   .m-prose styles the full set of elements Markdown can emit, not just the ones
   that happen to appear in today's articles. An unstyled <table> or <figure>
   discovered in production is a theme bug that should never have been possible.
--------------------------------------------------------------------------- */

.m-article {
    padding-block: 3rem 4.5rem;
    background: var(--m-surface);
}

.m-article__header {
    max-width: var(--m-prose-width);
    margin-inline: auto;
    margin-bottom: 2.5rem;
}

.m-article__title {
    font-family: var(--m-font-display);
    font-weight: 400;
    font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem);
    line-height: 1.1;
    color: var(--m-ink);
    margin: 0;
}

.m-article__lede {
    margin: 1rem 0 0;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--m-ink-muted);
}

.m-article__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 1.25rem 0 0;
    font-size: 0.875rem;
    color: var(--m-ink-muted);
}

.m-article__meta a { color: inherit; }

/* Drafts are reachable only in development, so this banner exists to make an
   unpublished page unmistakable rather than to look good. */
.m-draft {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
    padding: 0.65rem 0.9rem;
    border: 1px dashed var(--m-line);
    border-radius: var(--m-radius-sm);
    background: var(--m-surface-alt);
    font-size: 0.875rem;
    color: var(--m-ink-muted);
}

.m-draft .material-symbols-outlined { font-size: 1.15rem; }

/* --- Prose --------------------------------------------------------------- */

.m-prose {
    max-width: var(--m-prose-width);
    margin-inline: auto;
    color: var(--m-prose-ink);
    font-family: var(--m-font-body);
    font-size: 1.0625rem;
    line-height: 1.7;
}

.m-prose > :first-child { margin-top: 0; }
.m-prose > :last-child { margin-bottom: 0; }

.m-prose h2,
.m-prose h3,
.m-prose h4 {
    font-family: var(--m-font-display);
    font-weight: 400;
    color: var(--m-ink);
    line-height: 1.25;
    /* Scroll anchoring: an in-page link must not land the heading under the
       sticky header. */
    scroll-margin-top: 5rem;
}

.m-prose h2 { font-size: 1.75rem; margin: 2.75rem 0 1rem; }
.m-prose h3 { font-size: 1.3125rem; margin: 2.25rem 0 0.75rem; }
.m-prose h4 {
    font-family: var(--m-font-body);
    font-weight: 600;
    font-size: 1.0625rem;
    letter-spacing: 0.01em;
    margin: 1.75rem 0 0.5rem;
}

.m-prose p { margin: 0 0 1.25rem; }

.m-prose a {
    color: var(--m-accent);
    text-decoration: underline;
    text-underline-offset: 0.16em;
    text-decoration-thickness: 0.06em;
    transition: color var(--m-duration) var(--m-ease);
}

.m-prose a:hover { color: var(--m-accent-deep); }

.m-prose strong { font-weight: 600; color: var(--m-ink); }
.m-prose em { font-style: italic; }

.m-prose ul,
.m-prose ol {
    margin: 0 0 1.25rem;
    padding-left: 1.35rem;
}

.m-prose li { margin-bottom: 0.4rem; }
.m-prose li::marker { color: var(--m-ink-muted); }
.m-prose li > ul,
.m-prose li > ol { margin-top: 0.4rem; margin-bottom: 0.4rem; }

.m-prose dl { margin: 0 0 1.25rem; }
.m-prose dt { font-weight: 600; color: var(--m-ink); }
.m-prose dd { margin: 0 0 0.75rem 1.35rem; }

.m-prose blockquote {
    margin: 1.75rem 0;
    padding: 0.25rem 0 0.25rem 1.25rem;
    border-left: 3px solid var(--m-highlight);
    color: var(--m-ink-muted);
    font-style: italic;
}

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

.m-prose hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--m-line);
}

.m-prose img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--m-radius);
}

.m-prose figure { margin: 2rem 0; }

.m-prose figcaption {
    margin-top: 0.6rem;
    font-size: 0.875rem;
    color: var(--m-ink-muted);
    text-align: center;
}

.m-prose code {
    padding: 0.12em 0.36em;
    border-radius: var(--m-radius-sm);
    background: var(--m-surface-sunken);
    font-size: 0.9em;
    font-family: var(--m-font-mono);
}

.m-prose pre {
    margin: 1.75rem 0;
    padding: 1rem 1.15rem;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius);
    background: var(--m-surface-alt);
    overflow-x: auto;
    line-height: 1.55;
}

.m-prose pre code {
    padding: 0;
    background: none;
    font-size: 0.875rem;
}

/* A wide table has to scroll inside itself: the page body must never scroll
   sideways on a phone. */
.m-prose table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: 1.75rem 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.m-prose th,
.m-prose td {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--m-line);
    text-align: left;
    vertical-align: top;
}

.m-prose th {
    background: var(--m-surface-alt);
    font-weight: 600;
    color: var(--m-ink);
}

.m-prose caption {
    margin-bottom: 0.6rem;
    font-size: 0.875rem;
    color: var(--m-ink-muted);
    text-align: left;
}

.m-prose kbd {
    padding: 0.1em 0.4em;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius-sm);
    background: var(--m-surface-raised);
    font-size: 0.85em;
}

.m-prose mark {
    background: var(--m-highlight-soft);
    color: var(--m-highlight-contrast);
}

.m-prose abbr[title] { text-decoration: underline dotted; cursor: help; }

/* Footnotes, as emitted by the Python-Markdown `footnotes` extension. */
.m-prose sup[id^="fnref"] a { text-decoration: none; }

.m-prose .footnote {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--m-line);
    font-size: 0.9375rem;
    color: var(--m-ink-muted);
}

.m-prose .footnote ol { padding-left: 1.15rem; }
.m-prose .footnote-backref { text-decoration: none; }

/* Table of contents, as emitted by the `toc` extension. */
.m-prose .toc {
    margin: 0 0 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius);
    background: var(--m-surface-alt);
}

.m-prose .toc ul { margin: 0; padding-left: 1.15rem; list-style: none; }
.m-prose .toc > ul { padding-left: 0; }
.m-prose .toc a { text-decoration: none; }
.m-prose .toc a:hover { text-decoration: underline; }

/* --- Collection index ---------------------------------------------------- */

.m-index {
    padding-block: 3rem 4.5rem;
    background: var(--m-surface);
}

.m-index__header {
    max-width: var(--m-prose-width);
    margin: 0 auto 2.5rem;
}

.m-index__title {
    margin: 0;
    font-family: var(--m-font-display);
    font-weight: 400;
    font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem);
    line-height: 1.1;
    color: var(--m-ink);
}

.m-index__lede {
    margin: 0.75rem 0 0;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--m-ink-muted);
}

.m-index__empty {
    max-width: var(--m-prose-width);
    margin-inline: auto;
    color: var(--m-ink-muted);
}

.m-card-grid {
    display: grid;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.m-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius-lg);
    background: var(--m-surface-raised);
    transition: transform var(--m-duration) var(--m-ease), box-shadow var(--m-duration) var(--m-ease);
}

.m-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 1.5rem var(--m-shadow);
}

/* The whole card is the target; the anchor covers it so a click anywhere in the
   title/excerpt area navigates, without nesting interactive elements. */
.m-card__link {
    text-decoration: none;
    color: inherit;
}

.m-card__image {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: var(--m-radius);
    object-fit: cover;
    aspect-ratio: 16 / 9;
}

.m-card__title {
    margin: 0;
    font-family: var(--m-font-display);
    font-weight: 400;
    font-size: 1.375rem;
    line-height: 1.25;
    color: var(--m-ink);
}

.m-card__excerpt {
    margin: 0.6rem 0 0;
    color: var(--m-ink-muted);
    line-height: 1.6;
}

.m-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.15rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--m-line);
    font-size: 0.8125rem;
    color: var(--m-ink-muted);
}

.m-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 3rem;
    font-size: 0.9375rem;
}

.m-pagination__link {
    padding: 0.55rem 1rem;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius);
    color: var(--m-accent);
    text-decoration: none;
    font-weight: 600;
}

.m-pagination__link:hover { background: var(--m-surface-alt); }
.m-pagination__status { color: var(--m-ink-muted); }

/* --- Article extras ------------------------------------------------------ */

.m-article__eyebrow {
    margin: 0 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.m-article__eyebrow a {
    color: var(--m-accent);
    text-decoration: none;
}

.m-article__eyebrow a:hover { text-decoration: underline; }

.m-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.m-tag {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--m-highlight-soft);
    color: var(--m-highlight-contrast);
    font-size: 0.75rem;
    font-weight: 600;
}

.m-prev-next {
    display: grid;
    gap: 1rem;
    max-width: var(--m-prose-width);
    margin: 3.5rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--m-line);
}

.m-prev-next__link {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius);
    text-decoration: none;
    transition: background-color var(--m-duration) var(--m-ease);
}

.m-prev-next__link:hover { background: var(--m-surface-alt); }
.m-prev-next__link--next { text-align: right; }

.m-prev-next__label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--m-ink-muted);
}

.m-prev-next__title {
    font-family: var(--m-font-display);
    font-size: 1.0625rem;
    line-height: 1.3;
    color: var(--m-ink);
}

.m-back {
    max-width: var(--m-prose-width);
    margin: 1.5rem auto 0;
    font-size: 0.9375rem;
}

.m-back a { color: var(--m-accent); }

/* --- Breakpoints -------------------------------------------------------- */

@media (min-width: 640px) {
    .container { width: min(calc(100% - 3rem), var(--m-content-width)); }
    .m-article { padding-block: 4rem 6rem; }
    .m-index { padding-block: 4rem 6rem; }
    .m-card-grid { grid-template-columns: repeat(2, 1fr); }
    .m-prev-next { grid-template-columns: 1fr 1fr; }
    .header-actions .button--secondary { display: inline-flex; }
    .footer__inner { flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (min-width: 900px) {
    .header-nav { display: flex; }
    .m-card-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 639px) {
    /* Matches the pre-shell landing: the CTA pair drops on phones. The language
       switcher sits outside .header-actions so it survives. */
    .header-actions { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .js .reveal { opacity: 1; transform: none; }
}
