/* =============================================================================
   Base - Front-porch retheme: cream paper, rust ink, halftone dots
   ============================================================================= */

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

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Merriweather', Georgia, 'Times New Roman', serif;
    --font-display: 'Roboto Slab', Georgia, 'Times New Roman', serif;
    --font-script: 'Caveat', 'Comic Sans MS', cursive;

    --cream: #E7E1D6;
    --cream-deep: #D8D1C4;
    --cream-paper: #f2ebdc;
    --char: #0F0F10;
    --ink: #171615;
    --rust: #B23A2B;
    --rust-dark: #7A2A1F;
    --ash: #6E6A65;

    --text: var(--ink);
    --text-muted: rgba(15, 15, 16, 0.62);
    --bg: var(--cream);
    --accent: var(--rust);
    --link: var(--rust-dark);
    --link-hover: var(--rust);
    --border: rgba(15, 15, 16, 0.16);
    --line: rgba(15, 15, 16, 0.16);
    --code-background: rgba(15, 15, 16, 0.06);
    --code-border: rgba(15, 15, 16, 0.18);
    --bg-secondary: rgba(15, 15, 16, 0.05);
    --bg-alt: rgba(255, 250, 239, 0.55);
    --accent-dark: var(--rust-dark);
    --bg-primary: var(--cream);
    --text-primary: var(--ink);
    --text-secondary: var(--text-muted);
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
    --font-typewriter: 'Special Elite', 'Courier New', Consolas, monospace;

    --card: rgba(255, 250, 239, 0.72);
    --card-dark: rgba(15, 15, 16, 0.92);
    --shadow: 0 28px 80px rgba(15, 15, 16, 0.18);
    --shadow-soft: 0 12px 32px rgba(15, 15, 16, 0.10);
    --radius: 28px;
    --radius-sm: 18px;

    --sidebar-width: 220px;
    --content-max: 720px;
    --gap: 56px;
}

html {
    font-size: 16px;
    min-height: 100%;
    background: var(--cream);
}

body {
    font-family: var(--font-serif);
    line-height: 1.7;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 18% 8%, rgba(178, 58, 43, 0.14), transparent 32rem),
        radial-gradient(circle at 92% 22%, rgba(122, 42, 31, 0.13), transparent 28rem),
        linear-gradient(135deg, var(--cream), var(--cream-paper) 48%, var(--cream-deep));
}

/* Halftone dot overlay across the whole page */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.30;
    mix-blend-mode: multiply;
    background-image:
        radial-gradient(rgba(15, 15, 16, 0.18) 0.7px, transparent 0.7px),
        radial-gradient(rgba(15, 15, 16, 0.10) 0.5px, transparent 0.5px);
    background-position: 0 0, 12px 18px;
    background-size: 26px 26px, 34px 34px;
}

body.home-view ul li {
    margin-left: 2em;
}

body.home-view main a {
    text-decoration: underline;
    font-weight: 500;
    color: var(--rust-dark);
}

/* Inline Icons */
.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    display: inline-block;
    flex-shrink: 0;
}

/* Layout */
.layout {
    position: relative;
    z-index: 1;
    display: flex;
    gap: var(--gap);
    min-height: 100vh;
    max-width: calc(var(--sidebar-width) + var(--gap) + var(--content-max) + 80px);
    margin: 0 auto;
    padding: 2.25rem 1.5rem 2.5rem;
}

/* Sidebar — dark glass card */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 2.25rem;
    align-self: flex-start;
    padding: 22px 20px 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card-dark);
    color: var(--cream);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.logo {
    display: block;
    line-height: 0;
    margin: 0 auto;
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
    transform: rotate(-1.5deg);
    transition: transform 220ms ease;
}

.logo:hover {
    transform: rotate(-1.5deg) scale(1.02);
}

.logo-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 180px;
}

.logo-icon {
    width: 100%;
    background: var(--rust);
    color: var(--cream);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-weight: 800;
    font-size: 1.25rem;
}

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--cream);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

.menu-open .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.menu-open .hamburger span:nth-child(2) {
    opacity: 0;
}

.menu-open .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* Sidebar nav */
.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar nav a {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 600;
    color: rgba(231, 225, 214, 0.75);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    border: 1px solid transparent;
    position: relative;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.sidebar nav a:hover {
    color: #fff7e8;
    background: rgba(178, 58, 43, 0.16);
    border-color: rgba(178, 58, 43, 0.36);
}

.sidebar nav a.active {
    color: #fff7e8;
    background: rgba(178, 58, 43, 0.24);
    border-color: rgba(178, 58, 43, 0.55);
}

.sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: -0.4rem;
    top: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--rust);
    transform: translateY(-50%);
    box-shadow: 0 0 0 3px rgba(178, 58, 43, 0.22);
}

