/* frontend/styles/newspaper.css - Newspaper-style layout */

/* ========== CSS Variables ========== */
:root {
    /* Colors */
    --primary-color: #1a1a1a;
    --secondary-color: #333;
    --accent-color: #c41e3a;
    --text-color: #2c2c2c;
    --text-muted: #666;
    --border-color: #ddd;
    --bg-light: #f8f9fa;
    --white: #ffffff;
    
    /* Typography */
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --section-spacing: 3rem;
    --card-spacing: 1.5rem;
    
    /* Shadows */
    --shadow-light: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-medium: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
}

/* ========== Base Styles ========== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-color);
    margin: 0;
    background-color: var(--white);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ========== Loading States ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========== Header & Masthead ========== */
.newspaper-header {
    background: var(--white);
    border-bottom: 3px solid var(--primary-color);
    padding: 2rem 0 1rem;
    margin-bottom: 2rem;
}

.masthead {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.newspaper-title {
    font-family: var(--font-serif);
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary-color);
    margin: 0;
    letter-spacing: -2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.newspaper-tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
    font-style: italic;
}

.header-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 1rem;
}

/* ========== Navigation ========== */
.main-nav {
    border-top: 2px solid var(--border-color);
    padding-top: 1rem;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    margin-top: 0.15rem;
    padding: 0;
    gap: 0.5rem;
    flex: 1;
    min-width: 0; /* Allow shrinking */
    max-width: calc(100% - 250px); /* Reserve space for search */
}

.nav-list li {
    margin: 0;
}

 .nav-link {
    display: inline-block;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.20rem 0.4rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--accent-color);
    color: var(--white);
}

.search-wrapper {
    flex-shrink: 0;
}

.search-form {
    display: flex;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    overflow: hidden;
}

.search-form input {
    border: none;
    background: transparent;
    padding: 0.5rem 1rem;
    outline: none;
    width: 180px;
}

.search-form button {
    background: var(--accent-color);
    border: none;
    color: var(--white);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.search-form button:hover {
    background-color: #a01729;
}

/* ========== Breadcrumbs ========== */
.breadcrumb-nav {
    background: var(--bg-light);
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.breadcrumb {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    margin: 0 0.5rem;
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--accent-color);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ========== Main Content ========== */
.main-content {
    margin-bottom: var(--section-spacing);
}

/* Main + sidebar layout */
.content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 2rem;
    align-items: flex-start;
}

.content-layout__main {
    min-width: 0; /* allow grids/cards to shrink responsibly */
}

.content-layout__sidebar {
    position: sticky;
    top: 1.5rem;
}

/* Sidebar widgets */
.sidebar-widget {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-light);
    margin-bottom: 1.5rem;
}

.sidebar-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    margin: 0 0 0.75rem 0;
    color: var(--primary-color);
}

.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-list li + li {
    margin-top: 0.5rem;
}

.sidebar-placeholder {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* Sidebar ad slot */
.ad-slot {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin-inline: auto;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f1f1;
    box-shadow: var(--shadow-medium);
}

.ad-slot--square {
    aspect-ratio: 4 / 3; /* works for 300x225–300x250, adjust later if needed */
}

.ad-label {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar headlines */
.sidebar-headline {
    margin: 0.4rem 0;
}

.sidebar-headline__link {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary-color);
}

.sidebar-headline__link:hover .sidebar-headline__title {
    color: var(--accent-color);
}

.sidebar-headline__thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: #eaeaea;
}

.sidebar-headline__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.25);
    transition: transform 0.25s ease, filter 0.25s ease;
}

.sidebar-headline__link:hover .sidebar-headline__thumb img {
    transform: scale(1.12);
    filter: saturate(1.00);
}

.sidebar-headline__text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sidebar-headline__title {
    font-size: 0.95rem;
    line-height: 1.4;
}

.sidebar-headline__time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.section-header {
    margin-bottom: 2rem;
    position: relative;
}

.section-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    color: var(--accent-color);
    font-size: 2rem;
}

.section-line {
    height: 3px;
    background: linear-gradient(to right, var(--accent-color), transparent);
    border-radius: 2px;
    margin-bottom: 1rem;
}

/* ========== Featured Section ========== */
.featured-section {
    margin-bottom: var(--section-spacing);
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--card-spacing);
    margin-bottom: 2rem;
}

/* ========== Latest Section ========== */
.latest-section {
    margin-bottom: var(--section-spacing);
}

.latest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--card-spacing);
    margin-bottom: 2rem;
}

/* ========== Article Cards ========== */
.article-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
    position: relative;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}

.article-image {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.25);
    transition: transform 0.3s ease, filter 0.3s ease;
}

.article-card:hover .article-image img {
    transform: scale(1.12);
    filter: saturate(1.00);
}

.article-content {
    padding: 1.5rem;
}

