/* Patchwell media site — the whole visual layer.
 *
 * The rules this file implements are in DESIGN.md at the repository root.
 * Every colour is a token from the product's design system
 * (`patchwell/docs/design-system.md`), in both of its themes; the site adds
 * a display type scale and three page components, and no colour.
 *
 * Renamed on every change (site.2.css → site.3.css): /static is cached for a
 * week, so editing these bytes in place strands visitors on the old copy.
 */

/* ── Type ──────────────────────────────────────────────────────────────── */

/* The product's two faces, and no third. Latin subsets only, self-hosted.
 * Mona Sans is its weight axis alone (39 KB); the width axis would more than
 * double it for a range this site never sets. */
@font-face {
    font-family: "Mona Sans";
    src: url("/static/fonts/mona-sans-latin-wght.woff2") format("woff2-variations");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("/static/fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Mono";
    src: url("/static/fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* ── Tokens ────────────────────────────────────────────────────────────── */

:root {
    color-scheme: light dark;

    /* Palette — the product's six values, verbatim. */
    --ink: #1A1D21;
    --blue: #0B5FD0;
    --blue-content: #FFFFFF;
    --surface: #FFFFFF;
    --page: #F6F7F9;
    --rule: #D8DCE1;
    --muted: #606A75;
    --stitch: #9AA2AA;

    /* State — only ever on a state badge, never as decoration. */
    --passed: #1A7F44;
    --merged: #8250DF;
    --running: #9A6700;

    /* Avatar tints — avatars only. Three of the product's eight. */
    --tint-rose-bg: #FCE7F3;   --tint-rose-fg: #9D174D;
    --tint-teal-bg: #CCFBF1;   --tint-teal-fg: #115E59;
    --tint-indigo-bg: #E0E7FF; --tint-indigo-fg: #3730A3;

    --sans: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    --radius: 4px;
    --column: 1040px;
    --gutter: clamp(1.25rem, 4vw, 2.5rem);
}

/* Dark follows the visitor's system setting unless the header switch has
 * pinned a theme on <html data-theme>. The dark values are written twice —
 * once for the system, once for the switch — because a custom property can't
 * be shared between a media query and an attribute selector without JS. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #E4E7EA;
        --blue: #5B9DFF;
        --blue-content: #04101F;
        --surface: #151719;
        --page: #0E1013;
        --rule: #2A2F35;
        --muted: #8B949E;
        --stitch: #525B65;

        --passed: #2EA043;
        --merged: #A371F7;
        --running: #D29922;

        --tint-rose-bg: #4A1D34;   --tint-rose-fg: #F9A8D4;
        --tint-teal-bg: #113B38;   --tint-teal-fg: #5EEAD4;
        --tint-indigo-bg: #23264D; --tint-indigo-fg: #A5B4FC;
    }
}
:root[data-theme="dark"] {
    --ink: #E4E7EA;
    --blue: #5B9DFF;
    --blue-content: #04101F;
    --surface: #151719;
    --page: #0E1013;
    --rule: #2A2F35;
    --muted: #8B949E;
    --stitch: #525B65;

    --passed: #2EA043;
    --merged: #A371F7;
    --running: #D29922;

    --tint-rose-bg: #4A1D34;   --tint-rose-fg: #F9A8D4;
    --tint-teal-bg: #113B38;   --tint-teal-fg: #5EEAD4;
    --tint-indigo-bg: #23264D; --tint-indigo-fg: #A5B4FC;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ── Base ──────────────────────────────────────────────────────────────── */

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

/* The root stays at the browser default (the product learned this the hard
 * way); reading size is set on body, where it moves type and nothing else. */
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--page);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem; /* 17px — a reading page, not the app's 15px UI */
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }

::selection { background: color-mix(in oklab, var(--blue) 20%, transparent); }

/* Blue is the only thing you can interact with. */
a {
    color: var(--blue);
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    transition: color 120ms;
}
a:hover { color: color-mix(in oklab, var(--blue) 80%, var(--ink)); }

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 2px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.5rem 1rem;
    background: var(--surface);
    color: var(--ink);
}
.skip-link:focus { left: 0; z-index: 1; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Sans for what a person wrote. Mono for what the system assigned. */
.eyebrow {
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.ident {
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

/* ── Frame ─────────────────────────────────────────────────────────────── */

.wrap {
    width: 100%;
    max-width: calc(var(--column) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

/* The logo is the wordmark with its stitch — exactly the app's sidebar. The
 * navy square is the icon, for favicon-sized places only. */
.lockup {
    display: inline-flex;
    flex-direction: column;
    color: var(--ink);
    text-decoration: none;
}
.lockup:hover { color: var(--ink); }
.lockup-word {
    font-size: 1.1875rem;
    line-height: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.stitch-mark {
    display: block;
    width: 28px;
    height: 2px;
    margin-top: 6px;
    border-radius: 1px;
    background-image: repeating-linear-gradient(
        to right, var(--stitch) 0 7px, transparent 7px 12px);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9375rem;
}

/* The theme switch — the app's own control: a muted icon, moon in light and
 * sun in dark, that darkens to ink on hover. It is chrome, not a way into the
 * app, so it is not blue. */
.theme-toggle {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 120ms, background-color 120ms;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--ink); background: color-mix(in oklab, var(--rule) 45%, transparent); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

main { flex: 1 0 auto; }

.site-footer {
    margin-top: clamp(4rem, 10vw, 7rem);
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: 0.875rem;
}
.site-footer .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    padding-top: 2rem;
    padding-bottom: 2.5rem;
}
.site-footer .lockup-word { font-size: 1rem; }
.site-footer .stitch-mark { width: 22px; margin-top: 5px; }

/* ── Controls ──────────────────────────────────────────────────────────── */

.button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.125rem;
    border: 1px solid var(--blue);
    border-radius: var(--radius);
    background: var(--blue);
    color: var(--blue-content);
    font-size: 0.9375rem;
    line-height: 1.25rem;
    font-weight: 550;
    text-decoration: none;
    transition: background-color 120ms, border-color 120ms;
}
.button:hover {
    color: var(--blue-content);
    background: color-mix(in oklab, var(--blue) 86%, var(--ink));
    border-color: color-mix(in oklab, var(--blue) 86%, var(--ink));
}
.button-quiet {
    background: transparent;
    border-color: var(--rule);
    color: var(--blue);
}
.button-quiet:hover {
    background: var(--surface);
    border-color: var(--blue);
    color: var(--blue);
}
.button .arrow { transition: transform 120ms; }
.button:hover .arrow { transform: translateX(2px); }

/* ── Hero ──────────────────────────────────────────────────────────────── */

.hero .wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
    padding-top: clamp(2.5rem, 7vw, 5.5rem);
}
@media (min-width: 60rem) {
    .hero .wrap {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
        align-items: center;
        gap: 4rem;
    }
}

.display {
    margin-top: 1.25rem;
    font-size: clamp(2.375rem, 5.4vw, 3.875rem);
    line-height: 1.06;
    font-weight: 650;
    letter-spacing: -0.032em;
    text-wrap: balance;
}

.lede {
    margin-top: 1.5rem;
    max-width: 32rem;
    color: var(--muted);
    font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
    line-height: 1.6;
    text-wrap: pretty;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2.25rem;
}

/* ── The thread specimen ───────────────────────────────────────────────────
 * The product drawn with the product's own parts — a card, because this is
 * the one place on the page where a boundary helps: it says "this is the
 * app". The running stitch threads it, and sews itself once on load. */

.thread {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.thread-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rule);
}
.thread-title {
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 600;
}
.thread-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-top: 0.25rem;
    color: var(--muted);
}

.thread-body {
    --avatar: 28px;
    position: relative;
    list-style: none;
    padding: 1.25rem 1.25rem 1.5rem;
    display: grid;
    gap: 1.75rem;
}

/* The spine: 2px, 9px stitch, 6px gap — the product's measurements. It
 * starts at the first avatar and ends at the patch. */
.thread-body::before {
    content: "";
    position: absolute;
    left: calc(1.25rem + var(--avatar) / 2 - 1px);
    top: calc(1.25rem + var(--avatar) / 2);
    bottom: 1.5rem;
    width: 2px;
    border-radius: 1px;
    background-image: repeating-linear-gradient(
        to bottom, var(--stitch) 0 9px, transparent 9px 15px);
    animation: sew 640ms cubic-bezier(0.22, 1, 0.36, 1) 160ms both;
}
@keyframes sew {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

.node {
    position: relative; /* above the spine: the thread passes under the cloth */
    display: grid;
    grid-template-columns: var(--avatar) minmax(0, 1fr);
    gap: 0.875rem;
}

/* The seam ends at the patch: below the last marker, the cloth covers it. */
.node:last-child::after {
    content: "";
    position: absolute;
    left: 0;
    top: var(--avatar);
    bottom: -1.5rem;
    width: var(--avatar);
    background: var(--surface);
}

.node-who {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    line-height: var(--avatar);
    font-weight: 600;
    font-size: 0.875rem;
}
.node-who .ident { font-weight: 500; }
.node-who time {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 400;
}
.node p { color: var(--ink); }

/* Humans are circles; agents are squares. The tint tells people apart and
 * never tells kinds apart — the shape does that. */
.avatar {
    width: var(--avatar);
    height: var(--avatar);
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.6875rem;
    font-weight: 650;
    letter-spacing: 0.02em;
}
.avatar-agent { border-radius: var(--radius); font-family: var(--mono); font-weight: 500; }
.tint-rose { background: var(--tint-rose-bg); color: var(--tint-rose-fg); }
.tint-teal { background: var(--tint-teal-bg); color: var(--tint-teal-fg); }
.tint-indigo { background: var(--tint-indigo-bg); color: var(--tint-indigo-fg); }

/* The patch — where the seam ends. A plain square of cloth on the spine. */
.patch-dot {
    width: var(--avatar);
    height: var(--avatar);
    display: grid;
    place-items: center;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--merged);
}

.patch {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.75rem 0.875rem;
    display: grid;
    gap: 0.625rem;
    background: color-mix(in oklab, var(--rule) 22%, var(--surface));
}
.patch-title { font-weight: 600; font-size: 0.875rem; line-height: 1.4; }
.patch-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* Code in prose: a hairline and a derived ground, so it reads on either. */
code, .chip {
    font-family: var(--mono);
    font-size: 0.8125rem;
    padding: 0.0625rem 0.375rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--rule) 50%, var(--surface));
    white-space: nowrap;
}

