:root {
    --bg: #f6f1e7;
    --bg-elevated: #ece4d5;
    --bg-card: #fffdf8;
    --text: #1a1613;
    --text-muted: #726b60;
    --accent: #c2410c;
    --accent-warm: #ff6b35;
    --accent-red: #c1121f;
    --font-mono: 'Fira Code', 'SF Mono', monospace;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
}

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

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* Page transition overlay */
#page-transition {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.htmx-request #page-transition {
    opacity: 1;
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1.25rem 5vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: rgba(246, 241, 231, 0.72);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(26, 22, 19, 0.08);
}

.logo {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--text);
}

.nav-links {
    display: flex;
    gap: 2.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: color 0.3s;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

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

.nav-links a:hover::after {
    width: 100%;
}

/* Hero */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 5vw;
    position: relative;
    background-image:
        linear-gradient(rgba(246, 241, 231, 0.88), rgba(246, 241, 231, 0.7)),
        url("https://images.unsplash.com/photo-1510127034890-ba27508e9f1c?ixid=M3wxMDAzNTQ3fDB8MXxzZWFyY2h8MXx8dmludGFnZSUyMGNhbWVyYXxlbnwwfDB8fHwxNzg0NjQzNzYwfDA&ixlib=rb-4.1.0&w=2000&q=80&fm=jpg&fit=crop");
    background-size: cover;
    background-position: center;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 12vw, 10rem);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.04em;
    margin-bottom: 2rem;
}

.hero-title .line-1 {
    display: block;
    color: var(--text);
}

.hero-title .line-2 {
    display: block;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--accent);
    font-style: italic;
}

.hero-subtitle {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 480px;
    line-height: 1.8;
}

.hero-meta {
    position: absolute;
    bottom: 3rem;
    right: 5vw;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.8;
}

.hero-credit {
    position: absolute;
    bottom: 3rem;
    left: 5vw;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.hero-credit a {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.3s;
}

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

/* Asymmetric Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    padding: 2rem 5vw 6rem;
}

.post-card {
    background: var(--bg-card);
    border: 1px solid rgba(26, 22, 19, 0.08);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: var(--delay, 0s);
}

.post-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 107, 53, 0.55);
}

.posts-grid .post-card:nth-child(1) {
    grid-column: span 7;
}

.posts-grid .post-card:nth-child(2) {
    grid-column: span 5;
}

.posts-grid .post-card:nth-child(3) {
    grid-column: span 4;
}

.posts-grid .post-card:nth-child(4) {
    grid-column: span 4;
}

.posts-grid .post-card:nth-child(5) {
    grid-column: span 4;
}

.posts-grid .post-card:nth-child(6) {
    grid-column: span 6;
}

.posts-grid .post-card:nth-child(7) {
    grid-column: span 6;
}

.posts-grid .post-card:nth-child(n+8) {
    grid-column: span 4;
}

@keyframes rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-card-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    filter: grayscale(20%) contrast(1.02);
    transition: filter 0.5s;
}

.post-card:hover .post-card-image {
    filter: grayscale(0%) contrast(1);
}

.post-card-content {
    padding: 1.5rem;
}

.post-card-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.75rem;
}

.post-card-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-wrap: balance;
}

.post-card-title a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.3s;
}

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

.post-card-excerpt {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.post-card-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Post Page */
.post-hero {
    height: 70vh;
    position: relative;
    overflow: hidden;
}

.post-hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(1.05);
}

.post-hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 5rem 5vw 3rem;
    background: linear-gradient(transparent 0%, var(--bg) 88%);
}

.post-hero-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    max-width: 800px;
    line-height: 1.1;
}

.post-content {
    max-width: 680px;
    margin: 0 auto;
    padding: 4rem 2rem;
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content h1 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    margin: 3rem 0 1rem;
    color: var(--accent);
}

.post-content h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    color: var(--text);
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(194, 65, 12, 0.35);
    transition: border-color 0.3s;
}

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

.post-content img {
    width: 100%;
    border-radius: 2px;
    margin: 2.5rem 0;
    border: 1px solid rgba(26, 22, 19, 0.1);
}

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

.post-content pre {
    background: var(--bg-elevated);
    border: 1px solid rgba(26, 22, 19, 0.1);
    border-left: 2px solid var(--accent);
    padding: 1.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    margin: 2rem 0;
    border-radius: 0 4px 4px 0;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--accent);
    background: rgba(255, 107, 53, 0.12);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: var(--text);
}

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

.post-content li {
    margin-bottom: 0.5rem;
}

