/*
Theme Name: ERTNB
Author: Your Name
Description: A modern, responsive WordPress theme optimized for performance, accessibility, and SEO with a clean grid layout design.
Version: 1.0.4
Text Domain: ertnb
Domain Path: /languages
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: grid-layout, responsive-design, accessibility-ready, performance, clean, minimal
Requires at least: 5.0
Tested up to: 6.3
Requires PHP: 7.4
*/

/* Accessibility improvements */
.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999999;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
}

.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden;
}

/* Focus styles for better accessibility */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Use focus-visible to avoid showing outlines on mouse click */
:focus:not(:focus-visible) {
    outline: none !important;
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .article {
        border: 2px solid #000;
    }
    
    .site-header {
        border-bottom: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== */
/* Performance optimizations */
/* ==================== */

/* Button styling */
.btn {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

/* Form styling */
.form-group {
    margin-bottom: 20px;
}

/* Table styling */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Card styling */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
}

/* Grid styling */
.grid {
    display: grid;
    gap: 20px;
}

/* Flex styling */
.flex {
    display: flex;
}

/* Critical above-the-fold styles - Optimized for LCP */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    contain: layout style; /* CSS containment for better performance */
}

.site-header {
    background-color: #fff;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-bottom: 1px solid #ddd;
    will-change: transform;
    contain: layout style;
    transform: translateZ(0); /* Force hardware acceleration */
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Optimized font loading (removed incorrect @font-display rule placeholder) */

html, body {
    overflow-x: hidden; /* Prevent horizontal scroll / blank space on mobile */
}

/* Improved color contrast for accessibility */
:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --accent-color: #00CED1;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --white: #fff;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Force light background globally */
body {
    background: #ffffff;
    color: var(--text-color);
}

/* Improved focus states */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Better button styling */
.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background-color: rgba(0, 123, 255, 0.1);
}

/* Header styling consolidated */

.site-branding {
    margin: 0;
    z-index: 1001;
}

.site-title {
    margin: 0;
    font-size: 1.8em;
}

.site-title a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
}

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

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    z-index: 1002;
}

.toggle-bar {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #333;
    margin: 5px 0;
    transition: all 0.3s ease;
}

/* Main Navigation */
.main-navigation ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-navigation li {
    position: relative;
    margin-left: 25px;
}

.main-navigation a {
    color: #333;
    text-decoration: none;
    font-size: 1em;
    font-weight: 500;
    padding: 5px 0;
    transition: color 0.3s ease;
    position: relative;
}

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

.main-navigation a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.main-navigation a:hover::after {
    width: 100%;
}

/* ==================== */
/* Existing Styles Remain As Is */
/* ==================== */

/* Ads section styling */
.ads-section {
    padding: 10px 0;
    background-color: transparent;
    text-align: center;
    overflow: hidden; /* Prevent ad overflow */
}

.ads {
    background-color: transparent;
    padding: 10px;
    margin: 0 auto;
    max-width: 1200px;
    border-radius: 5px;
    position: relative;
}

.ad-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    display: block;
    margin: 0 auto;
}

/* JavaScript/HTML ads styling */
.ads script,
.ads ins,
.ads iframe {
    max-width: 100% !important;
    margin: 0 auto;
    display: block;
}

/* AdSense responsive styling */
.ads ins.adsbygoogle {
    display: block;
    text-align: center;
}

/* Responsive ad containers */
.ads > div[id*="ad"],
.ads > div[class*="ad"] {
    max-width: 100%;
    margin: 0 auto;
    text-align: center;
}

/* Mobile ad adjustments */
@media (max-width: 768px) {
    .ads-section {
        padding: 8px 0;
    }
    
    .ads {
        padding: 8px;
    }
    
    /* Force responsive behavior for ads */
    .ads script,
    .ads ins,
    .ads iframe,
    .ads > div {
        max-width: 100% !important;
        width: auto !important;
    }
}