.nav-spacer {
    height: 0.5rem;
    margin: 0.4rem 0;
    border-top: 1px solid rgba(231, 225, 214, 0.12);
}

/* Logout form styled as nav link */
.logout-form {
    display: inline;
    margin: 0;
}

.logout-form button {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 600;
    color: rgba(231, 225, 214, 0.75);
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    text-align: left;
    width: 100%;
    border-radius: 12px;
    transition: color 160ms, background 160ms;
}

.logout-form button:hover {
    color: #fff7e8;
    background: rgba(178, 58, 43, 0.16);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.75rem;
    padding: 0 0.4rem;
}

.lang-switcher button {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(231, 225, 214, 0.20);
    border-radius: 999px;
    background: transparent;
    color: rgba(231, 225, 214, 0.70);
    cursor: pointer;
    transition: all 160ms;
}

.lang-switcher button:hover {
    color: #fff7e8;
    border-color: rgba(178, 58, 43, 0.55);
}

.lang-switcher button.active {
    background: var(--rust);
    color: #fff7e8;
    border-color: var(--rust);
}

/* Language Filter (post lists) */
.lang-filter {
    display: flex;
    gap: 0.25rem;
    font-family: var(--font-sans);
    font-size: 0.8rem;
}

.lang-filter button {
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 250, 239, 0.55);
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 700;
}

.lang-filter button:hover {
    color: var(--ink);
    border-color: var(--rust);
}

.lang-filter button.active {
    background: var(--rust);
    color: #fff7e8;
    border-color: var(--rust);
}

/* List Header (filter controls) */
.list-header {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Reply Filter */
.reply-filter {
    font-family: var(--font-sans);
    font-size: 0.8rem;
}

.filter-toggle {
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 250, 239, 0.55);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
}

.filter-toggle:hover {
    color: var(--ink);
    border-color: var(--rust);
}

.filter-toggle.active {
    background: var(--rust);
    color: #fff7e8;
    border-color: var(--rust);
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    max-width: var(--content-max);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 6rem);
}

main {
    flex: 1;
}

/* Footer */
footer {
    margin-top: 4rem;
    padding-top: 1.25rem;
    border-top: 4px double var(--char);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.copyright {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--rust-dark);
}

.footer-links svg {
    display: block;
}

/* Empty state */
.no-posts {
    color: var(--text-muted);
    font-style: italic;
}

/* Wide content mode (editor pages) */
.wide-content .main-wrapper {
    max-width: 920px;
}

img.speed {
    max-width: 200px;
    margin: 1em auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 900px) {
    :root {
        --gap: 32px;
        --sidebar-width: 200px;
    }
}

@media (max-width: 800px) {
    .layout {
        flex-direction: column;
        padding: 0 1rem 2rem;
        gap: 1rem;
    }

    /* Mobile sidebar — top bar with brand mark + hamburger */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        z-index: 1000;
        padding: 0.6rem 1rem;
        border: none;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        background: rgba(15, 15, 16, 0.96);
        box-shadow: 0 6px 24px rgba(15, 15, 16, 0.18);
        /* No backdrop-filter on mobile: it would make .sidebar the containing
           block for the position:fixed nav drawer, collapsing it to bar height. */
        backdrop-filter: none;
    }

    .sidebar-header {
        margin-bottom: 0;
    }

    .logo {
        margin: 0;
        transform: rotate(-2deg);
    }

    .logo-img {
        width: 44px;
        height: 44px;
        max-width: 44px;
    }

    .hamburger {
        display: flex;
    }

    /* Off-canvas drawer */
    .sidebar nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        background: rgba(15, 15, 16, 0.97);
        padding: 5rem 1.25rem 2rem;
        flex-direction: column;
        gap: 0.4rem;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
        z-index: 999;
        overflow-y: auto;
    }

    .menu-open .sidebar nav {
        transform: translateX(0);
    }

    .sidebar nav a {
        font-size: 1rem;
        padding: 0.6rem 0.85rem;
    }

    .sidebar nav a.active::before {
        display: none;
    }

    .nav-spacer {
        height: 0.5rem;
        border-top: 1px solid rgba(231, 225, 214, 0.14);
        margin: 0.5rem 0;
    }

    .menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 15, 16, 0.45);
        z-index: 998;
    }

    .main-wrapper {
        margin-top: 70px;
        max-width: 100%;
    }

    .page-header {
        margin-bottom: 1rem;
    }

    footer {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}
