/* ── Discover (/discover): every public project on one page ──
   views/discover.ejs, drawn on the server (lib/discover-view.js) and filtered in the browser (public/js/discover.js).
   It sits inside the page frame (.st-shell, --st-outline-w) and never sets the frame's width. The H1 keeps
   .st-catalog-title, whose size home.css and the public layout's type scale set. */

.st-browse {
    padding-top: 28px;
}

.st-browse-shell {
    padding-bottom: 48px;
}

/* Header: the title, one line, and search */
.st-browse-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 20px;
}

.st-browse-intro {
    flex: 1 1 320px;
    min-width: 0;
}

.st-browse-h1 {
    line-height: 1.05;
}

.st-browse-lead {
    margin: 8px 0 0;
    max-width: 52ch;
    font-size: 15px;
    line-height: 1.5;
    color: var(--st-ink-muted);
}

.st-browse-search {
    display: flex;
    align-items: center;
    flex: 1 1 260px;
    max-width: 360px;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--st-line-strong);
    border-radius: 999px;
    background: #fff;
}

.st-browse-search:focus-within {
    border-color: var(--st-accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.st-browse-search input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 4px 0 18px;
    border: 0;
    background: none;
    outline: none;
    font-family: var(--st-font-ui);
    font-size: 16px;
    color: var(--st-ink);
}

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

.st-browse-search-go {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--st-ink-muted);
}

.st-browse-search-go:hover {
    color: var(--st-ink);
}

/* Filters: the framework list and the order */
.st-browse-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 14px;
}

.st-browse-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--st-line-strong);
    border-radius: 999px;
    background: #fff;
    font-family: var(--st-font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    color: var(--st-ink);
    white-space: nowrap;
}

.st-browse-sort-btn:hover {
    border-color: rgba(124, 58, 237, 0.45);
}

/* The framework list: a button with the one picked, its logo and count; it opens every framework the projects
   have, the biggest first, with a search box for a long list. */
.st-browse-kind {
    position: relative;
    min-width: 0;
}

.st-browse-kind-btn {
    max-width: 100%;
}

.st-browse-kind-btn > span:not(.st-sr-only):not(.st-browse-kind-n) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-browse-kind-ico {
    flex: none;
    width: 16px;
    height: 16px;
    fill: var(--kind, var(--st-accent));
}

.st-browse-kind-n {
    flex: none;
    min-width: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--st-bg-sunken);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--st-ink-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.st-browse-kind[open] .st-browse-kind-btn > svg:last-child {
    transform: rotate(180deg);
}

.st-browse-kind-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: 60;
    box-sizing: border-box;
    width: min(300px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid var(--st-line-strong);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(18, 18, 18, 0.14);
}

.st-browse-kind-find {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    margin: 0 0 6px;
    padding: 0 12px;
    border: 1px solid var(--st-line-strong);
    border-radius: 8px;
    background: #fff;
    font-family: var(--st-font-ui);
    font-size: 14px;
    color: var(--st-ink);
}

.st-browse-kinds {
    max-height: min(360px, 55vh);
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
}

.st-browse-kind-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    font-family: var(--st-font-ui);
    font-size: 14px;
    color: var(--st-ink);
}

.st-browse-kind-opt .st-browse-kind-ico {
    width: 18px;
    height: 18px;
}

.st-browse-kind-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-browse-kind-opt:hover {
    background: var(--st-bg-sunken);
}

.st-browse-kind-opt.is-active {
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--st-accent);
}

.st-browse-kind-none {
    margin: 6px 10px 4px;
    font-size: 13px;
    color: var(--st-ink-muted);
}

.st-browse-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.st-browse-sort {
    position: relative;
}

.st-browse-sort-btn {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.st-browse-sort-btn::-webkit-details-marker {
    display: none;
}

.st-browse-sort-k {
    font-weight: 500;
    color: var(--st-ink-muted);
}

.st-browse-sort[open] .st-browse-sort-btn svg {
    transform: rotate(180deg);
}

.st-browse-sort-menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    z-index: 60;
    min-width: 190px;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--st-line-strong);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(18, 18, 18, 0.14);
    list-style: none;
}

.st-browse-sort-opt {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    font-family: var(--st-font-ui);
    font-size: 14px;
    color: var(--st-ink);
}

.st-browse-sort-opt:hover {
    background: var(--st-bg-sunken);
}

.st-browse-sort-opt.is-active {
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--st-accent);
}

.st-browse-status {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--st-ink-muted);
    font-variant-numeric: tabular-nums;
}

/* The grid: as many 300 px columns as the frame holds; every card in a row as tall as the tallest. */
.st-browse-results {
    container: browse / inline-size;
}

.st-browse-symbols {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.st-browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.st-browse-grid[hidden] {
    display: none;
}

.st-browse-item {
    display: flex;
    min-width: 0;
}

.st-browse-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(18, 18, 18, 0.16);
    border-radius: 12px;
    background: #fff;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.st-browse-card:hover {
    border-color: rgba(124, 58, 237, 0.38);
    box-shadow: 0 14px 30px rgba(124, 58, 237, 0.1);
    transform: translateY(-2px);
}

.st-browse-card:has(.st-browse-link:focus-visible) {
    outline: 3px solid var(--st-accent);
    outline-offset: 2px;
}

