/* ==================================================== */
/* 1. CUSTOMIZABLE CSS VARIABLES */
/* ==================================================== */
/* LIGHT MODE DEFAULTS */
:root {
  --text: hsl(215, 10%, 10%);
  --text-muted: hsl(215, 10%, 25%);
  --accent: hsl(204, 100%, 50%);
  --accent-muted: hsl(204, 100%, 50%);
  --border: hsl(215, 20%, 75%);

  --bg: hsl(215, 25%, 95%);
  --header-bg: hsl(215, 45%, 80%);
  --secondary-bg: hsl(215, 45%, 85%);
  --tertiary-bg: hsl(215, 45%, 80%);

  --max-content-width: 800px;
  --base-spacing: 1.5rem;
}

/* DARK MODE OVERRIDES: Applied when body has the 'dark-mode' class */
html.dark-mode {
  --text: hsl(215, 10%, 90%);
  --text-muted: hsl(215, 10%, 75%);
  --accent: hsl(204, 100%, 50%);
  --accent-muted: hsl(204, 50%, 50%);
  --border: hsl(215, 20%, 25%);

  --bg: hsl(215, 25%, 20%);
  --header-bg: hsl(215, 25%, 25%);
  --secondary-bg: hsl(215, 25%, 25%);
  --tertiary-bg: hsl(215, 25%, 30%);
}

/* ==================================================== */
/* 2. BASE STYLES & RESET */
/* ==================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: "Inter", Arial, sans-serif;
  line-height: 1.6;
  /* Smooth transition for theme change */
  transition:
    background-color 0.5s,
    color 0.5s;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
  text-decoration: none;
}

/* ==================================================== */
/* 3. TOP BAR (HEADER & NAVIGATION) */
/* ==================================================== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background-color: var(--header-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.top-bar-content {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 1rem var(--base-spacing);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
}

.site-title span {
  color: var(--accent);
}

.main-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.main-nav a {
  color: var(--text);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition:
    border-bottom 0.2s,
    color 0.2s;
}

.main-nav a:hover {
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* --- SUBTLE MODE TOGGLE STYLING (SVG BASED) --- */
.mode-toggle {
  cursor: pointer;
  background-color: transparent;
  border: none;
  color: var(--text); /* SVG fills inherit this color */
  padding: 0 0.5rem;
  line-height: 1;
  transition: color 0.3s;
  margin-left: 0.5rem;
  user-select: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-toggle:hover {
  color: var(--accent);
}

.mode-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  /* SVG elements inherit fill/stroke from parent color */
}

/* ==================================================== */
/* Mobile menu styles */
/* ==================================================== */

.mobile-menu-toggle {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
}

.mobile-menu-toggle:hover {
  transition: color 0.1s linear;
  color: var(--text-muted);
}

/* Overlay behind the centered panel */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 60;
  display: none;
}

.mobile-menu-overlay[aria-hidden="false"] {
  display: block;

  transition: transform 0.28s ease, opacity 0.2s ease;
}

.mobile-menu {
  position: fixed;
  top: 10vh;
  left: 50%;
  transform: translate(-50%, -500%);
  width: calc(100% - 2rem);
  max-width: 480px;
  max-height: 80vh;
  transition: transform 0.28s ease, opacity 0.2s ease;
  z-index: 70;
  display: flex;
  flex-direction: column;
  opacity: 0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: visible;
  background: transparent; /* inner panel provides background */

  width: 75%;
  max-width: 300px;
  /* display: none; */
}

.mobile-menu[aria-hidden="false"] {
  transform: translate(-50%, 0);
  opacity: 1;

  transition: transform 0.28s ease, opacity 0.2s ease;
}

.mobile-menu-inner {
  background: var(--secondary-bg);
  padding: 1.25rem;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  z-index: 71;
  display: flex;
  flex-direction: column;
  border-radius: 12px;

}

.mobile-menu-close {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
}

.mobile-menu-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
}

.mobile-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.mobile-nav a {
  color: var(--text);
}

.mobile-nav a:hover {
  color: var(--text-muted);
  text-decoration: none;
}

/* Mobile theme toggle styling similar to the desktop mode-toggle */
.mode-toggle-mobile {
  cursor: pointer;
  background-color: transparent;
  border: none;
  color: var(--text);
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.2s;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  font-weight: 600;
}

.mode-toggle-mobile svg {
  width: 1.1rem;
  height: 1.1rem;
}

@media (min-width: 640px) {
  .mobile-menu-toggle {
    display: none;
  }
}


/* Hide navigation on smaller screens */
@media (max-width: 640px) {
  .main-nav {
    display: none;
  }
  .site-title {
    font-size: 1.75rem;
  }
  /* Show only the toggle button on mobile */
  .top-bar-content {
    justify-content: space-between;
  }
  .main-nav-mobile {
    display: block;
  }
}

