/* ==========================================================================
   enfren.dev – Global Stylesheet
   Purpose: Single source of truth for presentation across all pages.
   Approach: Mobile-first, semantic, accessible, maintainable.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CUSTOM PROPERTIES (Design Tokens)
   Central place to control colors, spacing, and typography.
   Change a value here and it updates site-wide.
   -------------------------------------------------------------------------- */
:root {
  /* Color palette – high contrast for readability (WCAG AA friendly) */
  --color-bg: #f8f9fa;
  --color-text: #212529;
  --color-header: #111111;
  --color-accent: #0d6efd;          /* Primary interactive color */
  --color-accent-hover: #0b5ed7;
  --color-muted: #6c757d;
  --color-border: #dee2e6;
  --color-white: #ffffff;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --line-height-body: 1.65;
  --line-height-heading: 1.25;

  /* Layout */
  --max-width: 860px;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
}

/* --------------------------------------------------------------------------
   2. CSS RESET / BASE
   Purpose: Remove inconsistent browser defaults and establish a clean foundation.
   box-sizing: border-box is a modern best practice so width includes padding + border.
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;                 /* Base for rem units */
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;          /* Sticky footer technique */
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   Clear visual hierarchy and comfortable reading measures.
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  line-height: var(--line-height-heading);
  margin-bottom: var(--space-sm);
  font-weight: 700;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; margin-top: var(--space-lg); }
h3 { font-size: 1.25rem; }

p {
  margin-bottom: var(--space-sm);
}

a {
  color: var(--color-accent);
  text-decoration-skip-ink: auto;
}

a:hover,
a:focus-visible {
  color: var(--color-accent-hover);
}

/* --------------------------------------------------------------------------
   4. LAYOUT STRUCTURE
   -------------------------------------------------------------------------- */
main {
  flex: 1;                         /* Pushes footer down */
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md) var(--space-sm);
}

/* --------------------------------------------------------------------------
   5. HEADER & NAVIGATION
   Semantic <header> + <nav>. Clear current-page indication.
   -------------------------------------------------------------------------- */
header {
  background-color: var(--color-header);
  color: var(--color-white);
  padding: var(--space-sm) var(--space-sm);
}

nav {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
}

nav a {
  color: var(--color-white);
  text-decoration: none;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

nav a:hover,
nav a:focus-visible {
  color: #8ab4ff;
}

nav a.active {
  color: #8ab4ff;
  border-bottom-color: #8ab4ff;
}

/* Focus styles for keyboard users (accessibility) */
nav a:focus-visible {
  outline: 2px solid #8ab4ff;
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   6. FOOTER
   -------------------------------------------------------------------------- */
footer {
  background-color: var(--color-header);
  color: #adb5bd;
  text-align: center;
  padding: var(--space-sm);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   7. REUSABLE COMPONENTS
   -------------------------------------------------------------------------- */
section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

section:last-of-type {
  border-bottom: none;
}

/* Simple card used on several pages */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-md);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* --------------------------------------------------------------------------
   8. FORMS, TABLES, MEDIA (shared improvements)
   -------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  background: var(--color-white);
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.75rem;
  text-align: left;
}

th {
  background-color: var(--color-header);
  color: var(--color-white);
}

img, video, audio {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   9. RESPONSIVE ADJUSTMENTS
   Mobile-first: base styles are for small screens.
   We only add complexity when the viewport is larger.
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  main {
    padding: var(--space-lg) var(--space-md);
  }

  h1 { font-size: 2.4rem; }
}

/* ==========================================================================
   END OF GLOBAL STYLES
   Page-specific demo styles remain in <style> blocks only when they are
   purely illustrative (e.g. specificity battles, box-model comparison).
   This keeps the teaching examples self-contained while the rest of the
   site stays maintainable.
   ========================================================================== */