/* ==========================================================================
   Identity 2.0 — Warm Brutalist Theme
   ========================================================================== */

/* ---------- Custom Properties ---------- */
:root {
    --bg: #FFF8F0;
    --bg-alt: #E8E0D8;
    --text: #4A4A4A;
    --heading: #1A1A1A;
    --accent: #FF5722;
    --accent-hover: #E64A19;
    --highlight: #FFD600;
    --link: #00897B;
    --link-hover: #00695C;
    --border: #1A1A1A;
    --white: #FFFFFF;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --radius: 3px;
    --shadow: 4px 4px 0 var(--heading);
    --shadow-sm: 2px 2px 0 var(--heading);
    --shadow-hover: 6px 6px 0 var(--heading);

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    --space-2xl: 6rem;

    --container: 1200px;
    --container-narrow: 800px;

    --header-h: 72px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote {
    margin: 0;
    padding: 0;
}

img, video, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
ul, ol { list-style: none; }

/* ---------- Base ---------- */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }

body {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--highlight);
    color: var(--heading);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--heading);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

h1 { font-size: clamp(2.5rem, 5vw + 1rem, 4.5rem); }
h2 { font-size: clamp(1.8rem, 3vw + 0.5rem, 3rem); }
h3 { font-size: clamp(1.4rem, 2vw + 0.5rem, 2rem); }
h4 { font-size: clamp(1.15rem, 1.5vw + 0.5rem, 1.5rem); }

.meta, .tag, .pill, .mono {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ---------- Layout ---------- */
.container {
    width: min(var(--container), 100% - 2rem);
    margin-inline: auto;
}

.container--narrow {
    width: min(var(--container-narrow), 100% - 2rem);
    margin-inline: auto;
}

.grid {
    display: grid;
    gap: var(--space-lg);
}

/* ---------- Reading Progress Bar ---------- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 1000;
    background: transparent;
}

.reading-progress__bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 50ms linear;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 3px solid var(--border);
    height: var(--header-h);
    display: flex;
    align-items: center;
    transition: box-shadow 0.3s ease;
}

.site-header.is-scrolled {
    box-shadow: 0 4px 20px rgba(26, 26, 26, 0.08);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header__logo {
    text-decoration: none;
    color: var(--heading);
}

.header__brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.03em;
}

/* Nav */
.nav-list {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.nav-list li a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--heading);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border: 2px solid transparent;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.nav-list li a:hover,
.nav-list li.current-menu-item a,
.nav-list li.current_page_item a {
    border-color: var(--border);
    background: var(--highlight);
    box-shadow: var(--shadow-sm);
}

/* Hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 2px solid var(--border);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius);
}

.nav-toggle__line {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--heading);
    transition: all 0.3s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__line:nth-child(2) {
    opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ---------- Hero ---------- */
.hero {
    padding: var(--space-lg) 0;
    border-bottom: 3px solid var(--border);
    background: var(--bg-alt);
    overflow: hidden;
}

.hero__title {
    font-size: clamp(2rem, 4vw + 1rem, 3.5rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    margin-bottom: var(--space-sm);
}

.hero__title em {
    font-style: normal;
    color: var(--accent);
    display: inline-block;
}

.hero__subtitle {
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--text);
    max-width: 600px;
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    background: var(--accent);
    border: 3px solid var(--border);
    padding: 0.8em 1.8em;
    text-decoration: none;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.hero__cta:hover {
    background: var(--accent-hover);
    color: var(--white);
    box-shadow: var(--shadow-hover);
    transform: translate(-2px, -2px);
}

/* ---------- Section ---------- */
.section {
    padding: var(--space-lg) 0;
}

.section__title {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 3px solid var(--border);
}

/* ---------- Post Cards ---------- */
.posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

.post-card {
    background: var(--white);
    border: 3px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translate(-2px, -2px);
}

.post-card__image {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-bottom: 3px solid var(--border);
}

.post-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.post-card:hover .post-card__image img {
    transform: scale(1.05);
}

.post-card__body {
    padding: var(--space-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.post-card__category {
    display: inline-block;
    background: var(--highlight);
    color: var(--heading);
    border: 2px solid var(--border);
    padding: 0.2em 0.7em;
    margin-bottom: var(--space-sm);
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
}

.post-card__title {
    font-size: clamp(1.15rem, 2vw, 1.5rem);
    margin-bottom: var(--space-xs);
}

.post-card__title a {
    color: var(--heading);
    text-decoration: none;
}

.post-card__title a:hover {
    color: var(--accent);
}

.post-card__excerpt {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
    flex: 1;
    margin-bottom: var(--space-sm);
}

.post-card__meta {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    color: var(--text);
    opacity: 0.7;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--bg-alt);
}

/* ---------- Single Post ---------- */
.single-header {
    padding: var(--space-xl) 0 var(--space-lg);
    border-bottom: 3px solid var(--border);
    background: var(--bg-alt);
}

.single-header__category {
    display: inline-block;
    background: var(--highlight);
    color: var(--heading);
    border: 2px solid var(--border);
    padding: 0.2em 0.7em;
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
}

.single-header__title {
    margin-bottom: var(--space-md);
}

.single-header__meta {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    color: var(--text);
}

.single-header__meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
}

/* Post content layout */
.single-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
    padding: var(--space-xl) 0;
}

.post-content {
    max-width: var(--container-narrow);
}

/* Prose styles for post content */
.post-content > * + * {
    margin-top: 1.5em;
}

.post-content h2 {
    margin-top: 2.5em;
    padding-bottom: 0.3em;
    border-bottom: 3px solid var(--bg-alt);
}

.post-content h3 {
    margin-top: 2em;
}

.post-content p { line-height: 1.8; }

.post-content a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: var(--highlight);
    text-decoration-thickness: 3px;
    text-underline-offset: 3px;
    transition: text-decoration-color 0.15s ease;
}

