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

body {
  line-height: 1.6;
  transition:
    background-color 0.3s ease,
    color 0.3s ease; /* Smooth transition */
}

/* CSS Variables for Colors */
:root {
  /* --- Specific Light Mode Colors --- */
  --color-chive-green-light: #4d9e50;
  --color-chive-mint-light: #9adea0;
  --color-chive-dark-light: #356c37;
  --color-surface-light: #ffffff;
  --color-surface-subtle-light: #f7f9f7;
  --color-surface-accent-light: #e9f5ea;
  --color-text-primary-light: #1a1c1a;
  --color-text-secondary-light: #4a524b;
  --color-text-tertiary-light: #6e776f;
  --color-success-light: #34c759;
  --color-warning-light: #ff9500;
  --color-error-light: #ff3b30;
  --color-background-hover-light: rgba(77, 158, 80, 0.08);
  --color-background-press-light: rgba(77, 158, 80, 0.15);

  /* --- Specific Dark Mode Colors --- */
  --color-chive-green-dark: #5eb962;
  --color-chive-mint-dark: #7bc97f;
  --color-chive-dark-dark: #2a5b2c;
  --color-surface-dark: #121212;
  --color-surface-subtle-dark: #1a1d1a;
  --color-surface-accent-dark: #1e2a1f;
  --color-text-primary-dark: #f2f2f2;
  --color-text-secondary-dark: #c2c8c3;
  --color-text-tertiary-dark: #9aa49b;
  --color-success-dark: #32d74b;
  --color-warning-dark: #ffd60a;
  --color-error-dark: #ff453a;
  --color-background-hover-dark: rgba(94, 185, 98, 0.15);
  --color-background-press-dark: rgba(94, 185, 98, 0.25);

  /* --- Generic Theme Variables (Default: Light Mode) --- */
  --color-primary: var(--color-chive-green-light);
  --color-secondary: var(--color-chive-mint-light);
  --color-accent: var(--color-chive-dark-light);
  --color-background: var(--color-surface-light);
  --color-background-subtle: var(--color-surface-subtle-light);
  --color-background-accent: var(--color-surface-accent-light);
  --color-text-primary: var(--color-text-primary-light);
  --color-text-secondary: var(--color-text-secondary-light);
  --color-text-tertiary: var(--color-text-tertiary-light);
  --color-button-primary-bg: var(--color-chive-green-light);
  --color-button-primary-text: var(
    --color-surface-light
  ); /* White text on green */
  --color-button-secondary-bg: transparent;
  --color-button-secondary-text: var(--color-chive-dark-light);
  --color-border: var(--color-surface-accent-light); /* Subtle border */
  --color-background-hover: var(--color-background-hover-light);
  --color-background-press: var(--color-background-press-light);
}

/* --- Dark mode variables override - Automatic (System Preference) --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: var(--color-chive-green-dark);
    --color-secondary: var(--color-chive-mint-dark);
    --color-accent: var(--color-chive-dark-dark);
    --color-background: var(--color-surface-dark);
    --color-background-subtle: var(--color-surface-subtle-dark);
    --color-background-accent: var(--color-surface-accent-dark);
    --color-text-primary: var(--color-text-primary-dark);
    --color-text-secondary: var(--color-text-secondary-dark);
    --color-text-tertiary: var(--color-text-tertiary-dark);
    --color-button-primary-bg: var(--color-chive-green-dark);
    --color-button-primary-text: var(
      --color-surface-dark
    ); /* Dark text on green */
    --color-button-secondary-bg: transparent;
    --color-button-secondary-text: var(--color-chive-mint-dark);
    --color-border: var(--color-surface-accent-dark);
    --color-background-hover: var(--color-background-hover-dark);
    --color-background-press: var(--color-background-press-dark);
  }
}

/* --- Dark mode variables override - Manual Toggle (.dark-mode class on body) --- */
body.dark-mode {
  /* Apply variables directly to the body element when class is present */
  --color-primary: var(--color-chive-green-dark);
  --color-secondary: var(--color-chive-mint-dark);
  --color-accent: var(--color-chive-dark-dark);
  --color-background: var(--color-surface-dark);
  --color-background-subtle: var(--color-surface-subtle-dark);
  --color-background-accent: var(--color-surface-accent-dark);
  --color-text-primary: var(--color-text-primary-dark);
  --color-text-secondary: var(--color-text-secondary-dark);
  --color-text-tertiary: var(--color-text-tertiary-dark);
  --color-button-primary-bg: var(--color-chive-green-dark);
  --color-button-primary-text: var(--color-surface-dark);
  --color-button-secondary-bg: transparent;
  --color-button-secondary-text: var(--color-chive-mint-dark);
  --color-border: var(--color-surface-accent-dark);
  --color-background-hover: var(--color-background-hover-dark);
  --color-background-press: var(--color-background-press-dark);
}

