/* ====================================================
   Root Variables & Reset
==================================================== */
@import url('https://fonts.googleapis.com/css2?family=League+Spartan&display=swap');

:root {
  --primary: #182183;
  --primary-hover: #005fa3;
  --text-dark: #222;
  --text-light: #444;
  --bg-light: #f9f9f9;
  --white: #fff;
  --border-color: #ddd;
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  --font-main: 'Segoe UI', sans-serif;
}

/* ====================================================
   Header Title & Logo
==================================================== */
#site-title {
  font-family: 'League Spartan', sans-serif;
  font-size: 3rem;
  font-weight: 1000;
  margin-left: 0;
  padding-left: 1rem;
}

#site-title a {
  text-decoration: none;
  color: #1a1a1a;
  font-weight: 900;
}

/* ====================================================
   Universal Reset
==================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ====================================================
   Global Styles & Header Container
==================================================== */
header {
  margin: 0;
  position: relative;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

.site-logo {
  display: flex;
  align-items: center;
  margin-right: auto;
  flex-shrink: 0;
  height: 80px;
}

.site-logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
  max-width: 200px;
}

/* ====================================================
   Desktop Navigation Menu (Always visible on desktop)
==================================================== */
.nav-menu {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-left: 0;
}

.nav-menu a {
  text-decoration: none;
  font-weight: 600;
  color: #001163;
  font-size: 1rem;
  white-space: nowrap;
}

.nav-menu a.active {
  text-decoration: underline;
}

/* ====================================================
   Desktop Search Bar (Always visible on desktop)
==================================================== */
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.search-bar input {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 200px;
}

.search-bar button {
  background-color: #001163;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

/* ====================================================
   Hamburger Menu (Hidden by default - Mobile Only)
==================================================== */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 0.5rem;
  background: none;
  border: none;
  z-index: 1001;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background-color: #001163;
  margin: 2px 0;
  transition: 0.3s ease;
  border-radius: 2px;
}

/* Hamburger Animation States */
.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Overlay (Hidden by default) */
.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.nav-overlay.active {
  display: block;
}

/* Mobile Navigation Menu (Hidden by default) */
.nav-mobile {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100%;
  background: var(--white);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: right 0.3s ease;
  overflow-y: auto;
}

.nav-mobile.active {
  right: 0;
}

.nav-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-mobile-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dark);
}

.nav-mobile-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  color: #666;
}

.nav-mobile-menu {
  padding: 1rem 0;
}

.nav-mobile-menu a {
  display: block;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  color: #001163;
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.nav-mobile-menu a:hover,
.nav-mobile-menu a.active {
  background-color: rgba(0, 17, 99, 0.05);
}

/* Mobile Search in Hamburger */
.nav-mobile-search {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-mobile-search input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.nav-mobile-search button {
  width: 100%;
  padding: 0.5rem;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* ====================================================
   Base Styles
==================================================== */
html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg-light);
  color: var(--text-dark);
}

main {
  flex: 1;
}

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

a:hover {
  text-decoration: underline;
}

/* ====================================================
   Layout: Container, Header, Footer
==================================================== */
.container {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.5rem;
}

header, footer {
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  padding: 1rem;
}

footer {
  border-top: 1px solid var(--border-color);
}

header h1 a {
  text-decoration: none;
  color: var(--text-dark);
}

nav a {
  margin-left: 1rem;
  font-weight: 500;
}

/* ====================================================
   Background Image Section (Mission)
==================================================== */
#mission {
  margin: 3rem auto;
  padding: 3rem;
  color: white;
  background-image: url('../data/img/mission-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
  backdrop-filter: brightness(0.7);
}

#mission::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: -1;
  border-radius: 12px;
}

/* ====================================================
   Homepage: Intro + Search Bar
==================================================== */
.intro {
  position: absolute;
  top: 20px;
  right: 100px;
  display: inline-block;
  padding: 2rem 0;
}

.intro input[type="text"] {
  padding: 0.5rem;
  width: 250px;
  max-width: 100%;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin-right: 0.5rem;
}

.intro button {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

/* ====================================================
   Articles Page: Cards Grid
==================================================== */
.article-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--white);
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* ====================================================
   Metadata + Badges
==================================================== */
.meta {
  font-size: 0.9rem;
  color: #666;
  margin: 0.5rem 0;
}

/* ====================================================
   Filters + Sort Controls
==================================================== */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.filters button {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--primary);
  background: var(--white);
  border-radius: 5px;
  cursor: pointer;
}

.filters button.active,
.filters button:hover {
  background: var(--primary);
  color: var(--white);
}

/* ====================================================
   Contact Form
==================================================== */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1em;
  margin-top: 1em;
}

.contact-form input,
.contact-form textarea {
  padding: 0.75em;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  width: 100%;
}

.contact-form button {
  padding: 0.75em 1.5em;
  font-size: 1em;
  background-color: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.contact-form button:hover {
  background-color: var(--primary-hover);
}

/* ====================================================
   Image Styles (Homepage + Articles)
==================================================== */
.card img.card-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  margin-bottom: 0.75rem;
}

/* ====================================================
   Articles Page Layout - Proper Flexbox Implementation
==================================================== */
.articles-page .article-cards {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.articles-page .article-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  overflow: hidden;
  min-height: 170px;
}