.post-content a:hover {
    text-decoration-color: var(--accent);
}

.post-content ul, .post-content ol {
    padding-left: 1.5em;
}

.post-content ul { list-style: square; }
.post-content ol { list-style: decimal; }

.post-content li + li { margin-top: 0.5em; }

.post-content blockquote {
    border-left: 5px solid var(--accent);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-alt);
    font-style: italic;
    font-size: 1.15rem;
}

.post-content pre {
    background: var(--heading);
    color: var(--bg);
    padding: var(--space-md);
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    border: 3px solid var(--border);
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-alt);
    padding: 0.15em 0.4em;
    border-radius: var(--radius);
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-content img {
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

.post-content figure figcaption {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text);
    opacity: 0.7;
    margin-top: var(--space-xs);
    text-align: center;
}

/* ---------- Table of Contents (Sidebar) ---------- */
.toc {
    position: sticky;
    top: calc(var(--header-h) + 2rem);
    max-height: calc(100vh - var(--header-h) - 4rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-alt) transparent;
}

.toc__heading {
    font-size: 0.8rem;
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 2px solid var(--border);
}

.toc__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc__link {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
    text-decoration: none;
    padding: 0.4em 0.8em;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
    transition: all 0.15s ease;
}

.toc__link:hover {
    color: var(--heading);
    background: var(--bg-alt);
}

.toc__link.is-active {
    color: var(--heading);
    background: var(--highlight);
    border-left-color: var(--accent);
    font-weight: 500;
}

.toc__link--h3 {
    padding-left: 1.5em;
    font-size: 0.7rem;
}

/* ---------- Post Navigation ---------- */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    padding: var(--space-lg) 0;
    border-top: 3px solid var(--border);
    margin-top: var(--space-xl);
}

.post-nav__item {
    padding: var(--space-md);
    background: var(--bg-alt);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.15s ease;
}

.post-nav__item:hover {
    box-shadow: var(--shadow-sm);
    transform: translate(-1px, -1px);
}

.post-nav__label {
    display: block;
    color: var(--text);
    margin-bottom: 0.3em;
}

.post-nav__title {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--heading);
    font-size: 1rem;
}

.post-nav__item--next { text-align: right; }

/* ---------- Archive Header ---------- */
.archive-header {
    padding: var(--space-xl) 0 var(--space-lg);
    border-bottom: 3px solid var(--border);
    background: var(--bg-alt);
}

