/* Design tokens */
:root {
    color-scheme: light;

    --paper: #f7f7f2;
    --ink: #080808;
    --muted: #555555;
    --line: #080808;
    --panel: #ffffff;
    --soft: #ededdf;
    --terminal: #080808;
    --terminal-text: #f7f7f2;

    --font-text: "Open Sans", Arial, sans-serif;
    --font-code: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --font-bold: DynaPuff, system-ui, sans-serif;

    --content-max: 73.75rem;
    --content-gutter: 1.25rem;
    --header-height: 4.25rem;

    --space-xs: 0.375rem;
    --space-sm: 0.625rem;
    --space-md: 0.75rem;
    --space-lg: 0.875rem;
    --space-xl: 1rem;
    --space-xxl: 1.125rem;
    --space-xxxl: 1.375rem;
    --space-huge: 1.5rem;
    --space-jumbo: 1.875rem;
    --space-section: clamp(3.75rem, 9vw, 7rem);

    --border-width: 2px;
    --border: var(--border-width) solid var(--line);
    --border-muted: var(--border-width) solid #333333;
    --radius-soft: 2px;
    --shadow: 3px 3px 0 var(--line);
    --button-shadow: 3px 3px 0 var(--line);
    --button-shadow-active: 1px 1px 0 var(--line);

    --control-height: 2.75rem;
    --brand-mark-size: 2.625rem;
    --terminal-dot-size: 11px;
}

@media (min-width: 38.75rem) {
    :root {
        --content-gutter: 1.75rem;
    }
}

/* Base */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-text);
    font-weight: 300;
    line-height: 1.5;
    background: var(--paper);
}

main {
    display: flex;
    flex-direction: column;
    gap: var(--space-section);
}

button,
input,
select {
    font: inherit;
}

svg {
    display: block;
}

a {
    color: inherit;
}

code,
pre,
table,
.stats,
.control-panel,
.copy-status {
    font-family: var(--font-code);
}

.brand,
.eyebrow,
.button {
    font-family: var(--font-bold);
    font-optical-sizing: auto;
    font-variation-settings: "wdth" 100;
}

/* Accessibility helpers */
:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 4px;
}

.sr-only {
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    position: absolute;
    overflow: hidden;
    white-space: nowrap;
    border: 0;
    clip: rect(0, 0, 0, 0);
}

.skip-link {
    padding: var(--space-sm) var(--space-md);
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 20;
    color: var(--paper);
    font-family: var(--font-code);
    font-size: 0.8125rem;
    font-weight: 900;
    text-transform: uppercase;
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--ink);
    transform: translateY(calc(-100% - var(--space-huge)));
}

.skip-link:focus {
    transform: translateY(0);
}

.noscript-message,
.hero,
.section,
.stats,
.site-footer {
    width: min(var(--content-max), calc(100% - var(--content-gutter)));
    margin-inline: auto;
}

.noscript-message {
    padding: var(--space-xl);
    margin-top: var(--space-xl);
    font-family: var(--font-code);
    font-weight: 700;
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--panel);
    box-shadow: var(--shadow);
}

/* Header */
.site-header {
    padding: var(--space-md) clamp(1rem, 3vw, 2.125rem);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xxxl);
    border-bottom: var(--border);
    background: rgba(247, 247, 242, 0.96);
}

@media (min-width: 38.75rem) {
    .site-header {
        flex-direction: row;
        align-items: center;
    }
}

.brand,
.nav {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.brand {
    justify-content: center;
    font-size: 1.0625rem;
    font-weight: 900;
    text-decoration: none;
    text-transform: uppercase;
}

@media (min-width: 38.75rem) {
    .brand {
        justify-content: flex-start;
    }
}

.brand-mark {
    width: var(--brand-mark-size);
    height: var(--brand-mark-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--paper);
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--ink);
}

.nav {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
}

@media (min-width: 38.75rem) {
    .nav {
        width: auto;
        justify-content: flex-end;
        gap: var(--space-lg);
    }
}

