/* ─── Browse (public files) ─── */

.browse-hero {
    max-width: 1100px;
    margin: 0 auto;
    padding: 50px 24px 20px;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.browse-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(800px 300px at 50% 0%, rgba(59, 130, 246, 0.12), transparent 60%);
    z-index: -1;
    pointer-events: none;
}

.browse-hero-inner {
    animation: browse-hero-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes browse-hero-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.browse-eyebrow {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #60a5fa;
    padding: 5px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 100px;
    margin-bottom: 14px;
}

.browse-title {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 10px;
}
@media (max-width: 640px) { .browse-title { font-size: 1.6rem; } }

.browse-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 560px;
    margin: 0 auto;
}

.browse-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 80px;
    position: relative;
    z-index: 1;
}
@media (max-width: 480px) { .browse-container { padding: 0 16px 60px; } }

/* ── Search + toolbar ── */
.browse-search {
    margin: 28px 0 16px;
    animation: browse-search-in 0.5s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes browse-search-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.browse-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 4px 6px 4px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.browse-search-wrap:focus-within {
    border-color: rgba(96, 165, 250, 0.55);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.browse-search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.browse-search-input {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 12px 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.browse-search-kbd {
    flex-shrink: 0;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
}
.browse-search-wrap:focus-within .browse-search-kbd { display: none; }
@media (max-width: 640px), (hover: none) { .browse-search-kbd { display: none; } }

.browse-search-btn {
    padding: 10px 22px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    border: 0;
    border-radius: 100px;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s;
}
.browse-search-btn:hover { transform: translateY(-1px); }
@media (max-width: 400px) { .browse-search-btn { padding: 10px 14px; } }

.browse-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}
@media (max-width: 720px) {
    .browse-toolbar { flex-direction: column; align-items: stretch; }
}

.browse-types {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    min-width: 0;
}
.browse-types::-webkit-scrollbar { display: none; }

.browse-type {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 100px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.browse-type:hover { color: var(--text-primary); border-color: rgba(96, 165, 250, 0.4); }
.browse-type.is-active {
    color: #fff;
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(96, 165, 250, 0.55);
}
.browse-type-count {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
}

.browse-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.browse-sort-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.browse-sort-select:focus { outline: none; border-color: rgba(96, 165, 250, 0.6); }

/* ── Popular tags ── */
.browse-tags {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
}
.browse-tags-label {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.browse-tags ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}
@media (max-width: 640px) {
    .browse-tags { flex-direction: column; gap: 6px; }
}

.browse-tag,
.browse-card-tags a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 500;
    color: #93c5fd;
    text-decoration: none;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 100px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.browse-tag span { font-size: 11px; color: var(--text-muted); }
.browse-tag:hover,
.browse-card-tags a:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(96, 165, 250, 0.5);
    color: #dbeafe;
}
.browse-tag.is-active,
.browse-card-tags a.is-active {
    background: #2563eb;
    border-color: #3b82f6;
    color: #fff;
}
.browse-tag.is-active span { color: rgba(255, 255, 255, 0.75); }

/* ── Result summary ── */
.browse-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 2px 18px;
}
.browse-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 6px 3px 10px;
    font-size: 12px;
    color: var(--text-primary);
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.browse-filter-pill span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
}
.browse-filter-pill:hover span { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.browse-clear { font-size: 12px; color: #60a5fa; text-decoration: none; }
.browse-clear:hover { text-decoration: underline; }

.browse-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fca5a5;
    font-size: 13px;
    margin-bottom: 18px;
}

/* ── Card grid ── */
.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}
@media (max-width: 540px) {
    .browse-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

.browse-card {
    --type-tint: 96, 165, 250;
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: inherit;
    overflow: hidden;
    /* Staggered entrance */
    opacity: 0;
    transform: translateY(14px);
    animation: browse-card-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: calc(0.02s * var(--idx, 0) + 0.15s);
    transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}
.browse-card--image    { --type-tint: 52, 211, 153; }
.browse-card--video    { --type-tint: 244, 114, 182; }
.browse-card--audio    { --type-tint: 167, 139, 250; }
.browse-card--document { --type-tint: 96, 165, 250; }
.browse-card--archive  { --type-tint: 251, 191, 36; }
.browse-card--other    { --type-tint: 148, 163, 184; }

@keyframes browse-card-in {
    to { opacity: 1; transform: translateY(0); }
}

.browse-card:hover,
.browse-card:focus-within {
    transform: translateY(-4px);
    border-color: rgba(96, 165, 250, 0.4);
    background: var(--bg-card-hover);
    box-shadow: 0 18px 36px -16px rgba(59, 130, 246, 0.35);
}

/* Media area: thumbnail for images, a tinted type icon for everything else */
.browse-card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(var(--type-tint), 0.18), transparent 70%),
        rgba(var(--type-tint), 0.05);
    border-bottom: 1px solid var(--border);
}
.browse-card-icon {
    width: 44px;
    height: 44px;
    color: rgba(var(--type-tint), 0.85);
    transition: transform 0.3s ease;
}
.browse-card:hover .browse-card-icon { transform: scale(1.08); }

