:root {
    --bg: #0a0a0a;
    --bg-raised: #121212;
    --rule: #262626;
    --rule-strong: #f5f5f0;
    --text: #f5f5f0;
    --text-secondary: #9a9a9a;
    --text-tertiary: #666666;
    --accent: #ffd400;
    --accent-text: #0a0a0a;
    --maxw: 1280px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem);
}

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

/* ---------- Masthead (sticky top bar) ---------- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--rule);
}

.masthead-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--text);
}

.brand-mark { display: block; flex: none; }

.brand-word {
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand-accent { color: var(--accent); }

.masthead-link {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    text-decoration: none;
}

.masthead-link:hover { color: var(--accent); }

/* ---------- Hero ---------- */

.hero { padding: clamp(2.5rem, 7vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2.5rem); }

.hero h1 {
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.02;
    margin-bottom: 1rem;
    max-width: 900px;
}

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

.hero .tagline {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.15rem);
    max-width: 640px;
    margin-bottom: 2rem;
}

/* ---------- Search ---------- */

.search-bar {
    max-width: 640px;
    margin-bottom: 1.75rem;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--rule-strong);
    padding-left: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-row:focus-within {
    box-shadow: 0 0 0 3px rgba(255, 212, 0, 0.25);
    border-color: var(--accent);
}

.search-icon { color: var(--text-tertiary); flex: none; }
.search-row:focus-within .search-icon { color: var(--accent); }

.search-row input {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.2rem 1rem 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

.search-row input::placeholder { color: var(--text-tertiary); }

/* ---------- Stats strip ---------- */

.stats-strip {
    display: flex;
    gap: 0;
    border: 1px solid var(--rule);
    max-width: 480px;
}

.stats-strip .stat {
    flex: 1;
    padding: 0.75rem 1rem;
    border-right: 1px solid var(--rule);
}

.stats-strip .stat:last-child { border-right: none; }

.stats-strip dt {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    font-weight: 700;
}

.stats-strip dd {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1.2;
}

/* ---------- Controls (filters + sort) ---------- */

.controls {
    position: sticky;
    top: 56px;
    z-index: 40;
    background: var(--bg);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    padding: 1rem 0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--rule-strong);
    color: var(--text);
    padding: 0.5rem 0.95rem;
    min-height: 40px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

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

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sort-controls label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.sort-controls select {
    background: var(--bg-raised);
    color: var(--text);
    border: 1px solid var(--rule-strong);
    padding: 0.5rem 0.9rem;
    min-height: 40px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

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

/* ---------- Loading / results ---------- */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 1rem;
    color: var(--text-secondary);
    padding: 4rem 0;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--rule);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.results-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 1.5rem 0 1rem;
}

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

/* ---------- Grid + cards ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
}

.card {
    position: relative;
    background: var(--bg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    transition: background-color 0.15s ease;
}

.card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.18s ease;
}

.card:hover { background: var(--bg-raised); }
.card:hover::before { transform: scaleY(1); }

.card .rank {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    word-break: break-word;
    line-height: 1.25;
}

.card-title:hover { color: var(--accent); }

.card-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag {
    font-size: 0.7rem;
    border: 1px solid var(--rule-strong);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    font-weight: 600;
}

.alt-tag {
    font-size: 0.7rem;
    background: var(--accent);
    color: var(--accent-text);
    padding: 0.15rem 0.5rem;
    font-weight: 800;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 700;
    border-top: 1px solid var(--rule);
    padding-top: 0.75rem;
}

.card-footer .star-link { color: var(--accent); text-decoration: none; }
.card-footer .star-link:hover { text-decoration: underline; }

/* ---------- Load more ---------- */

.loadmore-wrap { display: flex; justify-content: center; padding: 2rem 0 1rem; }

.loadmore {
    background: transparent;
    border: 1px solid var(--rule-strong);
    color: var(--text);
    font-family: inherit;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    padding: 0.9rem 2rem;
    min-height: 48px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.loadmore:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.loadmore:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Empty state ---------- */

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem 1.5rem;
}

.empty-state strong { color: var(--text); display: block; font-size: 1.1rem; margin-bottom: 0.5rem; }

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

footer {
    text-align: center;
    padding: 2.5rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--rule);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

/* ---------- Utility ---------- */

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

@media (max-width: 768px) {
    .grid { grid-template-columns: 1fr; }
    .controls { position: static; }
    .sort-controls { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .card, .card::before, .filter-btn, .loadmore, .search-row { transition: none; }
    .spinner { animation: none; }
}
