/* Petie Clark Blog Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #0a0d14;
    --bg-card: rgba(20, 25, 35, 0.7);
    --bg-card-hover: rgba(30, 38, 52, 0.85);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --purple: #818cf8;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(6, 182, 212, 0.4);
    --max-width: 1200px;
    --content-width: 720px;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

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

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 2rem; }

/* ============ NAVIGATION ============ */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 13, 20, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 64px;
}

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

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

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

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

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

.nav-link--cta {
    background: var(--accent);
    color: var(--bg) !important;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
}

.nav-link--cta:hover {
    background: var(--accent-hover);
    color: var(--bg) !important;
}

.nav-toggle { display: none; }

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
}

.hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text);
    transition: 0.2s;
}

/* ============ HERO ============ */
.hero-section {
    padding: 10rem 2rem 5rem;
    text-align: left;
    max-width: var(--max-width);
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 600px;
    line-height: 1.7;
}

/* ============ NEWSLETTER ============ */
.newsletter-section {
    padding: 4rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 2rem 0;
}

.newsletter-heading {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.newsletter-subtext {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.newsletter-form .input-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    max-width: 440px;
    margin: 0 auto;
}

.newsletter-form input[type="email"] {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.newsletter-form input[type="email"]:focus {
    border-color: var(--accent);
}

.newsletter-form input[type="email"]::placeholder { color: var(--text-muted); }

.btn--primary,
.newsletter-form button {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn--primary:hover,
.newsletter-form button:hover {
    background: var(--accent-hover);
}

.success-message, .error-message { display: none; margin-top: 0.75rem; font-size: 0.9rem; }
.success-message { color: #34d399; }
.error-message { color: #f87171; }

/* ============ POST FEED ============ */
.post-feed-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
}

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

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.post-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(6, 182, 212, 0.08);
}

.post-card-image {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

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

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

.post-card-link-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
}

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

.post-card-tag {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.post-card-tag .tag-link,
.post-card-tag a {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    text-decoration: none;
}

.post-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 0.5rem;
}

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

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

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

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

.reading-time { color: var(--accent); }

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 3rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

/* ============ SINGLE POST ============ */
.post-template .post-header {
    max-width: var(--content-width);
    margin: 7rem auto 2rem;
    padding: 0 2rem;
    text-align: center;
}

.post-template .post-tag-badge {
    margin-bottom: 1rem;
}

.post-template .post-tag-badge .tag-link {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    background: rgba(6, 182, 212, 0.1);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    border: 1px solid rgba(6, 182, 212, 0.2);
    transition: all 0.2s;
}

.post-template .post-tag-badge .tag-link:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.4);
}

.post-template .post-title {
    font-size: clamp(2rem, 4.5vw, 2.75rem);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.25rem;
}

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

.post-template .post-author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.25rem;
}

.post-template .post-author-name {
    font-weight: 500;
    color: var(--text);
}

.post-template .separator {
    color: var(--text-muted);
    opacity: 0.5;
}

.post-template .post-feature-image {
    max-width: 960px;
    margin: 2.5rem auto;
    border-radius: 12px;
    overflow: hidden;
}

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

.post-template .post-feature-image figcaption {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.75rem 1rem 0;
    line-height: 1.4;
}

.post-template .post-feature-image figcaption a {
    color: var(--text-muted);
    text-decoration: underline;
}

/* Post footer tags */
.post-footer {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.post-tags-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.post-tag-pill {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.post-tag-pill:hover {
    color: var(--accent);
    border-color: rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.06);
}

/* Related posts heading */
.related-heading {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.post-content {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 2rem 4rem;
    font-size: 1.05rem;
    line-height: 1.85;
}

.post-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    color: var(--text);
}

.post-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}

.post-content p { margin-bottom: 1.25rem; color: var(--text); }

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

.post-content strong { color: var(--text); font-weight: 600; }
.post-content em { color: var(--text); }

.post-content ul, .post-content ol {
    margin: 1rem 0 1.25rem 1.5rem;
}

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

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: rgba(6, 182, 212, 0.05);
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
    font-style: italic;
}

.post-content pre {
    background: #1a1a2e;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.post-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.88em;
}

.post-content p code,
.post-content li code {
    background: rgba(6, 182, 212, 0.1);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--accent);
}

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

/* Ghost Koenig editor width classes */
.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: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    width: 100vw;
}

.post-content .kg-width-wide img,
.post-content .kg-width-full img {
    width: 100%;
}

@media (max-width: 1100px) {
    .post-content .kg-width-wide {
        max-width: none;
        margin-left: -2rem;
        margin-right: -2rem;
    }
}

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

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

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

