/* --- Global Styles & Variables --- */

:root {
  /* Light Theme Variables */
  --light-background-color: #f0f2f5;
  --light-surface-color: #ffffff;
  --light-text-primary: #121212;
  --light-text-secondary: #6c757d;
  --light-accent-color: #4b4a68;
  --light-accent-hover: #3d3c52;
  --light-highlight-color: #ad3737;
  --light-border-color: #e0e0e0;
  --light-shadow-color: rgba(0, 0, 0, 0.1);

  /* Default to Dark Theme Variables */
  --background-color: #0d1222;
  --surface-color: #1a2238;
  --text-primary: #e0e7ff;
  --text-secondary: #94a3b8;
  --accent-color: #5d5b8d;
  --accent-hover: #7b78b1;
  --highlight-color: #df4736;
  --border-color: #3f4e6d;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

/* Set body theme based on class */
body.light-theme {
  --background-color: var(--light-background-color);
  --surface-color: var(--light-surface-color);
  --text-primary: var(--light-text-primary);
  --text-secondary: var(--light-text-secondary);
  --accent-color: var(--light-accent-color);
  --accent-hover: var(--light-accent-hover);
  --highlight-color: var(--light-highlight-color);
  --border-color: var(--light-border-color);
  --shadow-color: var(--light-shadow-color);
}

/* Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Roboto', sans-serif;
  color: var(--text-primary);
  background-color: var(--background-color);
  transition: background-color 0.4s ease, color 0.4s ease;
  line-height: 1.6;
}

/* --- General Layout & Structure (Tighter for Mobile) --- */
#main-content {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px; /* Reduced from 20px */
}

section {
  padding: 40px 8px;
  position: relative;
  overflow: hidden;
}

/* --- Typography & Headings (Optimized for Mobile Spacing) --- */
h1,
h2,
h3 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 1px 1px 3px var(--shadow-color);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -1px;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.8rem);
  text-align: center;
  position: relative;
  margin-bottom: 2rem; /* Reduced from 2.5rem */
}

h2::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: var(--highlight-color);
  margin: 15px auto 0;
  border-radius: 2px;
}

h3 {
  font-size: 1.5rem; /* Reduced from 1.6rem */
  display: flex;
  align-items: center;
  gap: 10px; /* Reduced gap from 12px */
  color: var(--highlight-color);
}

p {
  margin-bottom: 0.8rem; /* Reduced from 1rem */
  color: var(--text-secondary);
  font-size: 1rem; /* Reduced from 1.1rem */
}

/* --- FINAL Optimized Header & Navigation (Maximum Compactness) --- */
.main-header {
  /* Minimal vertical padding for the tightest possible header on mobile/tablet */
  padding: 0.5rem 1rem; /* Reduced from 0.8rem 2rem */

  transition: background-color 0.3s ease, border-bottom 0.3s ease, box-shadow 0.3s ease;

  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--surface-color);
  border-bottom: 2px solid var(--border-color);
  box-shadow: 0 4px 10px var(--shadow-color);
  backdrop-filter: blur(6px);
}

.header-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap; /* Allows wrapping on smaller screens */
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px; /* Reduced gap from 12px */
  text-decoration: none;
  color: inherit;
  justify-content: center;
  width: 100%;
}

.logo {
  height: 40px; /* Reduced from 44px for compactness */
  width: 40px;
  border-radius: 50%;
  border: 2px solid var(--highlight-color);
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.header-text {
  line-height: 1.1;
  text-align: center;
  width: 100%;
}

.header-text h1 {
  font-size: clamp(1.3rem, 3vw, 1.6rem); /* Reduced max size */
  margin-bottom: 0.1rem;
}

.header-text p {
  font-size: clamp(0.7rem, 1.2vw, 0.85rem); /* Tighter subtitle font size */
  margin: 0;
  color: var(--text-secondary);
}

/* NAVIGATION STYLES (Mobile First - Stacked) */
.main-nav {
  width: 100%;
  margin-top: 0.3rem;
}

.nav-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-list a {
  /* Increased padding to ensure a decent touch target (44px target) */
  padding: 0.5rem 0.6rem;
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 700;
  transition: color 0.3s ease, transform 0.3s ease;
  font-size: 0.95rem; /* Slightly reduced font size */
}

.nav-list a:hover {
  color: var(--highlight-color);
  transform: scale(1.02);
}

/* Desktop/Tablet Layout (Inline) */
@media (min-width: 750px) {
  #main-content {
    max-width: 1200px;
    padding: 40px;
    margin: 0 auto;
  }

  .main-header {
    padding: 0.8rem 2rem; /* Restore to a standard inline header size */
  }

  .header-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0;
  }

  .main-nav {
    width: auto;
    margin-top: 0;
  }

  .nav-list {
    flex-direction: row;
    gap: 20px;
    width: auto;
  }

  .nav-list a {
    padding: 0.4rem 0; /* Tighten up vertical padding on desktop */
    font-size: 1rem; /* Restore font size */
  }

  .button-container {
    flex-direction: row;
    justify-content: center;
    gap: 25px;
    margin-top: 3rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
  }

  .review-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
  }

  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    text-align: left;
  }

  .footer-brand,
  .social-media {
    flex-direction: row;
    align-items: center;
    width: auto;
  }
}

