/* Blog Engine — Polestar-inspired Design
   =========================================
   Minimal, monochrome, generous whitespace, clean neo-grotesque typography.
   Does NOT use Bootstrap classes — this is a full custom design system.
*/

/* ------------------------------------------------------------------
   Design Tokens
   ------------------------------------------------------------------ */
:root {
    --color-bg: #ffffff;
    --color-bg-alt: #f5f5f5;
    --color-text: #1a1a1a;
    --color-text-muted: #6b6b6b;
    --color-text-light: #999999;
    --color-border: #e5e5e5;
    --color-nav-bg: #1a1a1a;
    --color-nav-text: #ffffff;
    --color-nav-text-muted: #999999;
    --color-link: #1a1a1a;
    --color-link-hover: #000000;
    --color-tag-bg: #f0f0f0;
    --color-tag-text: #4a4a4a;

    --font-body: 'Outfit', sans-serif;
    --font-weight-light: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;

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

    --max-content: 1200px;
    --max-text: 900px;
    --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

[data-theme="dark"] {
    --color-bg: #1c1c1c;
    --color-bg-alt: #252525;
    --color-text: #e0e0e0;
    --color-text-muted: #999999;
    --color-text-light: #666666;
    --color-border: #333333;
    --color-nav-bg: #111111;
    --color-link: #e0e0e0;
    --color-link-hover: #ffffff;
    --color-tag-bg: #2a2a2a;
    --color-tag-text: #bbbbbb;
}

/* Larger text mode — bumps content text only, not nav/layout/images */
[data-fontsize="large"] .post-content { font-size: 1.2rem; line-height: 1.85; }
[data-fontsize="large"] .post-content h2 { font-size: 1.8rem; }
[data-fontsize="large"] .post-content h3 { font-size: 1.5rem; }
[data-fontsize="large"] .post-content blockquote { font-size: 1.1rem; }
[data-fontsize="large"] .post-content pre { font-size: 1rem; }
[data-fontsize="large"] .post-header h1 { font-size: clamp(2.2rem, 5.5vw, 3.3rem); }
[data-fontsize="large"] .post-meta { font-size: 0.9rem; }

/* Homepage: featured hero */
[data-fontsize="large"] .featured-title { font-size: clamp(2.1rem, 4.5vw, 3.4rem); }
[data-fontsize="large"] .featured-excerpt { font-size: 1.1rem; }
[data-fontsize="large"] .featured-date { font-size: 0.9rem; }

/* Homepage: post cards */
[data-fontsize="large"] .card-title { font-size: 1.3rem; }
[data-fontsize="large"] .card-excerpt { font-size: 1rem; }
[data-fontsize="large"] .card-date { font-size: 0.85rem; }


/* ------------------------------------------------------------------
   Reset & Base
   ------------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: var(--font-weight-regular);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    letter-spacing: -0.01em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

::selection {
    background: var(--color-text);
    color: var(--color-bg);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}


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

h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: var(--space-md); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); margin-bottom: var(--space-sm); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); margin-bottom: var(--space-sm); }

p {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 1.25rem;
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: opacity var(--transition);
}

a:hover {
    color: var(--color-link-hover);
    opacity: 0.7;
}


/* ------------------------------------------------------------------
   Navigation
   ------------------------------------------------------------------ */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--color-nav-bg);
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--max-content);
    margin: 0 auto;
}

.brand {
    color: var(--color-nav-text);
    font-weight: var(--font-weight-medium);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
}

.brand:hover { opacity: 1; color: var(--color-nav-text); }

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    list-style: none;
}

.nav-links a {
    color: var(--color-nav-text-muted);
    font-size: 0.875rem;
    font-weight: var(--font-weight-regular);
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: color var(--transition);
}

.nav-links a:hover { color: var(--color-nav-text); opacity: 1; }

