/*
  understudy.css
  Understudy website

  Created by Yousef Mohamed youseef.elserwey@gmail.com.
  Copyright © 2026 Yousef Mohamed. MIT License.

  The site's design system, built from the approved "Foundations" and "Components" boards of
  the site design canvas: the identity's --us-* colour tokens, the type scale, space and shape,
  layout widths, and the parts every page is built from.

  Schemes: night is the default and the landing page always uses it. A docs page sets
  data-theme on <html>: "day" or "night" when the reader picked one, "auto" to follow the
  system setting.
*/

/* Fonts: self-hosted variable fonts, latin subset, SIL Open Font License (see site/fonts). */

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

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-latin-variable.woff2") format("woff2");
}

/* Tokens */

:root {
    /* Night colours (Backstage). */
    --us-bg: #0f172a;
    --us-surface: #1e293b;
    --us-border: #334155;
    --us-text: #f1f5f9;
    --us-text-soft: #cbd5e1;
    --us-text-muted: #94a3b8;
    --us-accent: #38bdf8;
    --us-accent-hover: #7dd3fc;
    --us-on-accent: #0f172a;
    --us-highlight: #fbbf24;
    --us-http: #2dd4bf;
    --us-samples: #a78bfa;
    --us-pass: #4ade80;
    --us-fail: #f87171;
    --us-code-text: #e2e8f0;
    --us-code-keyword: #7dd3fc;
    --us-code-call: #fcd34d;
    --us-code-string: #a7f3d0;
    --us-code-comment: #94a3b8;
    --us-spotlight-line: rgb(251 191 36 / 12%);
    --us-top-bar-glass: rgb(15 23 42 / 80%);

    /* Type. */
    --us-font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --us-font-code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* Space: steps of 4. */
    --us-space-4: 4px;
    --us-space-8: 8px;
    --us-space-12: 12px;
    --us-space-16: 16px;
    --us-space-24: 24px;
    --us-space-32: 32px;
    --us-space-48: 48px;
    --us-space-72: 72px;
    --us-space-96: 96px;

    /* Shape. Depth comes from a border line and a lighter surface, never shadows. */
    --us-radius-chip: 8px;
    --us-radius-control: 12px;
    --us-radius-card: 16px;
    --us-radius-badge: 999px;

    /* Layout. */
    --us-content-width: 1120px;
    --us-side-padding: 24px;
    --us-navigator-width: 280px;
    --us-reading-width: 760px;
    --us-code-width: 920px;
    --us-top-bar-height: 64px;
    --us-target-size: 44px;

    color-scheme: dark;
}

/* Day colours (House lights): only the token values change. */
:root[data-theme="day"] {
    --us-bg: #fff;
    --us-surface: #f1f5f9;
    --us-border: #e2e8f0;
    --us-text: #0f172a;
    --us-text-soft: #334155;
    --us-text-muted: #475569;
    --us-accent: #0369a1;
    --us-accent-hover: #075985;
    --us-on-accent: #fff;
    --us-highlight: #b45309;
    --us-http: #0f766e;
    --us-samples: #6d28d9;
    --us-pass: #15803d;
    --us-fail: #b91c1c;
    --us-code-text: #0f172a;
    --us-code-keyword: #0369a1;
    --us-code-call: #92400e;
    --us-code-string: #047857;
    --us-code-comment: #475569;
    --us-spotlight-line: rgb(180 83 9 / 10%);
    --us-top-bar-glass: rgb(255 255 255 / 80%);

    color-scheme: light;
}

@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] {
        --us-bg: #fff;
        --us-surface: #f1f5f9;
        --us-border: #e2e8f0;
        --us-text: #0f172a;
        --us-text-soft: #334155;
        --us-text-muted: #475569;
        --us-accent: #0369a1;
        --us-accent-hover: #075985;
        --us-on-accent: #fff;
        --us-highlight: #b45309;
        --us-http: #0f766e;
        --us-samples: #6d28d9;
        --us-pass: #15803d;
        --us-fail: #b91c1c;
        --us-code-text: #0f172a;
        --us-code-keyword: #0369a1;
        --us-code-call: #92400e;
        --us-code-string: #047857;
        --us-code-comment: #475569;
        --us-spotlight-line: rgb(180 83 9 / 10%);
        --us-top-bar-glass: rgb(255 255 255 / 80%);

        color-scheme: light;
    }
}

/* Base */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--us-top-bar-height) + var(--us-space-16));
}

