/* =============================================================================
   Variables
   ============================================================================= */
:root {
  /* Color palette */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --color-background: #ffffff;
  --color-surface: #ffffff;
  --color-text: var(--gray-800);
  --color-text-muted: var(--gray-600);
  --color-border: var(--gray-200);

  --color-primary: #2563eb; /* educational, engaging blue */
  --color-primary-contrast: #ffffff;
  --color-primary-rgb: 37 99 235;

  --color-success: #16a34a;
  --color-success-rgb: 22 163 74;
  --color-warning: #d97706;
  --color-warning-rgb: 217 119 6;
  --color-danger: #dc2626;
  --color-danger-rgb: 220 38 38;

  --color-link: var(--color-primary);

  /* Typography */
  --font-sans: "Inter var", "Inter", "SF Pro Text", "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;
  --text-5xl: 48px;

  --leading-none: 1;
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Spacing scale (0–96px, 4px steps) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
  --space-13: 52px;
  --space-14: 56px;
  --space-15: 60px;
  --space-16: 64px;
  --space-17: 68px;
  --space-18: 72px;
  --space-19: 76px;
  --space-20: 80px;
  --space-21: 84px;
  --space-22: 88px;
  --space-23: 92px;
  --space-24: 96px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-round: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 320ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --container-max: 80rem; /* ~1280px */
  --container-pad: var(--space-6);
}

/* =============================================================================
   Reset / Normalize
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* Smooth scrolling (respects reduced motion) */
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Remove default margins */
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }

/* Responsive media */
img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Inherit fonts for form controls */
button, input, select, textarea { font: inherit; color: inherit; }

/* Improve text rendering */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

/* =============================================================================
   Base
   ============================================================================= */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  background-color: var(--color-background);
  color: var(--color-text);
}

/* Headings: scalable sizes with consistent spacing */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: var(--leading-tight); color: var(--color-text); }

h1 { font-size: clamp(2rem, 3.5vw + 0.5rem, 3rem); margin-top: var(--space-8); margin-bottom: var(--space-4); }
h2 { font-size: clamp(1.5rem, 2.5vw + 0.5rem, 2.25rem); margin-top: var(--space-7); margin-bottom: var(--space-4); }
h3 { font-size: clamp(1.25rem, 1.5vw + 0.5rem, 1.75rem); margin-top: var(--space-6); margin-bottom: var(--space-3); }
h4 { font-size: var(--text-xl); margin-top: var(--space-6); margin-bottom: var(--space-3); }
h5 { font-size: var(--text-lg); margin-top: var(--space-5); margin-bottom: var(--space-2); }
h6 { font-size: var(--text-base); margin-top: var(--space-5); margin-bottom: var(--space-2); }

p { margin-bottom: var(--space-4); max-width: 75ch; }
small { font-size: var(--text-sm); }

/* Links */
a { color: var(--color-link); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 3px solid rgb(var(--color-primary-rgb) / 0.6); outline-offset: 2px; }

/* Lists */
ul, ol { padding-left: var(--space-6); margin-bottom: var(--space-4); }
li { margin-block: var(--space-1); }

/* Code blocks (useful for educational content) */
code, kbd, samp { font-family: var(--font-mono); font-size: 0.95em; }
pre { font-family: var(--font-mono); padding: var(--space-4); background: var(--gray-50); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: auto; }

/* Blockquotes for notes/tips */
blockquote { padding-left: var(--space-4); border-left: 4px solid var(--gray-300); color: var(--gray-700); margin: var(--space-5) 0; }

/* =============================================================================
   Accessibility
   ============================================================================= */
:focus-visible { outline: 3px solid rgb(var(--color-primary-rgb) / 0.6); outline-offset: 2px; }

