/* ========================================
   Coders Farm — Base Styles
   Reset, CSS Variables, Typography, Theme
   ======================================== */

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Theme Variables */
:root {
  /* Dark theme (default) */
  color-scheme: dark;
  --bg-primary: #1e1e1e;
  --bg-surface: #252526;
  --bg-surface-hover: #2a2d2e;
  --bg-elevated: #333333;
  --text-primary: #d4d4d4;
  --text-secondary: #9d9d9d;
  --text-muted: #6d6d6d;
  --accent: #4fc1ff;
  --accent-hover: #6dd0ff;
  --success: #4ec9b0;
  --success-bg: rgba(78, 201, 176, 0.1);
  --error: #f44747;
  --error-bg: rgba(244, 71, 71, 0.1);
  --warning: #cca700;
  --border: #3e3e3e;
  --border-light: #4e4e4e;
  --shadow: rgba(0, 0, 0, 0.3);
  --code-bg: #1e1e1e;
  --overlay: rgba(0, 0, 0, 0.5);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Layout */
  --content-max-width: 800px;
  --nav-height: 56px;
}

/* Light Theme */
[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #ffffff;
  --bg-surface: #f5f5f5;
  --bg-surface-hover: #ebebeb;
  --bg-elevated: #e8e8e8;
  --text-primary: #1e1e1e;
  --text-secondary: #555555;
  --text-muted: #888888;
  --accent: #0066cc;
  --accent-hover: #0055aa;
  --success: #16825d;
  --success-bg: rgba(22, 130, 93, 0.1);
  --error: #cd3131;
  --error-bg: rgba(205, 49, 49, 0.1);
  --warning: #bf8803;
  --border: #d4d4d4;
  --border-light: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --code-bg: #f5f5f5;
  --overlay: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

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

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

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--bg-surface);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background-color: var(--code-bg);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: var(--space-3);
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-4);
  color: var(--text-secondary);
}

li {
  margin-bottom: var(--space-1);
}

/* Selection */
::selection {
  background-color: var(--accent);
  color: #ffffff;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
}

.skip-link:focus {
  top: var(--space-2);
}

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