/* ============================================
   PopcornBytes - Main Stylesheet
   Optimized for Core Web Vitals & Performance
   ============================================ */

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

:root {
    --color-primary: #e63946;
    --color-primary-dark: #c1121f;
    --color-secondary: #1d3557;
    --color-accent: #f4a261;
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #2b2d42;
    --color-text-light: #6c757d;
    --color-border: #e9ecef;
    --color-link: #1d3557;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Playfair Display', Georgia, serif;
    --container-width: 1200px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

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

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

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.3;
    color: var(--color-secondary);
}

/* --- Accessibility --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 1000;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* --- Layout --- */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.content-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
    align-items: start;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    text-align: center;
    font-family: var(--font-body);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--color-secondary);
    border-color: var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.1rem; }

/* --- Cookie Banner --- */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-secondary);
    color: #fff;
    z-index: 9999;
    padding: 1rem 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.cookie-content {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cookie-content p {
    margin: 0;
    font-size: 0.9rem;
    flex: 1;
}

.cookie-content a {
    color: var(--color-accent);
}

.cookie-actions {
    display: flex;
    gap: 0.5rem;
}

/* --- Header --- */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.logo-icon {
    font-size: 1.8rem;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-secondary);
}

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

/* --- Navigation --- */
.nav-list {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.nav-list a {
    display: block;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
    color: var(--color-primary);
    background: rgba(230, 57, 70, 0.06);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: all var(--transition);
}

.hamburger {
    position: relative;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
}

.hamburger::before { top: -7px; }
.hamburger::after { top: 7px; }

/* --- Hero --- */
.hero {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #457b9d 100%);
    color: #fff;
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* --- Post Cards --- */
.posts-section {
    padding: 3rem 0;
}

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.section-header p {
    color: var(--color-text-light);
}

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

.post-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.post-card-featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    margin-bottom: 1rem;
}

.post-card-image {
    display: block;
    overflow: hidden;
    aspect-ratio: 16/9;
    background: var(--color-border);
}

.post-card-featured .post-card-image {
    aspect-ratio: auto;
    min-height: 300px;
}

.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.03);
}

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

.post-card-featured .post-card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
}

.post-card-body h2 {
    font-size: 1.15rem;
    margin: 0.5rem 0;
}

.post-card-featured .post-card-body h2 {
    font-size: 1.6rem;
}

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

.post-card-body h2 a:hover {
    color: var(--color-primary);
}

.post-card-body p {
    color: var(--color-text-light);
    font-size: 0.92rem;
    margin-bottom: 0.75rem;
}

.post-category a {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    background: rgba(230, 57, 70, 0.08);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--color-text-light);
}

/* --- Article Page --- */
.breadcrumb {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
}