.nav a {
    font-size: 0.8125rem;
    font-family: var(--font-bold);
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
}

.nav a:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--border-width);
}

/* Page sections */
.hero {
    min-height: auto;
    padding: clamp(2.5rem, 7vw, 5.5rem) 0;
    display: flex;
    flex-direction: column;
    gap: clamp(1.375rem, 4vw, 3.25rem);
    align-items: center;
}

@media (min-width: 57.5rem) {
    .hero {
        min-height: calc(100vh - var(--header-height));
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(21.25rem, 0.76fr);
    }
}

.section {
    min-width: 0;
}

.section-heading {
    margin-bottom: var(--space-huge);
}

.eyebrow {
    margin: 0 0 var(--space-sm);
    font-size: 0.8125rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1,
.section-heading h2 {
    max-width: 65rem;
    margin: 0;
    font-size: clamp(3.125rem, 9vw, 7.75rem);
    font-weight: 800;
    letter-spacing: 0;
    line-height: 0.9;
}

.section-heading h2 {
    font-size: clamp(2.5rem, 7vw, 5.875rem);
}

.hero-text {
    max-width: 43.125rem;
    margin: var(--space-huge) 0 0;
    font-size: clamp(1.25rem, 2.2vw, 1.875rem);
    line-height: 1.25;
}

.section-lede {
    max-width: 47.5rem;
    margin: var(--space-xl) 0 0;
    color: var(--muted);
    font-size: 1.25rem;
}

.hero-actions,
.button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.hero-actions {
    margin-top: var(--space-jumbo);
}

/* Buttons */
.button {
    min-height: var(--control-height);
    padding: 0 var(--space-xl);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 900;
    text-decoration: none;
    text-transform: uppercase;
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--panel);
    box-shadow: var(--button-shadow);
    cursor: pointer;
}

.button:focus-visible,
.button:hover {
    box-shadow: var(--button-shadow-active);
    transform: translate(2px, 2px);
}

.button.primary {
    color: var(--paper);
    background: var(--ink);
}

/* Shared panels */
.hero-terminal,
.preview-panel,
.control-panel,
.catalog-table-wrap,
.api-table-wrap,
.doc-card {
    border: var(--border);
    border-radius: var(--radius-soft);
    box-shadow: var(--shadow);
}

.hero-terminal,
.preview-panel {
    min-width: 0;
    overflow: hidden;
    color: var(--terminal-text);
    background: var(--terminal);
}

/* Terminal previews */
.terminal-bar {
    padding: var(--space-md);
    display: flex;
    gap: 7px;
    border-bottom: var(--border-muted);
}

.terminal-bar span {
    width: var(--terminal-dot-size);
    height: var(--terminal-dot-size);
    border: var(--border-width) solid var(--paper);
    border-radius: 50%;
}

.hero-ascii,
.ascii-preview {
    margin: 0;
    overflow: auto;
    line-height: 1.05;
    white-space: pre;
}

.hero-ascii {
    padding: var(--space-huge);
    font-size: clamp(0.625rem, 1.4vw, 1rem);
}

.ascii-preview {
    max-width: 100%;
    padding: var(--space-huge);
    align-self: center;
    color: var(--preview-color, var(--terminal-text));
    font-size: clamp(0.625rem, 1.35vw, 1.0625rem);
}

.hero-terminal code {
    padding: var(--space-lg) var(--space-xl);
    overflow-x: auto;
    display: block;
    color: var(--paper);
    border-top: var(--border-muted);
}

.active-command-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    color: var(--paper);
    border-top: var(--border-muted);
}

.active-command {
    padding: var(--space-lg) var(--space-xl);
    overflow-x: auto;
    white-space: nowrap;
}

.terminal-button {
    padding: 0 var(--space-xl);
    color: var(--paper);
    font-family: var(--font-bold);
    font-size: 0.8125rem;
    font-weight: 900;
    text-transform: uppercase;
    background: var(--terminal);
    border: 0;
    cursor: pointer;
}

.preview-head .terminal-button {
    padding-inline: 0;
}