.archive-header__label {
    display: inline-block;
    background: var(--highlight);
    color: var(--heading);
    border: 2px solid var(--border);
    padding: 0.2em 0.7em;
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-sm);
}

.archive-header__desc {
    margin-top: var(--space-sm);
    max-width: 600px;
    font-size: 1rem;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
    align-items: center;
    padding: var(--space-xl) 0;
}

.pagination a, .pagination span {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.5em 1em;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--heading);
    transition: all 0.15s ease;
}

.pagination a:hover {
    background: var(--highlight);
    box-shadow: var(--shadow-sm);
}

.pagination .current {
    background: var(--accent);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

/* ---------- Search ---------- */
.search-form {
    display: flex;
    gap: 0;
    max-width: 500px;
}

.search-form input[type="search"] {
    flex: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.7em 1em;
    border: 3px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    background: var(--white);
    outline: none;
}

.search-form input[type="search"]:focus {
    border-color: var(--accent);
}

.search-form button {
    font-family: var(--font-display);
    font-weight: 600;
    padding: 0.7em 1.5em;
    background: var(--accent);
    color: var(--white);
    border: 3px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-form button:hover {
    background: var(--accent-hover);
}

/* ---------- 404 ---------- */
.error-page {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.error-page__code {
    font-family: var(--font-display);
    font-size: clamp(8rem, 20vw, 16rem);
    font-weight: 700;
    color: var(--heading);
    line-height: 1;
    text-shadow: 8px 8px 0 var(--bg-alt);
    margin-bottom: var(--space-md);
}

.error-page__text {
    font-size: 1.3rem;
    margin-bottom: var(--space-lg);
}

/* ---------- Comments ---------- */
.comments-area {
    padding: var(--space-xl) 0;
    border-top: 3px solid var(--border);
    margin-top: var(--space-xl);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.comment-body {
    background: var(--white);
    border: 2px solid var(--border);
    padding: var(--space-md);
    border-radius: var(--radius);
}

.comment-author {
    font-family: var(--font-display);
    font-weight: 600;
}

.comment-content { margin-top: var(--space-sm); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text);
    opacity: 0.7;
    margin-bottom: var(--space-md);
}

.breadcrumbs a { color: var(--link); }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--heading);
    color: var(--bg-alt);
    padding: var(--space-xl) 0;
    border-top: 5px solid var(--accent);
}

.footer__inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

.footer__logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--white);
    text-decoration: none;
}

.footer__tagline {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    opacity: 0.6;
    margin-top: var(--space-xs);
}

.footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.footer__links a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--bg-alt);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color 0.15s ease;
}

.footer__links a:hover { color: var(--highlight); }

.footer__bottom {
    font-size: 0.8rem;
    opacity: 0.5;
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ---------- Scroll to Top ---------- */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: var(--white);
    border: 3px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(1rem);
    transition: all 0.3s ease;
    z-index: 50;
}

.scroll-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-hover);
    transform: translate(-2px, -2px);
}

/* ---------- Utilities ---------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.animate-on-scroll {
    opacity: 1;
    transform: none;
}

.no-results {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.no-results__title {
    margin-bottom: var(--space-md);
}

/* ---------- Responsive ---------- */

/* Tablet */
@media (min-width: 768px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer__inner {
        grid-template-columns: 1fr 1fr;
    }

    .single-layout {
        grid-template-columns: 1fr 240px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .single-layout {
        grid-template-columns: 1fr 280px;
    }

    .footer__inner {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

/* Mobile nav */
@media (max-width: 767px) {
    .nav-toggle {
        display: flex;
    }

    .main-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg);
        border-top: 3px solid var(--border);
        padding: var(--space-lg);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 99;
    }

    .main-nav.is-open {
        transform: translateX(0);
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .nav-list li a {
        display: block;
        padding: var(--space-sm);
        font-size: 1rem;
        border-bottom: 1px solid var(--bg-alt);
    }

    .toc {
        position: static;
        max-height: none;
        margin-bottom: var(--space-lg);
        padding: var(--space-md);
        background: var(--bg-alt);
        border: 2px solid var(--border);
        border-radius: var(--radius);
    }

    .single-layout {
        display: flex;
        flex-direction: column-reverse;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }

    .hero__title {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }
}
