/*
 *  1ban.news — Echidna-inspired Design
 *  White + Pure Red (#ff0000) · DM Sans
 *  Content (2/3) + Sidebar (1/3) layout
 */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #f7f7f7;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --accent: #ff0000;
    --accent-hover: #cc0000;
    --accent-light: rgba(255,0,0,0.06);
    --border: #e6e6e6;
    --border-light: #f0f0f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.dark-mode {
    --bg-primary: #111111;
    --bg-secondary: #1a1a1a;
    --bg-card: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #999999;
    --text-muted: #666666;
    --accent: #ff3333;
    --accent-hover: #ff6666;
    --accent-light: rgba(255,51,51,0.1);
    --border: #2a2a2a;
    --border-light: #222222;
}

/* ===== SYSTEM DARK MODE (iOS/Android/macOS auto) =====
   When the user has dark mode set at the OS level but hasn't manually
   toggled the site theme, this catches the gap before JS adds .dark-mode.
   FIXES: white frames under text on iOS in dark mode. */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode):not(.dark-mode) {
        --bg-primary: #111111;
        --bg-secondary: #1a1a1a;
        --bg-card: #1e1e1e;
        --text-primary: #e0e0e0;
        --text-secondary: #999999;
        --text-muted: #666666;
        --accent: #ff3333;
        --accent-hover: #ff6666;
        --accent-light: rgba(255,51,51,0.1);
        --border: #2a2a2a;
        --border-light: #222222;
    }

    /* Override Astra's white backgrounds before JS adds .dark-mode */
    body:not(.light-mode):not(.dark-mode) article,
    body:not(.light-mode):not(.dark-mode) .ast-article-single,
    body:not(.light-mode):not(.dark-mode) .ast-article-post,
    body:not(.light-mode):not(.dark-mode) .ast-article-inner,
    body:not(.light-mode):not(.dark-mode) .entry-content,
    body:not(.light-mode):not(.dark-mode) .ast-container,
    body:not(.light-mode):not(.dark-mode) #primary,
    body:not(.light-mode):not(.dark-mode) .content-area,
    body:not(.light-mode):not(.dark-mode) .site-main,
    body:not(.light-mode):not(.dark-mode) .ast-row,
    body:not(.light-mode):not(.dark-mode) .comment-respond,
    body:not(.light-mode):not(.dark-mode) .comments-area,
    body:not(.light-mode):not(.dark-mode) .site-below-footer-wrap,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-wrap,
    body:not(.light-mode):not(.dark-mode) .ast-builder-menu-mobile,
    body:not(.light-mode):not(.dark-mode) .ast-main-header-bar-alignment,
    body:not(.light-mode):not(.dark-mode) .main-header-bar-navigation,
    body:not(.light-mode):not(.dark-mode) .main-header-bar-navigation .main-navigation,
    body:not(.light-mode):not(.dark-mode) .main-header-bar-navigation .main-navigation ul {
        background: #111111 !important;
    }

    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content .menu-item,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content .page_item,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content .menu-link,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content a,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content li,
    body:not(.light-mode):not(.dark-mode) .ast-header-break-point .main-navigation ul .menu-item .menu-link,
    body:not(.light-mode):not(.dark-mode) .ast-header-break-point .main-navigation ul li,
    body:not(.light-mode):not(.dark-mode) .ast-header-break-point .main-navigation ul li a {
        background: #111111 !important;
        color: #cccccc !important;
    }
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content .current-menu-item > a,
    body:not(.light-mode):not(.dark-mode) .ast-mobile-header-content .current-menu-item {
        background: #1a1a1a !important;
        color: #ff3333 !important;
    }

    body:not(.light-mode):not(.dark-mode) .entry-content,
    body:not(.light-mode):not(.dark-mode) .entry-content p,
    body:not(.light-mode):not(.dark-mode) .entry-content li,
    body:not(.light-mode):not(.dark-mode) .ast-excerpt-container p {
        color: #cccccc !important;
    }

    body:not(.light-mode):not(.dark-mode) .entry-title a,
    body:not(.light-mode):not(.dark-mode) h1,
    body:not(.light-mode):not(.dark-mode) h2,
    body:not(.light-mode):not(.dark-mode) h3,
    body:not(.light-mode):not(.dark-mode) h4,
    body:not(.light-mode):not(.dark-mode) .site-title a {
        color: #e0e0e0 !important;
    }

    body:not(.light-mode):not(.dark-mode) textarea,
    body:not(.light-mode):not(.dark-mode) input[type="text"],
    body:not(.light-mode):not(.dark-mode) input[type="email"],
    body:not(.light-mode):not(.dark-mode) input[type="url"] {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
        border-color: #2a2a2a !important;
    }

    body:not(.light-mode):not(.dark-mode) a {
        color: #ff3333;
    }
}