/* --- Buttons & CTAs (Tighter for Mobile) --- */
.cta-button {
  background: linear-gradient(45deg, var(--accent-color), var(--highlight-color));
  color: var(--text-primary);
  border: none;
  border-radius: 50px;
  padding: 12px 25px; /* Reduced from 15px 30px */
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
}

.cta-button:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  background: linear-gradient(45deg, var(--accent-hover), var(--highlight-color));
}

.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Reduced gap from 20px */
  margin-top: 2rem; /* Reduced margin from 3rem */
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
}

.card {
  background-color: var(--surface-color);
  border-radius: 20px;
  padding: 20px; /* Reduced from 30px */
  box-shadow: 0 5px 20px var(--shadow-color);
  border: 1px solid var(--border-color);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.4s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  border-color: var(--highlight-color);
}

.card ul {
  list-style: none;
  padding-left: 0;
}

.card ul li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px; /* Reduced margin */
  color: var(--text-secondary);
}

.card ul li i {
  color: var(--highlight-color);
  font-size: 1.2rem;
  margin-top: 2px;
}

/* --- Specific Section Styles --- */
.hero-section {
  padding: 80px 15px; /* Reduced padding */
  text-align: center;
  background-image: linear-gradient(rgba(13, 18, 34, 0.8) 0%, rgba(13, 18, 34, 0.8) 100%),
    url('https://kephsaresearchhub.co.ke/path-to-a-subtle-background-image.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

/* ---------------------------------- */
/* --- Featured Section Styles -- */
/* ---------------------------------- */
.featured-section {
  padding: 60px 15px; /* Reduced padding */
  text-align: center;
  background-color: var(--background-color);
}

.gallery-grid {
  display: grid;
  /* Responsive grid: Lowered minmax to allow for smaller tiles on tiny screens */
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
  margin-top: 40px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.gallery-item {
  background-color: var(--surface-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 20px var(--shadow-color);
  border: 1px solid var(--border-color);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  text-decoration: none;
  display: block;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  border-color: var(--highlight-color);
}

.gallery-item img {
  width: 100%;
  height: 180px; /* Reduced height for smaller mobile tiles */
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-item figcaption {
  padding: 15px;
  font-size: 1.05rem; /* Slightly reduced font size */
  font-weight: 700;
  color: var(--highlight-color);
  background-color: var(--surface-color);
  text-align: center;
  line-height: 1.3;
}

.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 2rem;
}

.secondary-cta {
  background: transparent;
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
  box-shadow: none;
}

.secondary-cta:hover {
  background: var(--accent-color);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.tagline {
  font-size: 1.1rem; /* Slightly reduced font size */
  font-weight: 300;
  max-width: 700px;
  margin: 0 auto 2rem; /* Reduced margin */
}

.cta-section p {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  font-size: 1rem; /* Reduced font size */
  line-height: 1.6;
}

.styled-link {
  font-weight: bold;
  color: var(--text-primary);
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

.styled-link:hover {
  color: var(--highlight-color);
}

.styled-link::after {
  content: '';
  position: absolute;
  width: 100%;
  transform: scaleX(0);
  height: 2px;
  bottom: -5px;
  left: 0;
  background-color: var(--highlight-color);
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

.styled-link:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.newsletter-section p {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 1.5rem; /* Reduced margin */
  font-size: 1rem; /* Reduced font size */
  line-height: 1.6;
  color: var(--text-secondary);
}


/* --- Forms (Mobile-friendly stacked by default) --- */
.newsletter-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px; /* Reduced gap from 15px */
  max-width: 500px;
  margin: 0 auto;
}

.newsletter-form input {
  width: 100%;
  padding: 12px 20px; /* Reduced padding */
  border-radius: 50px;
  border: 2px solid var(--border-color);
  background-color: var(--surface-color);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.newsletter-form input:focus {
  outline: none;
  border-color: var(--highlight-color);
  box-shadow: 0 0 10px rgba(255, 145, 77, 0.4);
}

.newsletter-form button {
  width: 100%;
}

/* Reviews Section */
.reviews-section {
  padding: 60px 15px; /* Reduced padding */
}

.review-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
  margin-top: 2rem; /* Reduced margin */
}

.review-card {
  background-color: var(--surface-color);
  padding: 20px; /* Reduced padding */
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  text-align: left;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.review-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.review-text {
  font-size: 1rem; /* Reduced font size */
  color: var(--text-color);
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

.reviewer-meta {
  font-size: 0.9rem; /* Reduced font size */
  color: var(--text-secondary);
  font-style: italic;
}


.write-review-card {
  margin-top: 3rem; /* Reduced margin */
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  background-color: var(--surface-color);
  padding: 30px; /* Reduced padding */
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 5px 20px var(--shadow-color);
}

.form-group {
  margin-bottom: 1.2rem; /* Reduced margin */
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px; /* Reduced padding */
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background-color: var(--background-color);
  color: var(--text-primary);
  transition: all 0.3s ease;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--highlight-color);
  box-shadow: 0 0 8px rgba(255, 145, 77, 0.4);
}

/* --- Footer (Mobile-friendly stacked by default) --- */
.main-footer {
  background-color: var(--surface-color);
  padding: 2rem 1rem; /* Reduced padding */
  border-top: 2px solid var(--border-color);
  text-align: center;
  color: var(--text-secondary);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  /* Use flexbox to center and wrap content cleanly */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: center;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px; /* Reduced gap */
}

.footer-brand h3 {
  color: var(--text-primary);
  margin: 0;
}

.social-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px; /* Reduced gap */
}

.social-icons {
  display: flex;
  gap: 12px; /* Reduced gap */
}

.social-icons a {
  color: var(--text-secondary);
  font-size: 1.6rem; /* Slightly reduced font size */
  transition: color 0.3s ease, transform 0.3s ease;
}

.social-icons a:hover {
  color: var(--highlight-color);
  transform: scale(1.2) translateY(-2px);
}

.copyright {
  margin-top: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

/* --- Animations & Effects (Keep as is) --- */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInMove 0.8s ease-out forwards;
}

@keyframes fadeInMove {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive Design for Larger Screens (768px+) --- */
@media (min-width: 768px) {
  #main-content {
    padding: 40px; /* Restore desktop padding */
  }

  /* Keep header desktop styles from 750px media query */

  .button-container {
    flex-direction: row;
    justify-content: center;
    gap: 25px;
    margin-top: 3rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
  }

  /* Newsletter Form (Horizontal on Desktop) */
  .newsletter-form {
    flex-direction: row;
    gap: 15px;
    max-width: 600px;
  }

  .newsletter-form input {
    flex-grow: 1;
  }

  .newsletter-form button {
    width: auto;
  }
  
  /* Footer (Horizontal on Desktop) */
  .footer-content {
    flex-direction: row; /* Horizontal layout */
    justify-content: space-between;
    align-items: center;
    gap: 40px;
  }

  .footer-brand {
    flex-direction: row;
  }

  .social-media {
    flex-direction: row;
  }

  .social-icons {
    gap: 20px;
    font-size: 1.8rem;
  }

  .copyright {
    text-align: left;
    margin-top: 0;
  }
}

/* Curtain animation */
.curtain {
  position: fixed;
  inset: 0;
  background: #0d1222;
  z-index: 9999;
  transition: opacity 1s ease;
}

.curtain-hide {
  opacity: 0;
  pointer-events: none;
}

/* Fade-in effect */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sticky header effect */
.main-header.scrolled {
  background-color: rgba(13, 18, 34, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.footer-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.tagline-footer {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.tagline-footer a {
  color: var(--highlight-color);
  text-decoration: none;
  font-weight: 600;
}

.tagline-footer a:hover {
  text-decoration: underline;
}

/* --- Mobile-First Layout Improvements --- */

/* Ensure main content uses full width on mobile */
#main-content {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px;
}

/* Section padding for mobile */
section {
  padding: 40px 8px;
}

/* Header: stack logo/title/nav vertically on mobile */
.header-container {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

/* Logo and header text: center on mobile */
.logo-link,
.header-text {
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
}

/* Navigation: full width, stacked */
.main-nav {
  width: 100%;
  margin-top: 0.3rem;
}

.nav-list {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.nav-list a {
  width: 100%;
  display: block;
  text-align: center;
}

/* Card grid: single column, full width */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
}

/* Gallery grid: single column, full width */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
}

/* Review grid: single column, full width */
.review-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 16px;
}

/* Footer: stack everything vertically, center aligned */
.footer-content {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: center;
}

.footer-brand,
.social-media {
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Responsive overrides for tablet/desktop */
@media (min-width: 750px) {
  #main-content {
    max-width: 1200px;
    padding: 40px;
    margin: 0 auto;
  }
  .header-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0;
  }
  .main-nav {
    width: auto;
    margin-top: 0;
  }
  .nav-list {
    flex-direction: row;
    gap: 20px;
    width: auto;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
  }
  .review-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
  }
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    text-align: left;
  }
  .footer-brand,
  .social-media {
    flex-direction: row;
    align-items: center;
    width: auto;
  }
}
