/* ==========================================================================
   CaffeineCast Theme — Dark & Modern
   ========================================================================== */

/* ---------- Custom Properties ---------- */
:root {
    --color-bg: #0d0d0d;
    --color-surface: #1a1a1a;
    --color-surface-hover: #242424;
    --color-border: #2a2a2a;
    --color-text: #e0e0e0;
    --color-text-muted: #888888;
    --color-heading: #ffffff;
    --color-accent: #04fcde;
    --color-accent-hover: #03d4ba;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;

    --content-width: 720px;
    --wide-width: 1200px;
    --full-width: 1400px;

    --header-height: 64px;
}

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

html {
    font-size: 62.5%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 1.7rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s;
}

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

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

h1, h2, h3, h4, h5, h6 {
    color: var(--color-heading);
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 4rem; }
h2 { font-size: 3.2rem; }
h3 { font-size: 2.6rem; }
h4 { font-size: 2.2rem; }

/* ---------- Utility ---------- */
.container {
    max-width: var(--full-width);
    margin: 0 auto;
    padding: 0 2.4rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Reading Progress Bar ---------- */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--color-accent);
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-logo img {
    height: 32px;
    width: auto;
}

.site-logo-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-heading);
    letter-spacing: -0.02em;
}

.site-logo-text:hover {
    color: var(--color-accent);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 2.8rem;
}

.site-nav a {
    color: var(--color-text-muted);
    font-size: 1.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.site-nav a:hover {
    color: var(--color-heading);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.6rem;
}

.search-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.search-btn:hover {
    color: var(--color-heading);
}

.search-btn svg {
    width: 20px;
    height: 20px;
}

.subscribe-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.8rem 1.8rem;
    background: var(--color-accent);
    color: #0d0d0d;
    font-size: 1.4rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.subscribe-btn:hover {
    background: var(--color-accent-hover);
    color: #0d0d0d;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: 0.4rem;
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .site-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--color-surface);
        flex-direction: column;
        padding: 2rem;
        gap: 1.6rem;
        border-bottom: 1px solid var(--color-border);
    }

    .site-nav.is-open {
        display: flex;
    }

    .header-actions .subscribe-btn {
        display: none;
    }
}

/* ---------- Hero ---------- */
.hero {
    position: relative;
    min-height: 500px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    margin-bottom: 4.8rem;
}

.hero-image {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(to top, rgba(13, 13, 13, 0.95) 0%, rgba(13, 13, 13, 0.4) 50%, rgba(13, 13, 13, 0.1) 100%);
}

.hero-content {
    position: relative;
    z-index: 3;
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 4.8rem 2.4rem;
    width: 100%;
}

.hero-tag {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background: var(--color-accent);
    color: #0d0d0d;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 3px;
    margin-bottom: 1.6rem;
}

.hero-title {
    font-size: 4.8rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.6rem;
    max-width: 800px;
}

.hero-title a {
    color: var(--color-heading);
}

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

.hero-excerpt {
    font-size: 1.9rem;
    color: var(--color-text);
    max-width: 600px;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    color: var(--color-text-muted);
    font-size: 1.4rem;
}

.hero-meta span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.hero-meta .sep {
    opacity: 0.4;
}

@media (max-width: 768px) {
    .hero {
        min-height: 400px;
    }

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

    .hero-excerpt {
        font-size: 1.7rem;
    }
}

/* ---------- Post Grid ---------- */
.post-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3.2rem;
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 0 2.4rem;
}

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

@media (max-width: 640px) {
    .post-grid {
        grid-template-columns: 1fr;
        gap: 2.4rem;
    }
}

/* ---------- Post Card ---------- */
.post-card {
    background: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: transform 0.2s, border-color 0.2s;
}

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

.post-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-surface-hover);
}

.post-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

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

.post-card-body {
    padding: 2rem;
}

.post-card-tag {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
    margin-bottom: 0.8rem;
}

.post-card-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    line-height: 1.3;
}

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

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

.post-card-excerpt {
    font-size: 1.5rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1.6rem;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.3rem;
    color: var(--color-text-muted);
}

.post-card-meta .sep {
    opacity: 0.4;
}

/* ---------- Newsletter CTA ---------- */
.newsletter-cta {
    grid-column: 1 / -1;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 4.8rem;
    text-align: center;
}

.newsletter-cta h2 {
    font-size: 3.2rem;
    margin-bottom: 1.2rem;
}

