/* Global Box Sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Root Variables for Theming */
:root {
  --primary-color: #2c3e50; /* Dark blue-gray for headings/accents */
  --text-color: #34495e;    /* Slightly lighter dark blue-gray for body text */
  --background-color: #ecf0f1; /* Light gray for overall page background */
  --container-bg-color: #ffffff; /* White for the main content container */

  --header-footer-bg: var(--primary-color);
  --header-footer-text: #ffffff;
  --link-hover-bg: #3498db; /* A slightly brighter blue for navigation link hover */

  --font-family-base: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  --font-size-base: 16px;
  --line-height-base: 1.6;
}

/* Base HTML and Body Styles */
html {
  font-size: var(--font-size-base); /* Defines 1rem */
  background-color: var(--background-color); /* Overall page background */
  min-height: 100vh; /* Ensure html takes full viewport height for background */
}

body {
  font-family: var(--font-family-base);
  font-size: 1rem; /* Base font size for body content */
  line-height: var(--line-height-base);
  color: var(--text-color);
  background-color: var(--container-bg-color); /* White background for the content block */
  margin: 2.5rem auto; /* Center the content block with margin from top/bottom */
  padding: 0; /* Remove padding from body itself, children will add it */
  max-width: 800px; /* Max width for content */
  border-radius: 8px; /* Slightly rounded corners for a modern look */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Subtle shadow for depth */
  display: flex; /* Use flexbox for header, main, footer layout */
  flex-direction: column;
  min-height: calc(100vh - 5rem); /* Adjust min-height to account for body margin */
}

/* Header Styles */
header {
  background-color: var(--header-footer-bg);
  color: var(--header-footer-text);
  padding: 1.5rem 2.5rem; /* Consistent horizontal padding with body max-width */
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
  border-top-left-radius: 8px; /* Match body border-radius */
  border-top-right-radius: 8px;
}

header h1 {
  color: var(--header-footer-text); /* Override primary-color for header h1 */
  font-size: 2rem; /* Slightly smaller than default h1, but still prominent */
  margin: 0; /* Remove default margin for flex alignment */
  text-align: left; /* Align with flex layout */
  flex-shrink: 0; /* Prevent shrinking */
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem; /* Spacing between nav items */
  flex-wrap: wrap; /* Allow nav items to wrap */
}

nav a {
  color: var(--header-footer-text);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.3s ease, color 0.3s ease;
  white-space: nowrap; /* Prevent links from breaking */
}

nav a:hover,
nav a:focus {
  background-color: var(--link-hover-bg);
  color: var(--header-footer-text);
  outline: 2px solid var(--header-footer-text); /* Accessibility: visible focus */
  outline-offset: 2px;
}

/* Main Content Styles */
main {
  padding: 2.5rem; /* Consistent padding for main content area */
  flex-grow: 1; /* Allow main to take up available space */
}

main section {
  margin-bottom: 2rem;
}

main section:last-of-type {
  margin-bottom: 0; /* No margin after the last section */
}

h2 {
  color: var(--primary-color);
  font-size: 1.8rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

p {
  margin-bottom: 1rem;
}

main ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  padding-left: 0;
  margin-bottom: 1rem; /* Consistent spacing */
}

main li {
  margin-bottom: 0.5rem;
}

/* Footer Styles */
footer {
  background-color: var(--header-footer-bg);
  color: var(--header-footer-text);
  text-align: center;
  padding: 1.5rem 2.5rem; /* Consistent horizontal padding */
  margin-top: auto; /* Push footer to the bottom in a flex column layout */
  border-bottom-left-radius: 8px; /* Match body border-radius */
  border-bottom-right-radius: 8px;
}

footer p {
  margin: 0; /* Remove default paragraph margin */
}

/* Responsive Layout (Mobile-first approach) */
@media (max-width: 768px) {
  body {
    margin: 1.5rem auto; /* Smaller margin on tablets/smaller desktops */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Lighter shadow */
    min-height: calc(100vh - 3rem); /* Adjust min-height for smaller body margin */
  }

  header {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem; /* Adjust padding */
  }

  header h1 {
    font-size: 1.8rem; /* Adjust heading size for medium screens */
    margin-bottom: 1rem; /* Add space below title */
  }

  nav ul {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%; /* Make nav items take full width */
    margin-top: 1rem; /* Space between title and nav */
  }

  nav a {
    display: block; /* Make links take full width for better touch target */
    text-align: center;
    padding: 0.8rem 1rem; /* More prominent touch target */
  }

  main {
    padding: 2rem; /* Slightly less padding for main content */
  }

  h2 {
    font-size: 1.6rem; /* Adjust heading size for medium screens */
  }

  footer {
    padding: 1.5rem; /* Adjust padding */
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px; /* Slightly smaller base font for very small devices */
  }
  body {
    margin: 0; /* Remove margin entirely on very small screens to fill width */
    border-radius: 0; /* No border-radius on very small screens */
    box-shadow: none; /* No shadow on very small screens */
    min-height: 100vh; /* Full height */
  }

  header {
    border-radius: 0; /* No border-radius */
    padding: 1rem; /* Smaller padding */
  }

  header h1 {
    font-size: 1.6rem; /* Adjust heading size for mobile */
    margin-bottom: 0.8rem;
  }

  nav ul {
    margin-top: 0.8rem;
  }

  nav a {
    padding: 0.6rem 1rem;
  }

  main {
    padding: 1.5rem; /* Even less padding */
  }

  h2 {
    font-size: 1.4rem; /* Adjust heading size for mobile */
    margin-top: 1.5rem;
  }

  footer {
    border-radius: 0; /* No border-radius */
    padding: 1rem; /* Smaller padding */
  }
}