/* ---------- Reset & Normalization ---------- */
:root {
  /* Light theme (default) */
  --color-bg: #ffffff;
  --color-text: #333333;
  --color-primary: #4a6da7;
  --color-secondary: #5f5f5f;
  --color-accent: #2c3e50;
  --color-border: #e1e1e1;
  --color-shadow: rgba(0, 0, 0, 0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 4px;
  --transition: 0.2s ease;
  --container-width: 1200px;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-text: #f0f0f0;
    --color-primary: #6d8fcb;
    --color-secondary: #b0b0b0;
    --color-accent: #8ca9d6;
    --color-border: #2d2d2d;
    --color-shadow: rgba(0, 0, 0, 0.3);
  }
}

/* Box sizing for all elements */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Reset margins and paddings */
html, body, h1, h2, h3, h4, h5, h6, p, ol, ul, li, figure, figcaption, blockquote, dl, dd {
  margin: 0;
  padding: 0;
}

/* Base HTML elements */
html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0.5em;
  line-height: 1.2;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.75rem;
}

h4 {
  font-size: 1.5rem;
}

p, ul, ol {
  margin-bottom: 1rem;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover, a:focus {
  color: var(--color-accent);
  text-decoration: underline;
}

/* Focus styling */
:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Images and media */
img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Layout */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
header {
  background-color: var(--color-accent);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 4px var(--color-shadow);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  margin: 0;
}

/* Navigation */
nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav li {
  margin-left: 1.5rem;
}

nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
}

nav a:hover:after, nav a:focus:after, nav a.active:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: white;
}

/* Main content */
main {
  flex: 1;
  padding: 2rem 0;
}

.page-content {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Footer */
footer {
  background-color: var(--color-accent);
  color: white;
  padding: 1rem 0;
  text-align: center;
}

footer a {
  color: white;
  text-decoration: underline;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 2rem;
  font-style: italic;
  color: var(--color-secondary);
}

/* NoScript warning */
.noscript-warning {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #f44336;
  color: white;
  text-align: center;
  padding: 1rem;
  z-index: 9999;
}

/* Card component */
.card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px var(--color-shadow);
}

.card-title {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

/* Button styles */
.button {
  display: inline-block;
  background-color: var(--color-primary);
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  text-align: center;
  transition: background-color var(--transition);
}

.button:hover, .button:focus {
  background-color: var(--color-accent);
  color: white;
  text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  header .container {
    flex-direction: column;
    text-align: center;
  }
  
  nav {
    margin-top: 1rem;
  }
  
  nav ul {
    justify-content: center;
  }
  
  nav li {
    margin: 0 0.75rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
}