/* Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #0077cc;
  --text-dark: #111;
  --text-light: #444;
  --background-light: #fff;
  --border-light: #ddd;
  --accent-color: #e54b4b; /* A new accent color for tags */
}

body {
  font-family: 'Georgia', serif;
  background: var(--background-light);
  color: var(--text-dark);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

/* --- Utility Classes & Tags --- */
.category-tag {
    display: inline-block;
    padding: 4px 8px;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    color: #fff;
    background-color: var(--accent-color);
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff !important;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 1rem;
    transition: background-color 0.3s;
    font-family: 'Arial', sans-serif;
}

.cta-button:hover {
    background-color: #005fa3;
    text-decoration: none;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--background-light);
  position: sticky; /* Sticky header for better navigation */
  top: 0;
  z-index: 1000;
  min-height: 64px; /* Ensure consistent height */
  position: relative; /* For absolute positioned children */
}

/* Reserve a small min-height for the nav placeholder so inserting the nav
     later via JS doesn't cause a large layout shift */
#nav-placeholder {
    min-height: 2.2rem; /* roughly the height of a simple nav */
    display: block;
    flex: 1;
    display: flex;
    justify-content: center;
}

/* Menu button styling: positioned absolutely so inserting it won't push other
     header elements and cause layout shifts. Keep it visually inside header. */
.menu-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: none; /* shown by JS on small screens */
    padding: 6px 8px;
    color: var(--text-dark);
    transition: color 0.3s ease;
    z-index: 1001;
}

.menu-btn:hover {
    opacity: 0.7;
}

header .logo {
  font-size: 2.2rem;
  font-weight: bold;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

header nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin: 0 auto;
}

header nav a {
  text-decoration: none;
  color: var(--text-dark);
  font-family: 'Arial', sans-serif;
  font-weight: 600;
  padding: 5px 0;
  position: relative;
  white-space: nowrap;
}

header nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    display: block;
    margin-top: 3px;
    right: 0;
    background: var(--primary-color);
    transition: width 0.3s cubic-bezier(0.85, 0, 0.15, 1);
}

header nav a:hover::after {
    width: 100%;
    left: 0;
    background: var(--primary-color);
}

#dark-mode {
  background: var(--text-dark);
  color: #fff;
  border: none;
  padding: 8px 15px;
  border-radius: 20px; /* Pill shape for better design */
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s;
  flex-shrink: 0;
  white-space: nowrap;
}

#dark-mode:hover {
  background: var(--primary-color);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- HOME PAGE SECTIONS --- */

/* Hero Section */
.hero-section {
    margin: 2rem 0 3rem;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hero-section article {
    display: flex;
    flex-direction: column;
}

.hero-section img {
    width: 100%;
    max-height: 450px;
    object-fit: cover;
    display: block;
}

/* Reserve image aspect ratios so the browser can allocate space before
     images load. This reduces cumulative layout shift for lazy images. */
.hero-section img {
    aspect-ratio: 16 / 9;
    background-color: #f4f4f4; /* neutral placeholder color */
}

.hero-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px;
    color: #fff;
    /* Gradient overlay for readability */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    line-height: 1.1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-content p {
    font-family: 'Arial', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.5rem;
    max-width: 600px;
}

/* Top Stories Grid */
.top-stories {
    padding: 2rem 0;
}

.top-stories h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 5px;
    font-family: 'Arial', sans-serif;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2.5rem;
}

.articles-grid article {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow 0.3s, transform 0.3s;
    background-color: var(--background-light);
}

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

.articles-grid img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

/* Reserve aspect ratio for grid images (prevents shift when images load) */
.articles-grid img {
    aspect-ratio: 3 / 2;
    background-color: #f4f4f4;
}

.articles-grid article > * {
    padding: 0 1rem;
}

.articles-grid h3 {
  font-size: 1.5rem;
  margin: 0.5rem 1rem 0;
  line-height: 1.2;
}

.articles-grid p {
  font-family: 'Arial', sans-serif;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.articles-grid a {
  color: var(--primary-color);
  font-weight: 600;
  display: block;
  padding: 0 1rem 1rem;
  text-decoration: none;
}

.articles-grid a:hover {
  text-decoration: underline;
}

/* Short News */
.short-news {
    margin: 3rem 0;
    padding: 1.5rem 0;
    border-top: 1px dashed var(--border-light);
}

.short-news h2 {
    font-family: 'Arial', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.short-news ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1rem;
}

.short-news li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-family: 'Arial', sans-serif;
}

.news-tag {
    font-weight: bold;
    color: var(--primary-color);
    margin-right: 5px;
}

.short-news .view-all {
    color: var(--accent-color);
    font-weight: bold;
    text-decoration: none;
}

.short-news .view-all:hover {
    text-decoration: underline;
}