.nav-links .rss-link { display: flex; align-items: center; }
.nav-links .rss-link svg { width: 14px; height: 14px; fill: var(--color-nav-text-muted); transition: fill var(--transition); }
.nav-links .rss-link:hover svg { fill: var(--color-nav-text); }

/* Font-size toggle */
.fontsize-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: baseline;
    gap: 1px;
    color: var(--color-nav-text-muted);
    font-family: var(--font-body);
    font-weight: var(--font-weight-medium);
    transition: color var(--transition);
    line-height: 1;
}
.fontsize-toggle:hover { color: var(--color-nav-text); }
.fontsize-toggle .fs-small { font-size: 0.7rem; }
.fontsize-toggle .fs-large { font-size: 1rem; }
[data-fontsize="large"] .fontsize-toggle { color: var(--color-nav-text); }

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    color: var(--color-nav-text-muted);
    transition: color var(--transition);
}

.theme-toggle:hover { color: var(--color-nav-text); }
.theme-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    position: relative;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 1.5px;
    background: var(--color-nav-text);
    position: absolute;
    left: 0;
    transition: all var(--transition);
}

.nav-toggle span:nth-child(1) { top: 6px; }
.nav-toggle span:nth-child(2) { top: 11px; }
.nav-toggle span:nth-child(3) { top: 16px; }

.nav-toggle.active span:nth-child(1) { top: 11px; transform: rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { top: 11px; transform: rotate(-45deg); }

.nav-spacer { height: 64px; }


/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */
.content-wrap {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.content-narrow {
    max-width: var(--max-text);
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.section { padding: var(--space-xl) 0; }
.section-sm { padding: var(--space-lg) 0; }


/* ------------------------------------------------------------------
   Featured Post (Hero)
   ------------------------------------------------------------------ */
.featured-post {
    position: relative;
    width: 100%;
    aspect-ratio: 21 / 9;
    min-height: 400px;
    max-height: 70vh;
    overflow: hidden;
    background: var(--color-bg-alt);
    margin-bottom: var(--space-xl);
}

.featured-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.1) 50%, transparent 100%);
}

.featured-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-lg) var(--space-md);
    max-width: var(--max-content);
    margin: 0 auto;
}

.featured-date {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    font-weight: var(--font-weight-regular);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.05em;
}

.featured-title {
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: var(--font-weight-light);
    color: #ffffff;
    margin-bottom: var(--space-xs);
    letter-spacing: -0.03em;
    line-height: 1.1;
    max-width: 700px;
}

.featured-title a { color: inherit; text-decoration: none; }
.featured-title a:hover { opacity: 0.85; }

.featured-excerpt {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    max-width: 550px;
    line-height: 1.6;
    font-weight: var(--font-weight-light);
}

/* No-image variant */
.featured-post.no-image {
    background: var(--color-nav-bg);
    aspect-ratio: auto;
    min-height: auto;
    padding: var(--space-2xl) var(--space-md);
    display: flex;
    align-items: flex-end;
}

.featured-post.no-image .featured-content {
    position: relative;
    padding: 0;
}


/* ------------------------------------------------------------------
   Post Cards
   ------------------------------------------------------------------ */
.posts-section-title {
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.post-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: opacity var(--transition);
}

.post-card:hover { opacity: 0.75; color: inherit; }

.card-image-wrap {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--color-bg-alt);
    margin-bottom: var(--space-sm);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.post-card:hover .card-image { transform: scale(1.03); }

.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-alt);
    color: var(--color-text-light);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.card-date {
    font-size: 0.75rem;
    color: var(--color-text-light);
    font-weight: var(--font-weight-regular);
    margin-bottom: 0.4rem;
    letter-spacing: 0.03em;
}

