/* Light theme (2a) tokens. The dark theme (3a) redefines only the colours,
   below, under both the media query and the explicit data-theme override. */
:root {
    --font-sans: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --pad: 52px;
    --content: 1200px;
    /* Tall enough for the search page's controls, so both headers match. */
    --header-height: 64px;
    /* Rules and backgrounds stay full-bleed while the content sits in a centred
       column: the gutter takes over from --pad once the viewport is wider. */
    --gutter: max(var(--pad), calc((100% - var(--content)) / 2));

    --accent: #306998;
    --accent-hover: #24527a;
    --accent-border: #7fa8cd;
    --mark: #ffd43b;
    --mark-hover: #f0c62f;
    --mark-border: #e8bd23;
    --on-accent: oklch(0.99 0.01 60);
    --on-mark: oklch(0.24 0.03 90);

    --bg: oklch(0.977 0.007 85);
    --bg-raised: oklch(0.99 0.008 60);
    --bg-sunken: oklch(0.95 0.008 85);
    --bg-input: oklch(1 0 0);
    --border-input: oklch(0.8 0.012 85);
    --border-sunken: oklch(0.87 0.008 85);
    --rule: oklch(0.88 0.008 85);
    --rule-faint: oklch(0.92 0.008 85);

    --ink: oklch(0.21 0.012 60);
    --ink-row: oklch(0.28 0.012 60);
    --ink-pkg: oklch(0.3 0.012 60);
    --ink-intro: oklch(0.35 0.012 60);
    --ink-prose: oklch(0.38 0.012 60);
    --ink-body: oklch(0.4 0.012 60);
    --ink-muted: oklch(0.46 0.012 60);
    --ink-label: oklch(0.48 0.012 60);
    --ink-eyebrow: oklch(0.5 0.012 60);
    --ink-faint: oklch(0.56 0.012 60);

    /* Drives the theme toggle's label: it names the theme it switches to. */
    --when-light: inline;
    --when-dark: none;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #4b8bbe;
        --accent-hover: #3f7aa8;
        --accent-border: #3d6f9e;
        --on-accent: oklch(0.16 0.01 250);
        --on-mark: oklch(0.2 0.03 90);

        --bg: oklch(0.19 0.008 250);
        --bg-raised: oklch(0.21 0.012 250);
        --bg-sunken: oklch(0.22 0.008 250);
        --bg-input: oklch(0.22 0.008 250);
        --border-input: oklch(0.34 0.01 250);
        --border-sunken: oklch(0.31 0.008 250);
        --rule: oklch(0.28 0.008 250);
        --rule-faint: oklch(0.26 0.008 250);

        --ink: oklch(0.94 0.005 250);
        --ink-row: oklch(0.9 0.01 250);
        --ink-pkg: oklch(0.88 0.01 250);
        --ink-intro: oklch(0.78 0.01 250);
        --ink-prose: oklch(0.74 0.01 250);
        --ink-body: oklch(0.72 0.01 250);
        --ink-muted: oklch(0.7 0.01 250);
        --ink-label: oklch(0.68 0.01 250);
        --ink-eyebrow: oklch(0.66 0.01 250);
        --ink-faint: oklch(0.63 0.01 250);

        --when-light: none;
        --when-dark: inline;

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --accent: #4b8bbe;
    --accent-hover: #3f7aa8;
    --accent-border: #3d6f9e;
    --on-accent: oklch(0.16 0.01 250);
    --on-mark: oklch(0.2 0.03 90);

    --bg: oklch(0.19 0.008 250);
    --bg-raised: oklch(0.21 0.012 250);
    --bg-sunken: oklch(0.22 0.008 250);
    --bg-input: oklch(0.22 0.008 250);
    --border-input: oklch(0.34 0.01 250);
    --border-sunken: oklch(0.31 0.008 250);
    --rule: oklch(0.28 0.008 250);
    --rule-faint: oklch(0.26 0.008 250);

    --ink: oklch(0.94 0.005 250);
    --ink-row: oklch(0.9 0.01 250);
    --ink-pkg: oklch(0.88 0.01 250);
    --ink-intro: oklch(0.78 0.01 250);
    --ink-prose: oklch(0.74 0.01 250);
    --ink-body: oklch(0.72 0.01 250);
    --ink-muted: oklch(0.7 0.01 250);
    --ink-label: oklch(0.68 0.01 250);
    --ink-eyebrow: oklch(0.66 0.01 250);
    --ink-faint: oklch(0.63 0.01 250);

    --when-light: none;
    --when-dark: inline;

    color-scheme: dark;
}

/* Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

.section {
    padding: 40px var(--gutter);
    border-bottom: 1px solid var(--rule);
}

.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-eyebrow);
}

/* Header */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: var(--header-height);
    padding: 12px var(--gutter);
    border-bottom: 1px solid var(--rule);
}