body {
    margin: 0;
    background: var(--us-bg);
    color: var(--us-text);
    font-family: var(--us-font-text);
    font-size: 17px;
    line-height: 1.65;
}

img,
svg {
    display: block;
    max-width: 100%;
}

:focus-visible {
    outline: 2px solid var(--us-accent);
    outline-offset: 2px;
}

a {
    color: var(--us-accent);
}

a:hover {
    color: var(--us-accent-hover);
}

/* Body links are underlined inside paragraphs. */
p a,
li a {
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

code,
kbd,
pre {
    font-family: var(--us-font-code);
}

.us-skip-link {
    position: absolute;
    top: var(--us-space-8);
    left: var(--us-space-8);
    z-index: 20;
    padding: var(--us-space-8) var(--us-space-16);
    border-radius: var(--us-radius-control);
    background: var(--us-accent);
    color: var(--us-on-accent);
    font-weight: 600;
    transform: translateY(-200%);
}

.us-skip-link:focus {
    transform: none;
}

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

/* Type scale */

.us-display {
    margin: 0;
    font-size: 60px;
    font-weight: 800;
    line-height: 1.04;
    letter-spacing: -0.03em;
}

h1,
.us-heading-1 {
    margin: 0;
    font-size: 40px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h2,
.us-heading-2 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h3,
.us-heading-3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.us-lead {
    font-size: 19px;
    line-height: 1.55;
    color: var(--us-text-soft);
}

.us-small {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--us-text-muted);
}

.us-eyebrow {
    margin: 0;
    font-family: var(--us-font-code);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--us-highlight);
}

/* Layout */

.us-container {
    width: 100%;
    max-width: calc(var(--us-content-width) + 2 * var(--us-side-padding));
    margin-inline: auto;
    padding-inline: var(--us-side-padding);
}

/* Top bar: 64 px, sticky, blurs the page under it. */

.us-top-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--us-border);
    background: var(--us-top-bar-glass);
    backdrop-filter: blur(12px);
}

.us-top-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--us-space-12);
    min-height: var(--us-top-bar-height);
}

.us-brand {
    display: flex;
    flex-grow: 1;
    align-items: center;
    gap: 10px;
    min-height: var(--us-target-size);
    color: var(--us-text);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.us-brand:hover {
    color: var(--us-text);
}

.us-main-nav {
    display: flex;
    gap: var(--us-space-4);
    font-size: 15px;
}

.us-main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--us-target-size);
    padding-inline: var(--us-space-12);
    color: var(--us-text-soft);
    text-decoration: none;
}

.us-main-nav a:hover {
    color: var(--us-text);
}

.us-main-nav a[aria-current="page"] {
    color: var(--us-text);
    box-shadow: inset 0 -2px 0 var(--us-accent);
}

.us-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--us-target-size);
    height: var(--us-target-size);
    color: var(--us-text-soft);
}

.us-icon-link:hover {
    color: var(--us-text);
}

/* The menu button only shows on a phone, where it opens the top bar's links. */
.us-menu-button {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--us-target-size);
    height: var(--us-target-size);
    border: 1px solid var(--us-border);
    border-radius: 10px;
    background: transparent;
    color: var(--us-text);
    cursor: pointer;
}

/* The mark: its dashed outline drifts, off with reduced motion. */

.us-mark-outline {
    animation: us-outline-drift 4s linear infinite;
}

@keyframes us-outline-drift {
    to {
        stroke-dashoffset: -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .us-mark-outline {
        animation: none;
    }
}

/* Buttons and links */

.us-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--us-space-8);
    min-height: 48px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: var(--us-radius-control);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.us-button-primary {
    background: var(--us-accent);
    color: var(--us-on-accent);
}

.us-button-primary:hover {
    background: var(--us-accent-hover);
    color: var(--us-on-accent);
}

.us-button-secondary {
    border-color: var(--us-border);
    background: transparent;
    color: var(--us-text);
}

.us-button-secondary:hover {
    border-color: var(--us-accent);
    color: var(--us-text);
}

/* The "Get started" pill in the top bar. */
.us-button-pill {
    min-height: var(--us-target-size);
    padding: 0 18px;
    border-radius: var(--us-radius-badge);
    font-size: 15px;
}

/* A link that goes somewhere: bold, no underline, a chevron after it. */
.us-more-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--us-target-size);
    font-weight: 600;
    text-decoration: none;
}