.newsletter-cta p {
    color: var(--color-text-muted);
    font-size: 1.7rem;
    margin-bottom: 2.4rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.newsletter-cta .subscribe-btn {
    font-size: 1.6rem;
    padding: 1.2rem 3.2rem;
}

@media (max-width: 640px) {
    .newsletter-cta {
        padding: 3.2rem 2rem;
    }
}

/* ---------- Post (Single Article) ---------- */
.post-header {
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 4rem 2.4rem 2rem;
    text-align: center;
}

.post-header .post-tag {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background: var(--color-accent);
    color: #0d0d0d;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 3px;
    margin-bottom: 2rem;
}

.post-header h1 {
    font-size: 4.8rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.post-header .post-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.post-header .post-meta .sep {
    opacity: 0.4;
}

.post-header .post-meta a {
    color: var(--color-text-muted);
}

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

.post-feature-image {
    max-width: var(--wide-width);
    margin: 0 auto 4rem;
    border-radius: 8px;
    overflow: hidden;
}

.post-feature-image img {
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
}

/* ---------- Ghost Content (kg- classes) ---------- */
.gh-content {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 2.4rem;
    font-family: var(--font-serif);
    font-size: 1.9rem;
    line-height: 1.75;
}

.gh-content > * + * {
    margin-top: 2.4rem;
}

.gh-content h2 {
    font-family: var(--font-sans);
    font-size: 3rem;
    margin-top: 4.8rem;
}

.gh-content h3 {
    font-family: var(--font-sans);
    font-size: 2.4rem;
    margin-top: 4rem;
}

.gh-content h4 {
    font-family: var(--font-sans);
    margin-top: 3.2rem;
}

.gh-content a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

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

.gh-content pre {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 2rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    line-height: 1.6;
}

.gh-content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-surface);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
}

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

.gh-content ul,
.gh-content ol {
    padding-left: 2.4rem;
}

.gh-content li + li {
    margin-top: 0.8rem;
}

.gh-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 4rem 0;
}

.gh-content figure {
    margin: 3.2rem 0;
}

.gh-content figcaption {
    text-align: center;
    font-size: 1.4rem;
    color: var(--color-text-muted);
    margin-top: 1rem;
    font-family: var(--font-sans);
}

.gh-content img {
    border-radius: 6px;
}

/* Wide and full width images */
.gh-content .kg-width-wide {
    max-width: var(--wide-width);
    margin-left: calc(50% - min(50vw, var(--wide-width) / 2));
    margin-right: calc(50% - min(50vw, var(--wide-width) / 2));
}