.post-content th {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

/* ============ AUTHOR CARD ============ */
.author-card {
    max-width: var(--content-width);
    margin: 0 auto 3rem;
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

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

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

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

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

/* ============ RELATED POSTS ============ */
.related-posts {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
    border-top: 1px solid var(--border);
}

.related-posts h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.related-posts .post-feed {
    grid-template-columns: repeat(3, 1fr);
}

/* ============ TAG/AUTHOR HEADERS ============ */
.tag-header, .author-header {
    padding: 8rem 2rem 3rem;
    text-align: center;
    max-width: var(--max-width);
    margin: 0 auto;
}

.tag-name, .author-name-large {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.tag-description, .author-bio-full {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.tag-count { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.5rem; }

.author-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
}

.author-location { color: var(--text-muted); font-size: 0.9rem; }

.author-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.author-social a {
    color: var(--accent);
    font-size: 0.9rem;
}

/* ============ ERROR PAGE ============ */
.error-page {
    text-align: center;
    padding: 12rem 2rem;
}

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

.error-page .error-message {
    display: block !important;
    font-size: 1.25rem;
    color: var(--text-muted);
    margin: 1rem 0 2rem;
}

.error-page .btn-primary {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--accent);
    color: var(--bg);
    border-radius: 6px;
    font-weight: 600;
}

/* ============ FOOTER ============ */
.site-footer {
    padding: 4rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer .tagline {
    margin-bottom: 1.25rem;
    font-size: 1rem;
    color: var(--text);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.social-links a {
    color: var(--text-muted);
    transition: color 0.2s;
    font-size: 0.9rem;
}

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

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

/* ============ READING PROGRESS ============ */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    z-index: 200;
    width: 0;
    transition: width 0.1s;
}

/* ============ TABLE OF CONTENTS ============ */
.toc-sidebar {
    display: none;
}

/* ============ PAGE TEMPLATE ============ */
.page-template .page-content,
.page-template .post-content {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.page-template .post-header {
    max-width: var(--content-width);
    margin: 8rem auto 2rem;
    padding: 0 2rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .post-feed { grid-template-columns: repeat(2, 1fr); }
    .related-posts .post-feed { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .post-feed { grid-template-columns: 1fr; }
    .related-posts .post-feed { grid-template-columns: 1fr; }
    
    .hero-section { padding: 7rem 1.5rem 3rem; }
    .hero-title { font-size: 2rem; }
    
    .nav-links { display: none; }
    .nav-links.is-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(10, 13, 20, 0.98);
        padding: 1.5rem;
        border-bottom: 1px solid var(--border);
        gap: 1rem;
    }
    
    .hamburger { display: flex; }
    
    .author-card { flex-direction: column; text-align: center; }
    
    .newsletter-form .input-group {
        flex-direction: column;
    }
    
    .post-template .post-header { margin-top: 6rem; }
}

@media (max-width: 480px) {
    .post-card-content { padding: 1rem; }
    .post-content { font-size: 1rem; padding: 0 1.25rem 3rem; }
}

/* ============ GHOST SPECIFIC ============ */
.gh-notification { display: none; }

/* Cards CSS overrides for dark theme */
.kg-card { margin: 1.5rem 0; }
.kg-image-card img { border-radius: 8px; }
.kg-bookmark-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Ghost portal adds .success/.error classes to the form */
form.success .success-message { display: block !important; }
form.success .input-group { display: none; }
form.error .error-message { display: block !important; }
form.loading button { opacity: 0.6; pointer-events: none; }
form.loading button::after { content: '...'; }

/* Better pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 3rem 0 4rem;
    font-size: 0.9rem;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 500;
    transition: all 0.2s;
}

.pagination a:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.page-number {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Post card image fix */
.post-card-image img[src=""],
.post-card-image img:not([src]) {
    display: none;
}

.post-card-image:has(img[src=""]),
.post-card-image:has(img:not([src])) {
    display: none;
}

/* Nav active state */
.site-nav .nav-link[aria-current="page"] {
    color: var(--text);
}

/* Smooth page transitions */
.post-feed-section,
.hero-section,
.newsletter-section {
    animation: fadeUp 0.4s ease-out;
}

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

/* When last row has fewer items, make them wider */
.post-feed {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* 2 items in last row: span wider */
.post-card:last-child:nth-child(3n - 1) {
    grid-column: span 1;
}

/* If only 2 in last row, center them */
.post-feed::after {
    content: '';
    flex: 0 0 calc(33.33% - 1rem);
}