.us-more-link::after {
    content: "\00a0›";
}

/* A product link takes its product colour. */
.us-product-core {
    --us-product: var(--us-accent);
}

.us-product-http {
    --us-product: var(--us-http);
}

.us-product-samples {
    --us-product: var(--us-samples);
}

.us-more-link[class*="us-product-"] {
    color: var(--us-product);
}

.us-more-link[class*="us-product-"]:hover {
    color: var(--us-product);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Labels and badges */

.us-kind-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--us-highlight);
}

.us-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: 1px solid var(--us-border);
    border-radius: var(--us-radius-badge);
    background: var(--us-bg);
    color: var(--us-product, var(--us-accent));
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
}

.us-badge-new {
    border-color: var(--us-highlight);
    background: var(--us-highlight);
    color: var(--us-on-accent);
}

/* Symbol kind tiles: class, struct, protocol, macro. */
.us-symbol-kind {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    color: var(--us-on-accent);
    font-family: var(--us-font-code);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.us-symbol-kind-class {
    background: var(--us-accent);
}

.us-symbol-kind-struct {
    background: var(--us-samples);
}

.us-symbol-kind-protocol {
    background: var(--us-highlight);
}

.us-symbol-kind-macro {
    background: var(--us-http);
}

/* Install box */

.us-install-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 16px;
    border: 1px solid var(--us-border);
    border-radius: var(--us-radius-control);
    background: var(--us-bg);
}

.us-install-box code {
    flex-grow: 1;
    overflow: hidden;
    color: var(--us-code-text);
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.us-copy-button {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: var(--us-target-size);
    height: var(--us-target-size);
    padding-inline: 12px;
    border: 1px solid var(--us-border);
    border-radius: 10px;
    background: var(--us-surface);
    color: var(--us-text-soft);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.us-copy-button:hover {
    color: var(--us-text);
}

.us-copy-button .us-copied-icon,
.us-copy-button.is-copied .us-copy-icon {
    display: none;
}

.us-copy-button.is-copied .us-copied-icon {
    display: block;
    color: var(--us-pass);
}

/* Code blocks with tabs */

.us-code-block {
    overflow: hidden;
    border-radius: var(--us-radius-card);
    background: var(--us-surface);
}

.us-code-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--us-space-4);
    padding: var(--us-space-8) 10px;
    border-bottom: 1px solid var(--us-border);
    font-size: 13px;
}

.us-code-tab {
    min-height: var(--us-target-size);
    padding: 0 var(--us-space-12);
    border: 0;
    border-radius: var(--us-radius-chip);
    background: transparent;
    color: var(--us-text-muted);
    font: inherit;
    cursor: pointer;
}

.us-code-tab:hover {
    color: var(--us-text);
}

.us-code-tab[aria-selected="true"] {
    background: var(--us-bg);
    color: var(--us-text);
    font-weight: 600;
}

.us-code-file-name {
    margin-left: auto;
    color: var(--us-text-muted);
    font-family: var(--us-font-code);
    font-size: 12px;
}

.us-code {
    margin: 0;
    padding: var(--us-space-16) 18px;
    color: var(--us-code-text);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.us-code .us-code-keyword {
    color: var(--us-code-keyword);
}

.us-code .us-code-call {
    color: var(--us-code-call);
}

.us-code .us-code-string {
    color: var(--us-code-string);
}

.us-code .us-code-comment {
    color: var(--us-code-comment);
}

/* Spotlight marks the line the text talks about. */
.us-code .us-code-spotlight {
    display: block;
    margin-inline: -18px;
    padding-inline: 15px;
    background: var(--us-spotlight-line);
    box-shadow: inset 3px 0 0 var(--us-highlight);
}

/* Asides: the word carries the colour, the box stays neutral. */

.us-aside {
    margin: var(--us-space-16) 0;
    padding: var(--us-space-12) 14px;
    border: 1px solid var(--us-border);
    border-radius: var(--us-radius-control);
    background: var(--us-bg);
    color: var(--us-text-soft);
    font-size: 15px;
    line-height: 1.55;
}

.us-aside-label {
    margin-right: 0.35em;
    font-weight: 700;
}

.us-aside-note .us-aside-label {
    color: var(--us-accent);
}

.us-aside-tip .us-aside-label {
    color: var(--us-pass);
}

.us-aside-important .us-aside-label {
    color: var(--us-highlight);
}

.us-aside-warning .us-aside-label {
    color: var(--us-fail);
}

/* Cards */

.us-feature-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border: 1px solid var(--us-border);
    border-radius: var(--us-radius-card);
    background: var(--us-surface);
}