/* --- ARTICLE VIEW STYLES --- */
.article-view {
    max-width: 900px; /* Narrower container for better readability */
    padding-top: 3rem;
    padding-bottom: 5rem;
}

.post-content {
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.7;
}

.post-hero-image {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.post-title {
    font-size: 3.2rem;
    line-height: 1.15;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.post-meta {
    font-family: 'Arial', sans-serif;
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 15px;
}

.lead-paragraph {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.post-body h2 {
    font-size: 2rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
    border-left: 5px solid var(--primary-color);
    padding-left: 10px;
}

.post-body h3 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
}

.post-body p, .post-body li {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: var(--text-dark);
}

.post-body ul {
    margin-left: 20px;
    list-style-type: disc;
}

.callout {
    border-left: 5px solid var(--accent-color);
    padding: 15px 20px;
    margin: 2rem 0;
    background-color: rgba(229, 75, 75, 0.1);
    border-radius: 0 5px 5px 0;
}

.callout h4 {
    color: var(--accent-color);
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-family: 'Arial', sans-serif;
    font-size: 1.2rem;
}

.callout p {
    margin-bottom: 0;
    font-size: 1rem;
}

.author-bio {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-light);
    font-family: 'Arial', sans-serif;
    color: var(--text-light);
}

.back-to-home-btn {
    margin-top: 3rem;
}

/* --- TABLE STYLES --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-family: 'Arial', sans-serif;
  font-size: 0.95rem;
}

thead {
  background-color: var(--primary-color);
  color: #fff;
}

thead th {
  text-align: left;
  padding: 12px 15px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: rgba(0, 119, 204, 0.05); /* Light blue hover */
}

td {
  padding: 12px 15px;
  color: var(--text-dark);
}

/* Zebra striping */
tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Dark mode adjustments */
body.dark thead {
  background-color: var(--primary-color);
}

body.dark tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.05);
}

body.dark tbody tr:hover {
  background-color: rgba(102, 170, 255, 0.1);
}



/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 3rem;
  font-family: 'Arial', sans-serif;
  color: var(--text-light);
  border-top: 1px solid var(--border-light);
  background-color: var(--background-light);
}

/* Enhanced Footer Styles */
.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  text-align: left;
  padding: 2rem 0;
}

.footer-section h3,
.footer-section h4 {
  margin-bottom: 1rem;
  color: var(--text-dark);
}

.footer-section p {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section ul li a {
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.3s;
}

.footer-section ul li a:hover {
  color: var(--primary-color);
}

.footer-bottom {
  border-top: 1px solid var(--border-light);
  padding-top: 1rem;
  margin-top: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-social {
  display: flex;
  gap: 1rem;
}

.footer-social a {
  font-size: 1.2rem;
  text-decoration: none;
  transition: transform 0.3s;
}

.footer-social a:hover {
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 5px;
}

/* --- DARK MODE --- */
body.dark {
  --text-dark: #eee;
  --text-light: #bbb;
  --background-light: #181818;
  --border-light: #444;
  --primary-color: #66aaff;
  --accent-color: #ff8c8c;
}

body.dark header {
  background-color: #222;
  border-bottom-color: var(--border-light);
}

body.dark header nav a {
    color: var(--text-dark);
}

body.dark footer {
  background-color: #222;
  border-top-color: var(--border-light);
  color: var(--text-light);
}

body.dark #dark-mode {
  background-color: #555;
  color: #fff;
}

body.dark #dark-mode:hover {
  background-color: var(--primary-color);
}

body.dark .hero-content .category-tag {
    background-color: var(--accent-color);
}

body.dark .articles-grid article {
    border-color: var(--border-light);
    background-color: #222;
}

body.dark .short-news li {
    border-bottom-color: var(--border-light);
}

body.dark .post-content p, body.dark .post-content li {
    color: var(--text-dark); /* Ensure main text remains light */
}

body.dark .callout {
    background-color: rgba(255, 140, 140, 0.15); /* Darker background for callout */
}

body.dark .post-meta, body.dark .author-bio {
    color: var(--text-light);
}

/* Ensure images remain visible in dark mode. Some browsers or third-party
     scripts may apply blend modes or filters when a dark class is present.
     Reset common properties here so images always render correctly. */
body.dark img {
    filter: none !important;
    -webkit-filter: none !important;
    opacity: 1 !important;
    mix-blend-mode: normal !important;
    background-color: transparent !important;
}

/* Dark mode enhancements for better consistency */
body.dark .menu-btn {
    color: #eee !important;
}

body.dark .back-link {
    color: var(--primary-color);
}

body.dark .cta-button {
    background-color: var(--primary-color);
}

body.dark .cta-button:hover {
    background-color: #4a9eee;
}

