/* ============================================
   Knightsrook Ghost Theme
   Dark, minimal, techy aesthetic
   ============================================ */

/* --- Reset & Base --- */

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

:root {
    --color-bg: #0a0a0f;
    --color-bg-card: #111118;
    --color-bg-code: #16161e;
    --color-border: #1e1e2a;
    --color-border-hover: #2a2a3a;
    --color-text: #e0e0e0;
    --color-text-muted: #8888a0;
    --color-accent: #4DFFFF;
    --color-accent-dim: rgba(77, 255, 255, 0.15);
    --color-link: #4DFFFF;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', Consolas, monospace;
    --content-width: 720px;
    --wide-width: 1200px;
}

html {
    font-size: 62.5%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 1.7rem;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    opacity: 0.8;
}

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

/* --- Site Header --- */

.site-header {
    border-bottom: 1px solid var(--color-border);
    padding: 2rem 0;
}

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

.site-logo img {
    max-height: 3.6rem;
}

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

.site-nav ul {
    list-style: none;
    display: flex;
    gap: 2.4rem;
}

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

.site-nav a:hover,
.site-nav .nav-current a {
    color: var(--color-accent);
    opacity: 1;
}

/* --- Site Main --- */

.site-main {
    flex: 1;
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 4rem 2.4rem;
    width: 100%;
}

/* --- Post Feed (index, tag, author pages) --- */

.post-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 3.2rem;
}

/* --- Post Card --- */

.post-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.post-card-link {
    display: block;
    color: inherit;
}

.post-card-link:hover {
    opacity: 1;
}

.post-card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

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

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

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

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

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

/* --- Post Full (single post/page) --- */

.post-full {
    max-width: var(--content-width);
    margin: 0 auto;
}

.post-header {
    margin-bottom: 3.2rem;
    text-align: center;
}

.post-title {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1.6rem;
    letter-spacing: -0.01em;
}

.post-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.6rem;
    font-size: 1.4rem;
    color: var(--color-text-muted);
}

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

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

.author-avatar {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 0.4rem;
}

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

/* --- Feature Image --- */

.post-feature-image {
    margin: 0 0 3.2rem;
    border-radius: 8px;
    overflow: hidden;
}

.post-feature-image img {
    width: 100%;
}

.post-feature-image figcaption {
    text-align: center;
    font-size: 1.3rem;
    color: var(--color-text-muted);
    padding: 1rem 0 0;
}

/* --- Post Content --- */

.post-content {
    font-size: 1.8rem;
    line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin: 3.2rem 0 1.2rem;
    font-weight: 700;
    line-height: 1.3;
}

.post-content h2 { font-size: 2.8rem; }
.post-content h3 { font-size: 2.2rem; }
.post-content h4 { font-size: 1.8rem; }

.post-content p {
    margin: 0 0 1.6rem;
}

.post-content a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-color: rgba(77, 255, 255, 0.3);
    text-underline-offset: 2px;
}

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

.post-content strong {
    font-weight: 700;
    color: #fff;
}

.post-content ul,
.post-content ol {
    margin: 0 0 1.6rem 2.4rem;
}

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

.post-content blockquote {
    margin: 2.4rem 0;
    padding: 1.6rem 2.4rem;
    border-left: 3px solid var(--color-accent);
    background: var(--color-accent-dim);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--color-text);
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--color-bg-code);
    padding: 0.2em 0.5em;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

.post-content pre {
    margin: 2.4rem 0;
    padding: 2rem;
    background: var(--color-bg-code);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.post-content pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: 1.4rem;
    line-height: 1.6;
}

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

.post-content img {
    border-radius: 6px;
    margin: 2rem 0;
}

.post-content figure {
    margin: 2.4rem 0;
}

.post-content figcaption {
    text-align: center;
    font-size: 1.3rem;
    color: var(--color-text-muted);
    margin-top: 0.8rem;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2.4rem 0;
}

