/* -------------------------------------------------
    Mobile-first, news-forward UI
    - Desktop: sticky sidebar + vertical nav
    - Mobile: top bar + menu button + slide-over panel
    - Single-column content feed
    - Story card expands into full article layout
  ------------------------------------------------- */

:root {
    --bg: #f6f7f9;
    --paper: #ffffff;
    --ink: #111827;
    /* slate-900 */
    --muted: #64748b;
    /* slate-500 */
    --border: #e5e7eb;
    /* gray-200 */
    --shadow: 0 10px 26px rgba(15, 23, 42, .06);

    --sidebar: #111827;
    --sidebarText: #cbd5e1;
    --sidebarActive: rgba(255, 255, 255, .10);

    --radius: 18px;
    --maxw: 820px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-news: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Layout ---------- */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* mobile first */
}

/* ---------- Sidebar (mobile = top bar) ---------- */
.sidebar {
    background: var(--sidebar);
    color: var(--sidebarText);
    border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.sidebar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .12);
    display: grid;
    place-items: center;
    font-weight: 900;
    color: #fff;
    letter-spacing: -0.02em;
}

.brand-title {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title strong {
    color: #fff;
    font-family: var(--font-news);
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: 16px;
}

.brand-title small {
    opacity: .75;
    font-size: 12px;
}

/* ---------- Desktop nav (hidden on mobile) ---------- */
.nav-desktop {
    display: none;
}

/* Base nav styles (desktop sidebar only) */
.nav {
    display: flex;
    gap: 6px;
}

.nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 14px;
    color: var(--sidebarText);
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}

.nav a:hover {
    background: var(--sidebarActive);
    text-decoration: none;
}

.nav a.active {
    background: var(--sidebarActive);
    color: #fff;
}

.nav-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .35);
}

/* ---------- Mobile menu button ---------- */
.menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, .12);
}

.menu-icon {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
}

/* ---------- Mobile overlay + slide-over ---------- */
.menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.menu-scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    border: 0;
    cursor: pointer;
}

.menu-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 86vw);
    height: 100vh;
    background: var(--sidebar);
    color: var(--sidebarText);
    border-right: 1px solid rgba(255, 255, 255, .10);
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
    transform: translateX(-105%);
    transition: transform .18s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-overlay.open .menu-panel {
    transform: translateX(0);
}

.menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.menu-title {
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.menu-close {
    width: 36px;
    height: 36px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #fff;
    cursor: pointer;
}

.menu-close:hover {
    background: rgba(255, 255, 255, .12);
}

/* Mobile menu nav (vertical, does NOT inherit .nav) */
.nav-mobile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding-right: 4px;
}

.nav-mobile a {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    color: var(--sidebarText);
    font-size: 14px;
    font-weight: 600;
}

.nav-mobile a:hover {
    background: var(--sidebarActive);
    text-decoration: none;
}

.nav-mobile a.active {
    background: var(--sidebarActive);
    color: #fff;
}

/* ---------- Main content ---------- */
.main {
    flex: 1;
    padding: 16px 14px 28px;
}

.container {
    max-width: var(--maxw);
    margin: 0 auto;
}

/* ---------- Page header ---------- */
.pagehead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin: 10px 0 16px;
}

.mast {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mast h4 {
    margin: 0;
    font-family: var(--font-news);
    letter-spacing: -0.05em;
    font-weight: 700;
    /* less shouty */
    font-size: 28px;
    line-height: 1.1;
}

.mast p {
    margin: 0;
    color: var(--muted);
    max-width: 58ch;
    font-size: 14px;
}

.tools {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
    min-width: min(320px, 100%);
}

.search input {
    border: 0;
    outline: none;
    width: 100%;
    font-size: 14px;
    background: transparent;
    color: var(--ink);
}

.pill {
    border: 1px solid var(--border);
    background: #fff;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
    display: inline-flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
}

.pill:hover {
    border-color: #cbd5e1;
}

/* ---------- Feed ---------- */
.feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- Story card ---------- */
.story {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.story:hover {
    border-color: #d1d5db;
    box-shadow: 0 16px 34px rgba(15, 23, 42, .08);
}

.story-inner {
    padding: 14px 14px 12px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    font-size: 12px;
}

.meta .sep {
    opacity: .55;
}

.story h2 {
    margin: 0 0 8px;
    font-family: var(--font-news);
    font-size: 20px;
    letter-spacing: -0.03em;
    line-height: 1.25;
    font-weight: 600;
    color: var(--ink);
}

.story p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
}

.story-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px 14px;
    border-top: 1px solid var(--border);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
}