/* ==================================================== */
/* 4. MAIN CONTENT & SECTIONS */
/* ==================================================== */
.content-wrapper {
  flex: 1;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 3rem var(--base-spacing);
  padding-bottom: 6rem;
}

.page-section {
  margin-bottom: 4rem;
}

.section-header {
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

/* --- About Content Layout --- */
.about-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.profile-picture {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent);
  background-color: var(--secondary-bg);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

  overflow: hidden;
}

.profile-picture span {
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--accent);
}

.about-text p {
  margin-bottom: 1rem;
}

/* Mobile adjustment for About section */
@media (max-width: 768px) {
  .about-content {
    flex-direction: column;
    gap: 1rem;
  }
  .profile-placeholder {
    margin: 0 auto;
  }
}

/* --- News Items --- */
.news-item-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.news-item-wrapper {
  width: 75%; /* Explicitly set the width to 75% of the parent */
  max-width: var(
    --max-content-width
  ); /* Prevent it from exceeding the content width */
  margin-left: auto; /* Center horizontally */
  margin-right: auto; /* Center horizontally */
}

@media (max-width: 640px) {
  .news-item-wrapper {
    width: 100%;
    /*margin: 0 var(--base-spacing);*/
  }
}

.news-item {
  padding: var(--base-spacing);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  background-color: var(--secondary-bg);
  transition:
    transform 0.2s,
    box-shadow 0.2s,
    background-color 0.5s;
  color: var(--text);
}

.news-item:hover {
  transform: translateY(-2px);
  /* Use a stronger shadow for dark mode visibility */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  background-color: var(
    --tertiary-bg
  ); /* Reverts to main background on hover for visual contrast */
}

.news-item h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.news-item .date {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- Post Styles --- */
.title {
  text-align: center;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
}

.post-header {
  margin-bottom: 2rem;
}

.main-content {
  width: 75%;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .main-content {
    width: 100%;
  }
}

.main-content > p {
  margin-bottom: 1rem;
}


/* --- Button Styles --- */
.button-container {
  text-align: center;
  margin-top: 2rem;
}

/* --- 404 Page Styles --- */
.error-page {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  padding: var(--base-spacing);
}

.error-page h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.error-message {
  margin-bottom: 2rem;
  font-size: 1.125rem;
  color: var(--text);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: 0.5rem;
  transition:
    background-color 0.3s,
    color 0.3s,
    box-shadow 0.3s;
}

.btn-primary {
  background-color: var(--accent-muted);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

  transition: 0.3s;
}

.btn-primary:hover {
  background-color: var(--accent);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ==================================================== */
/* 5. FOOTER */
/* ==================================================== */
.page-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  background-color: var(--secondary-bg);
  color: var(--text);
  margin-top: auto; /* Ensure footer sticks to the bottom */
}

body {
  min-height: 100vh; /* Ensure body takes up full height */
}

.content-wrapper {
  width: 100%;
  padding: 3rem var(--base-spacing);
  padding-bottom: 6rem;
}

.sidebyside {
  display: flex;
  gap: 1rem;
}

/* ==================================================== */
/* 6. Figure */
/* ==================================================== */

figure {
  margin: 2rem auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--secondary-bg);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  text-align: center;

  cursor: pointer;

  -webkit-transition:
    background-color 0.3s linear,
    transform 0.3s linear;

  -ms-transition:
    background-color 0.3s linear,
    transform 0.3s linear;

  transition:
    background-color 0.3s linear,
    transform 0.3s linear;
}

figure:hover {
  background-color: var(--tertiary-bg);
  transform: scale(1.05);
}

figure img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.figure-aside {
  margin: 0 0 0 auto;
}

figcaption {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.5rem 0 0;
  font-style: italic;
  border-top: 1px solid var(--text-muted);
  margin-top: 0.5rem;
}

/* ==================================================== */
/* 7. Image Popup */
/* ==================================================== */

.popup-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  visibility: hidden;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
  cursor: pointer; /* Default cursor for the backdrop */
}

.popup-wrapper {
  margin: 0;

  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-caption {
  position: absolute;
  bottom: 0.5rem;
  color: #ffffff;
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  max-width: 80%;
  text-align: center;

  cursor: default;
}

.popup-backdrop.active img {
  cursor: default; /* Default cursor when hovering over the image */
}

.popup-backdrop.active:not(:hover) {
  cursor: pointer; /* Hand cursor when not hovering over the image */
}

.popup-backdrop.active {
  visibility: visible;
  opacity: 1;
}

.popup-image {
  object-fit: contain;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#popup-close-button {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  width: 25px;
  height: 25px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}
