/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-hover: #22222f;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #707080;
    --accent-blue: #4285f4;
    --accent-purple: #a855f7;
    --border-color: #2a2a3a;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --radius: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(ellipse at top, rgba(102, 126, 234, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.08) 0%, transparent 55%),
        var(--bg-primary);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* ===== Logo ===== */
.logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -1px;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    background: linear-gradient(90deg, #4facfe 0%, #667eea 25%, #a855f7 50%, #f5576c 75%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Masthead (logo + tagline + search) ===== */
.masthead {
    text-align: center;
    padding: 56px 0 12px;
    animation: fadeInDown 0.6s ease-out;
    transition: padding 0.25s ease;
}

.masthead .logo {
    font-size: 4.5rem;
    margin-bottom: 6px;
    transition: font-size 0.2s ease;
}

.masthead .tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 36px;
    transition: opacity 0.2s ease;
}

.masthead .search-wrap {
    max-width: 640px;
    margin: 0 auto;
}

/* Compact state: collapse the big logo/tagline but KEEP the search bar visible */
.masthead.compact {
    padding: 24px 0 4px;
    animation: none;
}

.masthead.compact .logo {
    font-size: 1.9rem;
    margin-bottom: 0;
}

.masthead.compact .tagline {
    display: none;
}

.masthead.compact .search-wrap {
    margin-top: 14px;
}

.search-wrap {
    position: relative;
}

/* ===== Search box ===== */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 0 8px 0 20px;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.search-box:focus-within {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
    box-shadow: 0 8px 40px rgba(66, 133, 244, 0.18);
}

.search-box svg.ico {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 15px 14px;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-family: inherit;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.icon-btn[hidden] {
    display: none;
}

/* ===== Recent searches ===== */
.recent {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 8px;
    z-index: 50;
    box-shadow: 0 12px 40px var(--shadow-color);
}

.recent[hidden] {
    display: none;
}

.recent-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 6px 12px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.recent-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.recent-item svg {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Category chips ===== */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 28px 0 8px;
}

.chip {
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 7px;
}

.chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chip.active {
    background: var(--gradient-1);
    color: #fff;
    border-color: transparent;
}

.chip .count {
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.12);
    padding: 1px 7px;
    border-radius: 20px;
    color: inherit;
}

.chip.active .count {
    background: rgba(255, 255, 255, 0.22);
}

/* ===== Results meta ===== */
.meta-row {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 22px 2px 16px;
    min-height: 18px;
}

/* ===== Grid ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
    animation: fadeInUp 0.4s ease-out;
    outline: none;
}

.card:hover,
.card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
    box-shadow: 0 10px 30px rgba(66, 133, 244, 0.12);
    background: var(--bg-tertiary);
}

.card.kbd-active {
    transform: translateY(-3px);
    border-color: var(--accent-purple);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.18);
    background: var(--bg-tertiary);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 11px;
}

.logo-img,
.logo-ph {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.logo-ph {
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
}

.card-url {
    font-size: 0.76rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-cat {
    margin-left: auto;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

/* Neon "LIVE" badge */
.card-live {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #39ff14;
    border: 1px solid rgba(57, 255, 20, 0.5);
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
    background: rgba(57, 255, 20, 0.08);
    text-shadow: 0 0 6px rgba(57, 255, 20, 0.9);
    box-shadow: 0 0 6px rgba(57, 255, 20, 0.35), inset 0 0 6px rgba(57, 255, 20, 0.15);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #39ff14;
    box-shadow: 0 0 6px 1px rgba(57, 255, 20, 0.9);
    animation: livePulse 1.4s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.7); }
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
}

.card-title mark,
.card-desc mark {
    background: rgba(168, 85, 247, 0.35);
    color: #fff;
    border-radius: 3px;
    padding: 0 2px;
}

.card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 20px;
}

/* ===== Empty state ===== */
.empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.4s ease-out;
}

.empty[hidden] {
    display: none;
}

.empty svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.empty h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ===== Keyboard hint ===== */
.kbd-hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 36px;
    text-align: center;
}

.kbd-hint kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1px 7px;
    font-family: inherit;
    font-size: 0.75rem;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ===== Responsive ===== */
@media (max-width: 620px) {
    .shell { padding: 0 16px 60px; }
    .hero { padding: 40px 0 8px; }
    .hero .logo { font-size: 3.2rem; }
    .grid { grid-template-columns: 1fr; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