/* State is never colour alone: an icon and a word, always. */
.state {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.125rem 0.5rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 500;
}
.state svg { width: 12px; height: 12px; flex: none; }
.state-passed { color: var(--passed); }
.state-merged { color: var(--merged); }
.state-env { color: var(--muted); }

/* ── Sections ──────────────────────────────────────────────────────────── */

.section { margin-top: clamp(4.5rem, 11vw, 8rem); }

.section-head { max-width: 40rem; }
.section-title {
    margin-top: 0.75rem;
    font-size: clamp(1.75rem, 3.4vw, 2.5rem);
    line-height: 1.12;
    font-weight: 650;
    letter-spacing: -0.025em;
    text-wrap: balance;
}
.section-lede {
    margin-top: 1rem;
    color: var(--muted);
    font-size: 1.125rem;
    text-wrap: pretty;
}

/* The seam — the one claim the page is built on, drawn as the thread's own
 * path. The stitch here draws the same thing the spine does: the route a
 * change takes. That is the only thing a stitch is ever allowed to draw. */
.seam {
    --step-gap: 2.25rem;
    list-style: none;
    padding: 0;
    margin-top: 2.5rem;
    display: grid;
    gap: 1rem;
    position: relative;
}
.seam li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.seam .chip { background: var(--surface); padding: 0.375rem 0.75rem; }
.seam li:last-child .chip { border-color: var(--ink); font-weight: 500; }
.seam-note { color: var(--muted); font-size: 0.875rem; }