body.light-mode {
  /* Apply variables directly to the body element when class is present */
  --color-primary: var(--color-chive-green-light);
  --color-secondary: var(--color-chive-mint-light);
  --color-accent: var(--color-chive-dark-light);
  --color-background: var(--color-surface-light);
  --color-background-subtle: var(--color-surface-subtle-light);
  --color-background-accent: var(--color-surface-accent-light);
  --color-text-primary: var(--color-text-primary-light);
  --color-text-secondary: var(--color-text-secondary-light);
  --color-text-tertiary: var(--color-text-tertiary-light);
  --color-button-primary-bg: var(--color-chive-green-light);
  --color-button-primary-text: var(
    --color-surface-light
  ); /* White text on green */
  --color-button-secondary-bg: transparent;
  --color-button-secondary-text: var(--color-chive-dark-light);
  --color-border: var(--color-surface-accent-light); /* Subtle border */
  --color-background-hover: var(--color-background-hover-light);
  --color-background-press: var(--color-background-press-light);
}

/* Apply variables to body */
body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
}

h1,
h2,
h3 {
  color: var(
    --color-text-primary
  ); /* Default text color, specific heading colors below */
  margin-bottom: 0.5em;
  line-height: 1.2;
}

h1 {
  font-size: 2.5em;
}

h2 {
  font-size: 2em;
  text-align: center;
  margin-bottom: 1.5em;
}

h3 {
  font-size: 1.3em;
  margin-bottom: 0.3em;
  color: var(
    --color-chive-dark-light
  ); /* Default heading color in light mode */
}

/* Separate rules for dark mode heading color */
body.dark-mode h3 {
  color: var(
    --color-chive-mint-dark
  ); /* Use lighter green for headings in dark mode */
}

@media (prefers-color-scheme: dark) {
  h3 {
    color: var(
      --color-chive-mint-dark
    ); /* Use lighter green for headings in dark mode */
  }
}

p {
  margin-bottom: 1em;
  color: var(--color-text-secondary);
}

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

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1em; /* Responsive padding */
}

/* Header Styling */
.site-header {
  background-color: var(--color-background-subtle);
  padding: 1em 0;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 60px; /* Ensure minimum height for mobile row */
  display: flex; /* Use flex on the header itself */
  align-items: center; /* Vertically center header content */
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%; /* Take full width of container */
}

.brand-logo {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--color-chive-dark-light); /* Dark green logo in light mode */

  a {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 0.5em;
  }

  img {
    height: 40px;
    width: auto;
  }
}

/* Separate rules for dark mode brand logo color */
body.dark-mode .brand-logo {
  color: var(--color-chive-mint-dark); /* Mint green logo in dark mode */
}

@media (prefers-color-scheme: dark) {
  .brand-logo {
    color: var(--color-chive-mint-dark); /* Mint green logo in dark mode */
  }
}

/* --- Mobile Menu & Hamburger --- */

/* Hamburger Toggle: Visible on mobile, hidden on desktop */
.hamburger-toggle {
  display: grid; /* Show on mobile */
  place-content: center; /* Center the icon */
  background: none;
  border: none;
  font-size: 2em; /* Adjust size as needed */
  cursor: pointer;
  color: var(--color-text-primary); /* Icon color */
  padding: 0.1em 0.3em;
  z-index: 110; /* Ensure it's above the mobile menu overlay */
  transition: color 0.2s ease;
  width: 2rem;
  height: 2rem;

  &:before {
    content: "☰"; /* Hamburger icon */
  }
}

.menu-open .hamburger-toggle::before {
  content: "×"; /* Change icon when menu is open */
}

.hamburger-toggle:hover {
  color: var(--color-primary);
}

/* Mobile Menu Wrapper: Hidden by default on mobile */
.mobile-menu {
  display: none; /* Hide the menu */
  position: fixed; /* Position fixed for overlay */
  top: 60px; /* Position below the header height (adjust if header height changes) */
  left: 0;
  width: 100%;
  height: calc(100% - 60px); /* Take remaining viewport height */
  background-color: var(
    --color-background-subtle
  ); /* Background uses subtle surface variable */
  flex-direction: column; /* Stack items vertically */
  align-items: center; /* Center items horizontally */
  padding: 2em 1em;
  overflow-y: auto; /* Allow scrolling if content is long */
  z-index: 105; /* Above page content, below hamburger */
  transition: transform 0.3s ease-in-out; /* Smooth slide animation */
  transform: translateX(100%); /* Start off-screen to the right */
}

