/* ============================================
   Beat Writers Block - Custom Ghost Theme
   Evidence-based writing advice for academics
   ============================================ */

/* ===== CSS Variables ===== */
:root {
    /* Colors - Academic & Professional Palette */
    --color-primary: #2563eb;        /* Professional blue */
    --color-secondary: #1e293b;      /* Dark slate */
    --color-accent: #f59e0b;         /* Warm amber for CTAs */
    --color-text: #1e293b;           /* Dark text */
    --color-text-light: #64748b;     /* Light gray text */
    --color-bg: #ffffff;             /* White background */
    --color-bg-alt: #f8fafc;         /* Light gray background */
    --color-border: #e2e8f0;         /* Light border */

    /* Typography */
    --font-serif: 'Merriweather', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --spacing-unit: 8px;
    --container-width: 1200px;
    --container-narrow: 720px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ===== Reset & Base Styles ===== */
*, *::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-serif);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
}

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

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

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

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--color-secondary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5, h6 { font-size: 1rem; }

p {
    margin-bottom: 1.5rem;
}

/* ===== Layout ===== */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 3);
}

.container-narrow {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 3);
}

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
}

/* ===== Header ===== */
.site-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: calc(var(--spacing-unit) * 3) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(var(--spacing-unit) * 4);
}

.site-branding {
    flex: 0 0 auto;
}

.site-title {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-secondary);
    text-decoration: none;
}

.site-description {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: calc(var(--spacing-unit) / 2);
}

.site-logo img {
    max-height: 50px;
}

.site-nav ul {
    display: flex;
    list-style: none;
    gap: calc(var(--spacing-unit) * 3);
}

.site-nav a {
    font-family: var(--font-sans);
    font-size: 0.938rem;
    font-weight: 500;
    color: var(--color-text);
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 2);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.site-nav a:hover {
    background-color: var(--color-bg-alt);
    color: var(--color-primary);
}

/* ===== Hero Section ===== */
.hero {
    background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-bg) 100%);
    padding: calc(var(--spacing-unit) * 8) 0;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.hero-title {
    font-size: 3rem;
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--color-secondary);
}

.hero-subtitle {
    font-family: var(--font-sans);
    font-size: 1.25rem;
    color: var(--color-text-light);
    max-width: 700px;
    margin: 0 auto;
}

