/* Papers — the design system for pages.cory.land.
   Ported from the email app that set the house style: pure white canvas,
   zinc neutrals, hairline borders, Geist for chrome, one serif reserved for
   mastheads, and a single blue accent that appears only on live or
   interactive affordances. Pages build from these tokens and roles; a page
   may add a short style block for its own layout, but never new colors,
   new type sizes, or new motion curves. */

@font-face {
    font-family: "Geist";
    src: url("/fonts/Geist-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist Mono";
    src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light;

    --background: hsl(0 0% 100%);
    --foreground: hsl(240 10% 3.9%);
    --secondary: hsl(240 4.8% 95.9%);
    --muted-foreground: hsl(240 3.8% 46.1%);
    --subtle-foreground: hsl(240 5% 64.9%);
    --border: hsl(240 5.9% 90%);
    --border-strong: hsl(240 5.9% 82%);
    --surface: hsl(240 4.8% 98.5%);

    /* Monochrome accent: interactive and live affordances (focus ring,
       sliders, progress, today-markers) use the foreground itself, shadcn
       style. Color survives only where it carries meaning — destructive,
       warning, success, and data-viz category hues. */
    --brand: hsl(240 5.9% 10%);
    --brand-soft: hsl(240 5.9% 10% / 0.05);
    --destructive: hsl(0 72% 51%);
    --destructive-soft: hsl(0 72% 51% / 0.07);
    --success: hsl(142 71% 36%);
    --success-soft: hsl(142 71% 36% / 0.08);
    --warning: hsl(38 92% 40%);
    --warning-soft: hsl(45 93% 47% / 0.1);

    --radius: 8px;
    --radius-sm: 6px;

    --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
    /* The one serif: mastheads and reading prose. Chrome stays Geist. */
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

    /* Motion spec: two durations, one curve. */
    --motion-fast: 140ms;
    --motion-settle: 240ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);

    /* Page widths: prose reads at reading width, tools at tool width, and
       only surfaces that earn it (dashboards, charts, split panes) go wide. */
    --w-reading: 760px;
    --w-tool: 920px;
    --w-wide: 1140px;
}

/* ---------------------------------------------------------------- base */

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

html {
    height: 100%;
    background: var(--background);
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "rlig" 1, "calt" 1, "ss01" 1, "cv11" 1;
    /* Numbers hold their width as they update (counts, times, scores). */
    font-variant-numeric: tabular-nums;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: hsl(240 10% 3.9% / 0.12);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid var(--background);
    border-radius: 999px;
}

a {
    color: var(--foreground);
    text-decoration-color: var(--border-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

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

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

h1, h2, h3, h4 {
    margin: 0;
    text-wrap: balance;
}

p {
    margin: 0;
}

/* ------------------------------------------------------------ topbar
   Injected by site-shell.js on every page. */

.site-topbar {
    position: relative;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: hsl(0 0% 100% / 0.94);
    backdrop-filter: blur(16px);
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--foreground);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.site-brand:hover {
    color: var(--foreground);
}

.site-mark {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--secondary);
}

.site-mark svg {
    width: 16px;
    height: 16px;
    color: var(--foreground);
}

.site-context {
    min-width: 0;
    overflow: hidden;
    padding-left: 12px;
    border-left: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-standard),
                color var(--motion-fast) var(--ease-standard);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    background: var(--secondary);
    color: var(--foreground);
}

.site-nav svg {
    width: 14px;
    height: 14px;
}

/* ------------------------------------------------------- page scaffold */

.page {
    width: min(100% - 48px, var(--w-tool));
    margin-inline: auto;
    padding: 44px 0 96px;
}

.page--reading {
    width: min(100% - 48px, var(--w-reading));
}

.page--wide {
    width: min(100% - 48px, var(--w-wide));
}

/* Masthead: eyebrow, serif title, quiet subtitle. Every page is a paper. */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-family: var(--font-serif);
    font-size: clamp(28px, 4.5vw, 38px);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.page-header .eyebrow {
    display: block;
    margin-bottom: 10px;
}