body.dark .news-tag {
    color: var(--primary-color);
}

body.dark input, body.dark textarea, body.dark select {
    background-color: #333;
    color: var(--text-dark);
    border: 1px solid var(--border-light);
}

body.dark input:focus, body.dark textarea:focus, body.dark select:focus {
    border-color: var(--primary-color);
}

/* Fix any gradient overlays in dark mode */
body.dark .hero-content {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.2));
}


/* --- RESPONSIVE --- */
@media (max-width: 992px) {
    .hero-content h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    /* Header adjustments for mobile */
    header {
        padding: 1rem 1.5rem;
    }
    
    header .logo {
        font-size: 1.8rem;
    }
    
    /* Show mobile menu button */
    .menu-btn {
        display: block !important;
        right: 1rem;
    }
    
    /* Hide navigation by default on mobile */
    #nav-placeholder nav {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--background-light);
        border-bottom: 1px solid var(--border-light);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        flex-direction: column !important;
        gap: 1rem !important;
        z-index: 999;
    }
    
    /* When mobile menu is shown */
    #nav-placeholder nav.mobile-nav-open {
        display: flex !important;
    }
    
    /* Mobile nav links styling */
    #nav-placeholder nav a {
        padding: 12px 16px;
        margin: 0;
        border-bottom: 1px solid var(--border-light);
        transition: background-color 0.2s;
    }
    
    #nav-placeholder nav a:last-child {
        border-bottom: none;
    }
    
    #nav-placeholder nav a:hover {
        background-color: rgba(0, 119, 204, 0.1);
    }
    
    /* Adjust dark mode button position on mobile */
    #dark-mode {
        font-size: 0.8rem;
        padding: 6px 12px;
        position: absolute;
        right: 4rem;
        top: 50%;
        transform: translateY(-50%);
    }

    /*
    1. Force the article to stack its children (image and content) vertically.
       This assumes your desktop style uses flex or grid to place them side-by-side.
    */
    .hero-section article {
        display: flex;
        flex-direction: column;
        border-radius: 0; /* Optional: Remove rounded corners for full-width look */
        overflow: hidden;
    }

    /*
    2. Make the image take up the full width and set a fixed mobile height.
    */
    .hero-section article img {
        width: 100%;
        height: 250px; /* Set a specific height to keep it from being too tall */
        object-fit: cover; /* Ensures the image fills the container without distortion */
        /* If the image was absolutely positioned for desktop overlay,
           this resets it to normal flow. */
        position: static; 
    }

    /*
    3. Ensure the content box is full width and flows below the image.
    */
    .hero-content {
        width: 100%;
        position: static; /* Ensures it sits in the normal flow, not over the image */
        transform: none; /* Resets any centering transform from desktop */
        text-align: left; /* Ensure text is left-aligned on mobile */
        padding: 20px; /* Use the existing padding for good spacing */
    }

    /*
    4. Adjust the CTA button for better tap target size on mobile.
    */
    .hero-content .cta-button {
        display: block; /* Make the button full-width */
        text-align: center;
    }
    
    /* Existing style: ensure the font size is appropriate */
    .hero-content h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.5rem;
    }
    .hero-content p {
        font-size: 0.9rem;
    }
    .hero-section img {
        max-height: 300px;
    }
    .post-title {
        font-size: 1.8rem;
    }
}
@media (max-width: 600px) {
    header {
        padding: 0.8rem 1rem;
    }
    
    header .logo {
        font-size: 1.6rem;
    }
    
    #dark-mode {
        font-size: 0.7rem;
        padding: 5px 10px;
        right: 3.5rem;
    }
    
    .menu-btn {
        right: 0.8rem;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.5rem;
    }
    .hero-content p {
        font-size: 0.9rem;
    }
    .hero-section img {
        max-height: 300px;
    }
    .post-title {
        font-size: 1.8rem;
    }
    
    header .logo {
        font-size: 1.4rem;
    }
    
    #dark-mode {
        font-size: 0.65rem;
        padding: 4px 8px;
    }
}

@media (max-width: 400px) {
    .cta-button {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    header .logo {
        font-size: 1.3rem;
    }
}

@media (max-width: 320px) {
    .cta-button {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    header {
        padding: 0.6rem 0.8rem;
    }
    
    header .logo {
        font-size: 1.2rem;
    }
    
    #dark-mode {
        font-size: 0.6rem;
        padding: 3px 6px;
    }
    
    .menu-btn {
        font-size: 1.2rem;
        right: 0.6rem;
    }
}

/* Dark mode mobile adjustments */
body.dark #nav-placeholder nav {
    background-color: #222;
    border-bottom-color: var(--border-light);
}

body.dark #nav-placeholder nav a:hover {
    background-color: rgba(102, 170, 255, 0.1);
}

/* End of CSS */