.us-feature-card:hover,
.us-feature-card:focus-within {
    border-color: var(--us-accent);
}

/* The whole card is the link: the title's link covers the card. */
.us-feature-card a {
    color: var(--us-text);
    text-decoration: none;
}

.us-feature-card a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.us-feature-card p {
    margin: 0;
    color: var(--us-text-soft);
    font-size: 15px;
    line-height: 1.55;
}

.us-icon-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--us-border);
    border-radius: 10px;
    background: var(--us-bg);
    color: var(--us-accent);
}

.us-product-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--us-radius-card);
    background: var(--us-surface);
    box-shadow: inset 0 4px 0 var(--us-product, var(--us-accent));
}

.us-product-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px 22px 20px;
}

.us-product-card-body p {
    margin: 0;
    color: var(--us-text-soft);
    font-size: 15px;
    line-height: 1.55;
}

.us-product-card-import {
    color: var(--us-text-muted);
    font-size: 13px;
}

/* The product half of a name, such as HTTP in UnderstudyHTTP. */
.us-product-name {
    color: var(--us-product, var(--us-accent));
}

/* Docs navigator */

.us-navigator {
    display: flex;
    flex-direction: column;
    gap: var(--us-space-4);
    font-size: 14px;
}

.us-navigator-filter {
    display: flex;
    align-items: center;
    gap: var(--us-space-8);
    min-height: var(--us-target-size);
    padding: 0 var(--us-space-12);
    border: 1px solid var(--us-border);
    border-radius: var(--us-radius-control);
    background: var(--us-bg);
    color: var(--us-text-muted);
}

.us-navigator-filter:focus-within {
    outline: 2px solid var(--us-accent);
    outline-offset: 2px;
}

.us-navigator-filter input {
    flex-grow: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--us-text);
    font: inherit;
    outline: none;
}

.us-navigator-filter input::placeholder {
    color: var(--us-text-muted);
}

.us-navigator-filter kbd {
    padding: 1px 6px;
    border: 1px solid var(--us-border);
    border-radius: 6px;
    font-size: 12px;
}

.us-navigator-group {
    margin: var(--us-space-8) 0 0;
    color: var(--us-text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.us-navigator a {
    display: flex;
    align-items: center;
    gap: var(--us-space-8);
    min-height: var(--us-target-size);
    padding: 0 10px;
    border-radius: var(--us-radius-chip);
    color: var(--us-text-soft);
    text-decoration: none;
}

.us-navigator a:hover {
    color: var(--us-text);
}

.us-navigator a[aria-current="page"] {
    background: var(--us-bg);
    color: var(--us-text);
    box-shadow: inset 3px 0 0 var(--us-accent);
}

/* Breakpoints: 1024 (the navigator becomes a drawer, built with the docs pages) and 640 (one
   column, buttons full width). */

@media (width <= 640px) {
    .us-display {
        font-size: 40px;
    }

    h1,
    .us-heading-1 {
        font-size: 30px;
    }

    h2,
    .us-heading-2 {
        font-size: 24px;
    }

    h3,
    .us-heading-3 {
        font-size: 19px;
    }

    .us-lead {
        font-size: 17px;
    }

    .us-button:not(.us-button-pill) {
        width: 100%;
    }

    /* Without the script, the links wrap onto their own row under the brand. */
    .us-top-bar:not(.has-menu) .us-main-nav {
        flex-basis: 100%;
        flex-wrap: wrap;
        order: 1;
    }

    /* Once the script sets up the menu, the top bar keeps the brand and the menu button; the
       menu opens the links under it, one per row. */
    .us-top-bar.has-menu .us-main-nav,
    .us-top-bar.has-menu .us-button-pill {
        display: none;
    }

    .us-top-bar.has-menu .us-menu-button {
        display: inline-flex;
    }

    .us-top-bar.is-menu-open {
        background: var(--us-bg);
    }

    .us-top-bar.is-menu-open .us-main-nav {
        display: flex;
        flex-basis: 100%;
        flex-direction: column;
        order: 1;
        padding-bottom: var(--us-space-8);
    }

    .us-top-bar.is-menu-open .us-button-pill {
        display: inline-flex;
        flex-basis: 100%;
        order: 2;
        margin-bottom: var(--us-space-12);
    }
}
