/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f13;
    color: #e2e2e8;
    line-height: 1.5;
}

a { color: #7eb8f7; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App layout ───────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

.layout__content {
    flex: 1;
    padding: 2rem 1.5rem;
    min-width: 0; /* prevents flex child from overflowing */
    max-width: 1200px;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    min-width: 220px;
    background: #1a1a24;
    border-right: 1px solid #2e2e3e;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2e2e3e;
    min-height: 48px;
}

.sidebar__toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.sidebar__toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #b0b0c0;
    border-radius: 1px;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    gap: 0.125rem;
}

.sidebar__section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5a5a70;
    padding: 0.75rem 1rem 0.25rem;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #b0b0c0;
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.1s, color 0.1s;
}

.sidebar__link:hover {
    background: #23232f;
    color: #e2e2e8;
    text-decoration: none;
}

.sidebar__link.active {
    color: #7eb8f7;
    background: #1e2a3a;
}

.sidebar__link-icon {
    font-size: 0.85rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* ── Site logo ────────────────────────────────────────────── */
.site-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.site-logo__ekg {
    width: 120px;
    height: 24px;
    overflow: visible;
}

.site-logo__ekg-line {
    fill: none;
    stroke: #7eb8f7;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: ekg-draw 1.6s ease-out forwards;
}

@keyframes ekg-draw {
    to { stroke-dashoffset: 0; }
}

.site-logo__name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
    line-height: 1;
}

/* ── Trending feed ────────────────────────────────────────── */
.trending-feed {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ── Trending row ─────────────────────────────────────────── */
.trending-row__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2e2e3e;
}

.trending-row__header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7eb8f7;
}

.trending-row__see-all {
    font-size: 0.8rem;
    color: #5a5a70;
    text-decoration: none;
    transition: color 0.15s;
}

.trending-row__see-all:hover {
    color: #7eb8f7;
    text-decoration: none;
}

/* Horizontal scroll */
.trending-row__scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: #2e2e3e transparent;
}

.trending-row__scroll::-webkit-scrollbar { height: 4px; }
.trending-row__scroll::-webkit-scrollbar-track { background: transparent; }
.trending-row__scroll::-webkit-scrollbar-thumb { background: #2e2e3e; border-radius: 2px; }

/* ── Trending card ────────────────────────────────────────── */
.trending-card {
    flex: 0 0 260px;
    background: #1a1a24;
    border: 1px solid #2e2e3e;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, background 0.15s;
    scroll-snap-align: start;
    cursor: pointer;
}

.trending-card--podcast {
    align-self: flex-start;
}

.trending-card:hover {
    border-color: #7eb8f7;
    background: #1e1e2a;
    text-decoration: none;
    color: inherit;
}

.trending-card__title {
    font-weight: 600;
    color: #e2e2e8;
    font-size: 0.9rem;
    line-height: 1.4;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trending-card:hover .trending-card__title { color: #7eb8f7; }

.trending-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #7a7a90;
}

.trending-card__score {
    background: #2e2e3e;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-weight: 600;
    color: #b0b0c0;
    font-size: 0.75rem;
}

.trending-card__stats {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: #7a7a90;
}

/* ── Source grid (source page) ────────────────────────────── */
.source-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.source-grid .trending-card {
    flex: unset; /* override horizontal scroll fixed width */
}

@media (min-width: 600px) {
    .source-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
    .source-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Source badge ─────────────────────────────────────────── */
.source-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: #2e2e3e;
    color: #b0b0c0;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.source-badge--reddit      { background: #e5342a; color: #fff; }
.source-badge--hackernews  { background: #ff6600; color: #fff; }
.source-badge--producthunt { background: #3b82f6; color: #fff; }
.source-badge--podcast     { background: #7c3aed; color: #fff; }
.source-badge--devto       { background: #22c55e; color: #fff; }

/* ── States ───────────────────────────────────────────────── */
.loading, .error { color: #7a7a90; padding: 2rem 0; }

/* ── Blazor error UI ──────────────────────────────────────── */
#blazor-error-ui {
    background: #2a1a1a;
    border-top: 1px solid #7b2020;
    bottom: 0;
    color: #e2e2e8;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 639px) {
    .layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        min-width: unset;
        min-height: unset;
        position: relative;
        height: auto;
    }

    .sidebar__toggle { display: flex; }

    .sidebar__nav--collapsed { display: none; }

    .layout__content { padding: 1.25rem 1rem; }
}
