
/* ========== CSS VARIABLES (with fallbacks) ========== */
:root {
  --primary-color: #004aad;
  --secondary-color: #e63946;
  --bg-color: #f7f9fc;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-heading: "Playfair Display", serif;
}

/* GLOBAL RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body, Arial, sans-serif);
  color: #222;
  background-color: var(--bg-color, #fff);
  line-height: 1.6;
}

/* HEADER & NAVIGATION */
header {
  background-color: var(--primary-color, #004aad);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

header h1 {
  font-family: var(--font-heading, Georgia, serif);
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

nav a {
  text-decoration: none;
  color: white;
  font-weight: 600;
  transition: color 0.3s ease, transform 0.3s ease;
}

nav a:hover {
  color: var(--secondary-color, #e63946);
  transform: translateY(-2px);
}

/*  MAIN CONTENT LAYOUT  */
main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 2rem;
}

section, article {
  background-color: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* TYPOGRAPHY */
h2, h3 {
  font-family: var(--font-heading, serif);
  margin-bottom: 1rem;
  color: var(--primary-color, #004aad);
}

/* RELATIVE & DYNAMIC UNITS */
p {
  font-size: 1rem;
  margin-bottom: 1rem;
  padding: 0.5em 0;
  max-width: 60ch;
}

footer {
  background-color: var(--primary-color, #004aad);
  color: white;
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  position: relative;
  bottom: 0;
}

/* CUSTOM FONTS (with fallback) */
@font-face {
  font-family: "Inter";
  src: url("https://fonts.gstatic.com/s/inter/v12/UcCO3FwrKQ8.woff2") format("woff2");
  font-display: swap;
}

/*  CSS TRANSITIONS / ANIMATIONS / TRANSFORMS  */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

section {
  animation: fadeIn 0.6s ease-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

section:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/*  NESTED / SCOPED CSS  */
@scope (.nested-example) {
  section {
    border: 2px solid var(--secondary-color, red);

    h2 {
      color: var(--secondary-color, red);
    }
  }
}

/* BASELINE 2025 FEATURE */
/* Container Query */
.container-box {
  container-type: inline-size;
  background-color: white;
  padding: 1rem;
}

@container (max-width: 400px) {
  .container-box {
    background-color: color-mix(in srgb, var(--secondary-color) 20%, white);
  }
}

/* MEDIA QUERIES */
@media (max-width: 768px) {
  header {
    padding: 1rem;
  }

  nav ul {
    flex-direction: column;
    gap: 0.5rem;
  }

  main {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.6rem;
  }
}

@media (min-width: 1024px) {
  main {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  }
}

/* ========== EXTRA CREDIT: color-mix() & :has() selector ========== */
.card:has(img:hover) {
  outline: 3px solid color-mix(in srgb, var(--primary-color), var(--secondary-color));
  outline-offset: 4px;
}

/* PROJECT IMAGE STYLING (Part 2) */
picture img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Slight zoom & shadow on hover */
picture img:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

/*  PART 3  RESPONSIVE DESIGN & ACCESSIBILITY  */

/* Responsive grid layout for projects */
main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  align-items: start;
  justify-content: center;
  padding: 2rem;
}

/* Figure & caption styling */
figure {
  margin: 0;
  text-align: center;
}

figcaption {
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin-top: 0.5rem;
}

/* Active nav link styling */
nav a[aria-current="page"] {
  text-decoration: underline;
  font-weight: 700;
}

/* Prevent horizontal scroll on small screens */
body {
  overflow-x: hidden;
}

/* Responsive breakpoints for smaller screens */
@media (max-width: 600px) {
  header h1 {
    font-size: 1.5rem;
  }

  nav ul {
    flex-direction: column;
    gap: 0.5rem;
  }

  section {
    padding: 1rem;
  }

  figure {
    margin-bottom: 1rem;
  }
}

/*  PART 4  PERFORMANCE & PROGRESSIVE ENHANCEMENT  */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Gentle page fade-in (if supported) */
@supports (animation: fadeIn 1s ease-in) {
  body {
    animation: fadeIn 0.8s ease-in;
  }
}

/* Placeholder for lazy images */
img[loading="lazy"] {
  background-color: #f0f0f0;
  display: block;
  min-height: 100px;
}

