/* ===== GLOBAL CSS RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ===== ROOT VARIABLES ===== */
:root {
  /* Primary colors */
  --primary: #2c3e50;        /* deep blue‑grey */
  --primary-hover: #1a2a38;   /* darker */
  
  /* Text colors */
  --text-primary: #1e293b;    /* dark slate */
  --text-secondary: #475569;  /* muted slate */
  
  /* Background & borders */
  --background: #ffffff;
  --muted-bg: #f8fafc;
  --border: #e2e8f0;
  
  /* Status / subtle colors */
  --success-subtle: #f0fdf4;
  --info-subtle: #eff6ff;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  
  /* Container */
  --container-max: 1280px;
  --container-padding: 1.5rem;
}

/* ===== TYPOGRAPHY SYSTEM ===== */
h1 {
  font-size: 2.5rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

h3 {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

p {
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

small,
.text-small {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  margin-bottom: var(--space-xs);
}

/* ===== GLOBAL LAYOUT PRIMITIVES ===== */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  width: 100%;
}

.page-section {
  padding: var(--space-xl) 0;
}

.two-column-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
}

.sidebar-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
}

.content-area {
  min-width: 0; /* prevent overflow */
}

/* ===== NAVBAR ===== */
.site-header {
  position: sticky;
  top: 0;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--container-padding);
  max-width: var(--container-max);
  margin: 0 auto;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.navbar-brand .logo {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.navbar-search {
  flex: 1 1 300px;
  max-width: 400px;
}

.navbar-search input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  background: var(--muted-bg);
  transition: border 0.1s ease;
}

.navbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--background);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.1s, border-color 0.1s;
}

.nav-links a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== HERO SECTION ===== */
.hero {
  padding: var(--space-xl) 0;
  text-align: left;
  max-width: 800px;
}

.hero h1 {
  font-size: 2.75rem;
  margin-bottom: var(--space-md);
}

.hero .subhead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ===== BUTTON SYSTEM ===== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s, color 0.1s;
  background: transparent;
  line-height: 1.5;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--muted-bg);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

/* Guided entry button */
.btn-guided {
  background: var(--info-subtle);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
}

.btn-guided:hover {
  background: var(--primary);
  color: white;
}

/* ===== FORM ELEMENTS (GLOBAL) ===== */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--background);
  transition: border 0.1s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23475669%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
  margin-right: 0.5rem;
  accent-color: var(--primary);
}

/* ===== FILTER SIDEBAR BASE ===== */
.filter-sidebar {
  background: var(--muted-bg);
  padding: var(--space-md);
  border-radius: 4px;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.filter-header h3 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.clear-filters {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
}

.mobile-close-filters {
  display: none; /* hidden until mobile */
  background: none;
  border: none;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.filters-form fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-md) 0;
}

.filters-form legend {
  font-weight: 500;
  margin-bottom: var(--space-xs);
  font-size: 0.95rem;
  color: var(--text-primary);
}

.filters-form label {
  font-weight: normal;
  display: flex;
  align-items: center;
  margin-bottom: 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--muted-bg);
  border-top: 1px solid var(--border);
  padding: var(--space-lg) 0;
  margin-top: var(--space-xl);
  font-size: 0.95rem;
}

.footer-content {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  justify-content: space-between;
}

.footer-description {
  flex: 2 1 300px;
}

.footer-description p {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.brand-tagline {
  font-weight: 500;
  color: var(--text-primary);
}

.disclaimer {
  font-style: italic;
}

.open-source {
  font-size: 0.875rem;
}

.footer-nav {
  flex: 1 1 200px;
}

.footer-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-nav a {
  text-decoration: none;
  color: var(--text-secondary);
}

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

.copyright {
  flex: 1 1 100%;
  text-align: center;
  margin-top: var(--space-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 1024px) {
  :root {
    --container-padding: 1rem;
  }
  
  .two-column-layout,
  .sidebar-layout {
    gap: var(--space-md);
  }
  
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.75rem; }
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .navbar-search {
    max-width: none;
  }
  
  .nav-links {
    justify-content: center;
  }
  
  .two-column-layout,
  .sidebar-layout {
    grid-template-columns: 1fr;
  }
  
  .filter-sidebar {
    order: -1; /* show above content */
  }
  
  .mobile-close-filters {
    display: inline-block; /* show placeholder for JS */
  }
  
  .hero {
    text-align: center;
  }
  
  .hero-actions {
    justify-content: center;
  }
  
  .footer-content {
    flex-direction: column;
    gap: var(--space-md);
  }
}

@media (max-width: 480px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  
  .hero .subhead {
    font-size: 1.1rem;
  }
  
  .btn {
    width: 100%;
  }
  
  .hero-actions {
    flex-direction: column;
  }
  
  .nav-links {
    gap: var(--space-sm);
  }
}

/* ===== ACCESSIBILITY FOCUS STYLES ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove outline for mouse users, but keep for keyboard */
:focus:not(:focus-visible) {
  outline: none;
}