/* ===== Search Bar ===== */
.search-section {
    padding: calc(var(--spacing-unit) * 4) 0;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.search-box {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 1em 3em 1em 1.5em;
    font-family: var(--font-sans);
    font-size: 1em;
    border: 2px solid var(--color-border);
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-button {
    position: absolute;
    right: 0.5em;
    top: 50%;
    transform: translateY(-50%);
    background: #8B1E3F;
    color: white;
    border: none;
    padding: 0.7em 1.5em;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.3s ease;
}

.search-button:hover {
    background: #6d1730;
}

.search-results {
    margin-top: 2em;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.search-result-item {
    padding: 1.5em;
    border-bottom: 1px solid var(--color-border);
}

.search-result-item h3 {
    margin: 0 0 0.5em;
    font-size: 1.25rem;
}

.search-result-item a {
    color: var(--color-secondary);
}

.search-result-item a:hover {
    color: var(--color-primary);
}

.search-result-excerpt {
    font-family: var(--font-sans);
    color: var(--color-text-light);
    font-size: 0.938rem;
    margin: 0.5em 0;
}

.no-results {
    text-align: center;
    color: var(--color-text-light);
    padding: 2em;
    font-family: var(--font-sans);
}

/* ===== Posts Grid ===== */
.posts-section {
    padding: calc(var(--spacing-unit) * 8) 0;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: calc(var(--spacing-unit) * 4);
    margin-bottom: calc(var(--spacing-unit) * 6);
}

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

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.post-card-image {
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

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

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

.post-card-content {
    padding: calc(var(--spacing-unit) * 3);
}

.post-card-tag {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: calc(var(--spacing-unit) * 1);
    display: inline-block;
}

.post-card-title {
    font-size: 1.25rem;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

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

.post-card-excerpt {
    font-size: 0.938rem;
    color: var(--color-text-light);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.post-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.post-card-author {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 1);
}

.author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* ===== Single Post ===== */
.post-header {
    padding: calc(var(--spacing-unit) * 8) 0 calc(var(--spacing-unit) * 4) 0;
    background: var(--color-bg-alt);
}

.post-tag {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: calc(var(--spacing-unit) * 2);
    display: inline-block;
}

.post-title {
    font-size: 3rem;
    line-height: 1.2;
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.post-excerpt {
    font-size: 1.25rem;
    color: var(--color-text-light);
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.post-meta {
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.post-author {
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
}

.author-avatar-large {
    width: 56px;
    height: 56px;
    border-radius: 50%;
}

.author-info {
    font-family: var(--font-sans);
}

.author-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-secondary);
    display: block;
    margin-bottom: calc(var(--spacing-unit) / 2);
}

.post-meta-details {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.post-meta-simple {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.post-feature-image {
    margin-top: calc(var(--spacing-unit) * 4);
}

.post-feature-image img {
    width: 100%;
    border-radius: 12px;
}

/* ===== Post Content ===== */
.post-content {
    padding: calc(var(--spacing-unit) * 8) 0;
}

.post-content h2 {
    margin-top: calc(var(--spacing-unit) * 6);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.post-content h3 {
    margin-top: calc(var(--spacing-unit) * 4);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.post-content ul, .post-content ol {
    margin-bottom: calc(var(--spacing-unit) * 3);
    padding-left: calc(var(--spacing-unit) * 4);
}

.post-content li {
    margin-bottom: calc(var(--spacing-unit) * 1);
}

.post-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: calc(var(--spacing-unit) * 3);
    margin: calc(var(--spacing-unit) * 4) 0;
    font-style: italic;
    color: var(--color-text-light);
}

.post-content code {
    background: var(--color-bg-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'Monaco', 'Courier New', monospace;
}

.post-content pre {
    background: var(--color-bg-alt);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: 8px;
    overflow-x: auto;
    margin: calc(var(--spacing-unit) * 3) 0;
}

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

/* ===== Post Footer ===== */
.post-footer {
    padding: calc(var(--spacing-unit) * 4) 0 calc(var(--spacing-unit) * 8) 0;
    border-top: 1px solid var(--color-border);
}

.author-card {
    display: flex;
    gap: calc(var(--spacing-unit) * 3);
    padding: calc(var(--spacing-unit) * 4);
    background: var(--color-bg-alt);
    border-radius: 12px;
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.author-card-content h4 {
    margin-bottom: calc(var(--spacing-unit) * 1);
}

.author-card-bio {
    font-size: 0.938rem;
    color: var(--color-text-light);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.author-card-website {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-primary);
}

/* ===== CTA Box ===== */
.post-cta {
    margin-bottom: calc(var(--spacing-unit) * 6);
}

.cta-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    padding: calc(var(--spacing-unit) * 5);
    text-align: center;
}

.cta-box h3 {
    color: var(--color-secondary);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.cta-box p {
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--color-text);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.cta-button {
    display: inline-block;
    background: var(--color-accent);
    color: white;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 4);
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.cta-button:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: white;
}

/* ===== Tags ===== */
.post-tags {
    font-family: var(--font-sans);
}

.post-tags h4 {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.tag-link {
    display: inline-block;
    background: var(--color-bg-alt);
    color: var(--color-text);
    font-size: 0.875rem;
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 2);
    border-radius: 6px;
    margin-right: calc(var(--spacing-unit) * 1);
    margin-bottom: calc(var(--spacing-unit) * 1);
    transition: all 0.2s ease;
}

.tag-link:hover {
    background: var(--color-primary);
    color: white;
}

/* ===== Related Posts ===== */
.related-posts {
    background: var(--color-bg-alt);
    padding: calc(var(--spacing-unit) * 8) 0;
}

.related-posts h3 {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: calc(var(--spacing-unit) * 4);
}

/* ===== Footer ===== */
.site-footer {
    background: var(--color-secondary);
    color: white;
    padding: calc(var(--spacing-unit) * 8) 0 calc(var(--spacing-unit) * 4) 0;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: calc(var(--spacing-unit) * 6);
    margin-bottom: calc(var(--spacing-unit) * 6);
}

.footer-section h4 {
    color: white;
    font-size: 1rem;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.footer-section p {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: #cbd5e1;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: calc(var(--spacing-unit) * 1);
}

.footer-section a {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: #cbd5e1;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: calc(var(--spacing-unit) * 4);
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: #94a3b8;
}

.footer-bottom a {
    color: #cbd5e1;
}

/* ===== Footer Newsletter Form ===== */
.footer-newsletter-form {
    margin-top: calc(var(--spacing-unit) * 3);
}

.footer-newsletter-input {
    width: 100%;
    padding: calc(var(--spacing-unit) * 1.5);
    font-family: var(--font-sans);
    font-size: 0.938rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    margin-bottom: calc(var(--spacing-unit) * 2);
    transition: all 0.2s ease;
}

.footer-newsletter-input::placeholder {
    color: #94a3b8;
}

.footer-newsletter-input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: rgba(255, 255, 255, 0.15);
}

.footer-newsletter-button {
    display: block;
    width: 100%;
    padding: calc(var(--spacing-unit) * 1.5);
    font-family: var(--font-sans);
    font-size: 0.938rem;
    font-weight: 600;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
    text-align: center;
}

.footer-newsletter-button:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.footer-newsletter-button .button-loader {
    display: none;
}

.footer-newsletter-button.loading .button-text {
    visibility: hidden;
}

.footer-newsletter-button.loading .button-loader {
    display: inline-block;
}

.footer-newsletter-form .message-success,
.footer-newsletter-form .message-error {
    display: none;
    margin-top: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
}

.footer-newsletter-form .message-success {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86efac;
}

.footer-newsletter-form .message-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.footer-newsletter-form.success .message-success {
    display: block;
}

.footer-newsletter-form.error .message-error,
.footer-newsletter-form .message-error:not(:empty) {
    display: block;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: calc(var(--spacing-unit) * 2);
    font-family: var(--font-sans);
    margin-top: calc(var(--spacing-unit) * 6);
}

.pagination a, .pagination .page-number {
    padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2.5);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination .page-number {
    font-weight: 600;
}

/* ===== Ghost Editor Content Blocks (Required for Ghost 5.0) ===== */
.kg-width-wide {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.kg-width-full {
    width: 100vw;
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

.kg-width-full img {
    width: 100%;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-nav ul {
        flex-wrap: wrap;
        gap: calc(var(--spacing-unit) * 2);
    }

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

    .post-title {
        font-size: 2rem;
    }

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

    .author-card {
        flex-direction: column;
        text-align: center;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}