.post-content th,
.post-content td {
    padding: 1rem 1.4rem;
    border: 1px solid var(--color-border);
    text-align: left;
}

.post-content th {
    background: var(--color-bg-code);
    font-weight: 700;
}

/* Ghost-specific content cards */
.post-content .kg-card {
    margin: 2.4rem 0;
}

.post-content .kg-image-card img {
    margin: 0 auto;
}

.post-content .kg-width-wide {
    max-width: 1040px;
    margin-left: calc(50% - 520px);
    margin-right: calc(50% - 520px);
}

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

.post-content .kg-bookmark-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.post-content .kg-bookmark-container {
    display: flex;
    color: inherit;
    text-decoration: none;
}

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

.post-content .kg-bookmark-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--color-text);
}

.post-content .kg-bookmark-description {
    font-size: 1.4rem;
    color: var(--color-text-muted);
    margin-top: 0.6rem;
}

.post-content .kg-bookmark-thumbnail {
    width: 200px;
    flex-shrink: 0;
}

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

/* --- Post Tags Footer --- */

.post-tags {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.post-tags a {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background: var(--color-accent-dim);
    color: var(--color-accent);
    border-radius: 4px;
    font-size: 1.3rem;
    font-weight: 500;
}

.post-tags a:hover {
    background: rgba(77, 255, 255, 0.25);
    opacity: 1;
}

/* --- Tag Header --- */

.tag-header,
.author-header {
    text-align: center;
    margin-bottom: 4rem;
    padding-bottom: 3.2rem;
    border-bottom: 1px solid var(--color-border);
}

.tag-title,
.author-title {
    font-size: 3.2rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
}

.tag-description,
.author-bio {
    font-size: 1.6rem;
    color: var(--color-text-muted);
    max-width: 560px;
    margin: 0 auto;
}

/* --- Author Header --- */

.author-header-avatar {
    width: 8rem;
    height: 8rem;
    border-radius: 50%;
    margin: 0 auto 1.6rem;
    border: 2px solid var(--color-border);
}

.author-meta {
    margin-top: 1.2rem;
    font-size: 1.4rem;
    color: var(--color-text-muted);
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.author-website {
    color: var(--color-accent);
}

/* --- Pagination --- */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 4rem;
    padding-top: 3.2rem;
    border-top: 1px solid var(--color-border);
    font-size: 1.4rem;
    color: var(--color-text-muted);
}

.pagination a {
    color: var(--color-accent);
    font-weight: 500;
}

/* --- Error Page --- */

.error-page {
    text-align: center;
    padding: 8rem 0;
}

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

.error-message {
    font-size: 2.4rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.error-description {
    font-size: 1.6rem;
    color: var(--color-text-muted);
    margin-bottom: 3.2rem;
}

.error-link {
    display: inline-block;
    padding: 1rem 2.4rem;
    background: var(--color-accent);
    color: var(--color-bg);
    font-weight: 600;
    font-size: 1.4rem;
    border-radius: 6px;
    transition: opacity 0.2s ease;
}

.error-link:hover {
    opacity: 0.85;
    color: var(--color-bg);
}

/* --- Site Footer --- */

.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 2.4rem 0;
}

.site-footer-inner {
    max-width: var(--wide-width);
    margin: 0 auto;
    padding: 0 2.4rem;
    text-align: center;
    font-size: 1.3rem;
    color: var(--color-text-muted);
}

.site-footer a {
    color: var(--color-text-muted);
}

.site-footer a:hover {
    color: var(--color-accent);
    opacity: 1;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .post-title {
        font-size: 2.8rem;
    }

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

    .site-header-inner {
        flex-direction: column;
        gap: 1.2rem;
    }

    .post-content .kg-width-wide {
        margin-left: -2.4rem;
        margin-right: -2.4rem;
    }

    .error-code {
        font-size: 8rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 56%;
    }

    .site-main {
        padding: 2.4rem 1.6rem;
    }

    .post-meta {
        flex-direction: column;
        gap: 0.6rem;
    }
}
