/* ==========================================================================
   Starter Theme Flavor — Main Stylesheet
   ALL colors use CSS variables for Customizer compatibility
   ========================================================================== */

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

:root {
    --stf-primary: #2563eb;
    --stf-primary-dark: #1d4ed8;
    --stf-secondary: #7c3aed;
    --stf-accent: #f59e0b;
    --stf-header-bg: #ffffff;
    --stf-header-text: #1f2937;
    --stf-footer-bg: #111827;
    --stf-footer-text: #f3f4f6;
    --stf-body-bg: #ffffff;
    --stf-body-text: #1f2937;
    --stf-font-size: 16px;
    --stf-line-height: 1.7;
    --stf-border: #e5e7eb;
    --stf-muted: #6b7280;
    --stf-surface: #f9fafb;
    --stf-radius: 8px;
    --stf-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --stf-shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --stf-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --stf-font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --stf-container: 1200px;
}

html { scroll-behavior: smooth; font-size: var(--stf-font-size); }
body {
    font-family: var(--stf-font-body); line-height: var(--stf-line-height);
    color: var(--stf-body-text); background: var(--stf-body-bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--stf-primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--stf-primary-dark); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 { font-family: var(--stf-font-heading); font-weight: 700; line-height: 1.3; color: var(--stf-body-text); }
h1 { font-size: clamp(1.75rem, 2.5vw, 2.5rem); }
h2 { font-size: clamp(1.375rem, 2vw, 1.875rem); }
h3 { font-size: clamp(1.125rem, 1.5vw, 1.5rem); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sr-only:focus { position: fixed; top: 0; left: 0; z-index: 99999; width: auto; height: auto; padding: 1rem; margin: 0; clip: auto; white-space: normal; background: var(--stf-primary); color: #fff; font-size: 1rem; }

/* ---------- Container ---------- */
.container { max-width: var(--stf-container); margin: 0 auto; padding: 0 1rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-block; padding: 0.625rem 1.25rem; border-radius: var(--stf-radius); font-weight: 600; font-size: 0.875rem; cursor: pointer; border: none; transition: all 0.2s; text-align: center; min-height: 44px; }
.btn-primary { background: var(--stf-primary); color: #fff; }
.btn-primary:hover { background: var(--stf-primary-dark); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--stf-primary); color: var(--stf-primary); }
.btn-outline:hover { background: var(--stf-primary); color: #fff; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-primary { background: var(--stf-primary); color: #fff; }
.badge-secondary { background: var(--stf-secondary); color: #fff; }
.badge-sm { font-size: 0.65rem; padding: 0.15rem 0.4rem; }
.badge-sponsored { background: var(--stf-accent); color: #1f2937; }

/* ---------- Reading Progress Bar ---------- */
.reading-progress-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--stf-primary); z-index: 10000; transition: width 0.1s; }

/* ---------- Top Bar ---------- */
.top-bar { padding: 0.4rem 0; font-size: 0.75rem; }
.top-bar-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.top-bar-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.top-bar-right { display: flex; gap: 0.5rem; }
.top-bar-date { opacity: 0.8; }
.trending-label { font-weight: 600; }
.trending-tag { color: inherit; font-weight: 500; }
.trending-tag:hover { opacity: 0.8; }
.social-link { color: inherit; display: inline-flex; align-items: center; }
.social-link:hover { color: var(--stf-primary); }

/* ---------- Header ---------- */
.site-header { background: var(--stf-header-bg); color: var(--stf-header-text); border-bottom: 1px solid var(--stf-border); position: relative; z-index: 100; }
.sticky-header { position: sticky; top: 0; }
.header-main { padding: 0.75rem 0; }
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.site-branding { display: flex; align-items: center; gap: 0.5rem; }
.site-title-link { text-decoration: none; }
.site-title { font-size: 1.5rem; font-weight: 800; color: var(--stf-header-text); }
.site-tagline { font-size: 0.75rem; color: var(--stf-muted); margin: 0; }
.logo-img { max-height: 50px; width: auto; }

.search-toggle, .mobile-menu-toggle { background: none; border: none; cursor: pointer; padding: 0.5rem; color: var(--stf-header-text); display: flex; align-items: center; min-width: 44px; min-height: 44px; justify-content: center; }
.header-search { display: none; padding: 0.75rem 0; }
.header-search.active { display: block; }
.search-form { display: flex; gap: 0.5rem; }
.search-field { flex: 1; padding: 0.5rem 1rem; border: 1px solid var(--stf-border); border-radius: var(--stf-radius); font-size: 0.875rem; min-height: 44px; background: var(--stf-body-bg); color: var(--stf-body-text); }
.search-submit { background: var(--stf-primary); color: #fff; border: none; border-radius: var(--stf-radius); padding: 0 1rem; cursor: pointer; display: flex; align-items: center; min-height: 44px; }

/* ---------- Nav ---------- */
.primary-nav { background: var(--stf-header-bg); border-top: 1px solid var(--stf-border); border-bottom: 1px solid var(--stf-border); }
.primary-nav .container { display: flex; align-items: center; }
.primary-menu, .primary-nav ul, .primary-nav .menu { list-style: none !important; display: flex; gap: 0; flex-wrap: wrap; margin: 0; padding: 0; }
.primary-menu li, .primary-nav ul li, .primary-nav .menu li { position: relative; list-style: none; }
.primary-menu > li > a, .primary-nav ul > li > a, .primary-nav .menu > li > a { display: block; padding: 0.75rem 1rem; font-size: 0.875rem; font-weight: 600; color: var(--stf-header-text); transition: color 0.2s; white-space: nowrap; }
.primary-menu > li > a:hover, .primary-menu > li.current-menu-item > a, .primary-menu > li.current_page_item > a { color: var(--stf-primary); }
.primary-menu .sub-menu, .primary-nav .children { display: none; position: absolute; top: 100%; left: 0; background: var(--stf-header-bg); min-width: 220px; box-shadow: var(--stf-shadow-lg); border-radius: 0 0 var(--stf-radius) var(--stf-radius); list-style: none !important; z-index: 200; border: 1px solid var(--stf-border); margin: 0; padding: 0; }
.primary-menu li:hover > .sub-menu, .primary-nav li:hover > .children { display: block; }
.primary-menu .sub-menu a, .primary-nav .children a { display: block; padding: 0.5rem 1rem; font-size: 0.8rem; color: var(--stf-body-text); }
.primary-menu .sub-menu a:hover, .primary-nav .children a:hover { background: var(--stf-surface); color: var(--stf-primary); }
.menu-item-has-children > a { display: flex !important; align-items: center; gap: 0.25rem; }
.menu-item-viewall a { border-top: 1px solid var(--stf-border); margin-top: 0.25rem; padding-top: 0.5rem !important; }

.mobile-menu-toggle { display: none; }
@media (max-width: 768px) {
    .mobile-menu-toggle { display: flex; }
    .primary-nav { display: none; }
}

/* Breaking news */
.breaking-news-bar { background: #dc2626; color: #fff; padding: 0.4rem 0; font-size: 0.8rem; overflow: hidden; white-space: nowrap; }
.breaking-news-bar .container { display: flex; align-items: center; gap: 0.75rem; }
.breaking-label { font-weight: 700; text-transform: uppercase; flex-shrink: 0; }
.breaking-ticker { overflow: hidden; }
.breaking-ticker a { color: #fff; animation: ticker 20s linear infinite; display: inline-block; }
@keyframes ticker { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* ---------- Mobile Menu ---------- */
.mobile-menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--stf-body-bg); z-index: 10000; transform: translateX(100%); transition: transform 0.3s; overflow-y: auto; }
.mobile-menu-overlay.active { transform: translateX(0); }
.mobile-menu-inner { padding: 1.5rem; }
.mobile-menu-close { background: none; border: none; cursor: pointer; position: absolute; top: 1rem; right: 1rem; color: var(--stf-body-text); min-width: 44px; min-height: 44px; }
.mobile-search-form { margin: 2rem 0 1rem; }
.mobile-search-form input { width: 100%; padding: 0.75rem; border: 1px solid var(--stf-border); border-radius: var(--stf-radius); font-size: 1rem; background: var(--stf-body-bg); color: var(--stf-body-text); }
.mobile-nav-menu { list-style: none; }
.mobile-nav-menu li a { display: block; padding: 0.75rem 0; border-bottom: 1px solid var(--stf-border); font-size: 1rem; color: var(--stf-body-text); }
.mobile-nav-menu .sub-menu { padding-left: 1rem; list-style: none; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { padding: 1rem 0 0.5rem; font-size: 0.8rem; color: var(--stf-muted); }
.breadcrumb-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0; }
.breadcrumb-item { display: inline; }
.breadcrumb-item a { color: var(--stf-muted); }
.breadcrumb-item a:hover { color: var(--stf-primary); }
.breadcrumb-sep { margin: 0 0.4rem; }
.breadcrumb-current { color: var(--stf-body-text); }

/* ---------- Content Layout ---------- */
.content-area { padding: 1.5rem 0; }
.content-area.has-sidebar { display: grid; gap: 2rem; }
.content-area.has-sidebar.sidebar-right { grid-template-columns: 1fr 300px; }
.content-area.has-sidebar.sidebar-left { grid-template-columns: 300px 1fr; }
@media (max-width: 960px) { .content-area.has-sidebar { grid-template-columns: 1fr !important; } }

/* ---------- Post Cards ---------- */
.posts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media (max-width: 960px) { .posts-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .posts-grid { grid-template-columns: 1fr; } }

.post-card { background: var(--stf-body-bg); border: 1px solid var(--stf-border); border-radius: var(--stf-radius); overflow: hidden; transition: box-shadow 0.2s; }
.post-card:hover { box-shadow: var(--stf-shadow-lg); }
.post-card-thumb img { width: 100%; height: 200px; object-fit: cover; }
.post-card-thumb-placeholder { width: 100%; height: 200px; background: var(--stf-surface); }
.post-card-content { padding: 1rem; }
.post-card-content .badge { margin-bottom: 0.5rem; }
.post-card-title { font-size: 1rem; margin: 0.4rem 0; }
.post-card-title a { color: var(--stf-body-text); }
.post-card-title a:hover { color: var(--stf-primary); }
.post-card-excerpt { font-size: 0.85rem; color: var(--stf-muted); margin-bottom: 0.5rem; }
.post-card-meta { font-size: 0.75rem; color: var(--stf-muted); display: flex; gap: 0.75rem; }

/* ---------- Load More ---------- */
.load-more-wrap { text-align: center; padding: 2rem 0; }
.load-more-btn { min-width: 200px; }
.load-more-btn:disabled { opacity: 0.6; cursor: wait; }

/* ---------- Sidebar ---------- */
.sidebar-inner { position: sticky; top: 80px; }
.widget { margin-bottom: 1.5rem; padding: 1.25rem; background: var(--stf-body-bg); border: 1px solid var(--stf-border); border-radius: var(--stf-radius); }
.widget-title { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--stf-primary); }
.widget ul { list-style: none; }
.widget ul li { padding: 0.3rem 0; }
.widget ul li a { color: var(--stf-body-text); font-size: 0.85rem; }
.widget ul li a:hover { color: var(--stf-primary); }
.related-post-item { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; align-items: flex-start; }
.related-thumb img { width: 70px; height: 50px; object-fit: cover; border-radius: 4px; }
.related-title { font-size: 0.8rem; font-weight: 600; color: var(--stf-body-text); }
.toc-nav a { display: block; padding: 0.3rem 0; font-size: 0.8rem; color: var(--stf-muted); border-left: 2px solid var(--stf-border); padding-left: 0.75rem; }
.toc-nav a:hover, .toc-nav a.active { color: var(--stf-primary); border-left-color: var(--stf-primary); }
.toc-h3 { padding-left: 1.5rem !important; }

/* ---------- Footer ---------- */
.site-footer { background: var(--stf-footer-bg); color: var(--stf-footer-text); padding-top: 3rem; }
.footer-widgets { padding-bottom: 2rem; }
.footer-grid { display: grid; gap: 2rem; }
.footer-cols-4 { grid-template-columns: repeat(4, 1fr); }
.footer-cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) { .footer-cols-4, .footer-cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .footer-cols-4, .footer-cols-3 { grid-template-columns: 1fr; } }
.footer-col .widget { background: transparent; border: none; padding: 0; color: var(--stf-footer-text); }
.footer-col .widget-title { color: #fff; border-bottom-color: var(--stf-primary); font-size: 0.85rem; }
.footer-col .widget ul { list-style: none; margin: 0; padding: 0; }
.footer-col .widget ul li { margin-bottom: 0.35rem; }
.footer-col a, .footer-col .widget ul li a { color: var(--stf-footer-text); opacity: 0.8; font-size: 0.875rem; transition: opacity 0.2s; }
.footer-col a:hover, .footer-col .widget ul li a:hover { opacity: 1; color: #fff; }
.footer-about-text { font-size: 0.875rem; line-height: 1.6; opacity: 0.7; margin-bottom: 0.75rem; }
.footer-contact-email a { color: var(--stf-primary) !important; opacity: 1 !important; font-weight: 500; }
.footer-rss { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid rgba(255,255,255,0.1); }
.footer-rss a { opacity: 0.7; font-size: 0.85rem; }
.footer-rss a:hover { opacity: 1; }
.footer-newsletter-form input { width: 100%; padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; border: 1px solid rgba(255,255,255,0.15); border-radius: var(--stf-radius); background: rgba(255,255,255,0.08); color: var(--stf-footer-text); font-size: 0.85rem; }
.footer-newsletter-form input::placeholder { color: rgba(255,255,255,0.4); }
.footer-newsletter-form .btn { width: 100%; font-size: 0.85rem; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); padding: 1.5rem 0; }
.footer-bottom-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; font-size: 0.8rem; }
.legal-menu { list-style: none; display: flex; gap: 1rem; margin: 0; padding: 0; flex-wrap: wrap; }
.legal-menu li { list-style: none; }
.legal-menu a { color: var(--stf-footer-text); opacity: 0.6; transition: opacity 0.2s; }
.legal-menu a:hover { opacity: 1; }
.footer-social { display: flex; gap: 0.75rem; }
.footer-social a { color: var(--stf-footer-text); opacity: 0.6; }
.footer-social a:hover { opacity: 1; color: var(--stf-primary); }

/* ---------- Back to Top ---------- */
.back-to-top { position: fixed; bottom: 2rem; right: 2rem; width: 44px; height: 44px; background: var(--stf-primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s; z-index: 999; box-shadow: var(--stf-shadow-lg); }
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--stf-primary-dark); color: #fff; }

/* ---------- Ad Slots ---------- */
.ad-slot { text-align: center; padding: 1rem 0; }
.ad-slot:empty { display: none; }

/* ---------- Search Results ---------- */
.search-result { padding: 1.25rem 0; border-bottom: 1px solid var(--stf-border); }
.search-result-title { font-size: 1.125rem; margin-bottom: 0.3rem; }
.search-result-title a { color: var(--stf-body-text); }
.search-result-title a:hover { color: var(--stf-primary); }
.search-result-meta { font-size: 0.8rem; color: var(--stf-muted); margin-bottom: 0.5rem; }
.search-result-excerpt { font-size: 0.9rem; }
.search-count { color: var(--stf-muted); margin-bottom: 1rem; }

/* ---------- 404 ---------- */
.error-404 { text-align: center; padding: 3rem 0; }
.error-404 h1 { margin-bottom: 1rem; }
.error-404 .search-form { max-width: 500px; margin: 2rem auto; }
.recent-posts-list { list-style: none; text-align: left; max-width: 500px; margin: 1rem auto; }
.recent-posts-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--stf-border); }

/* ---------- Loading ---------- */
.loading-spinner { text-align: center; padding: 2rem; }
.spinner { width: 36px; height: 36px; margin: 0 auto; border: 3px solid var(--stf-border); border-top-color: var(--stf-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Archive ---------- */
.archive-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--stf-border); }
.archive-description { color: var(--stf-muted); margin-top: 0.5rem; }
.page-title { margin-bottom: 1rem; }
.subcategories { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ---------- Author Page Hero ---------- */
.author-hero { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); color: #fff; padding: 3rem 0 2rem; }
.author-hero-inner { display: flex; gap: 2rem; align-items: flex-start; }
.author-hero-avatar { flex-shrink: 0; position: relative; }
.author-hero-avatar img { border-radius: 50%; width: 120px; height: 120px; border: 4px solid rgba(255,255,255,0.2); }
.author-hero-info { flex: 1; }
.author-hero-name { font-size: 1.75rem; margin: 0 0 0.25rem; color: #fff; }
.author-hero-role { font-size: 0.9rem; color: var(--stf-primary); font-weight: 600; display: block; margin-bottom: 0.5rem; }
.author-hero-bio { font-size: 0.9rem; color: #cbd5e1; line-height: 1.6; max-width: 600px; margin-bottom: 0.75rem; }
.author-hero-expertise { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.author-hero-expertise .expertise-tag { background: rgba(59,130,246,0.2); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.author-hero-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.author-link { color: #94a3b8; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.author-link:hover { color: #fff; }
.author-stats-bar { display: flex; gap: 2.5rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); }
.author-stat { text-align: center; }
.author-stat-num { display: block; font-size: 1.25rem; font-weight: 700; color: #fff; }
.author-stat-label { font-size: 0.75rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.author-page .section-title { margin-top: 0; }
@media (max-width: 600px) {
    .author-hero-inner { flex-direction: column; align-items: center; text-align: center; }
    .author-hero-expertise { justify-content: center; }
    .author-hero-links { justify-content: center; }
    .author-stats-bar { justify-content: center; }
}

/* ---------- Placeholder ---------- */
.post-card-thumb-placeholder, .hero-placeholder { background: var(--stf-surface); }

/* Accessibility */
:focus-visible { outline: 2px solid var(--stf-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