.card-title {
    font-size: 1.15rem;
    font-weight: var(--font-weight-medium);
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.card-excerpt {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.55;
    font-weight: var(--font-weight-regular);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    margin-top: auto;
    padding-top: var(--space-xs);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    background: var(--color-tag-bg);
    color: var(--color-tag-text);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.tag-pill:hover { background: var(--color-text); color: var(--color-bg); opacity: 1; }

.draft-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    background: #f5c518;
    color: var(--color-text);
    margin-left: 0.5rem;
    vertical-align: middle;
}


/* ------------------------------------------------------------------
   Single Post
   ------------------------------------------------------------------ */
.post-header {
    padding: var(--space-xl) 0 var(--space-lg);
}

.post-meta {
    font-size: 0.8rem;
    color: var(--color-text-light);
    letter-spacing: 0.03em;
    margin-bottom: var(--space-sm);
}

.post-meta span + span::before { content: "·"; margin: 0 0.5rem; }

.post-header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: var(--font-weight-light);
    max-width: var(--max-text);
    margin-bottom: var(--space-sm);
}

.post-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: var(--space-sm); }

.post-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
    max-width: var(--max-text);
}

.post-content > * + * { margin-top: 1.5rem; }
.post-content h2 { font-size: 1.6rem; font-weight: var(--font-weight-regular); margin-top: var(--space-lg); }
.post-content h3 { font-size: 1.3rem; font-weight: var(--font-weight-regular); margin-top: var(--space-md); }
.post-content a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.post-content a:hover { opacity: 0.6; }
.post-content img { width: 100%; margin: var(--space-md) 0; }
.post-content iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; margin: var(--space-md) 0; }
.post-content figure { margin: var(--space-lg) 0; }
.post-content figure img { margin: 0; }
.post-content figcaption { font-size: 0.8rem; color: var(--color-text-light); margin-top: 0.6rem; line-height: 1.5; letter-spacing: 0.01em; }
.post-content blockquote { border-left: 2px solid var(--color-text); padding: var(--space-sm) var(--space-md); margin: var(--space-md) 0; font-style: italic; color: var(--color-text-muted); }
.post-content pre { background: var(--color-bg-alt); border: 1px solid var(--color-border); padding: var(--space-sm) var(--space-md); overflow-x: auto; font-size: 0.9rem; line-height: 1.65; margin: var(--space-md) 0; }
.post-content code { font-size: 0.9em; background: var(--color-bg-alt); padding: 0.15em 0.35em; }
.post-content pre code { background: none; padding: 0; }
.post-content table { width: 100%; border-collapse: collapse; margin: var(--space-md) 0; font-size: 0.95rem; }
.post-content th, .post-content td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--color-border); text-align: left; }
.post-content th { font-weight: var(--font-weight-medium); font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-muted); }


/* ------------------------------------------------------------------
   Post Nav
   ------------------------------------------------------------------ */
.post-nav {
    display: flex;
    justify-content: space-between;
    padding: var(--space-lg) 0;
    margin-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
    max-width: var(--max-text);
}

.post-nav a { font-size: 0.85rem; color: var(--color-text-muted); letter-spacing: 0.02em; }
.post-nav a:hover { color: var(--color-text); opacity: 1; }


/* ------------------------------------------------------------------
   Archive
   ------------------------------------------------------------------ */
.archive-year {
    font-size: 1.5rem;
    font-weight: var(--font-weight-light);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--color-border);
}

.archive-list { list-style: none; }
.archive-list li { padding: 0.6rem 0; display: flex; align-items: baseline; gap: var(--space-sm); }
.archive-list .archive-date { font-size: 0.8rem; color: var(--color-text-light); font-variant-numeric: tabular-nums; min-width: 5rem; flex-shrink: 0; }
.archive-list a { font-size: 1rem; color: var(--color-text); }
.archive-list a:hover { opacity: 0.6; }


/* ------------------------------------------------------------------
   Search
   ------------------------------------------------------------------ */