/* 16:10, from the first paint: the owner's picture, or the stack's colour and mark. */
.st-browse-cover {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-bottom: 1px solid var(--st-line);
    background-color: #f4f1fb;
    background-color: color-mix(in srgb, var(--kind, #7c3aed) 10%, #fff);
    background-image:
        radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--kind, #7c3aed) 20%, transparent), transparent 58%),
        radial-gradient(circle at 88% 92%, color-mix(in srgb, var(--kind, #7c3aed) 14%, transparent), transparent 52%);
    color: var(--kind, #7c3aed);
    color: color-mix(in srgb, var(--kind, #7c3aed) 88%, #000);
}

.st-browse-glyph {
    width: 30%;
    max-width: 76px;
    height: auto;
    aspect-ratio: 1;
    fill: currentColor;
}

.st-browse-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.st-browse-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 14px 16px 16px;
}

.st-browse-name {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-family: var(--st-font-display);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--st-ink);
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.st-browse-link {
    color: inherit;
    text-decoration: none;
}

/* The heading's link covers the card: a click anywhere opens the project, Ctrl or Cmd-click a new tab. */
.st-browse-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.st-browse-link:focus-visible {
    outline: none;
    text-decoration: underline;
}

.st-browse-by {
    margin: 0;
    overflow: hidden;
    font-size: 13px;
    color: var(--st-ink-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-browse-owner {
    font-weight: 600;
}

.st-browse-desc {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    color: var(--st-ink-muted);
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.st-browse-marks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: auto 0 0;
    padding: 6px 0 0;
    list-style: none;
}

.st-browse-mark {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 24px;
    padding: 0 9px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--st-bg-sunken);
    font-family: var(--st-font-ui);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--st-ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-browse-mark--boost {
    background: #ede9fe;
    color: #5b21b6;
}

.st-browse-mark--live {
    gap: 6px;
    background: #dcfce7;
    color: #166534;
}

.st-browse-mark--live::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.st-browse-empty {
    padding: 48px 20px;
    border: 1px dashed var(--st-line-strong);
    border-radius: 12px;
    text-align: center;
    color: var(--st-ink-muted);
}

.st-browse-empty[hidden],
.st-browse-more-row[hidden] {
    display: none;
}

.st-browse-empty p {
    margin: 0;
}

.st-browse-empty .st-browse-empty-title {
    margin-bottom: 6px;
    font-family: var(--st-font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--st-ink);
}

.st-browse-empty a {
    font-weight: 600;
    color: var(--st-accent-deep);
    text-decoration: underline;
}

.st-browse-more-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
}

.st-browse-more-left {
    font-size: 13px;
    color: var(--st-ink-muted);
}

/* Make your own: one way to start, after the list. */
.st-browse-make {
    padding: 40px 0;
    border-top: 1px solid var(--st-line);
    background:
        radial-gradient(ellipse 70% 120% at 0% 0%, rgba(124, 58, 237, 0.08), transparent 60%),
        var(--st-bg-sunken);
}

.st-browse-make-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
}

.st-browse-make-copy {
    flex: 1 1 320px;
    min-width: 0;
}

.st-browse-make-title {
    margin: 0;
    font-family: var(--st-font-display);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--st-ink);
}

.st-browse-make-text {
    margin: 6px 0 0;
    max-width: 52ch;
    font-size: 15px;
    line-height: 1.5;
    color: var(--st-ink-muted);
}

.st-browse-make-btn {
    flex: 0 0 auto;
}

/* A visible focus on every control */
.st-browse-kind-opt:focus-visible,
.st-browse-kind-find:focus-visible,
.st-browse-sort-btn:focus-visible,
.st-browse-sort-opt:focus-visible,
.st-browse-empty a:focus-visible,
.st-browse .st-btn:focus-visible {
    outline: 3px solid var(--st-accent);
    outline-offset: 2px;
}

.st-browse-search-go:focus-visible {
    outline: 3px solid var(--st-accent);
    outline-offset: -3px;
}

/* Phones: one compact row a card, its 96 x 60 cover beside the name. */
@container browse (max-width: 619px) {
    .st-browse-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .st-browse-card {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 10px;
    }

    .st-browse-card:hover {
        transform: none;
    }

    .st-browse-cover {
        flex: 0 0 96px;
        width: 96px;
        border: 0;
        border-radius: 8px;
    }

    .st-browse-glyph {
        width: 40%;
    }

    .st-browse-body {
        gap: 3px;
        padding: 0;
    }

    .st-browse-name {
        font-size: 15px;
    }

    .st-browse-desc,
    .st-browse-mark--remix,
    .st-browse-mark--domain {
        display: none;
    }

    .st-browse-marks {
        margin-top: 2px;
        padding: 0;
    }

    .st-browse-mark {
        min-height: 20px;
        padding: 0 7px;
        font-size: 11px;
    }
}

/* Phones: the framework button and the order share one row; the framework's name gives way first. */
@media (max-width: 640px) {
    .st-browse {
        padding-top: 20px;
    }

    .st-browse-search {
        max-width: none;
    }

    .st-browse-bar {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .st-browse-tools {
        flex: none;
        flex-wrap: nowrap;
    }

    .st-browse-sort-btn {
        padding: 0 12px;
    }

    /* "Sort:" stays for screen readers; the button shows the order and its arrow. */
    .st-browse-sort-k {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (pointer: coarse) {
    .st-browse-kind-opt,
    .st-browse-kind-find,
    .st-browse-sort-btn,
    .st-browse-sort-opt {
        min-height: 44px;
    }

}

@media (prefers-reduced-motion: reduce) {
    .st-browse-card {
        transition: none;
    }

    .st-browse-card:hover {
        transform: none;
    }
}