.article-category {
    display: inline-block;
    background: var(--accent-color);
    color: var(--white);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    text-decoration: none;
}

.article-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 0.75rem 0;
}

.article-title a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.article-title a:hover {
    color: var(--accent-color);
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.article-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.article-excerpt {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

/* Featured articles get special styling */
.featured-grid .article-card {
    border: 2px solid transparent;
}

.featured-grid .article-card::before {
    content: "★";
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--accent-color);
    color: var(--white);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    z-index: 1;
}

/* ========== Pagination ========== */
.pagination-nav {
    margin-top: 3rem;
    text-align: center;
}

.pagination {
    display: inline-flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
}

.pagination .page-item {
    border-radius: 4px;
}

.pagination .page-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--primary-color);
    text-decoration: none;
    border: 1px solid var(--border-color);
    background: var(--white);
    transition: all 0.3s ease;
}

.pagination .page-link:hover {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.pagination .page-item.active .page-link {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    background: var(--bg-light);
    cursor: not-allowed;
}

/* ========== Empty States ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--border-color);
}

.empty-state p {
    font-size: 1.1rem;
    margin: 0;
}

/* ========== Footer ========== */
.newspaper-footer {
    background: var(--primary-color);
    color: var(--white);
    margin-top: 4rem;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    font-family: var(--font-serif);
    margin-bottom: 1rem;
}

.footer-section h3 {
    font-size: 1.5rem;
    color: var(--white);
}

.footer-section h4 {
    font-size: 1.2rem;
    color: #ccc;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--white);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.social-links a:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 1rem;
    text-align: center;
    color: #ccc;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .newspaper-title {
        font-size: 2.5rem;
    }
    
    .nav-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-list {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .search-form input {
        width: 150px;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .featured-grid,
    .latest-grid {
        grid-template-columns: 1fr;
    }

    /* Stack main + sidebar on small screens */
    .content-layout {
        grid-template-columns: 1fr;
    }

    .content-layout__main {
        order: 1;
    }

    .content-layout__sidebar {
        position: static;
        order: 2;
        margin-top: 1.5rem;
    }
    
    .article-content {
        padding: 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .newspaper-title {
        font-size: 2rem;
    }
    
    .container {
        padding: 0 0.75rem;
    }
    
    .section-title {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ========== Single Post Content ========== */
.single-post-content {
    margin-bottom: var(--section-spacing);
}

.single-post {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
}

.post-header {
    padding: 2rem 0;
    border-bottom: 3px solid var(--accent-color);
    margin-bottom: 2rem;
}

.post-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary-color);
    margin: 0 0 1rem 0;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.post-meta time {
    font-weight: 500;
}

.post-categories {
    color: var(--accent-color);
    font-weight: 500;
}

/* Post Content - Hard limits and styling */
.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Constrain ALL child elements */
.post-content > * {
    max-width: 100%;
}

/* Images - Responsive and constrained */
.post-content img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 2rem auto;
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
}

/* Videos and iframes */
.post-content iframe,
.post-content video,
.post-content embed,
.post-content object {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 2rem auto;
}

/* Tables */
.post-content table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
    border-collapse: collapse;
    margin: 2rem 0;
}

.post-content table th,
.post-content table td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.post-content table th {
    background: var(--bg-light);
    font-weight: 600;
}

/* Code blocks */
.post-content pre {
    max-width: 100%;
    overflow-x: auto;
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 4px;
    border-left: 3px solid var(--accent-color);
}

.post-content code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Blockquotes */
.post-content blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    background: var(--bg-light);
    font-style: italic;
    color: var(--text-muted);
}

/* Paragraphs */
.post-content p {
    margin: 1.2rem 0;
}

/* Headings within content */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-family: var(--font-serif);
    margin: 2rem 0 1rem 0;
    line-height: 1.3;
    color: var(--primary-color);
}

.post-content h2 {
    font-size: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.post-content h3 {
    font-size: 1.6rem;
}

.post-content h4 {
    font-size: 1.3rem;
}

/* Lists */
.post-content ul,
.post-content ol {
    margin: 1.2rem 0;
    padding-left: 2rem;
}

.post-content li {
    margin: 0.5rem 0;
}

/* Links */
.post-content a {
    color: var(--accent-color);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.post-content a:hover {
    color: var(--secondary-color);
}

/* Post Tags */
.post-tags {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.post-tags strong {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

/* Responsive adjustments for single posts */
@media (max-width: 768px) {
    .post-title {
        font-size: 2rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .post-content h2 {
        font-size: 1.6rem;
    }
    
    .post-content h3 {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .post-header {
        padding: 1.5rem 0;
    }
    
    .post-title {
        font-size: 1.6rem;
    }
    
    .post-content {
        font-size: 0.95rem;
    }
    
    .post-content img {
        margin: 1rem auto;
    }
}