/* Articles section styling - Performance optimized */
.articles-section {
    padding: 40px 0;
    contain: layout; /* CSS containment */
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    align-items: start;
    contain: layout; /* Improve layout performance */
}

.article {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: fit-content;
    contain: layout style; /* CSS containment for articles */
    transform: translateZ(0); /* Force hardware acceleration */
}

.article:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.article-thumbnail {
    aspect-ratio: 4/3; /* Prevent layout shift */
    overflow: hidden;
    background-color: #f5f5f5; /* Placeholder while loading */
}

.article-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    will-change: transform;
    contain: layout;
    /* Optimize image rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.article-thumbnail img:hover {
    transform: scale(1.05);
}

.article-content {
    padding: 20px 15px; /* Increase top and bottom padding */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px; /* Increase height for visual balance */
    background: linear-gradient(to bottom, #fafafa, #fff); /* Light gradient background */
}

.article-title {
    font-size: 1.3em; /* Slightly increase font size */
    margin: 0;
    line-height: 1.4;
    font-weight: 600;
    max-width: 100%;
    word-wrap: break-word; /* Handle long titles */
}

.article-title a {
    text-decoration: none;
    color: #333;

    display: block;
    padding: 8px 5px;
}

.article-title a:hover {
    color: var(--primary-color);
    text-shadow: 0 1px 3px rgba(0, 123, 255, 0.2);
}

/* Remove article-excerpt styles since we're not using it */

/* Pagination styling */
.pagination {
    margin-top: 40px;
    text-align: center;
}

.pagination .nav-links {
    display: inline-flex;
    gap: 10px;
}

.pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    background-color: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.pagination .page-numbers.current {
    background-color: #00CED1;
    color: #fff;
}

.pagination .page-numbers:hover {
    background-color: #ddd;
}

/* Single Post Section */
.single-post-section {
    padding: 40px 0;
}

/* Center using margin auto (avoid flex to prevent side-by-side stacking issues) */
.single-post-section .container,
.page-section .container {
    display: block;
}

.single-post {
    border: 2px solid #00CED1;
    border-radius: 10px;
    padding: 25px;
    margin: 30px 0; /* full width inside container */
    position: relative;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

.single-post:before {
    content: "";
    position: absolute;
    top: -15px;
    left: 20px;
    width: 30px;
    height: 30px;
    background-color: #00CED1;
    transform: rotate(45deg);
    z-index: -1;
}

.single-post:after {
    content: "Article";
    position: absolute;
    top: -20px;
    left: 30px;
    background-color: #00CED1;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9em;
}

.post-header {
    position: relative;
    margin-bottom: 30px;
    padding-bottom: 20px;
    text-align: left;
}

.post-title {
    font-size: 2.2em;
    margin: 20px 0 10px;
    color: #333;
    line-height: 1.3;
}

.post-meta {
    margin: 0;
}

.post-quote {
    font-size: 1.1em;
    color: #666;
    font-style: italic;
}

.post-thumbnail img {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    margin-bottom: 30px;
    border-radius: 5px;
}

.post-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: #444;
}

.post-content p:first-of-type {
    font-size: 1.2em;
    line-height: 1.6;
    color: #666;
}

/* Post Footer and Meta Styles */
.post-footer {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
}

.post-meta {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.post-meta > div {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.meta-label {
    font-weight: 600;
    color: #555;
    min-width: 100px;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.entry-date {
    color: #007bff;
    font-weight: 500;
}

.categories-list a {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    margin-right: 8px;
    margin-bottom: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.2);
}

.categories-list a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    background: linear-gradient(135deg, var(--primary-hover), #004494);
}

/* Tags Styling */
.post-tags {
    align-items: flex-start !important;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tags-list li {
    margin: 0;
    padding: 0;
}

.tag-link {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #008B8B, #006d6d); /* darker for contrast */
    color: #fff;
    padding: 6px 14px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: .3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.tag-link:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.tag-link:hover:before {
    left: 100%;
}

.tag-link:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #006d6d, #004f4f);
}

.tag-link:focus {
    outline: 2px solid #00CED1;
    outline-offset: 2px;
}

.tag-icon {
    margin-right: 4px;
    font-weight: bold;
    opacity: 0.8;
}

/* Tag Archive Page Styles */
.tag-archive-section {
    padding: 40px 0;
}

.archive-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border: 2px solid #00CED1;
    position: relative;
    overflow: hidden;
}

.archive-header:before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 49%, rgba(0, 206, 209, 0.05) 50%, transparent 51%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(0%) translateY(0%) rotate(45deg); }
}

