/* Base styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.3s, color 0.3s;
}

/* CSS variables for theme */
:root {
  /* Updated color palette for a more modern, vibrant feel */
  --primary: #0066a6;
  --secondary: #00a693;
  --accent: #ff8c42;
  /* Background colors */
  --bg: #f1f8fe;
  --card-bg: #ffffff;
  --text: #0a192f;
  --shadow: rgba(0, 0, 0, 0.05);
}

body.dark-mode {
  --bg: #021726;
  --card-bg: #0a2540;
  --text: #dfeaf4;
  --shadow: rgba(255, 255, 255, 0.08);
}

/* Navigation */
header {
  /* Use the primary colour as the base for the header but allow a subtle gradient for depth */
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
header .logo {
  display: flex;
  align-items: center;
  font-size: 1.25rem;
  font-weight: bold;
  text-decoration: none;
  color: #ffffff;
}
header .logo img {
  height: 32px;
  margin-right: 0.5rem;
}

/* Override nav logo images so they don’t display their dark backgrounds. We achieve this by forcing the images to act as transparent overlays. */
header .logo img {
  /* Remove any default background from the logo image so transparency shows through */
  display: block;
  background-color: transparent;
}

/* Position the navigation links and theme toggle to the right of the header. */
.header-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* Ensure the navigation inside the header right group aligns content horizontally and leaves space for the theme toggle */
.header-right nav {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

/* Nav logo wrapper for rotating heart and static hands */
.nav-logo-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
  margin-right: 0.5rem;
  perspective: 800px;
}
.nav-logo-wrapper .nav-heart {
  width: 100%;
  height: 100%;
  animation: rotateY 6s infinite linear;
  transform-style: preserve-3d;
}
.nav-logo-wrapper .nav-hands {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
nav a {
  color: #ffffff;
  margin-left: 1rem;
  text-decoration: none;
  font-size: 0.95rem;
}
nav a:hover {
  text-decoration: underline;
}
.theme-toggle {
  cursor: pointer;
  border: none;
  background: none;
  color: #ffffff;
  font-size: 1.2rem;
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  position: relative;
  /* Add a colourful gradient backdrop that transitions from primary to secondary */
  background: linear-gradient(135deg, var(--primary) 40%, var(--secondary));
  color: #ffffff;
}
.hero .logo-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: 1rem;
  perspective: 1000px;
}
/* For the hero’s combined logo, rotate the entire image slowly */
.hero .logo-wrapper img {
  width: 100%;
  height: 100%;
  animation: rotateY 12s infinite linear;
  transform-style: preserve-3d;
}
@keyframes rotateY {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}
.hero h1 {
  margin: 0.5rem 0;
  font-size: 2rem;
}
.hero p {
  margin: 0;
  font-size: 1.1rem;
  max-width: 600px;
}

/* Call-to-action buttons on the home page */
.cta-buttons {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.cta-buttons .btn {
  font-size: 1rem;
  padding: 0.6rem 1.2rem;
}

/* Sections */
/*
 * Sections are full-width by default. Instead of constraining
 * content to a fixed max width, we allow the section to span
 * the entire viewport width. Padding uses a clamp to scale
 * appropriately on small and large screens. A subtle shadow
 * and rounded corners keep sections distinct from the background.
 */
section {
  width: 100%;
  max-width: none;
  margin: 0 0 2rem 0;
  padding: 2rem clamp(12px, 3vw, 32px);
  background-color: var(--card-bg);
  border-radius: 0.75rem;
  box-shadow: 0 4px 8px var(--shadow);
}
section h2 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
}

/*
 * Cards
 *
 * Cards live in a flex-based container that centers its children
 * horizontally and wraps them as needed. Individual cards have a
 * preferred width but can shrink to fit smaller screens. On very
 * narrow viewports (phones), cards take up the full width.
 */
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.card {
  flex: 0 1 360px;
  max-width: 480px;
  background-color: var(--card-bg);
  border-radius: 0.75rem;
  box-shadow: 0 4px 8px var(--shadow);
  padding: 1.25rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px var(--shadow);
}
.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
  /* On small screens, cards span the full width for readability */
  .card {
    flex-basis: 100%;
    max-width: 700px;
  }
}

/* KPIs */
.kpis {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.kpi {
  background-color: var(--card-bg);
  padding: 1.25rem 1.75rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 8px var(--shadow);
  text-align: center;
  min-width: 160px;
}
.kpi .value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary);
}
.kpi .label {
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* Buttons */
.btn {
  background-image: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #ffffff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.2s, opacity 0.2s;
}
.btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

/* Form styles */
.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}
.form-group label {
  margin-bottom: 0.25rem;
}
.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  font-size: 1rem;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Footer */