.wordmark {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.py-blue {
    color: var(--accent);
}

.py-yellow {
    color: var(--mark);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: var(--ink-body);
}

.theme-toggle {
    font-size: 13px;
    color: var(--ink-body);
}

.theme-toggle:hover {
    text-decoration: underline;
}

.theme-toggle .when-light {
    display: var(--when-light);
}

.theme-toggle .when-dark {
    display: var(--when-dark);
}

/* Hero */
.hero {
    padding: 60px var(--gutter) 52px;
    border-bottom: 1px solid var(--rule);
    text-align: center;
}

.hero-title {
    position: relative;
    display: inline-block;
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* The dot the mark has always had: Python yellow, tucked behind the wordmark's
   opening letters. */
.hero-title::before {
    content: "";
    position: absolute;
    top: -15px;
    left: -25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mark);
    opacity: 0.6;
    z-index: -1;
}

.tagline {
    font-size: 18px;
    line-height: 1.55;
    color: var(--ink-body);
    margin: 14px auto 0;
    max-width: 48ch;
}

.counts {
    display: flex;
    justify-content: center;
    gap: 44px;
    margin-top: 34px;
}

.count-value {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.count-label {
    font-size: 13px;
    color: var(--ink-label);
    margin-top: 3px;
}

.count-divider {
    width: 3px;
    background: var(--mark);
}

.hero-intro {
    margin: 42px auto 0;
    max-width: 66ch;
}

.hero-intro p {
    max-width: 54ch;
    margin-inline: auto;
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink-intro);
    /* Centred, so two lines of even length read better than a full-width line
       with a short tail under it. */
    text-wrap: balance;
}

.hero-intro a {
    color: var(--accent);
}

/* The field is a live input, so its text starts at the left edge however the
   hero around it is aligned. */
.pattern-box {
    text-align: left;
    display: flex;
    align-items: center;
    margin-top: 16px;
    border: 1px solid var(--accent-border);
    border-left: 5px solid var(--mark);
    border-radius: 8px;
    background: var(--bg-raised);
}

/* The focus ring belongs to the whole box: the input inside it is chromeless,
   so a ring around the input alone would read as a second, smaller box. The
   submit hint keeps its own ring, hence :has() rather than :focus-within. */
.pattern-box:has(.pattern-input:focus) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pattern-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    padding: 18px 22px;
    font-family: var(--font-mono);
    font-size: 24px;
    letter-spacing: -0.015em;
    cursor: text;
}

.pattern-box .prefix {
    color: var(--ink-eyebrow);
}

.pattern-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    font-weight: 600;
    color: var(--accent);
    caret-color: var(--accent);
}

.pattern-input:focus {
    outline: none;
}

/* Matches the weight and colour the symbol had when it was static text, so the
   box looks unchanged until it is used. */
.pattern-input::placeholder {
    font-weight: 600;
    color: var(--accent);
    opacity: 1;
}

/* Hidden rather than transparent while the field is empty: there is nothing to
   submit yet, so it must not be clickable or reachable by tab either. */
.pattern-hint {
    flex: none;
    align-self: stretch;
    padding: 0 22px 0 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    letter-spacing: 0;
    color: var(--ink-faint);
    white-space: nowrap;
    visibility: hidden;
}

.pattern-box:has(.pattern-input:not(:placeholder-shown)) .pattern-hint {
    visibility: visible;
}

.pattern-hint:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Examples */
.examples {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    font-family: var(--font-mono);
    font-size: 15px;
    list-style: none;
}

.examples .prefix {
    color: var(--ink-faint);
}

.examples .symbol {
    color: var(--accent);
}

/* Search control */
.search-control {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    max-width: 720px;
}

.select-wrap {
    position: relative;
    display: flex;
    min-width: 190px;
}

.package-select {
    appearance: none;
    width: 100%;
    border: 1px solid var(--border-input);
    border-radius: 7px;
    background: var(--bg-input);
    color: var(--ink-pkg);
    padding: 12px 32px 12px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
}

.select-caret {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--ink-faint);
    pointer-events: none;
}

.search-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-input);
    border-radius: 7px;
    background: var(--bg-input);
    color: var(--ink);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 15px;
}

.search-input::placeholder {
    color: var(--ink-faint);
}

.btn-search,
.btn-lucky {
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.btn-search {
    background: var(--accent);
    color: var(--on-accent);
    padding: 12px 22px;
    border: 1px solid var(--accent);
}

.btn-search:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-lucky {
    background: var(--mark);
    color: var(--on-mark);
    padding: 12px 20px;
    border: 1px solid var(--mark-border);
}

.btn-lucky:hover {
    background: var(--mark-hover);
}

/* Browser setup */
.setup-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
}

.setup-grid p {
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink-prose);
    margin-top: 14px;
    text-wrap: pretty;
}

.setup-grid a {
    color: var(--accent);
}

code {
    font-family: var(--font-mono);
    font-size: 13px;
}