/* ===== BASE ===== */
body {
    background: var(--bg-primary) !important;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
}
a { color: var(--accent); transition: color 0.2s; text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1,h2,h3,h4,h5,h6 { color: var(--text-primary); font-weight: 700; line-height: 1.3; }

/* ===== HEADER & NAV ===== */
.site-header, .main-header-bar {
    background: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border) !important;
    position: sticky !important;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

.site-title a {
    font-weight: 800 !important;
    font-size: 1.25em !important;
    letter-spacing: -0.5px !important;
}
.site-title a, .site-title { color: var(--text-primary) !important; }

.main-navigation { display: flex; align-items: center; justify-content: space-between; }
.main-navigation ul { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; }
.main-navigation li { position: relative; }

.main-navigation a {
    color: var(--text-secondary) !important;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px !important;
    border-radius: 4px;
    transition: all 0.2s;
}
.main-navigation a:hover,
.main-navigation .current-menu-item > a {
    color: var(--accent) !important;
    background: var(--accent-light);
}

/* Dark mode toggle */
.theme-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; padding: 5px 10px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg-secondary);
    color: var(--text-secondary); font-size: 12px; font-weight: 500;
    transition: all 0.2s; margin-left: 8px; font-family: var(--font-sans);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Login button */
.btn-login {
    display: inline-flex; align-items: center;
    padding: 6px 16px; border-radius: 6px;
    border: 1px solid var(--accent); background: var(--accent);
    color: #fff !important; font-size: 13px; font-weight: 600;
    margin-left: 8px; transition: all 0.2s;
}
.btn-login:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ===== ECHIDNA LAYOUT (front page) ===== */
.echidna-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 48px 20px;
}

.echidna-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 40px;
    align-items: start;
}

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

/* Main content */
.echidna-content { min-width: 0; }

.latest-stories-heading {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px;
}

/* ===== SIDEBAR CARDS ===== */
.echidna-sidebar { display: flex; flex-direction: column; gap: 20px; }

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.sidebar-card-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.sidebar-card-header svg { flex-shrink: 0; }
.sidebar-card-header h3 {
    font-size: 1.125rem; font-weight: 700; color: var(--text-primary); margin: 0;
}

.sidebar-card-title {
    font-size: 1.125rem; font-weight: 700;
    color: var(--text-primary); margin: 0 0 16px;
}