/* State when menu is open */
.header-content.menu-open .mobile-menu {
  display: flex; /* Show the menu */
  transform: translateX(0); /* Slide in from the right */
}

/* Styling for content inside the mobile menu */
.mobile-menu .site-nav {
  display: flex;
  flex-direction: column; /* Stack nav links */
  align-items: center;
  gap: 1.5em; /* Space between links */
  margin-bottom: 2em; /* Space between nav and actions */
  width: 100%; /* Take full width */
  text-align: center;
}

.mobile-menu .site-nav a {
  font-size: 1.2em;
  margin: 0; /* Reset margin */
  color: var(--color-text-primary); /* Link color */
}

.mobile-menu .header-actions {
  display: flex;
  flex-direction: column; /* Stack action buttons */
  align-items: center;
  gap: 1em; /* Space between buttons */
  width: 100%; /* Take full width */
}

/* Ensure buttons stretch appropriately or are centered */
.mobile-menu .header-actions .btn {
  width: 80%; /* Make buttons wider in mobile menu */
  max-width: 300px; /* Prevent them from getting too wide */
}

.site-nav a {
  margin-left: 1.5em;
  color: var(--color-text-primary);
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.8em; /* Space between buttons */
}

/* Buttons */
.btn {
  padding: 0.6em 1.2em;
  border-radius: 5px;
  font-size: 1em;
  cursor: pointer;
  border: none;
  display: inline-block;
  text-align: center;
  transition:
    background-color 0.2s ease,
    opacity 0.2s ease;
}

.btn-primary {
  background-color: var(--color-button-primary-bg);
  color: var(--color-button-primary-text);
}

.btn-primary:hover {
  /* Use a slightly darker/lighter shade or opacity change for hover */
  background-color: var(--color-primary);
  opacity: 0.9;
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--color-button-secondary-bg);
  color: var(--color-button-secondary-text);
  /* Default border color in light mode */
  border: 1px solid var(--color-chive-dark-light);
}

/* Separate rules for dark mode secondary button border color */
body.dark-mode .btn-secondary {
  border-color: var(--color-chive-mint-dark); /* Mint border in dark mode */
  /* Ensure text color is also correctly inherited or set */
  color: var(--color-button-secondary-text);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary {
    border-color: var(--color-chive-mint-dark); /* Mint border in dark mode */
    /* Ensure text color is also correctly inherited or set */
    color: var(--color-button-secondary-text);
  }
}

.btn-secondary:hover {
  background-color: var(--color-background-hover);
  text-decoration: none;
}

.btn-large {
  padding: 0.8em 1.8em;
  font-size: 1.1em;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.3em;
  cursor: pointer;
  color: var(--color-text-primary);
  padding: 0.3em;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  display: flex; /* Center the icon */
  align-items: center;
  justify-content: center;
  width: 1.8em; /* Give it a fixed size */
  height: 1.8em;
}

.theme-toggle:hover {
  background-color: var(--color-background-hover);
}

/* Hero Section */
.hero-section {
  background-color: var(--color-background-accent);
  padding: 4em 0;
  text-align: center; /* Center text on small screens */
}

.hero-content {
  display: flex;
  align-items: center;
  gap: 2em;
  flex-direction: column; /* Stack on small screens */
}

.hero-text {
  max-width: 600px;
  margin-bottom: 2em; /* Space below text on small screens */
}

.hero-text h1 {
  margin-bottom: 0.5em;
  color: var(--color-chive-dark-light); /* Dark green heading in light mode */
}

/* Separate rules for dark mode hero heading color */
body.dark-mode .hero-text h1 {
  color: var(--color-chive-mint-dark); /* Mint green heading in dark mode */
}

@media (prefers-color-scheme: dark) {
  .hero-text h1 {
    color: var(--color-chive-mint-dark); /* Mint green heading in dark mode */
  }
}

.hero-text .tagline {
  font-size: 1.2em;
  color: var(--color-text-secondary);
  margin-bottom: 1.5em;
}

.cta-group {
  display: flex;
  justify-content: center; /* Center buttons on small screens */
  gap: 1em;
  flex-wrap: wrap; /* Allow buttons to wrap */
}

.hero-image .mockup-placeholder {
  width: 300px; /* Adjust size as needed */
  height: 400px; /* Adjust size as needed */
  background-color: var(--color-surface-subtle); /* Placeholder color */
  border: 1px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
  font-size: 1em;
  flex-shrink: 0; /* Prevent shrinking too much */
  max-width: 90%; /* Ensure it doesn't overflow on very small screens */
}

/* Features Section */
.features-section {
  padding: 4em 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2em;
}