.code-block {
    margin-top: 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-sunken);
    border: 1px solid var(--border-sunken);
    border-radius: 6px;
    padding: 11px 13px;
    overflow-x: auto;
}

.patterns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
    list-style: none;
}

.pattern-url {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
    overflow-wrap: anywhere;
}

.pattern-desc {
    font-size: 13px;
    color: var(--ink-muted);
    margin-top: 2px;
}

/* Supported packages */
.packages {
    padding-bottom: 48px;
    border-bottom: none;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.packages-total {
    font-size: 13px;
    color: var(--ink-label);
}

/* A column count of 5 with a minimum width: the widest package name is 36
   characters, which no fifth of a narrow viewport can hold without overlapping
   the next column. */
.packages-index {
    columns: 5 290px;
    column-gap: 26px;
    margin-top: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 2;
    list-style: none;
}

.packages-index li {
    white-space: nowrap;
    color: var(--ink-pkg);
}

.packages-index .stdlib-package a {
    color: var(--accent);
    font-weight: 600;
}

/* Footer */
.footer {
    padding: 26px var(--gutter) 32px;
    border-top: 1px solid var(--rule);
    font-size: 13px;
    line-height: 1.8;
    color: var(--ink-label);
}

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

/* Search results */
.results-header {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--header-height);
    padding: 12px var(--gutter);
    border-bottom: 1px solid var(--rule);
}

.results-header .wordmark {
    flex-shrink: 0;
}

.results-header .search-control {
    flex: 1;
    max-width: 660px;
    gap: 8px;
    margin-top: 0;
}

.results-header .package-select,
.results-header .search-input,
.results-header .btn-search,
.results-header .btn-lucky {
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
}

.results-header .select-wrap {
    min-width: 168px;
}

.results-header .package-select {
    padding-right: 30px;
}

.results-header .search-input {
    font-size: 14px;
}

.results-header .btn-search {
    padding: 9px 18px;
}

.results-header .btn-lucky {
    padding: 9px 16px;
}

.results-count {
    padding: 26px var(--gutter) 0;
    font-size: 15px;
    color: var(--ink-body);
}

.results-count .count {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--ink);
}

.results-count a {
    color: var(--accent);
}

.results-list {
    padding: 20px var(--gutter) 44px;
}

/* A column width, not a count: symbol names are unbreakable dotted strings and
   the widest need ~412px, so let the browser pick how many fit. */
.results-columns {
    columns: 300px;
    column-gap: 22px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 2.05;
    overflow-wrap: anywhere;
    list-style: none;
}

.result-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    border-bottom: 1px solid var(--rule-faint);
    break-inside: avoid;
}

.result-symbol {
    flex: 1;
    min-width: 0;
    color: var(--ink-row);
}

.copy-button {
    flex: none;
    display: flex;
    align-items: center;
    padding: 2px;
    color: var(--ink-faint);
    opacity: 0;
}

.result-item:hover .copy-button,
.copy-button:focus-visible {
    opacity: 1;
}

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

.hidden-result {
    display: none;
}

.show-more-container {
    margin-top: 20px;
}

.show-more-button {
    border: 1px solid var(--border-input);
    border-radius: 7px;
    background: var(--bg-input);
    color: var(--ink-body);
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
}

.show-more-button:hover {
    color: var(--ink);
    border-color: var(--ink-faint);
}

.no-results {
    padding: 20px var(--gutter) 44px;
    font-size: 15px;
    color: var(--ink-body);
}

/* Copy-to-clipboard toast */
.notification {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    background: var(--bg-raised);
    border: 1px solid var(--border-input);
    border-left: 5px solid var(--mark);
    border-radius: 8px;
    padding: 12px 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink);
    opacity: 0;
    z-index: 100;
}

.notification.show {
    opacity: 1;
}

.notification.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 900px) {
    :root {
        --pad: 24px;
    }

    .hero-title {
        font-size: 38px;
    }

    .pattern-field {
        font-size: 19px;
    }

    .setup-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 32px;
    }

    .search-control {
        flex-wrap: wrap;
    }

    .select-wrap,
    .search-input {
        min-width: 190px;
    }

    .btn-search,
    .btn-lucky {
        flex: 1;
    }

    .results-header {
        flex-wrap: wrap;
    }

    .results-header .search-control {
        max-width: none;
    }
}

@media (max-width: 520px) {
    .hero {
        padding-top: 40px;
    }

    .hero-title {
        font-size: 32px;
    }

    .counts {
        gap: 24px;
    }

    .select-wrap,
    .search-input {
        min-width: 100%;
    }
}

/* The pattern box is one unbreakable line: the prefix plus a 34-character
   placeholder. Below this width the submit hint no longer fits beside it (a
   keyboard's go key still submits), and the line itself has to track the
   viewport or its tail gets clipped. */
@media (max-width: 560px) {
    .pattern-hint {
        display: none;
    }

    .pattern-field {
        padding: 16px;
        font-size: min(19px, calc(4.9vw - 4px));
    }
}