.gh-content .kg-width-full {
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

.gh-content .kg-width-full img {
    border-radius: 0;
}

/* Ghost cards */
.gh-content .kg-image-card,
.gh-content .kg-gallery-card {
    margin-top: 3.2rem;
    margin-bottom: 3.2rem;
}

.gh-content .kg-gallery-container {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.gh-content .kg-gallery-row {
    display: flex;
    gap: 1.2rem;
}

.gh-content .kg-gallery-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gh-content .kg-bookmark-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.gh-content .kg-bookmark-container {
    display: flex;
    text-decoration: none;
    color: var(--color-text);
}

.gh-content .kg-bookmark-content {
    flex: 1;
    padding: 2rem;
}

.gh-content .kg-bookmark-title {
    font-family: var(--font-sans);
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--color-heading);
    line-height: 1.3;
}

.gh-content .kg-bookmark-description {
    font-size: 1.4rem;
    color: var(--color-text-muted);
    margin-top: 0.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gh-content .kg-bookmark-metadata {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1.2rem;
    font-size: 1.3rem;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
}

.gh-content .kg-bookmark-icon {
    width: 20px;
    height: 20px;
}

.gh-content .kg-bookmark-author,
.gh-content .kg-bookmark-publisher {
    font-family: var(--font-sans);
    font-size: 1.3rem;
}

.gh-content .kg-bookmark-thumbnail {
    width: 200px;
    min-height: 100%;
}

.gh-content .kg-bookmark-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Callout card */
.gh-content .kg-callout-card {
    display: flex;
    gap: 1.2rem;
    padding: 2rem;
    border-radius: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.gh-content .kg-callout-emoji {
    font-size: 2rem;
    line-height: 1;
}

.gh-content .kg-callout-text {
    font-family: var(--font-sans);
    font-size: 1.6rem;
}

/* Button card */
.gh-content .kg-button-card {
    text-align: center;
    margin: 3.2rem 0;
}

.gh-content .kg-btn {
    display: inline-block;
    padding: 1rem 2.4rem;
    background: var(--color-accent);
    color: #0d0d0d;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1.6rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.2s;
}

.gh-content .kg-btn:hover {
    background: var(--color-accent-hover);
    color: #0d0d0d;
}

/* Toggle card */
.gh-content .kg-toggle-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 2rem;
}

.gh-content .kg-toggle-heading-text {
    font-family: var(--font-sans);
    font-weight: 600;
}

/* Video/audio */
.gh-content .kg-video-card,
.gh-content .kg-audio-card {
    border-radius: 6px;
    overflow: hidden;
}

/* ---------- Tag Pills ---------- */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 4rem;
    padding-top: 2.4rem;
    border-top: 1px solid var(--color-border);
    max-width: var(--content-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 2.4rem;
    padding-right: 2.4rem;
}

.post-tags a {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1.3rem;
    color: var(--color-text-muted);
    transition: border-color 0.2s, color 0.2s;
}

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

/* ---------- Author Card ---------- */
.author-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    max-width: var(--content-width);
    margin: 4rem auto;
    padding: 2.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.author-card-avatar img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.author-card-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.author-card-name a {
    color: var(--color-heading);
}

.author-card-name a:hover {
    color: var(--color-accent);
}

.author-card-bio {
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

@media (max-width: 640px) {
    .author-card {
        flex-direction: column;
        text-align: center;
    }
}

/* ---------- Related Posts ---------- */
.related-posts {
    max-width: var(--wide-width);
    margin: 6rem auto 0;
    padding: 0 2.4rem;
}

.related-posts h2 {
    font-size: 2.4rem;
    margin-bottom: 2.4rem;
}

.related-posts .post-grid {
    padding: 0;
}

/* ---------- Author Page ---------- */
.author-header {
    text-align: center;
    padding: 6rem 2.4rem 4rem;
    max-width: var(--wide-width);
    margin: 0 auto;
}

.author-header .author-avatar img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 2rem;
}

.author-header h1 {
    font-size: 4rem;
    margin-bottom: 1.2rem;
}

.author-header .author-bio {
    font-size: 1.8rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.author-header .author-social {
    display: flex;
    justify-content: center;
    gap: 1.6rem;
}

.author-header .author-social a {
    color: var(--color-text-muted);
    font-size: 1.4rem;
}

.author-header .author-social a:hover {
    color: var(--color-accent);
}

/* ---------- Tag Page ---------- */
.tag-header {
    text-align: center;
    padding: 6rem 2.4rem 4rem;
    max-width: var(--wide-width);
    margin: 0 auto;
}

.tag-header h1 {
    font-size: 4rem;
    margin-bottom: 1.2rem;
}

.tag-header .tag-description {
    font-size: 1.8rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 4.8rem 2.4rem;
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.8rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text);
    font-weight: 500;
    transition: border-color 0.2s, color 0.2s;
}

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

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 4.8rem 0;
    margin-top: 6rem;
}

.footer-inner {
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 0 2.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-heading);
}

.footer-nav {
    display: flex;
    gap: 2rem;
}

.footer-nav a {
    color: var(--color-text-muted);
    font-size: 1.4rem;
}

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

.footer-copyright {
    font-size: 1.3rem;
    color: var(--color-text-muted);
    width: 100%;
    text-align: center;
    margin-top: 2rem;
}

@media (max-width: 640px) {
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* ---------- Error Pages ---------- */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 4rem 2.4rem;
}

.error-code {
    font-size: 12rem;
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 1.6rem;
}

.error-page h1 {
    font-size: 3.2rem;
    margin-bottom: 1.6rem;
}

.error-page p {
    font-size: 1.8rem;
    color: var(--color-text-muted);
    margin-bottom: 3.2rem;
}

.error-page a.btn {
    display: inline-block;
    padding: 1rem 2.4rem;
    background: var(--color-accent);
    color: #0d0d0d;
    font-weight: 600;
    border-radius: 4px;
    transition: background 0.2s;
}

.error-page a.btn:hover {
    background: var(--color-accent-hover);
    color: #0d0d0d;
}

/* ---------- Page (Static) ---------- */
.page-header {
    text-align: center;
    padding: 6rem 2.4rem 2rem;
}

.page-header h1 {
    font-size: 4.8rem;
    font-weight: 800;
}

.page-feature-image {
    max-width: var(--wide-width);
    margin: 0 auto 4rem;
    border-radius: 8px;
    overflow: hidden;
}

.page-feature-image img {
    width: 100%;
    aspect-ratio: 3 / 1;
    object-fit: cover;
}

/* ---------- Post (single) responsive ---------- */
@media (max-width: 768px) {
    .post-header h1 {
        font-size: 3.2rem;
    }

    .gh-content {
        font-size: 1.7rem;
    }
}