.browse-card-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.4s ease;
    z-index: 1;
}
.browse-card-thumb.is-loaded { opacity: 1; }
.browse-card-thumb.is-broken { display: none; }
.browse-card:hover .browse-card-thumb.is-loaded { transform: scale(1.04); }
/* Without JS the thumbnail simply shows once loaded */
html:not(.js) .browse-card-thumb { opacity: 1; }

.browse-card-ext {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    color: rgb(var(--type-tint));
    background: rgba(10, 14, 26, 0.72);
    border: 1px solid rgba(var(--type-tint), 0.35);
    border-radius: 6px;
    backdrop-filter: blur(6px);
}

.browse-card-body {
    flex: 1;
    padding: 14px 16px 0;
}
.browse-card-name {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}
.browse-card-link {
    color: var(--text-primary);
    text-decoration: none;
}
/* The whole card is clickable; tag links sit above this overlay */
.browse-card-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
}
.browse-card-link:focus-visible { outline: none; }
.browse-card:has(.browse-card-link:focus-visible) {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.browse-card-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.browse-card-tags {
    position: relative;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}
.browse-card-tags a { padding: 2px 8px; font-size: 11px; }

.browse-card-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 16px 0;
    padding: 10px 0 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
@media (max-width: 540px) {
    .browse-card-body { padding: 10px 12px 0; }
    .browse-card-name { font-size: 14px; }
    .browse-card-desc { display: none; }
    .browse-card-footer { margin: 10px 12px 0; padding: 8px 0 10px; }
    .browse-card-footer > span:nth-child(2) { display: none; }
}

/* ── Empty state ── */
.browse-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    animation: browse-card-in 0.45s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.browse-empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.browse-empty-icon svg { width: 28px; height: 28px; }
.browse-empty h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}
.browse-empty p { font-size: 13px; margin: 0; }
.browse-empty-action {
    display: inline-block;
    margin-top: 16px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #60a5fa;
    text-decoration: none;
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: 8px;
}
.browse-empty-action:hover { background: rgba(59, 130, 246, 0.1); }

/* ── Pagination ── */
.browse-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 34px;
    flex-wrap: wrap;
}
.browse-pagination a,
.browse-pagination .current {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.browse-pagination a:hover {
    border-color: rgba(96, 165, 250, 0.4);
    color: var(--text-primary);
}
.browse-pagination .current {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(96, 165, 250, 0.4);
    color: #60a5fa;
}

@media (prefers-reduced-motion: reduce) {
    .browse-hero-inner,
    .browse-search,
    .browse-card,
    .browse-empty { animation: none !important; opacity: 1 !important; transform: none !important; }
    .browse-card-thumb,
    .browse-card-icon { transition: none; }
}