/* Narrow: vertical, a spine down the left of the chips. */
.seam::before {
    content: "";
    position: absolute;
    left: 1.5rem;
    top: 1rem;
    bottom: 1rem;
    width: 2px;
    border-radius: 1px;
    background-image: repeating-linear-gradient(
        to bottom, var(--stitch) 0 9px, transparent 9px 15px);
    z-index: -1;
}
.seam { isolation: isolate; }

@media (min-width: 60rem) {
    .seam {
        grid-template-columns: repeat(7, auto);
        justify-content: space-between;
        gap: 0;
    }
    .seam li { flex-direction: column; align-items: flex-start; gap: 0.625rem; }
    .seam::before {
        left: 0.5rem;
        right: 0.5rem;
        top: calc(0.375rem + 0.75rem + 1px);
        bottom: auto;
        width: auto;
        height: 2px;
        background-image: repeating-linear-gradient(
            to right, var(--stitch) 0 9px, transparent 9px 15px);
    }
}

/* Features: flat rows on hairlines, not a wall of cards. */
.features {
    list-style: none;
    padding: 0;
    margin-top: 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    column-gap: 2.5rem;
}
.feature {
    padding: 1.5rem 0 2rem;
    border-top: 1px solid var(--rule);
}
.feature h3 {
    margin-top: 0.625rem;
    font-size: 1.125rem;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.feature p {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.9375rem;
}

/* Why: an editorial two-column — the heading holds, the argument scrolls. */
.why .wrap { display: grid; gap: 2rem; }
@media (min-width: 60rem) {
    .why .wrap { grid-template-columns: 20rem minmax(0, 1fr); gap: 4rem; }
    .why .section-head { position: sticky; top: 2rem; align-self: start; }
}
.why ul { list-style: none; padding: 0; }
.why li {
    padding: 1.5rem 0;
    border-top: 1px solid var(--rule);
    color: var(--muted);
}
.why li:last-child { border-bottom: 1px solid var(--rule); }
.why li strong {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--ink);
    font-size: 1.1875rem;
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.012em;
}