.page-subtitle {
    max-width: 64ch;
    margin-top: 8px;
    color: var(--muted-foreground);
    font-size: 13px;
    line-height: 1.55;
}

.section {
    margin-top: 40px;
}

.section-label {
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ----------------------------------------------------------- type roles
   Semantic sizes; below 768px each reading role steps up one notch. */

.eyebrow {
    color: var(--muted-foreground);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.text-ui { font-size: 13px; }
.text-preview { font-size: 12px; }
.text-body { font-size: 15px; line-height: 1.625; }
.text-stamp { font-size: 10px; }

.editorial {
    font-family: var(--font-serif);
    letter-spacing: -0.01em;
}

.mono {
    font-family: var(--font-mono);
}

.muted { color: var(--muted-foreground); }
.subtle { color: var(--subtle-foreground); }

/* -------------------------------------------------------------- surfaces */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
}

.card-body {
    padding: 20px;
}

.card-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.hairline-t { border-top: 1px solid var(--border); }
.hairline-b { border-bottom: 1px solid var(--border); }

/* A quiet inset panel inside a card (results, code-ish displays). */
.well {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.callout {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-left: 2px solid var(--brand);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    line-height: 1.6;
}

.callout .eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--brand);
}

/* ----------------------------------------------------------------- lists */

.list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.list-row {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-standard);
}

.list-row:last-child {
    border-bottom: 0;
}

a.list-row:hover,
.list-row.interactive:hover {
    background: var(--secondary);
    color: inherit;
}

/* ---------------------------------------------------------------- tables */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.1em;
    text-align: left;
    text-transform: uppercase;
}

.table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: 0;
}

/* ---------------------------------------------------------------- controls */

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 550;
    letter-spacing: -0.01em;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-standard),
                border-color var(--motion-fast) var(--ease-standard),
                transform var(--motion-fast) var(--ease-standard);
}

button:hover,
.btn:hover {
    border-color: var(--border-strong);
    background: var(--secondary);
    color: var(--foreground);
}

button:active,
.btn:active {
    transform: scale(0.98);
}

button:disabled,
.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    border-color: var(--foreground);
    background: var(--foreground);
    color: var(--background);
}

.btn-primary:hover {
    border-color: hsl(240 6% 20%);
    background: hsl(240 6% 20%);
    color: var(--background);
}

.btn-danger {
    color: var(--destructive);
}

/* Ghost: no chrome until hovered (icon buttons, dismissals). */
.btn-ghost {
    min-height: 0;
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--subtle-foreground);
}

.btn-ghost:hover {
    border: 0;
    background: hsl(240 10% 3.9% / 0.06);
    color: var(--foreground);
}

input,
select,
textarea {
    font: inherit;
    color: var(--foreground);
}

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    font-family: var(--font-sans);
    font-size: 13px;
}

textarea {
    padding: 12px;
    line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
    color: var(--subtle-foreground);
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted-foreground);
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Segmented control: one bordered strip, quiet active fill. */
.segmented {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
}

.segmented button {
    flex: 1;
    min-height: 38px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    font-weight: 500;
}

.segmented button:last-child {
    border-right: 0;
}

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

.segmented button.active {
    background: var(--secondary);
    font-weight: 600;
}

/* range inputs: hairline track, brand thumb */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border: 0;
    border-radius: 999px;
    background: var(--secondary);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--background);
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 2px solid var(--background);
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
    cursor: pointer;
}

/* ------------------------------------------------------------------ chips */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    color: var(--muted-foreground);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge--fill {
    border-color: var(--foreground);
    background: var(--foreground);
    color: var(--background);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--secondary);
    color: var(--muted-foreground);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 550;
}

code {
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--secondary);
    font-family: var(--font-mono);
    font-size: 0.88em;
}

pre {
    overflow-x: auto;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
}

pre code {
    padding: 0;
    border: 0;
    background: transparent;
    font-size: inherit;
}

/* ------------------------------------------------------------------ stats */