.post-meta-footer {
    border-top: 1px solid rgba(26, 22, 19, 0.1);
    padding-top: 2rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.related-posts {
    margin-top: 4rem;
}

.related-posts h3 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1.5rem;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.related-card {
    background: var(--bg-card);
    border: 1px solid rgba(26, 22, 19, 0.08);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.3s;
}

.related-card:hover {
    border-color: rgba(255, 107, 53, 0.4);
}

.related-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin-top: 0.5rem;
    line-height: 1.3;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.5rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    background: var(--bg-elevated);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-item:hover img {
    transform: scale(1.08);
}

.gallery-item-exif {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem;
    background: linear-gradient(transparent, rgba(20, 14, 8, 0.88));
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: rgba(255, 251, 245, 0.85);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    line-height: 1.7;
}

.gallery-item:hover .gallery-item-exif {
    transform: translateY(0);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(246, 241, 231, 0.96);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-img {
    max-width: 75%;
    max-height: 85%;
    object-fit: contain;
    box-shadow: 0 25px 80px rgba(26, 22, 19, 0.28);
}

.lightbox-info {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2rem;
    border: 1px solid rgba(26, 22, 19, 0.12);
    min-width: 220px;
    line-height: 2;
}

.lightbox-info strong {
    color: var(--accent);
    font-weight: 400;
    display: inline-block;
    width: 90px;
}

.lightbox-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Admin */
.admin-container {
    max-width: 760px;
    margin: 0 auto;
    padding: 8rem 2rem 4rem;
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.6rem;
}

.form-input,
.form-textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid rgba(26, 22, 19, 0.14);
    color: var(--text);
    padding: 0.9rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    border-radius: 2px;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.16);
}

.form-textarea {
    min-height: 320px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.7;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.drop-zone {
    border: 2px dashed rgba(26, 22, 19, 0.18);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    border-radius: 2px;
}

.drop-zone p {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.06);
}

.drop-zone input[type="file"] {
    display: none;
}

.btn {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 1rem 2.5rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 2px;
    font-weight: 600;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(194, 65, 12, 0.28);
}

.alert {
    padding: 1rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border-radius: 2px;
}

.alert-success {
    background: rgba(39, 107, 77, 0.12);
    border: 1px solid rgba(39, 107, 77, 0.28);
    color: #276b4d;
}

.alert-error {
    background: rgba(193, 18, 31, 0.1);
    border: 1px solid rgba(193, 18, 31, 0.25);
    color: var(--accent-red);
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

/* Unsplash picker */
.unsplash-trigger {
    display: inline-block;
    margin-top: 0.75rem;
    background: none;
    border: 1px solid rgba(26, 22, 19, 0.18);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0.7rem 1.25rem;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 0.3s, color 0.3s;
}

.unsplash-trigger:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.unsplash-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(246, 241, 231, 0.96);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 6vh 5vw;
}

.unsplash-modal.active {
    display: flex;
}

.unsplash-panel {
    background: var(--bg-card);
    border: 1px solid rgba(26, 22, 19, 0.12);
    border-radius: 4px;
    width: 100%;
    max-width: 900px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(26, 22, 19, 0.2);
}

.unsplash-head {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(26, 22, 19, 0.08);
}

.unsplash-head input {
    flex: 1;
    background: var(--bg);
    border: 1px solid rgba(26, 22, 19, 0.14);
    color: var(--text);
    padding: 0.8rem 1rem;
    border-radius: 2px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
}

.unsplash-head input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.16);
}

.unsplash-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: color 0.3s;
}

.unsplash-close:hover {
    color: var(--accent);
}

.unsplash-results {
    overflow-y: auto;
    padding: 1.25rem;
}

.unsplash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.unsplash-item {
    padding: 0;
    border: 1px solid rgba(26, 22, 19, 0.08);
    background: var(--bg-elevated);
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 1;
    border-radius: 2px;
    transition: border-color 0.2s, transform 0.2s;
}

.unsplash-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.unsplash-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.unsplash-msg {
    grid-column: 1 / -1;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 1rem;
}

.unsplash-hint {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(26, 22, 19, 0.08);
    text-align: center;
}

/* Journal archive */
.journal {
    padding: 8rem 5vw 6rem;
}

.journal-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.03em;
    margin-bottom: 3rem;
}

.journal-title .line-1 {
    display: block;
    color: var(--text);
}

.journal-title .line-2 {
    display: block;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--accent);
    font-style: italic;
}

.journal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.load-more {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 2rem;
    background: none;
    border: 1px solid rgba(26, 22, 19, 0.18);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0.9rem 2rem;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 0.3s, color 0.3s;
}

.load-more:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.view-all-wrap {
    text-align: center;
    padding: 0 5vw 6rem;
}

.view-all {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(194, 65, 12, 0.35);
    padding-bottom: 2px;
    transition: border-color 0.3s;
}

.view-all:hover {
    border-color: var(--accent);
}

@media (max-width: 1024px) {
    .journal-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .posts-grid {
        grid-template-columns: 1fr;
    }

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

    .posts-grid .post-card:nth-child(n) {
        grid-column: span 1;
    }

    .hero-title {
        font-size: 3.5rem;
    }

    .nav {
        padding: 1rem 1.5rem;
    }

    .nav-links {
        gap: 1.25rem;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .lightbox-info {
        position: static;
        transform: none;
        margin-top: 1rem;
        width: 90%;
    }

    .lightbox {
        flex-direction: column;
        padding: 1rem;
    }

    .lightbox-img {
        max-width: 100%;
        max-height: 60%;
    } }