/* Trending list */
.sidebar-trending { list-style: none; margin: 0; padding: 0; }
.sidebar-trending li { padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.sidebar-trending li:last-child { border-bottom: none; }
.sidebar-trending a {
    display: flex; justify-content: space-between; align-items: baseline;
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
    gap: 8px;
}
.sidebar-trending a:hover { color: var(--accent); }
.trending-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trending-date { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.trending-empty { color: var(--text-muted); font-size: 14px; }

/* Colored category badges */
.sidebar-categories { display: flex; flex-direction: column; gap: 8px; }

.sidebar-cat-badge {
    display: block;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none !important;
}
.sidebar-cat-badge:hover {
    transform: scale(1.02);
    filter: brightness(0.95);
}
.sidebar-cat-name { font-weight: 500; }

/* Newsletter */
.sidebar-newsletter-text {
    color: var(--text-secondary); font-size: 14px; margin: 0 0 12px;
}
.newsletter-form { display: flex; gap: 8px; }
.newsletter-form input[type="email"] {
    flex: 1; padding: 8px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; background: var(--bg-primary); color: var(--text-primary);
}
.newsletter-form button {
    padding: 8px 16px; background: var(--accent); color: #fff;
    border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.newsletter-form button:hover { background: var(--accent-hover); }

/* Ad slot */
.ad-slot-sidebar {
    background: var(--bg-card) !important;
    border: 2px dashed var(--border) !important;
    border-radius: 12px; padding: 60px 20px; text-align: center;
    color: var(--text-muted); font-size: 14px;
}
.ad-slot-sidebar p { margin: 0 0 4px; font-weight: 500; }
.ad-slot-sidebar span { font-size: 12px; }

/* ===== ARTICLE CARDS ===== */
.article-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin: 0;
}

@media (max-width: 600px) {
    .article-grid { grid-template-columns: 1fr; }
}

.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

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

.article-card .card-body { padding: 20px; }

.article-card .card-category {
    display: inline-block;
    color: var(--accent);
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.article-card .card-title {
    font-size: 1.05em; font-weight: 700; line-height: 1.4; margin: 0 0 8px;
}
.article-card .card-title a { color: var(--text-primary); }
.article-card .card-title a:hover { color: var(--accent); }

.article-card .card-excerpt {
    color: var(--text-secondary); font-size: 0.88em; line-height: 1.6; margin: 0;
}

.article-card .card-meta {
    color: var(--text-muted); font-size: 0.8em; margin-top: 10px;
    padding-top: 10px; border-top: 1px solid var(--border-light);
}

/* ===== HIDE ASTRA DEFAULTS (front page) ===== */
.home .ast-container { max-width: none !important; padding: 0 !important; }
.home #primary { width: 100% !important; }
.home .ast-row { margin: 0 !important; }
.home .content-area { margin: 0 !important; }
.home article.page { padding: 0 !important; }
.home .entry-header, .home .entry-header .entry-title { display: none !important; }

/* ===== FOOTER ===== */
.site-footer {
    background: #1a1a1a !important;
    color: #999 !important;
    padding: 48px 0 24px !important;
    border-top: 3px solid var(--accent);
    margin-top: 60px;
}
.site-footer a { color: #999 !important; }
.site-footer a:hover { color: var(--accent) !important; }
.site-footer .ast-container { max-width: 1280px !important; padding: 0 20px !important; }

.footer-widget-area .widget { background: transparent; border: none; padding: 0; }
.footer-widget-area .widget-title { color: #fff !important; border-bottom: 1px solid #333; }

/* ===== CATEGORY PAGE ===== */
.category-header { margin: 20px 0; padding-bottom: 16px; border-bottom: 2px solid var(--accent); }
.category-header h1 { font-size: 2em; font-weight: 700; margin: 0; }
.category-desc { color: var(--text-secondary); margin-top: 6px; font-size: 0.95em; }

/* ===== INNER PAGES — DARK MODE FIX ===== */
/* Astra sets white backgrounds on articles/containers that break dark mode.
   Force dark backgrounds and proper text color on all inner pages. */

body.dark-mode article,
body.dark-mode .ast-article-single,
body.dark-mode .ast-article-post,
body.dark-mode .ast-article-inner,
body.dark-mode .entry-content,
body.dark-mode .ast-container,
body.dark-mode #primary,
body.dark-mode #secondary,
body.dark-mode .content-area,
body.dark-mode .site-main,
body.dark-mode .ast-row,
body.dark-mode .ast-col-sm-12,
body.dark-mode .comment-respond,
body.dark-mode .comments-area,
body.dark-mode .post-navigation,
body.dark-mode .ast-separate-container,
body.dark-mode .ast-plain-container,
body.dark-mode .ast-archive-description,
body.dark-mode .site-below-footer-wrap,
body.dark-mode .ast-mobile-header-content { 
    background: var(--bg-primary) !important;
}

/* Mobile hamburger menu inner containers */
body.dark-mode .ast-mobile-header-wrap,
body.dark-mode .ast-mobile-header-wrap .ast-main-header-wrap,
body.dark-mode .ast-mobile-header-wrap .main-header-bar-wrap,
body.dark-mode .ast-mobile-header-wrap .ast-primary-header-bar,
body.dark-mode .ast-mobile-header-wrap .site-primary-header-wrap,
body.dark-mode .ast-builder-menu-mobile,
body.dark-mode .ast-main-header-bar-alignment,
body.dark-mode .main-header-bar-navigation,
body.dark-mode .main-header-bar-navigation .main-navigation,
body.dark-mode .main-header-bar-navigation .main-navigation ul {
    background: var(--bg-primary) !important;
}

/* Hamburger toggle button */
body.dark-mode .menu-toggle,
body.dark-mode .ast-mobile-menu-trigger-minimal,
body.dark-mode .ast-mobile-header-wrap .ast-button-wrap .menu-toggle {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Mobile nav dropdown — menu items and links */
body.dark-mode .ast-mobile-header-content .menu-item,
body.dark-mode .ast-mobile-header-content .page_item,
body.dark-mode .ast-mobile-header-content .menu-link,
body.dark-mode .ast-mobile-header-content a,
body.dark-mode .ast-mobile-header-content li,
body.dark-mode .ast-header-break-point .main-navigation ul .menu-item .menu-link,
body.dark-mode .ast-header-break-point .main-navigation ul li,
body.dark-mode .ast-header-break-point .main-navigation ul li a {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}
body.dark-mode .ast-mobile-header-content .current-menu-item > a,
body.dark-mode .ast-mobile-header-content .current-menu-item {
    background: var(--bg-secondary) !important;
    color: var(--accent) !important;
}

/* Fix text color on inner pages */
body.dark-mode article,
body.dark-mode .entry-content,
body.dark-mode .entry-content p,
body.dark-mode .entry-content li,
body.dark-mode .ast-excerpt-container,
body.dark-mode .ast-excerpt-container p,
body.dark-mode .read-more { 
    color: var(--text-primary) !important; 
}

/* Category page post listings */
body.dark-mode .ast-article-post .entry-title a { color: var(--text-primary) !important; }
body.dark-mode .ast-article-post .entry-title a:hover { color: var(--accent) !important; }

/* Post meta / breadcrumbs */
body.dark-mode .entry-meta,
body.dark-mode .entry-meta a,
body.dark-mode .ast-breadcrumbs-wrapper,
body.dark-mode .ast-breadcrumbs-wrapper a { 
    color: var(--text-muted) !important;
}

/* Comments area */
body.dark-mode .comment-respond label,
body.dark-mode .comments-title,
body.dark-mode .comment-reply-title { color: var(--text-primary) !important; }
body.dark-mode .comment-form-comment textarea,
body.dark-mode .comment-form-author input,
body.dark-mode .comment-form-email input,
body.dark-mode .comment-form-url input,
body.dark-mode textarea,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="url"] {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

/* Archive/category description */
body.dark-mode .archive-description,
body.dark-mode .term-description { color: var(--text-secondary) !important; }
body.dark-mode .page-header { background: transparent !important; }

/* Archive post card metadata */
body.dark-mode .ast-article-post .posted-on,
body.dark-mode .ast-article-post .posted-by,
body.dark-mode .ast-article-post .ast-taxonomy-container { color: var(--text-muted) !important; }

/* Single post navigation */
body.dark-mode .post-navigation .nav-links a { color: var(--text-secondary) !important; }
body.dark-mode .post-navigation .nav-links a:hover { color: var(--accent) !important; }

/* ===== INNER PAGES — LIGHT MODE TWEAKS ===== */
/* Ensure good contrast in light mode too */
.category-page .entry-content p,
.archive .entry-content p,
.single .entry-content p,
.single .entry-content li {
    color: var(--text-primary);
}
.ast-article-post .entry-title a { color: var(--text-primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .echidna-container { padding: 24px 16px; }
    .latest-stories-heading { font-size: 24px; }
    .main-navigation a { padding: 4px 8px !important; font-size: 13px; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.article-card { animation: fadeInUp 0.35s ease-out both; }
.article-card:nth-child(1) { animation-delay: 0.05s; }
.article-card:nth-child(2) { animation-delay: 0.1s; }
.article-card:nth-child(3) { animation-delay: 0.15s; }
.article-card:nth-child(4) { animation-delay: 0.2s; }
.article-card:nth-child(5) { animation-delay: 0.25s; }
.article-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== UTILITY ===== */
/* Hide Astra skip link visually */
.ast-skip-link, .skip-link, .skip-to-content { display: none !important; }

/* Hide Astra credit in footer */
.site-footer a[href*="wpastra"],
.site-footer-below-section { display: none !important; }

/* Also hide the separator "|" before the credit */
.site-footer .ast-builder-footer-grid-columns + * { display: none !important; }

/* Clean up Astra's default page title on inner pages */
.page .entry-header { margin-bottom: 24px; }
.page .entry-header .entry-title { font-size: 2em; font-weight: 700; }

/* Ensure sidebar cards have proper spacing */
.echidna-sidebar > * { margin: 0; }

/* Make categories sidebar scroll if needed */
.sidebar-categories { max-height: none; overflow: visible; }

/* ===== DARK MODE HEADINGS ===== */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode .entry-content h1,
body.dark-mode .entry-content h2,
body.dark-mode .entry-content h3,
body.dark-mode .entry-content h4,
body.dark-mode .entry-content h5,
body.dark-mode .entry-content h6,
body.dark-mode .entry-title a {
    color: #e0e0e0 !important;
}
body.dark-mode .entry-content,
body.dark-mode .entry-content p {
    color: #cccccc;
}
body.dark-mode .entry-content a {
    color: #ff3333 !important;
}
body.dark-mode .entry-content a:hover {
    color: #ff6666 !important;
}
body.dark-mode hr {
    border-color: #333 !important;
}
body.dark-mode .ast-separate-container .ast-article-single {
    background-color: #1a1a1a !important;
}

/* ===== MOBILE TOGGLE VISIBILITY ===== */
/* On mobile, the toggle is inside the hamburger dropdown menu.
   Ensure it remains visible and tappable when the menu is open. */
.ast-mobile-header-content .theme-toggle {
    margin: 8px 0;
    width: 100%;
    justify-content: center;
    font-size: 14px;
    padding: 8px 16px;
}