.articles-page .article-card-inner {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  padding: 1rem;
  align-items: flex-start;
  min-height: 150px;
}

.articles-page .article-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
}

.articles-page .article-card-content h3 {
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.articles-page .article-card-content p {
  flex-grow: 1;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.articles-page .article-card-content .read-more {
  margin-top: auto;
  align-self: flex-start;
  font-weight: 500;
  color: var(--primary);
}

.articles-page .article-card-image-wrapper {
  width: 180px;
  height: 130px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 6px;
}

.articles-page .article-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

/* ====================================================
   Single Article Image Styles
==================================================== */
#article-image {
  float: right;
  margin: 0 0 16px 32px;
  max-width: 40%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

#article-image:hover {
  transform: scale(1.02);
}

#article-content::after {
  content: "";
  display: block;
  clear: both;
}

/* ====================================================
   Utility Classes
==================================================== */
.centered-image {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* ====================================================
   Trivia Game Styles
==================================================== */
.option-btn {
  display: block;
  margin: 8px 0;
  padding: 10px 15px;
  font-size: 1rem;
  cursor: pointer;
}

#category-picker { 
  display: flex; 
  flex-wrap: wrap; 
  gap: .5rem; 
  margin-bottom: .75rem; 
}

.category-btn { 
  padding: .5rem .75rem; 
  border: 1px solid #ccc; 
  border-radius: .5rem; 
  cursor: pointer; 
}

.category-btn.active { 
  border-color: var(--primary); 
  color: var(--primary); 
}

.options { 
  display: grid; 
  gap: .5rem; 
  margin-top: .75rem; 
}

.option-btn { 
  padding: .6rem .8rem; 
  border: 1px solid #ddd; 
  border-radius: .5rem; 
  cursor: pointer; 
}

.option-btn:disabled { 
  opacity: .6; 
  cursor: not-allowed; 
}

#next-btn { 
  margin-top: .75rem; 
}

#progress-bar { 
  background: var(--primary); 
  transition: width 200ms ease; 
}

.feedback { 
  min-height: 1.2em; 
  margin-top: .5rem; 
}

.post-quiz-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.post-quiz-actions button {
  background-color: var(--primary);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.post-quiz-actions button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
}

.post-quiz-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.post-quiz-actions button.secondary {
  background-color: #f1f1f1;
  color: var(--text-dark);
}

.post-quiz-actions button.secondary:hover {
  background-color: #e0e0e0;
}

/* ====================================================
   MOBILE RESPONSIVE DESIGN (≤768px)
   This is where hamburger menu becomes active
==================================================== */

@media (max-width: 768px) {
  /* Mobile header - logo on left, hamburger on right */
  .header-container {
    height: 70px;
    padding: 0 1rem;
    /* Keep flex layout: logo left, hamburger right */
  }

  .site-logo {
    height: 50px;
  }

  .site-logo img {
    max-width: 160px;
  }

  /* HIDE desktop navigation and search on mobile */
  .nav-menu,
  .search-bar {
    display: none !important;
  }

  /* SHOW hamburger button and mobile navigation on mobile ONLY */
  .hamburger {
    display: flex !important;
  }

  .nav-overlay.active,
  .nav-mobile.active {
    display: block !important;
  }

  .nav-mobile.active .nav-mobile-header,
  .nav-mobile.active .nav-mobile-menu,
  .nav-mobile.active .nav-mobile-search {
    display: block !important;
  }

  .nav-mobile.active .nav-mobile-header {
    display: flex !important;
  }

  /* FIXED: Mobile article content images */
  #article-content img,
  #article-content .centered-image {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    margin: 1rem 0 !important;
    padding: 0 !important;
  }

  /* Ensure article content doesn't overflow */
  #article-content {
    overflow-x: hidden;
    word-wrap: break-word;
  }

  /* Mobile content adjustments */
  .intro {
    position: static;
    width: 100%;
    padding: 1rem 0;
    text-align: center;
  }

  #mission {
    padding: 2rem 1rem;
  }

  .articles-page .article-card {
    min-height: auto;
  }

  .articles-page .article-card-inner {
    flex-direction: column;
    min-height: auto;
  }

  .articles-page .article-card-image-wrapper {
    width: 100%;
    height: 180px;
  }

  .articles-page .article-card-content {
    min-height: auto;
  }

  #site-title {
    font-size: 2rem;
    padding-left: 0;
  }

  .container {
    padding: 1rem;
  }

  /* Responsive image stack for smaller screens */
  #article-image {
    float: none;
    display: block;
    margin: 20px auto;
    max-width: 100%;
  }
}

/* ====================================================
   SMALL MOBILE RESPONSIVE (≤480px)
==================================================== */

@media (max-width: 480px) {
  .header-container {
    padding: 0 0.75rem;
  }

  .site-logo {
    height: 45px;
  }

  .site-logo img {
    max-width: 140px;
  }

  .hamburger span {
    width: 22px;
  }

  /* Smaller mobile navigation menu */
  .nav-mobile {
    width: 260px;
    right: -260px;
  }
}

/* ====================================================
   RESPONSIVE DESIGN FOR TABLETS AND LARGER MOBILE
==================================================== */

@media (max-width: 600px) {
  nav a {
    display: block;
    margin: 0.5rem 0;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }
}