/* Screen reader only */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Accessibility: skip link (from home.css) */
.skip-link { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.skip-link:focus { left: 16px; top: 16px; width: auto; height: auto; padding: var(--space-3) var(--space-4); background: #fff; border: 2px solid var(--color-primary); border-radius: var(--radius-md); z-index: 10000; }

/* =============================================================================
   Utilities
   ============================================================================= */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* Layout helpers */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.gap-0 { gap: var(--space-0); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }

.measure { max-width: 75ch; }

/* =============================================================================
   Components
   ============================================================================= */
/* Buttons */
.btn {
  --_bg: var(--color-primary);
  --_fg: var(--color-primary-contrast);
  --_bd: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: calc(var(--space-2) + 2px) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--_bd);
  background-color: var(--_bg);
  color: var(--_fg);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-normal) var(--ease-in-out),
              box-shadow var(--duration-fast) var(--ease-in-out),
              border-color var(--duration-fast) var(--ease-in-out),
              color var(--duration-fast) var(--ease-in-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: 0 0 0 3px rgb(var(--color-primary-rgb) / 0.35); outline: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* Button variants */
.btn--primary { --_bg: var(--color-primary); --_fg: var(--color-primary-contrast); --_bd: var(--color-primary); }
.btn--secondary { --_bg: var(--gray-100); --_fg: var(--gray-800); --_bd: var(--gray-300); }
.btn--success { --_bg: var(--color-success); --_fg: #fff; --_bd: var(--color-success); }
.btn--warning { --_bg: var(--color-warning); --_fg: #fff; --_bd: var(--color-warning); }
.btn--danger  { --_bg: var(--color-danger);  --_fg: #fff; --_bd: var(--color-danger); }
.btn--outline { --_bg: transparent; --_fg: var(--color-text); --_bd: var(--gray-300); }
.btn--ghost   { --_bg: transparent; --_fg: var(--color-link); --_bd: transparent; }

/* Inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: #fff;
  color: var(--color-text);
  line-height: var(--leading-snug);
  transition: border-color var(--duration-fast) var(--ease-in-out), box-shadow var(--duration-fast) var(--ease-in-out), background-color var(--duration-fast) var(--ease-in-out);
  appearance: none;
}

input::placeholder, textarea::placeholder { color: var(--gray-500); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(var(--color-primary-rgb) / 0.25);
}

label { display: inline-block; margin-bottom: var(--space-2); font-weight: 600; }

/* Input group and help text */
.form-help { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-2); }

/* Cards */
.card {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

.card--interactive { transition: box-shadow var(--duration-normal) var(--ease-in-out), transform var(--duration-fast) var(--ease-out); }
.card--interactive:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.card__header { margin-bottom: var(--space-4); }
.card__footer { margin-top: var(--space-4); }

/* Alerts (useful for course progress/status) */
.alert { padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid; }
.alert--success { background: color-mix(in srgb, var(--color-success) 8%, #fff); border-color: var(--color-success); color: var(--gray-900); }
.alert--warning { background: color-mix(in srgb, var(--color-warning) 10%, #fff); border-color: var(--color-warning); color: var(--gray-900); }
.alert--danger  { background: color-mix(in srgb, var(--color-danger) 8%, #fff); border-color: var(--color-danger);  color: var(--gray-900); }

/* =============================================================================
   Header & Footer styles (from home.css)
   ============================================================================= */
/* Header */
.site-header { position: sticky; top: 0; z-index: 1000; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand a { display: inline-block; line-height: 0; }
.brand img { max-width: 80px; height: auto; }

@media (min-width: 768px) {
  .brand img { max-width: 120px; }
}

.nav-toggle { display: inline-flex; flex-direction: column; gap: 4px; width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: #fff; color: var(--color-text); cursor: pointer; }
.nav-toggle__bar { display: block; width: 20px; height: 2px; background: var(--gray-700); border-radius: 2px; }

.primary-nav { position: fixed; inset: 64px 0 auto 0; transform: translateY(-8px); background: var(--color-surface); border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow-md); transition: transform var(--duration-normal) var(--ease-in-out), opacity var(--duration-normal) var(--ease-in-out); opacity: 0; pointer-events: none; }
.primary-nav.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.nav-list { list-style: none; margin: 0; padding: var(--space-4) var(--container-pad); display: grid; gap: var(--space-2); }
.nav-list a { display: block; padding: var(--space-3) var(--space-2); border-radius: var(--radius-md); color: var(--gray-800); font-weight: 600; }
.nav-list a:hover { background: var(--gray-100); text-decoration: none; }
.nav-cta .btn { width: 100%; }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .primary-nav { position: static; inset: auto; transform: none; opacity: 1; pointer-events: auto; background: transparent; border: 0; box-shadow: none; }
  .nav-list { display: flex; align-items: center; gap: var(--space-4); padding: 0; }
  .nav-list a { padding: var(--space-2) var(--space-2); }
  .nav-cta .btn { width: auto; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--color-border); background: var(--color-surface); }
.footer__grid { display: grid; gap: var(--space-6); padding-top: var(--space-8); padding-bottom: var(--space-6); }
.footer__title { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.footer__nav ul, .footer__legal ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.footer__bottom { padding: var(--space-4) 0; border-top: 1px solid var(--color-border); color: var(--color-text-muted); }
.footer-logo { font-weight: 800; color: var(--gray-900); }

@media (min-width: 900px) { .footer__grid { grid-template-columns: 2fr 1fr 1fr; } }

/* Cookie consent */
.cookie-consent { position: fixed; inset: auto 0 0 0; background: var(--color-surface); border-top: 1px solid var(--color-border); box-shadow: 0 -6px 20px rgba(0,0,0,0.06); z-index: 1100; }
.cookie-consent__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0; }
.cookie-consent__inner p { margin: 0; }
.cookie-consent__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* =============================================================================
   Misc helpers
   ============================================================================= */
.hr { height: 1px; background: var(--color-border); border: 0; }

/* Prefer reduced motion already handled above */

/* =============================================================================
   Optional: Dark scheme (can be enabled with [data-theme="dark"]) for accessibility
   ============================================================================= */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-background: #0b1220;
    --color-surface: #121a2b;
    --color-text: #e5e7eb;
    --color-text-muted: #a1a7b3;
    --color-border: #1f2a44;

    --gray-50: #141a27;
    --gray-100: #182033;
    --gray-200: #1f2a44;
    --gray-300: #2a3756;
    --gray-400: #495678;
    --gray-500: #7f8a9f;
    --gray-600: #a1a7b3;
    --gray-700: #c4c8d2;
    --gray-800: #e5e7eb;
    --gray-900: #f3f4f6;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6);
  }
}

[data-theme="dark"] {
  --color-background: #0b1220;
  --color-surface: #121a2b;
  --color-text: #e5e7eb;
  --color-text-muted: #a1a7b3;
  --color-border: #1f2a44;
}

/* =============================================================================
   End of base.css
   ============================================================================= */
