/* =============================================================================
   Rust Tool Index — calm, professional, table-driven layout.

   A restrained white/grey palette with hairline borders, barely-there shadows,
   tight radii, per-category icons, a roomy sticky search header, and one table
   per category with friendly green/amber/red status badges. Overrides the dark
   tokens from base.css.
   ============================================================================= */

:root {
    /* Surfaces & ink */
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --surface-hover: #f9fbfc;

    /* Hairline borders */
    --border: #e5e8ee;
    --border-soft: #eef1f5;
    --border-strong: #d7dce4;

    /* Text ramp (warm slate greys) */
    --ink: #18222f;
    --text: #45505f;
    --text-dim: #69727f;
    --text-faint: #98a1ae;

    /* Friendly green accent */
    --accent: #1f9d6b;
    --accent-ink: #157049;
    --accent-soft: #eaf6f0;
    --accent-ring: rgba(31, 157, 107, 0.16);

    /* Status colours (kept friendly, softened) */
    --ok-ink: #1a7a4c;
    --ok-bg: #ecf7f1;
    --warn-ink: #9a6a14;
    --warn-bg: #fcf3e2;
    --err-ink: #c0392b;
    --err-bg: #fcecea;

    /* Geometry — deliberately tight & consistent */
    --r-lg: 10px;
    --r-md: 8px;
    --r-sm: 6px;
    --r-xs: 4px;

    /* Whisper-soft elevation */
    --shadow: 0 1px 2px rgba(20, 28, 44, 0.04);

    --max-width: 1200px;
    --gutter: 32px;
    --header-h: 65px;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

a:visited {
    color: var(--accent-ink);
}

a:hover {
    opacity: 0.82;
}

::selection {
    background: var(--accent-ring);
}

/* ----------------------------------------------------------------- Header -- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
    text-align: left;
    margin: 0;
}

.site-header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14px var(--gutter);
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    flex-shrink: 0;
}

.brand:hover {
    opacity: 1;
}

.brand-logo {
    width: 24px;
    height: 24px;
}

.brand-title {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    max-width: 440px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--text-faint);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
    transition: stroke 0.12s ease;
}

.filter-input {
    width: 100%;
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--ink);
    font-size: 0.92rem;
    font-family: inherit;
    padding: 9px 16px 9px 40px;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease;
}

.filter-input::placeholder {
    color: var(--text-faint);
}

.filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.search-wrap:focus-within .search-icon {
    stroke: var(--accent);
}

.header-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.8rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

.header-stat {
    white-space: nowrap;
}

.header-pill {
    color: var(--text-dim);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 5px 12px;
    font-weight: 600;
    background-color: var(--surface);
    transition:
        color 0.12s ease,
        border-color 0.12s ease;
}

.header-pill:hover {
    color: var(--accent-ink);
    border-color: var(--accent);
    opacity: 1;
}

/* --------------------------------------------------------------- Catalog -- */

.catalog {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px var(--gutter) 96px;
    width: 100%;
    flex: 1;
}

.catalog-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
    flex-wrap: wrap;
    padding-bottom: 22px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border);
}

.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    flex: 1 1 auto;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-dim);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 5px 11px;
    transition:
        color 0.12s ease,
        border-color 0.12s ease,
        background-color 0.12s ease;
}

.category-chip:hover {
    color: var(--accent-ink);
    border-color: var(--accent);
    background-color: var(--accent-soft);
    opacity: 1;
}

.chip-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.chip-count {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.category-chip:hover .chip-count {
    color: var(--accent-ink);
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.toggle input {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}

/* Right-hand filter cluster: deprecated/recommended toggles + license select. */
.filter-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px 18px;
    /* Keep the cluster pinned right even when it wraps below the category nav. */
    margin-left: auto;
}

.select-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.select-filter-label {
    color: var(--text-faint);
}

.select-filter select {
    font: inherit;
    font-size: 0.8rem;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 4px 26px 4px 9px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2390a0a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease;
}

.select-filter select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ------------------------------------------------------------- Category --- */

.category {
    margin-bottom: 52px;
    scroll-margin-top: calc(var(--header-h) + 24px);
}

.category-head {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 14px;
    row-gap: 3px;
    align-items: center;
    margin-bottom: 16px;
}

.category-icon {
    grid-row: 1 / span 2;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--r-md);
    background-color: var(--accent-soft);
    color: var(--accent-ink);
}

.category-icon svg {
    width: 18px;
    height: 18px;
}

.category-heading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.category-title {
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.015em;
    margin: 0;
    display: inline;
}

.category-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 9px;
    flex-shrink: 0;
}

.category-desc {
    grid-column: 2;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: 0;
    text-align: left;
}

/* ---------------------------------------------------------------- Table --- */

.table-wrap {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tool-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.tool-table thead th {
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface-alt);
}

.col-tool {
    width: 17%;
    min-width: 176px;
}
.col-num {
    width: 88px;
    text-align: right !important;
}
.col-status {
    width: 112px;
    text-align: right !important;
}

/* Tighten the right-hand metric cluster so the numbers and status badge read
   as one neat, right-aligned block instead of drifting apart. */
.tool-table thead th.col-num,
.tool-table thead th.col-status,
.cell-num,
.cell-status {
    padding-left: 8px;
    padding-right: 18px;
}

.tool-table tbody tr {
    border-bottom: 1px solid var(--border-soft);
    transition: background-color 0.1s ease;
}

.tool-table tbody tr:last-child {
    border-bottom: none;
}