.terminal-button:focus-visible,
.terminal-button:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--border-width);
    text-underline-offset: 4px;
    background: var(--terminal);
}

.copy-status {
    min-height: 2.25rem;
    padding: var(--space-sm) var(--space-xl);
    margin: 0;
    color: var(--paper);
    font-size: 0.8125rem;
    font-weight: 700;
    border-top: var(--border-muted);
}

.copy-status:empty::before {
    content: "\00a0";
}

/* Stats */
.stats {
    display: flex;
    flex-direction: column;
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--panel);
    box-shadow: var(--shadow);
}

@media (min-width: 57.5rem) {
    .stats {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }
}

.stats article {
    min-width: 0;
    padding: var(--space-xxl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: var(--border);
}

@media (min-width: 57.5rem) {
    .stats article {
        border-right: var(--border);
        border-bottom: 0;
    }
}

.stats article:last-child {
    border-bottom: 0;
}

@media (min-width: 57.5rem) {
    .stats article:last-child {
        border-right: 0;
    }
}

.stats a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
}

.stats span {
    display: block;
    font-size: clamp(1.75rem, 4vw, 3.375rem);
    font-family: var(--font-bold);
    line-height: 1;
}

.stats p {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--muted);
}

.github-icon {
    width: clamp(2rem, 4vw, 3.375rem);
    height: clamp(2rem, 4vw, 3.375rem);
}

.github-icon svg {
    width: 100%;
    height: 100%;
}

.stats article a:focus-visible,
.stats article a:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--border-width);
    text-underline-offset: 4px;
}

/* Documentation */
.doc-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-xxxl);
}

.doc-grid {
    min-width: 0;
}

@media (min-width: 57.5rem) {
    .doc-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.doc-card,
.api-table-wrap {
    background: var(--panel);
}

.doc-copy,
.doc-card {
    min-width: 0;
}

.doc-card>* {
    min-width: 0;
}

.doc-card {
    padding: var(--space-xl);
}

@media (min-width: 38.75rem) {
    .doc-card {
        padding: var(--space-xxl);
    }
}

.doc-card-wide {
    grid-column: 1 / -1;
}

.doc-card p {
    color: var(--muted);
    font-size: 1.125rem;
}

.doc-card p code {
    overflow-wrap: anywhere;
}

.doc-copy h3,
.doc-card h3 {
    margin: 0 0 var(--space-sm);
    font-size: 1.625rem;
    font-weight: 800;
    line-height: 1.1;
}

.doc-copy h3:not(:first-child),
.doc-card h3:not(:first-of-type) {
    margin-top: var(--space-huge);
}

.doc-copy pre,
.doc-card pre {
    margin: 0;
}

.doc-card dl {
    margin: var(--space-xxl) 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-card dt {
    font-weight: 900;
}

.doc-card dd {
    margin: 0;
    color: var(--muted);
}

pre {
    width: 100%;
    max-width: 100%;
    padding: var(--space-md);
    overflow: auto;
    color: var(--paper);
    font-size: 0.8125rem;
    white-space: pre;
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--ink);
}

@media (min-width: 38.75rem) {
    pre {
        padding: var(--space-xl);
        font-size: 1rem;
    }
}

pre code {
    display: block;
    min-width: max-content;
}

.api-table-wrap {
    margin-bottom: var(--space-xxxl);
    overflow-x: auto;
}

.api-table td:first-child {
    width: 34%;
}

/* Playground */
.playground {
    display: flex;
    flex-direction: column;
    gap: var(--space-xxxl);
}

@media (min-width: 57.5rem) {
    .playground {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 22.5rem;
    }
}

.preview-panel {
    min-height: 33.75rem;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.preview-head {
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-xl);
    border-bottom: var(--border-muted);
}

@media (min-width: 57.5rem) {
    .preview-head {
        flex-direction: row;
        align-items: center;
    }
}

.preview-head h3 {
    margin: 0;
    color: var(--paper);
    font-size: 1.5rem;
}

.preview-head p {
    margin: 0.25rem 0 0;
    color: #cccccc;
    font-size: 0.8125rem;
    font-weight: 800;
    text-transform: uppercase;
}

.control-panel {
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-content: start;
    gap: var(--space-lg);
    background: var(--soft);
}

.control-panel label {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: 0.8125rem;
    font-weight: 900;
    text-transform: uppercase;
}

.control-panel input,
.control-panel select,
.catalog-tools input,
.catalog-tools select {
    width: 100%;
    min-height: var(--control-height);
    color: var(--ink);
    padding: 0 var(--space-md);
    border: var(--border);
    border-radius: var(--radius-soft);
    background: var(--panel);
}

.color-field {
    display: grid;
    grid-template-columns: var(--control-height) minmax(0, 1fr);
    gap: var(--space-sm);
}

.control-panel input[type="color"] {
    padding: 4px;
    cursor: pointer;
}

.control-panel input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.control-panel input[type="color"]::-webkit-color-swatch {
    border: 0;
}

.control-panel .check-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
}