.feature-item {
  background-color: var(--color-background-subtle);
  padding: 1.5em;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.feature-item h3 {
  margin-top: 0; /* Remove default top margin */
}

/* Download Section */
.download-section {
  background-color: var(--color-background-accent);
  padding: 4em 0;
  text-align: center;
}

.download-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5em;
}

.download-text h2 {
  margin-bottom: 0.5em;
}

.app-store-links {
  display: flex;
  gap: 1.5em;
  flex-wrap: wrap;
  justify-content: center;
}

.app-store-links img {
  height: 48px;
  width: auto;
}

/* Footer Styling */
.site-footer {
  background-color: var(--color-background-subtle);
  padding: 2em 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9em;
}

.footer-content {
  display: flex;
  flex-direction: column; /* Stack on small screens */
  align-items: center;
  gap: 1em;
}

.footer-brand {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--color-chive-dark-light); /* Dark green in light mode */

  img {
    height: 48px;
    opacity: 0.8;
    width: auto;
  }
}

/* Separate rules for dark mode footer brand color */
body.dark-mode .footer-brand {
  color: var(--color-chive-mint-dark); /* Mint green in dark mode */
}

@media (prefers-color-scheme: dark) {
  .footer-brand {
    color: var(--color-chive-mint-dark); /* Mint green in dark mode */
  }
}

.footer-nav a {
  margin: 0 1em;
  color: var(--color-text-secondary);
}

.footer-nav a:hover {
  color: var(--color-text-primary);
}

.footer-copyright {
  margin-top: 1em;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
  h1 {
    font-size: 3.5em;
  }

  h2 {
    font-size: 2.5em;
  }

  .hero-content {
    flex-direction: row; /* Side-by-side on larger screens */
    text-align: left;
  }

  .hero-text {
    flex: 1;
    margin-bottom: 0;
  }

  .hero-image {
    flex: 1;
    display: flex; /* Use flex to center placeholder */
    justify-content: center;
    align-items: center;
  }

  .header-content {
    flex-wrap: nowrap; /* Prevent wrapping */
  }

  /* Hamburger: Hide on desktop */
  .hamburger-toggle {
    display: none;
  }

  /* Mobile Menu Wrapper: Revert to normal flow on desktop */
  .mobile-menu {
    display: flex; /* Show on desktop */
    position: static; /* Remove fixed positioning */
    top: auto;
    left: auto;
    width: auto; /* Revert width */
    height: auto; /* Revert height */
    background-color: transparent; /* Remove background */
    flex-direction: row; /* Arrange items in a row */
    padding: 0; /* Remove padding */
    overflow-y: visible; /* Remove scrolling */
    z-index: auto;
    transform: translateX(0); /* Ensure no transform */

    /* Site Nav: Revert to desktop layout */
    .site-nav {
      display: flex;
      flex-direction: row; /* Arrange nav links in a row */
      align-items: center;
      gap: 1.5em; /* Space between links */
      margin-left: 2em; /* Space after logo */
      margin-right: 2rem; /* Push actions to the right */
      margin-bottom: 0; /* Remove mobile margin */
      width: auto; /* Revert width */
      text-align: left;
    }

    .site-nav a {
      font-size: 1em; /* Revert font size */
      color: var(--color-text-primary); /* Ensure correct color */
      margin: 0; /* Ensure no margin from mobile styles */
    }

    /* Header Actions: Revert to desktop layout */
    .header-actions {
      display: flex;
      flex-direction: row; /* Arrange actions in a row */
      align-items: center;
      gap: 0.8em; /* Space between buttons */
      width: auto; /* Revert width */
    }

    .header-actions .btn {
      width: auto; /* Revert button width */
      max-width: none; /* Remove max width */
    }
  }

  .cta-group {
    justify-content: flex-start; /* Align left on larger screens */
  }

  .footer-content {
    flex-direction: row; /* Row on larger screens */
    justify-content: space-between;
  }

  .footer-nav {
    order: 1; /* Place nav after brand */
  }

  .footer-copyright {
    order: 2; /* Place copyright last */
    margin-top: 0;
  }
}

@media (max-width: 767px) {
  .site-nav {
    margin-top: 1em; /* Add space above nav on small screens */
    width: 100%;
    text-align: center;
  }
  .site-nav a {
    margin: 0 0.5em; /* Adjust spacing */
  }
  .header-actions {
    margin-top: 1em; /* Add space above actions */
    width: 100%;
    justify-content: center; /* Center buttons */
  }
  .hero-image .mockup-placeholder {
    width: 250px;
    height: 350px;
  }
  .app-store-links {
    flex-direction: column; /* Stack app badges */
    align-items: center;
  }
  .footer-nav a {
    margin: 0 0.5em;
  }
}