.story-actions a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.01em;
}

.story-actions a:hover {
    text-decoration: none;
    opacity: .9;
}

.arrow {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    line-height: 1;
}

.bookmark {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

.bookmark:hover {
    border-color: #cbd5e1;
}

/* ---------- Full article mode ---------- */
.article-page .pagehead .mast h4 {
    font-size: 30px;
}

.story--full .story-inner {
    padding: 18px 18px 6px;
}

.story--full h1 {
    font-size: 26px;
    margin-bottom: 10px;
    font-family: var(--font-news);
}

.story--full h2 {
    font-size: 20px;
    margin: 20px 0 5px 0;
    font-family: var(--font-news);
}

.story--full .story-actions {
    border-top: 0;
    background: transparent;
    padding-top: 0;
}

.article-body {
    padding: 0 18px 18px;
    color: var(--ink);
}

.article-body h3 {
    font-family: var(--font-news);
    letter-spacing: -0.03em;
    font-weight: 600;
    margin: 18px 0 8px;
}

.article-body p {
    margin: 0 0 12px;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.65;
}

.article-body .muted {
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Footer ---------- */
.sitefoot {
    margin-top: 18px;
    color: var(--muted);
    font-size: 12px;
    padding: 8px 2px;
}

/* ---------- Desktop breakpoint ---------- */
@media (min-width: 980px) {
    .app {
        flex-direction: row;
    }

    .sidebar {
        width: 270px;
        min-height: 100vh;
        border-bottom: 0;
        border-right: 1px solid rgba(255, 255, 255, .10);
        position: sticky;
        top: 0;
        height: 100vh;
    }

    .sidebar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 18px 16px;
    }

    .brand {
        min-width: unset;
    }

    /* Show desktop nav, hide mobile menu */
    .nav-desktop {
        display: flex;
        flex-direction: column;
    }

    .menu-btn {
        display: none;
    }

    .menu-overlay {
        display: none !important;
    }

    /* Desktop nav layout */
    .nav {
        flex-direction: column;
    }

    .nav a {
        justify-content: flex-start;
    }

    .main {
        padding: 22px 22px 34px;
    }

    .pagehead {
        align-items: center;
        margin-top: 6px;
    }

    .mast h4 {
        font-size: 34px;
    }

    .search {
        min-width: 420px;
    }
}

/* Hard overrides to prevent mobile nav conflicts */
@media (max-width: 979px) {
    .nav.nav-desktop {
        display: none !important;
    }

    .menu-btn {
        display: inline-flex !important;
    }
}

@media (min-width: 980px) {
    .menu-overlay {
        display: none !important;
    }

    .nav-mobile {
        display: none !important;
    }
}

/* Pagination */
.pagination {
    margin: 28px 0 10px;
}

.pagination nav {
    display: flex;
    justify-content: center;
}

.pagination ul {
    display: flex;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination li {
    display: block;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
}

.pagination a:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.pagination a.is-active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
    cursor: default;
}

.pagination a.is-active:hover {
    background: var(--ink);
}

/* ---------- Auth / Register ---------- */
.auth-card {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.form-row input {
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 14px;
    background: #fff;
    color: var(--ink);
}

.form-row input:focus {
    outline: none;
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, .06);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

.btn-primary {
    height: 44px;
    border-radius: 14px;
    border: none;
    background: var(--ink);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.btn-primary:hover {
    opacity: .92;
}

.form-hint {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.form-hint a {
    color: var(--ink);
    font-weight: 600;
}