/*
Theme Name: Newsroom
Theme URI: https://example.com/newsroom
Author: Your Name
Author URI: https://example.com
Description: An original, lightweight news & magazine theme with a grid homepage, mega menu, AJAX load more, popular posts & social widgets, and dark/light mode.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: newsroom
Tags: news, magazine, blog, grid, mega-menu, dark-mode
*/

/* ==========================================================================
   Root variables / theming (light + dark)
   ========================================================================== */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #d42b2b;
  --accent-hover: #b71f1f;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 8px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Georgia", "Times New Roman", serif;
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-alt: #1a1a1a;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --border: #2e2e2e;
  --accent: #ff5252;
  --accent-hover: #ff7b7b;
  --card-bg: #1c1c1c;
  --header-bg: #171717;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  transition: background .2s ease, color .2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.25;
  margin: 0 0 .5em;
}

.screen-reader-text { position: absolute; left: -9999px; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 20px;
}

.site-branding .site-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.5px;
}
.site-branding .site-title a { color: var(--text); }
.site-branding img.custom-logo { max-height: 48px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Theme toggle switch */
.theme-toggle {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 44px;
  height: 26px;
  position: relative;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 2px;
}
.theme-toggle .knob {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .2s ease;
}
[data-theme="dark"] .theme-toggle .knob { transform: translateX(18px); }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}

/* ==========================================================================
   Mega menu
   ========================================================================== */
.primary-navigation { position: relative; }
.mega-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}
.mega-menu > li {
  position: relative;
}
.mega-menu > li > a {
  display: block;
  padding: 12px 14px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .3px;
  border-radius: var(--radius);
}
.mega-menu > li > a:hover,
.mega-menu > li.current-menu-item > a {
  color: var(--accent);
  background: var(--bg-alt);
}

.mega-menu .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  list-style: none;
  margin: 4px 0 0;
  z-index: 200;
}
.mega-menu li.menu-item-has-children:hover > .sub-menu {
  display: block;
}
.mega-menu .sub-menu li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
}
.mega-menu .sub-menu li a:hover {
  background: var(--bg-alt);
  color: var(--accent);
}

/* Wide "mega" panel for top-level items flagged as mega */
.mega-menu li.is-mega > .sub-menu {
  display: none;
  min-width: 600px;
  columns: 3;
  column-gap: 24px;
}
.mega-menu li.is-mega:hover > .sub-menu { display: block; }
.mega-menu li.is-mega .sub-menu li { break-inside: avoid; }

/* ==========================================================================
   Layout: main content + sidebar
   ========================================================================== */
.site-main-wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  padding: 32px 20px;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .site-main-wrap { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Homepage magazine grid
   ========================================================================== */
.featured-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}
@media (max-width: 700px) {
  .featured-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }

.card .card-thumb { aspect-ratio: 16/9; overflow: hidden; background: var(--bg-alt); }
.card .card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .card-body { padding: 16px; }
.card .card-category {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.card .card-title { font-size: 17px; margin: 0 0 6px; }
.card .card-meta { font-size: 13px; color: var(--text-muted); }
.card .card-excerpt { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

.card.card-lead .card-title { font-size: 26px; }
.card.card-lead .card-thumb { aspect-ratio: 16/9; }

.secondary-list { display: flex; flex-direction: column; gap: 16px; }
.secondary-list .card { display: flex; flex-direction: row; }
.secondary-list .card .card-thumb { width: 120px; flex-shrink: 0; aspect-ratio: 1/1; }
.secondary-list .card .card-body { padding: 10px 14px; }
.secondary-list .card .card-title { font-size: 15px; }

.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 900px) { .news-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .news-grid { grid-template-columns: 1fr; } }

.section-title {
  font-size: 20px;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  margin: 32px 0 16px;
}

/* Load more button */
.load-more-wrap { text-align: center; margin: 32px 0; }
.btn-load-more {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
.btn-load-more:hover { background: var(--accent-hover); }
.btn-load-more[disabled] { opacity: .6; cursor: default; }
.load-more-spinner { display: none; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.load-more-spinner.active { display: block; }

/* ==========================================================================
   Single post
   ========================================================================== */
.single-post .post-header { margin-bottom: 20px; }
.single-post .post-title { font-size: 32px; }
.single-post .post-meta { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.single-post .post-thumb { margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; }
.single-post .post-content { font-size: 17px; }
.single-post .post-content p { margin: 0 0 1.2em; }
.single-post .post-content img { border-radius: var(--radius); margin: 1em 0; }

.related-posts { margin-top: 48px; border-top: 1px solid var(--border); padding-top: 24px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 700px) { .related-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Sidebar widgets
   ========================================================================== */
.widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 24px;
}
.widget-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

/* Social widget */
.social-widget-list { display: flex; gap: 10px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
.social-widget-list a {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.social-widget-list a:hover { background: var(--accent); color: #fff; }

/* Popular posts widget */
.popular-posts-list { list-style: none; margin: 0; padding: 0; }
.popular-posts-list li {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.popular-posts-list li:last-child { border-bottom: none; }
.popular-posts-list .rank {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  width: 24px;
  flex-shrink: 0;
}
.popular-posts-list img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.popular-posts-list .p-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.popular-posts-list .p-meta { font-size: 12px; color: var(--text-muted); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 40px 20px;
  margin-top: 40px;
}
.footer-widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto 24px;
}
@media (max-width: 700px) { .footer-widgets { grid-template-columns: 1fr; } }
.site-footer .footer-bottom {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ==========================================================================
   Mobile nav
   ========================================================================== */
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .primary-navigation { display: none; width: 100%; }
  .primary-navigation.is-open { display: block; }
  .mega-menu { flex-direction: column; }
  .mega-menu .sub-menu, .mega-menu li.is-mega > .sub-menu {
    position: static; display: none; columns: 1; min-width: 0; box-shadow: none; border: none; padding-left: 12px;
  }
  .mega-menu li.menu-item-has-children.is-open > .sub-menu { display: block; }
  .header-inner { flex-wrap: wrap; }
}