.breadcrumb ol {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.breadcrumb li + li::before {
    content: '/';
    margin-right: 0.5rem;
    color: var(--color-text-light);
}

.breadcrumb a {
    color: var(--color-text-light);
}

.breadcrumb [aria-current] {
    color: var(--color-text);
    font-weight: 500;
}

.article-page {
    padding: 2.5rem 0;
}

.article-header {
    margin-bottom: 2rem;
}

.article-header h1 {
    font-size: 2.4rem;
    margin: 0.75rem 0;
    line-height: 1.25;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.article-hero-image {
    margin-bottom: 2rem;
    border-radius: var(--radius);
    overflow: hidden;
}

.article-content {
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 2rem;
}

.article-content h2 {
    font-size: 1.6rem;
    margin: 2.5rem 0 1rem;
}

.article-content h3 {
    font-size: 1.3rem;
    margin: 2rem 0 0.75rem;
}

.article-content p {
    margin-bottom: 1.25rem;
}

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

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

.article-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: rgba(230, 57, 70, 0.04);
    font-style: italic;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.article-content img {
    border-radius: var(--radius);
    margin: 1.5rem 0;
}

/* --- Tags --- */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.tag {
    display: inline-block;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--color-text-light);
}

/* --- Share Buttons --- */
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.share-btn {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
}

.share-twitter { background: #1da1f2; }
.share-facebook { background: #4267B2; }
.share-linkedin { background: #0077b5; }

.share-btn:hover {
    opacity: 0.85;
    color: #fff;
}

/* --- Related Posts --- */
.related-posts {
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

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

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.post-card-small .post-card-image {
    aspect-ratio: 16/10;
}

.post-card-small .post-card-body {
    padding: 0.75rem;
}

.post-card-small h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

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

.post-card-small .post-date {
    font-size: 0.78rem;
    color: var(--color-text-light);
}

/* --- Sidebar --- */
.sidebar {
    position: sticky;
    top: 80px;
}

.sidebar-widget {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-widget h3 {
    font-size: 1.05rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary);
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 0.5rem;
}

.category-list a {
    display: block;
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.category-list a:hover {
    color: var(--color-primary);
}

.popular-posts {
    list-style: none;
}

.popular-posts li {
    margin-bottom: 0.75rem;
}

.popular-posts a {
    display: block;
}

.popular-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.15rem;
    transition: color var(--transition);
}

.popular-posts a:hover .popular-title {
    color: var(--color-primary);
}

.popular-date {
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.sidebar-cta {
    background: linear-gradient(135deg, var(--color-secondary) 0%, #457b9d 100%);
    color: #fff;
}

.sidebar-cta h3 {
    color: #fff;
    border-bottom-color: var(--color-accent);
}

.sidebar-cta p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* --- Newsletter Form --- */
.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.newsletter-form input[type="email"] {
    padding: 0.6rem 0.85rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-family: var(--font-body);
}

.newsletter-form input::placeholder {
    color: rgba(255,255,255,0.6);
}

.footer-newsletter .newsletter-form input[type="email"] {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #fff;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 0;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--color-text-light);
}

/* --- Pages (About, Contact, Privacy) --- */
.page-section {
    padding: 3rem 0;
}

.page-content {
    max-width: 800px;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
}

.page-content-narrow {
    max-width: 640px;
    margin: 0 auto;
}

.page-content h1 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
}

.page-content h2 {
    font-size: 1.4rem;
    margin: 2rem 0 0.75rem;
}

.page-content .lead {
    font-size: 1.15rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.page-content p {
    margin-bottom: 1rem;
}

.page-content ul {
    margin: 1rem 0 1rem 1.5rem;
}

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

/* --- Contact Form --- */
.contact-form {
    margin: 2rem 0;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-body);
    transition: border-color var(--transition);
    background: var(--color-bg);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.contact-alt {
    margin-top: 2rem;
    text-align: center;
    color: var(--color-text-light);
}

/* --- Error Page --- */
.error-page {
    text-align: center;
    padding: 5rem 0;
}

.error-content h1 {
    font-size: 6rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.error-content h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.error-content p {
    color: var(--color-text-light);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

/* --- Ad Containers --- */
.ad-container {
    text-align: center;
    padding: 0.75rem 0;
    overflow: hidden;
}

.ad-in-feed {
    grid-column: 1 / -1;
}

.ad-article-top {
    margin-bottom: 1.5rem;
}

.ad-after-content {
    margin: 2rem 0;
    padding: 1.25rem 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.sticky-ad {
    position: sticky;
    top: 80px;
}

/* --- Footer --- */
.site-footer {
    background: var(--color-secondary);
    color: rgba(255,255,255,0.85);
    padding: 3rem 0 1.5rem;
    margin-top: 3rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.5fr;
    gap: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
}

.footer-logo .logo-text {
    color: #fff;
    font-size: 1.3rem;
}

.footer-about p {
    font-size: 0.9rem;
    opacity: 0.8;
}

.site-footer h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 1rem;
}

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

.site-footer li {
    margin-bottom: 0.5rem;
}

.site-footer a {
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
}

.site-footer a:hover {
    color: #fff;
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.5rem;
    font-size: 0.85rem;
    opacity: 0.7;
}

.footer-social {
    display: flex;
    gap: 1rem;
}

.footer-social a {
    opacity: 0.7;
    transition: opacity var(--transition);
}

.footer-social a:hover {
    opacity: 1;
}

.footer-social svg {
    fill: #fff;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--color-surface);
    border-radius: var(--radius);
}

.empty-state h2 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--color-text-light);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr 280px;
        gap: 2rem;
    }

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

@media (max-width: 768px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    /* Mobile Navigation */
    .nav-toggle {
        display: block;
    }

    .nav-list {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        padding: 0.5rem 1rem;
        box-shadow: var(--shadow-md);
    }

    .nav-list.active {
        display: flex;
    }

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

    .hero-subtitle {
        font-size: 1rem;
    }

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

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

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

    .article-header h1 {
        font-size: 1.8rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .page-content {
        padding: 1.5rem;
    }

    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
}

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

    .hero {
        padding: 2.5rem 0;
    }

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

    .article-content {
        font-size: 1rem;
    }

    .share-buttons {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* --- Print Styles --- */
@media print {
    .site-header,
    .sidebar,
    .site-footer,
    .cookie-banner,
    .ad-container,
    .share-buttons,
    .related-posts,
    .pagination,
    .nav-toggle {
        display: none !important;
    }

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

    .article-content {
        font-size: 12pt;
    }
}