.search-input {
    width: 100%;
    padding: 1rem 0;
    font-family: var(--font-body);
    font-size: 1.5rem;
    font-weight: var(--font-weight-light);
    color: var(--color-text);
    border: none;
    border-bottom: 1.5px solid var(--color-text);
    background: transparent;
    outline: none;
    letter-spacing: -0.02em;
}

.search-input::placeholder { color: var(--color-text-light); }
.search-input:focus { border-bottom-color: var(--color-text); box-shadow: none; }

.search-status { font-size: 0.8rem; color: var(--color-text-light); margin-top: var(--space-sm); letter-spacing: 0.03em; }

.search-result { padding: var(--space-sm) 0; border-bottom: 1px solid var(--color-border); }
.search-result h2 { font-size: 1.1rem; font-weight: var(--font-weight-medium); margin-bottom: 0.25rem; }
.search-result .search-result-date { font-size: 0.75rem; color: var(--color-text-light); }
.search-result .search-result-excerpt { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.3rem; }


/* ------------------------------------------------------------------
   Tags Page
   ------------------------------------------------------------------ */
.tag-header { padding: var(--space-xl) 0 var(--space-md); }
.tag-header h1 { font-weight: var(--font-weight-light); }
.tag-count { font-size: 0.85rem; color: var(--color-text-light); }

.sidebar-section { margin-bottom: var(--space-lg); }
.sidebar-title { font-size: 0.75rem; font-weight: var(--font-weight-medium); letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-sm); }
.tags-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.view-all { display: inline-block; font-size: 0.85rem; color: var(--color-text-muted); letter-spacing: 0.02em; padding-top: var(--space-md); }
.view-all:hover { color: var(--color-text); opacity: 1; }
.view-all::after { content: " \2192"; }


/* ------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------ */
.site-footer {
    margin-top: var(--space-2xl);
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--color-border);
}

.footer-inner {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: 0 var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-copy { font-size: 0.8rem; color: var(--color-text-light); letter-spacing: 0.02em; }
.footer-links { display: flex; gap: var(--space-md); }
.footer-links a { font-size: 0.8rem; color: var(--color-text-light); letter-spacing: 0.02em; }
.footer-links a:hover { color: var(--color-text); opacity: 1; }


/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 991px) {
    .posts-grid { grid-template-columns: repeat(2, 1fr); }
    .featured-post { aspect-ratio: 16 / 9; }
}

@media (max-width: 767px) {
    .nav-toggle { display: block; }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--color-nav-bg);
        flex-direction: column;
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    .nav-links.open { display: flex; }
    .posts-grid { grid-template-columns: 1fr; }
    .featured-post { aspect-ratio: 4 / 3; min-height: 300px; }
    .featured-title { font-size: 1.6rem !important; }
    .featured-content { padding: var(--space-md) !important; }
    .site-footer .footer-inner { flex-direction: column; gap: var(--space-sm); text-align: center; }
    .archive-list li { flex-direction: column; gap: 0.2rem; }
    .archive-list .archive-date { min-width: auto; }
}

@media (max-width: 480px) {
    :root { --space-md: 1.25rem; --space-lg: 2.5rem; --space-xl: 4rem; }
}


/* ------------------------------------------------------------------
   Lightbox
   ------------------------------------------------------------------ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox.open {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 80vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
}

.lb-prev, .lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 3rem;
    cursor: pointer;
    padding: 1rem;
    line-height: 1;
    transition: color 0.2s ease;
    user-select: none;
}

.lb-prev:hover, .lb-next:hover { color: #ffffff; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-single .lb-prev, .lb-single .lb-next, .lb-single .lb-counter { display: none; }

.lb-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    font-family: var(--font-body);
}

.post-content img {
    cursor: zoom-in;
}


/* ------------------------------------------------------------------
   Print
   ------------------------------------------------------------------ */
@media print {
    .site-nav, .site-footer, .nav-spacer { display: none !important; }
    .post-content { font-size: 11pt; max-width: 100%; }
}