/* Admin styles */
.admin-nav {
  margin-bottom: 1rem;
}
.admin-nav a {
  margin-right: 0.75rem;
  color: var(--primary);
  text-decoration: none;
}
.admin-nav a:hover {
  text-decoration: underline;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.table th,
.table td {
  border: 1px solid #ddd;
  padding: 0.5rem;
}
.table th {
  background-color: var(--primary);
  color: #fff;
}

/* Drag and drop styles */
.draggable {
  cursor: move;
}
.drag-over {
  border: 2px dashed var(--primary);
}

/* WYSIWYG editor */
.editor-toolbar {
  margin-bottom: 0.5rem;
}
.editor-toolbar button {
  background-color: var(--card-bg);
  border: 1px solid #ccc;
  padding: 0.25rem 0.5rem;
  margin-right: 0.25rem;
  cursor: pointer;
}
.editor-toolbar button:hover {
  background-color: #eee;
}
.editor {
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  padding: 0.5rem;
  min-height: 200px;
  background-color: var(--card-bg);
}

/* Slideshow */
/*
 * Slideshow
 *
 * The slideshow spans the full width of its container. The
 * underlying frame component will set a max-width when
 * appropriate via inline styles, but by default the slideshow
 * can take up the entire width of the viewport.
 */
.slideshow {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0 auto 2rem auto;
  overflow: hidden;
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px var(--shadow);
}
.slide-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  display: none;
}
.slide-image.active {
  display: block;
}
.slide-controls {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}
.slide-controls button {
  background-color: var(--primary);
  border: none;
  color: #fff;
  padding: 0.5rem;
  margin: 0 0.25rem;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1rem;
}
.slide-controls button.active {
  background-color: var(--secondary);
}

/* Frame slides with image/text side by side */
.frame-slide {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.frame-slide.active {
  display: flex;
}
.frame-slide .img-container {
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.frame-slide .img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame-slide .text-container {
  padding: 1rem;
  height: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1.4;
}

/* Extra section on home page */
#extraSection {
  background-color: var(--card-bg);
  border-radius: 0.5rem;
  box-shadow: 0 2px 4px var(--shadow);
  margin-top: 2rem;
  padding-top: 2rem;
}
#extraSection h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Volunteer filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}
.filters input,
.filters select {
  padding: 0.3rem;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}
.filters button {
  align-self: flex-end;
}

/*
 * Lists for How It Works and Why It Matters
 */
.steps {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 0;
}
.steps li {
  margin-bottom: 0.75rem;
}
.benefits {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.benefits li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}
.benefits li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--secondary);
  font-weight: bold;
}

/* Generic list styling used in Services and other pages */
ul.list {
  list-style: disc;
  padding-left: 1.5rem;
}

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

/*
 * About → Our Team
 *
 * Group headings (e.g., Founder, Director, Team) are injected into
 * #teamContainer as immediate children. Space them apart and center
 * the text. The first heading should not have a large top margin.
 */
#teamSection #teamContainer > h3 {
  text-align: center;
  margin: 2rem auto 0.75rem;
}
#teamSection #teamContainer > h3:first-of-type {
  margin-top: 0;
}

/* =====================================================
   Custom enhancements for final version
   ===================================================== */
/* Remove underline from buttons / links styled as buttons */
.btn {
  text-decoration: none;
}

/*
 * Lists for "How It Works", "Why It Matters", and Services pages
 *
 * The section headings remain centred, but the lists themselves are
 * left–aligned within a centred container.  We remove the full
 * centering on the text so icons (e.g. checkmarks) align neatly
 * with their corresponding text.  The list block is centred on
 * the page using auto margins and minimal padding.
 */
.steps {
  list-style: decimal;
  margin: 0 auto;
  padding: 0 0 0 1.5rem;
  display: inline-block;
  text-align: left;
}
.steps li {
  margin-bottom: 0.75rem;
}

/* Benefits list uses custom checkmark icons via ::before pseudo-element.  The
 * list container is centred, but each item is left–aligned with its
 * checkmark.  Using display:inline-block ensures the list takes up only
 * the width it needs and centres as a group.
 */
.benefits {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: inline-block;
  text-align: left;
}
.benefits li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}
.benefits li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--secondary);
  font-weight: bold;
}

/* Generic lists used in services and other pages should remain left–aligned
 * but centred within their section.  Use display:inline-block so the
 * list occupies only the space it needs and centre it with auto margins.
 */
ul.list {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0 auto;
  display: inline-block;
  text-align: left;
}
ul.list li {
  margin-bottom: 0.5rem;
}

/* Event section: let headings and card groups stack naturally */
#eventsSection {
  /* No flex container here; the script will insert heading elements and
   * separate card groups.  Let them stack vertically with default
   * spacing. */
}

/* Footer styling with social icons and contact */
footer {
  background-color: var(--card-bg);
  padding: 1rem;
  text-align: center;
}
footer .footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
footer .footer-contact a {
  color: var(--primary);
  text-decoration: none;
}
footer .social-icons {
  display: flex;
  gap: 0.5rem;
}
footer .social-icons img {
  width: 24px;
  height: 24px;
  display: block;
  filter: grayscale(0.2);
}