.tool-table tbody tr:hover {
    background-color: var(--surface-hover);
}

.tool-table td {
    padding: 18px 20px;
    vertical-align: top;
}

.tool-table tbody tr:target {
    background-color: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Tool cell */

/* Editor's pick: a prominent badge plus a subtle row accent. */
.tool.is-recommended td {
    background-color: var(--accent-soft);
}

.tool.is-recommended td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

.pick-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    padding: 2px 8px 2px 6px;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    background-color: var(--accent);
    border-radius: var(--r-xs);
}

.pick-star {
    width: 11px;
    height: 11px;
    fill: currentColor;
    stroke: none;
}

.cell-tool .tool-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.005em;
}

.cell-tool .tool-name:hover {
    color: var(--accent-ink);
    opacity: 1;
}

.tool-repo {
    display: inline-flex;
    align-items: flex-start;
    gap: 5px;
    font-size: 0.74rem;
    color: var(--text-faint);
    font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
    margin-top: 5px;
    max-width: 100%;
}

.tool-repo:hover {
    color: var(--text-dim);
    opacity: 1;
}

.tool-repo span {
    overflow-wrap: anywhere;
}

.repo-icon {
    width: 13px;
    height: 13px;
    fill: currentColor;
    flex-shrink: 0;
    margin-top: 1px;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
}

.tag {
    font-size: 0.68rem;
    color: var(--text-dim);
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    padding: 1px 7px;
    font-variant-numeric: tabular-nums;
}

.tool-maint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-faint);
    margin-top: 8px;
}

/* Notes cell */

.cell-notes {
    color: var(--text);
}

.notes-body {
    font-size: 0.86rem;
    line-height: 1.62;
}

.notes-body p {
    margin: 0 0 8px;
}

.notes-body p:last-child {
    margin-bottom: 0;
}

.notes-body code {
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    padding: 0.5px 5px;
    font-size: 0.82em;
    color: #39455a;
    font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
}

.notes-body strong {
    color: var(--ink);
    font-weight: 600;
}

.notes-body a {
    color: var(--accent-ink);
    text-decoration: underline;
    text-decoration-color: var(--accent-ring);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.12s ease;
}

.notes-body a:hover {
    text-decoration-color: var(--accent);
}

.relation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 12px 0 0;
    font-size: 0.74rem;
}

.relation-label {
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.65rem;
    font-weight: 600;
}

.relation-tool {
    border-radius: var(--r-xs);
    padding: 1px 7px;
}

/* Resolved references link to the target tool's row: a solid, clickable pill. */
a.relation-tool--link {
    color: var(--text);
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    text-decoration: none;
    cursor: pointer;
    transition:
        border-color 0.12s ease,
        color 0.12s ease;
}

a.relation-tool--link:hover,
a.relation-tool--link:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Unresolved references (built-ins, non-Rust tools) are inert labels, not
   links: muted text, a dashed border, and no pointer affordance. */
span.relation-tool {
    color: var(--text-faint);
    background-color: transparent;
    border: 1px dashed var(--border);
    cursor: default;
}

/* Numeric cells */

.cell-num {
    text-align: right;
    font-size: 0.82rem;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-num .muted {
    color: var(--text-faint);
}

.cell-status {
    text-align: right;
}

/* Status badges — friendly colours, gently rounded */

.pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: var(--r-sm);
    padding: 3px 10px;
    white-space: nowrap;
    line-height: 1.5;
}

.status-ok {
    color: var(--ok-ink);
    background-color: var(--ok-bg);
}

.status-deprecated {
    color: var(--err-ink);
    background-color: var(--err-bg);
}

.status-stale {
    color: var(--warn-ink);
    background-color: var(--warn-bg);
}

/* Deprecated rows: gently muted, not hidden. */

.tool.is-archived td {
    background-color: var(--surface-alt);
}

.tool.is-archived .tool-name {
    color: var(--text-dim);
}

.tool.is-archived .notes-body {
    color: var(--text-dim);
}

/* ------------------------------------------------------------- Utilities -- */

.no-results {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.95rem;
    padding: 80px 0;
}

/* ---------------------------------------------------------------- Footer -- */

.site-footer {
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    margin-top: auto;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 26px var(--gutter) 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-dim);
}

.footer-links a:hover {
    color: var(--accent-ink);
    opacity: 1;
}

.footer-logo {
    height: 20px;
    opacity: 0.65;
    filter: grayscale(1);
    transition: opacity 0.15s ease;
}

.footer-brand:hover .footer-logo {
    opacity: 1;
}

.footer-note {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter) 28px;
    font-size: 0.78rem;
    color: var(--text-faint);
}

/* --------------------------------------------------------------- 404 ------ */

.notfound {
    max-width: 520px;
    margin: 16vh auto;
    text-align: center;
    padding: 0 24px;
}

.notfound h1 {
    font-size: 4rem;
    color: var(--ink);
    display: block;
}

.notfound p {
    color: var(--text-dim);
    margin-top: 10px;
}

/* ------------------------------------------------------------ Responsive -- */

@media (max-width: 900px) {
    .site-header-inner {
        flex-wrap: wrap;
        gap: 14px 20px;
    }

    .search-wrap {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }

    .header-meta {
        margin-left: auto;
    }

    .table-wrap {
        overflow-x: auto;
    }

    .tool-table {
        min-width: 760px;
    }
}

@media (max-width: 620px) {
    :root {
        --gutter: 18px;
    }

    .category-desc {
        grid-column: 1 / -1;
    }
}