/* Closing call — the page's last word is the product's first action. */
.closing .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}
.closing-title {
    font-size: clamp(1.75rem, 3.4vw, 2.5rem);
    line-height: 1.12;
    font-weight: 650;
    letter-spacing: -0.025em;
}

/* ── Pricing ───────────────────────────────────────────────────────────────
 * Plans are flat columns on hairlines, like the feature rows — no cards. The
 * lead plan is marked the way the seam marks production: an ink line, not a
 * colour, plus a word. It has the page's one filled button. */

.pricing-head .wrap { padding-top: clamp(2.5rem, 7vw, 5.5rem); }
.pricing-head .display { max-width: 44rem; }

.plans-section { margin-top: clamp(3rem, 7vw, 4.5rem); }
.plans {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    gap: 0 2.5rem;
}
.plan {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem 0 2.5rem;
    border-top: 1px solid var(--rule);
}
.plan-lead { border-top: 2px solid var(--ink); padding-top: calc(1.5rem - 1px); }
.plan .eyebrow { display: flex; align-items: center; gap: 0.625rem; color: var(--ink); }
.plan-flag {
    padding: 0 0.375rem;
    border: 1px solid var(--ink);
    border-radius: var(--radius);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
}
.price { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.price-figure {
    font-size: clamp(2rem, 3.4vw, 2.5rem);
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -0.03em;
}
.price-unit { color: var(--muted); font-size: 0.9375rem; }
.plan-for {
    margin-top: 0.75rem;
    min-height: 3.2em;
    color: var(--muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}
.plan .button { margin-top: 1.5rem; }
.plan-list {
    list-style: none;
    padding: 0;
    margin-top: 1.75rem;
    display: grid;
    gap: 0.625rem;
    font-size: 0.9375rem;
    line-height: 1.5;
}
.plan-list li { position: relative; padding-left: 1.5rem; }
/* A tick, drawn in the stitch grey: included, not a state. */
.plan-list li::before {
    content: "";
    position: absolute;
    left: 0.125rem;
    top: 0.4em;
    width: 0.5rem;
    height: 0.3rem;
    border-left: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
}

/* ── 404 ───────────────────────────────────────────────────────────────── */

.lost .wrap { padding-top: clamp(3rem, 12vw, 8rem); max-width: 40rem; }
.lost .display { font-family: var(--mono); font-weight: 500; letter-spacing: -0.02em; }

/* ── Motion ────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