.check-row input {
    width: 1.375rem;
    height: 1.375rem;
    min-height: 1.375rem;
    padding: 0;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    appearance: none;
    cursor: pointer;
}

.check-row input::before {
    content: "";
    width: 0.625rem;
    height: 0.625rem;
    background: var(--ink);
    transform: scale(0);
    transition: transform 120ms ease;
}

.check-row input:checked::before {
    transform: scale(1);
}

.button-grid {
    display: flex;
    flex-direction: column;
}

.button-grid .button {
    width: 100%;
    min-height: 3rem;
    background: var(--panel);
}

/* Catalog */
.catalog-tools {
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: center;
}

@media (min-width: 57.5rem) {
    .catalog-tools {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 13.75rem auto;
    }
}

.catalog-tools span {
    font-size: 0.8125rem;
    font-weight: 900;
    text-align: left;
    text-transform: uppercase;
}

@media (min-width: 57.5rem) {
    .catalog-tools span {
        text-align: right;
    }
}

.catalog-table-wrap {
    overflow-x: auto;
    background: var(--panel);
}

table {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

th,
td {
    padding: var(--space-md);
    text-align: left;
    white-space: nowrap;
    border-bottom: var(--border);
}

thead th {
    color: var(--paper);
    font-size: 0.75rem;
    text-transform: uppercase;
    background: var(--ink);
}

.catalog-table th:nth-child(3),
.catalog-table td:nth-child(3) {
    max-width: 14rem;
    white-space: normal;
}

tbody tr:hover td,
tbody tr:hover th[scope="row"] {
    background: var(--soft);
}

.name-button {
    padding: 0;
    color: var(--ink);
    font-weight: 900;
    text-decoration: underline;
    text-decoration-thickness: var(--border-width);
    border: 0;
    background: transparent;
    cursor: pointer;
}

.color-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.color-dot {
    width: 14px;
    height: 14px;
    border: var(--border);
    border-radius: 50%;
    background: var(--dot-color);
}

/* Footer */
.site-footer {
    padding: var(--space-xxxl) 0 2.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xxl);
    text-align: center;
}

.signature {
    display: inline-flex;
    align-items: center;
    color: var(--ink);
    font-family: var(--font-bold);
    font-size: 0.75rem;
    font-optical-sizing: auto;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    font-weight: 700;
    text-decoration: none;
}

@media (min-width: 38.75rem) {
    .signature {
        font-size: 1rem;
    }
}

.signature-logo {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    overflow: visible;
}

@media (min-width: 38.75rem) {
    .signature-logo {
        width: 3rem;
        height: 3rem;
    }
}

.signature-logo-pupil {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 180ms ease;
}

.signature:focus-visible .signature-logo-pupil,
.signature:hover .signature-logo-pupil {
    transform: translateX(30px);
}

.signature-tagline {
    transform: scaleY(1.75) skewX(5deg);
}

/* Motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 1ms;
        animation-iteration-count: 1;
        transition-duration: 1ms;
    }
}
