/* ===== FOUNDATION ===== */

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

:root {
    color-scheme: dark;

    /* Palette — warm night library */
    --bg: #0c0a09;
    --surface: #151210;
    --surface-hover: #1e1a16;
    --text: #f5f2ed;
    --text-bright: #ffffff;
    --muted: #9e968e;
    --line: #2a2521;
    --accent: #c9784e;
    --accent-hover: #dfa07a;
    --accent-dim: rgba(201, 120, 78, 0.1);

    /* Layout */
    --max-width: 760px;
    --gutter: max(1.25rem, 4vw);

    /* Type */
    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'Figtree', system-ui, -apple-system, sans-serif;
}

/* --- Grain overlay --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 450;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ambient glow */
body::after {
    content: '';
    position: fixed;
    top: -15vh;
    left: -10vw;
    width: 50vw;
    height: 50vh;
    background: radial-gradient(ellipse at center, rgba(201, 120, 78, 0.05), transparent 70%);
    pointer-events: none;
    z-index: -1;
}

::selection {
    background: rgba(201, 120, 78, 0.25);
    color: var(--text-bright);
}

/* ===== LINKS ===== */

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.25s ease;
}

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

/* ===== SITE HEADER ===== */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: min(100% - var(--gutter) * 2, var(--max-width));
    margin: 0 auto;
    padding: 2rem 0;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--text-bright);
    letter-spacing: 0.01em;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    justify-content: flex-end;
}

nav a {
    position: relative;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width 0.3s ease;
}

nav a:hover {
    color: var(--accent-hover);
}

nav a:hover::after {
    width: 100%;
}

/* ===== MAIN CONTENT ===== */

main {
    width: min(100% - var(--gutter) * 2, var(--max-width));
    margin: 0 auto;
    padding: 2rem 0 6rem;
}

/* ===== HERO ===== */

.home-hero,
.page-heading,
.post-header {
    padding: 5rem 0 4rem;
}

.eyebrow,
time {
    display: inline-block;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1 {
    max-width: 14ch;
    margin-top: 1.25rem;
    color: var(--text-bright);
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 5.5rem);
    font-weight: 400;
    font-style: italic;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variation-settings: 'opsz' 72, 'WONK' 1;
}

.role {
    margin-top: 2rem;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.role strong {
    color: var(--text);
    font-weight: 600;
}

.intro,
.page-heading p,
.post-header p {
    max-width: 38rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.7;
}

/* CTA actions */

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 2.5rem;
}

.actions a {
    display: inline-flex;
    align-items: center;
    height: 2.6rem;
    padding: 0 1.15rem;
    border: 1px solid var(--line);
    border-radius: 100px;
    background: transparent;
    color: var(--muted);
    font-size: 0.87rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    transition: all 0.3s ease;
}

.actions a:first-child {
    border-color: var(--accent);
    color: var(--accent);
}

.actions a:hover {
    border-color: var(--accent);
    color: var(--text-bright);
    background: var(--accent-dim);
    transform: translateY(-1px);
}

/* ===== LATEST POSTS ===== */

.latest-posts {
    position: relative;
    padding-top: 3rem;
}

.latest-posts::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--accent) 40px, var(--line) 40px);
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.section-heading h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text);
}

.section-heading a {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.25s ease;
}

.section-heading a:hover {
    color: var(--accent-hover);
}

/* ===== POST LIST ===== */

.post-list {
    display: grid;
    gap: 0;
}

.post-preview {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0 1.5rem;
    align-items: baseline;
    padding: 1.35rem 0;
    border-bottom: 1px solid var(--line);
}

.post-preview:first-child {
    border-top: 1px solid var(--line);
}

.post-preview time {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.post-preview h2,
.post-preview h3 {
    grid-column: 2;
    grid-row: 1;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--text);
    margin-top: 0;
    transition: color 0.25s ease;
}

.post-preview:hover h2,
.post-preview:hover h3 {
    color: var(--accent-hover);
}

.post-preview p {
    grid-column: 2;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.55;
}

.muted {
    color: var(--muted);
}

/* ===== BLOG POST ===== */

.post {
    max-width: 680px;
}

.post-header {
    border-bottom: 1px solid var(--line);
    padding-bottom: 3rem;
}

.post-header h1 {
    max-width: 16ch;
    font-size: clamp(2.5rem, 7vw, 4.5rem);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 2rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.25s ease;
}

.back-link::before {
    content: '\2190';
    font-size: 0.9rem;
    transition: transform 0.25s ease;
}

.back-link:hover {
    color: var(--accent-hover);
}

.back-link:hover::before {
    transform: translateX(-3px);
}

/* ===== POST CONTENT ===== */

.post-content {
    padding-top: 2.5rem;
    color: #e8e3db;
    font-size: 1.06rem;
    line-height: 1.8;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content pre {
    margin-top: 1.35rem;
}

.post-content h2,
.post-content h3 {
    margin-top: 2.5rem;
    color: var(--text-bright);
    font-family: var(--font-display);
    font-weight: 400;
    font-style: italic;
    line-height: 1.3;
}

.post-content h2 {
    font-size: 1.6rem;
}

.post-content h3 {
    font-size: 1.3rem;
}

.post-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(201, 120, 78, 0.35);
    text-underline-offset: 0.2em;
    transition: text-decoration-color 0.25s ease;
}

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

.post-content code {
    border-radius: 4px;
    background: var(--surface);
    padding: 0.15rem 0.4rem;
    font-size: 0.92em;
}

.post-content pre {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 1.25rem;
}

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

.post-content blockquote {
    border-left: 2px solid var(--accent);
    padding-left: 1.25rem;
    color: var(--muted);
    font-style: italic;
}

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

.post-content li {
    margin-top: 0.4rem;
}


/* ===== ENTRANCE ANIMATIONS ===== */

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

.home-hero .eyebrow   { animation: enter 0.6s ease-out 0.05s both; }
.home-hero h1         { animation: enter 0.7s ease-out 0.12s both; }
.home-hero .role      { animation: enter 0.6s ease-out 0.20s both; }
.home-hero .intro     { animation: enter 0.6s ease-out 0.26s both; }
.home-hero .actions   { animation: enter 0.6s ease-out 0.32s both; }
.latest-posts         { animation: enter 0.7s ease-out 0.38s both; }
.page-heading         { animation: enter 0.7s ease-out both; }
.page-heading ~ .post-list { animation: enter 0.7s ease-out 0.1s both; }
.post-header          { animation: enter 0.7s ease-out both; }
.post-content         { animation: enter 0.7s ease-out 0.1s both; }

/* ===== REDUCED MOTION ===== */

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

/* ===== RESPONSIVE ===== */

@media (max-width: 620px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    nav {
        justify-content: flex-start;
        gap: 1.25rem;
    }

    main {
        padding-top: 0.5rem;
    }

    .home-hero,
    .page-heading,
    .post-header {
        padding: 3rem 0 2.5rem;
    }

    .post-preview {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .post-preview time {
        grid-column: 1;
        grid-row: auto;
    }

    .post-preview h2,
    .post-preview h3 {
        grid-column: 1;
        grid-row: auto;
    }

    .post-preview p {
        grid-column: 1;
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