.archive-title {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.tag-name {
    color: #00CED1;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 206, 209, 0.2);
    position: relative;
}

.tag-name:before {
    content: '#';
    margin-right: 5px;
    opacity: 0.7;
}

.archive-description {
    font-size: 1.1em;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.no-posts-found {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px dashed #dee2e6;
}

.no-posts-found h2 {
    color: #6c757d;
    font-size: 1.8em;
    margin-bottom: 15px;
}

.no-posts-found p {
    color: #868e96;
    font-size: 1.1em;
    margin-bottom: 25px;
}

.back-home {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.back-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    background: linear-gradient(135deg, var(--primary-hover), #004494);
}

/* Enhanced Article Meta for Tag Archives */
.tag-archive-section .article-meta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.article-date {
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: 500;
}

/* Responsive Adjustments for Tags */
@media (max-width: 768px) {
    .post-meta {
        gap: 15px;
    }
    
    .post-meta > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .meta-label {
        min-width: auto;
        font-size: 0.9em;
    }
    
    .archive-title {
        font-size: 2em;
        line-height: 1.3;
    }
    
    .tag-name:before {
        display: block;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .post-footer {
        padding: 20px 15px;
        margin: 20px -15px 15px;
        border-radius: 0;
    }
    
    .tag-link {
        padding: 5px 10px;
        font-size: 0.8em;
    }
    
    .archive-header {
        padding: 20px 15px;
        margin-bottom: 30px;
    }
    
    .archive-title {
        font-size: 1.8em;
    }
    
    .categories-list a {
        padding: 4px 10px;
        font-size: 0.85em;
    }
}

/* Page Section Styling */
.page-section {
    padding: 40px 0;
}

.page-frame {
    border: 2px solid #00CED1;
    border-radius: 10px;
    padding: 30px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

.page-frame:before {
    content: "";
    position: absolute;
    top: -15px;
    left: 20px;
    width: 30px;
    height: 30px;
    background-color: #00CED1;
    transform: rotate(45deg);
    z-index: -1;
}

.page-frame:after {
    content: "Page";
    position: absolute;
    top: -20px;
    left: 30px;
    background-color: #00CED1;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9em;
    text-transform: uppercase;
}

/* ==================== */
/* RTL Adjustments for Frames */
/* ==================== */
html[dir="rtl"] .single-post:before,
html[dir="rtl"] .page-frame:before {
    right: 20px;
    left: auto;
}

html[dir="rtl"] .single-post:after,
html[dir="rtl"] .page-frame:after {
    right: 30px;
    left: auto;
}

.page-header {
    margin-bottom: 30px;
    text-align: center;
}

.page-title {
    color: #333;
    font-size: 2.2em;
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
}

.page-title:after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: #00CED1;
}

.page-content {
    line-height: 1.8;
    font-size: 1.1em;
}

.page-content p {
    margin-bottom: 20px;
}

/* Related Articles Section */
.related-articles {
    margin-top: 60px;
    padding: 0 10px;
}

.related-articles h2 {
    font-size: 2em;
    margin: 0 0 25px;
    color: #333;
    font-weight: 700;
}

.related-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 30px;
}

.related-article {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform .25s ease, box-shadow .25s ease;
    display: flex;
    flex-direction: column;
}

.related-article:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
}

.related-thumbnail img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.related-title { font-size: 0.95em; line-height:1.4; margin: 12px 14px 14px; font-weight:600; }
.related-title a { text-decoration:none; color:#222; }
.related-title a:hover { color: var(--primary-color); }

@media (max-width: 768px) {
  .related-articles { margin-top: 50px; }
  .related-articles-grid { gap:20px; }
  .related-title { font-size: 0.9em; }
}

@media (max-width: 480px) {
  .related-articles { margin-top: 40px; }
  .related-thumbnail img { height: 130px; }
  .related-title { font-size: 0.9em; margin:10px 12px 12px; }
}

/* Related articles styling consolidated */

/* Enhanced accessibility for links */
.related-article a[aria-label],
.article-title a[aria-label] {
    position: relative;
}

/* Better focus indicators for article links */
.related-article a:focus,
.article-title a:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
    background-color: rgba(0, 123, 255, 0.05);
    border-radius: 3px;
}

/* Improved hover states for better UX */
.related-article:hover .related-title a,
.article:hover .article-title a {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* Footer styling */
.site-footer {
    background: #005f63; /* Darker teal for WCAG contrast */
    padding: 30px 0 20px;
    text-align: center;
}

/* Footer Navigation */
.footer-navigation {
    margin-bottom: 20px;
}

.footer-navigation ul {
    display: flex;
    justify-content: center;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-navigation li {
    margin: 0;
}

.footer-navigation a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 22px;
    transition: background .25s ease, transform .25s ease;
    display: block;
    background: #007f85; /* Button teal */
    border: 2px solid #00d1d6;
    line-height: 1;
}

.footer-navigation a:hover,
.footer-navigation a:focus-visible {
    background: #004e52;
    transform: translateY(-2px);
}

.footer-navigation a:active {
    transform: translateY(0);
}

.footer-navigation a:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.copyright {
    margin: 0;
    color: #ffffff;
    font-size: 0.85em;
    font-weight: 500;
    letter-spacing: .3px;
}

/* ==================== */
/* Responsive optimizations */
/* ==================== */

/* Better mobile optimization */
@media (max-width: 768px) {
    .container, .header-container {
        width: 95%;
        padding: 0 10px;
    }

    /* Mobile Menu Styles - Improved performance */
    .mobile-menu-toggle {
        display: block;
        transform: translateZ(0); /* Force hardware acceleration */
    }
    
    /* Off-canvas menu reworked to avoid enlarging page width */
    .main-navigation {
        position: fixed;
        top: 0;
        right: 0; /* Keep anchored */
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--white);
        box-shadow: -2px 0 15px rgba(0,0,0,0.1);
        transform: translateX(100%); /* Move off canvas without affecting layout width */
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        padding-top: 80px;
        overflow-y: auto;
        will-change: transform;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .main-navigation.active {
        transform: translateX(0);
    }
    
    /* Improved animations */
    .main-navigation ul {
        flex-direction: column;
        padding: 20px;
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    .main-navigation.active ul {
        opacity: 1;
        transform: translateY(0);
    }
    
    .main-navigation li {
        margin: 15px 0;
        margin-left: 0;
        transform: translateX(-20px);
        opacity: 0;
        animation: slideInLeft 0.3s ease forwards;
    }
    
    .main-navigation li:nth-child(1) { animation-delay: 0.1s; }
    .main-navigation li:nth-child(2) { animation-delay: 0.2s; }
    .main-navigation li:nth-child(3) { animation-delay: 0.3s; }
    .main-navigation li:nth-child(4) { animation-delay: 0.4s; }
    
    .main-navigation a {
        padding: 15px 0;
        display: block;
        font-size: 1.1em;
        border-bottom: 1px solid #f0f0f0;
        transition: var(--transition);
    }
    
    .main-navigation a:hover {
        padding-left: 10px;
        color: var(--primary-color);
        background-color: rgba(0, 123, 255, 0.05);
    }
    
    /* Layout Adjustments */
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px; /* Increase spacing on tablet */
    }

    .related-articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Improve cards on tablet */
    .article-content {
        padding: 18px 12px;
        min-height: 70px;
    }
    
    .article-title {
        font-size: 1.2em;
    }
    /* Additional spacing adjustments stay inside media query */
    .single-post-section, .page-section { padding: 20px 0; }
    .post-title, .page-title { font-size: 2em; line-height: 1.2; }
    .post-content, .page-content { font-size: 1em; line-height: 1.6; }
    .single-post, .page-frame { padding: 20px; margin: 20px 0; width:100%; max-width:none; }
    
    /* Footer navigation on tablet */
    .footer-navigation ul {
        gap: 12px;
    }
    
    .footer-navigation a {
        font-size: 0.9em;
        padding: 7px 14px;
    }
}

/* Ultra-small screens optimization - Performance focused */
@media (max-width: 480px) {
    .container, .header-container {
        width: 100%;
        padding: 0 15px;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 20px; /* Reduce gap for mobile performance */
        contain: layout;
    }
    
    /* Improve cards on mobile */
    .article-content {
        padding: 16px 12px; /* Reduce padding slightly */
        min-height: 60px; /* Reduce min-height for performance */
    }
    
    .article-title {
        font-size: 1.2em; /* Optimize font size */
        line-height: 1.3; /* Better line height */
    }
    
    .article-thumbnail {
        aspect-ratio: 16/9; /* Better mobile aspect ratio */
    }

    .related-articles-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .single-post-section, .page-section {
        padding: 15px 0;
    }

    .post-title, .page-title {
        font-size: 1.8em;
        line-height: 1.3;
    }

    .post-content, .page-content {
        font-size: 0.95em;
        line-height: 1.7;
    }

    .post-thumbnail img {
        max-height: 300px;
    }

    .related-articles h2 {
        font-size: 1.5em;
    }

    .related-thumbnail img {
        height: 120px;
    }

    .single-post, .page-frame { padding:15px 14px; margin:15px 0; border-width:1px; width:100%; max-width:none; }

/* Inner readable width */
.single-post .post-header, .single-post .post-content, .single-post .post-footer,
.page-frame .page-header, .page-frame .page-content {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

    /* Simplify decorative elements on small screens for better clarity */
    .single-post:before, .page-frame:before {
        display: none;
    }

    .single-post:after, .page-frame:after {
        top: -12px;
        right: 15px; /* Align to right for RTL & LTR consistency */
        left: auto;
        padding: 3px 9px;
        font-size: 0.7em;
        letter-spacing: 0.5px;
    }

    html[dir="ltr"] .single-post:after,
    html[dir="ltr"] .page-frame:after {
        right: auto;
        left: 15px; /* Keep left alignment in LTR */
    }
    
    /* Adjust mobile menu for very small screens */
    .main-navigation {
        width: 90%;
    }
    
    /* Optimize touch targets */
    .main-navigation a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Footer navigation responsive */
    .footer-navigation ul {
        flex-direction: column;
        gap: 10px;
    }
    
    .footer-navigation a {
        font-size: 0.9em;
        padding: 6px 12px;
    }
}

/* Animation keyframes */
@keyframes slideInLeft {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Print styles */
@media print {
    .site-header,
    .ads-section,
    .mobile-menu-toggle,
    .pagination {
        display: none !important;
    }
    
    .article,
    .single-post,
    .page-frame {
        border: 1px solid #000 !important;
        break-inside: avoid;
    }
    
    .article-thumbnail img,
    .post-thumbnail img {
        max-height: 200px !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
    /* Keep interface light even in dark mode preference */
    --white: #ffffff;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    }
    
    .site-header {
    background-color: #ffffff !important;
    border-bottom-color: #ddd;
    }
    
    .article {
    background-color: #ffffff;
    border-color: #ddd;
    }
    
    .main-navigation {
    background-color: #ffffff;
    }
}