.stat-value {
    font-family: var(--font-mono);
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

/* The stat strip: the site's signature for headline numbers. Figures sit in
   one hairline-bounded band with column rules, like a newspaper data row —
   never in individual boxes. */
.stat-strip {
    display: flex;
    border-block: 1px solid var(--border);
}

.stat-strip > * {
    flex: 1 1 0;
    min-width: 0;
    padding: 18px 22px;
    border-left: 1px solid var(--border);
}

.stat-strip > :first-child {
    padding-left: 0;
    border-left: 0;
}

.stat-strip .eyebrow {
    display: block;
    margin-top: 7px;
}

@media (max-width: 640px) {
    .stat-strip {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .stat-strip > * {
        padding: 14px 0 14px 0;
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    .stat-strip > :nth-child(-n+2) {
        border-top: 0;
    }

    .stat-strip > :nth-child(even) {
        padding-left: 18px;
        border-left: 1px solid var(--border);
    }
}

/* ------------------------------------------------------------------ prose
   Reading surfaces: serif body, sans headings, hairline section breaks. */

.prose {
    font-family: var(--font-serif);
    font-size: 15.5px;
    letter-spacing: -0.008em;
    line-height: 1.68;
    color: hsl(240 5% 15%);
}

.prose p {
    margin: 0 0 1em;
}

.prose h2 {
    margin: 34px 0 14px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--foreground);
}

.prose h3 {
    margin: 26px 0 10px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 650;
    color: var(--foreground);
}

.prose ul,
.prose ol {
    margin: 0 0 1em;
    padding-left: 1.4em;
}

.prose li {
    margin-bottom: 0.35em;
}

.prose pre {
    margin: 0 0 1.2em;
}

.prose blockquote {
    margin: 0 0 1em;
    padding: 2px 0 2px 16px;
    border-left: 2px solid var(--border-strong);
    color: var(--muted-foreground);
}

/* Memo front-matter: label/value rows under a masthead. */
.memo-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted-foreground);
}

.memo-meta dt {
    color: var(--subtle-foreground);
    font-size: 10px;
    font-weight: 550;
    letter-spacing: 0.08em;
    line-height: 1.8;
    text-transform: uppercase;
}

.memo-meta dd {
    margin: 0;
}

.redacted {
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--foreground);
    color: var(--background);
    font-family: var(--font-sans);
    font-size: 0.78em;
    letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- motion */

/* Arrival: the one orchestrated moment. Blocks settle onto the page like
   papers landing in an inbox — set --arrive-i per block to stagger. */
@media (prefers-reduced-motion: no-preference) {
    @keyframes arrive {
        from {
            opacity: 0;
            transform: translateY(-4px);
        }
        to {
            opacity: 1;
            transform: none;
        }
    }

    .arrive {
        animation: arrive var(--motion-settle) var(--ease-standard) both;
        animation-delay: calc(var(--arrive-i, 0) * 40ms);
    }
}

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

/* ---------------------------------------------------------------- mobile
   Reading roles step up one notch at phone distance; controls hold. */

@media (max-width: 767px) {
    .page,
    .page--reading,
    .page--wide {
        width: min(100% - 32px, var(--w-wide));
        padding-top: 28px;
    }

    .site-topbar {
        min-height: 48px;
        padding: 0 12px;
    }

    .site-context {
        display: none;
    }

    .site-nav a span {
        display: none;
    }

    .site-nav a {
        width: 32px;
        justify-content: center;
        padding: 0;
    }

    .eyebrow { font-size: 11px; }
    .text-ui { font-size: 15px; }
    .text-preview { font-size: 13px; }
    .text-body { font-size: 16px; line-height: 1.6; }
    .text-stamp { font-size: 11px; }

    .prose {
        font-size: 17px;
        line-height: 1.6;
    }

    /* iOS Safari auto-zooms when a focused control is under 16px. */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    .segmented {
        flex-direction: column;
    }

    .segmented button {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .segmented button:last-child {
        border-bottom: 0;
    }
}
