/* Chenology Website Styles */

/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  hanging-punctuation: first last;
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* CSS Variables */
:root {
  /* Light theme */
  --bg: #f5f3f0;
  --text: #2d3748;
  --primary: #4f8cff;
  --muted: #718096;
  --border: #e2d9d0;
  --surface: #faf9f7;
  --surface-hover: #f0ede8;
  
  /* Spacing scale (8pt grid) */
  --space-1: 0.5rem;   /* 8px */
  --space-2: 1rem;     /* 16px */
  --space-3: 1.5rem;   /* 24px */
  --space-4: 2rem;     /* 32px */
  --space-5: 2.5rem;   /* 40px */
  --space-6: 3rem;     /* 48px */
  --space-8: 4rem;     /* 64px */
  --space-10: 5rem;    /* 80px */
  --space-12: 6rem;    /* 96px */
  
  /* Typography */
  --font-family: ui-sans-serif, -apple-system, 'Segoe UI', Roboto, Inter, 'Noto Sans', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  
  /* Fluid typography */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.6rem + 1.375vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.9rem + 1.75vw, 3rem);
  --text-5xl: clamp(3rem, 2.5rem + 2.5vw, 4rem);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Borders */
  --radius-sm: 0.125rem;
  --radius: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1611;
    --text: #f5f3f0;
    --border: #2d2620;
    --surface: #211e18;
    --surface-hover: #2d2620;
  }
}

/* Manual theme overrides */
[data-theme="light"] {
  --bg: #f5f3f0;
  --text: #2d3748;
  --border: #e2d9d0;
  --surface: #faf9f7;
  --surface-hover: #f0ede8;
}

[data-theme="dark"] {
  --bg: #1a1611;
  --text: #f5f3f0;
  --border: #2d2620;
  --surface: #211e18;
  --surface-hover: #2d2620;
}

/* Base styles */
body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 150ms ease, color 150ms ease;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: var(--space-2);
  background: var(--primary);
  color: white;
  padding: var(--space-1) var(--space-2);
  text-decoration: none;
  border-radius: var(--radius);
  z-index: 1000;
  font-size: var(--text-sm);
  font-weight: 500;
}

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

/* Layout utilities */
.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 0 var(--space-2);
}

.stack-1 > * + * { margin-top: var(--space-1); }
.stack-2 > * + * { margin-top: var(--space-2); }
.stack-3 > * + * { margin-top: var(--space-3); }
.stack-4 > * + * { margin-top: var(--space-4); }
.stack-5 > * + * { margin-top: var(--space-5); }
.stack-6 > * + * { margin-top: var(--space-6); }
.stack-8 > * + * { margin-top: var(--space-8); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.cluster-sm { gap: var(--space-1); }
.cluster-lg { gap: var(--space-3); }

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

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

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

.text-center { text-align: center; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
}

.nav-brand {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.logo {
  height: 32px;
  width: auto;
  border-radius: var(--radius-sm);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: var(--space-4);
  align-items: center;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color 150ms ease;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--text);
}

.nav-link[aria-current="page"] {
  color: var(--primary);
}

/* Mobile nav */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  color: var(--text);
  border-radius: var(--radius);
}

.nav-toggle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-toggle svg {
  width: 24px;
  height: 24px;
}

.nav-mobile {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.nav-mobile.is-open {
  display: block;
}

.nav-mobile .nav-links {
  flex-direction: column;
  padding: var(--space-3);
  gap: var(--space-2);
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  
  .nav-toggle {
    display: block;
  }
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-1);
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: all 150ms ease;
}

.theme-toggle:hover {
  background: var(--surface-hover);
}

.theme-toggle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
  line-height: 1;
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background: #3b7aef;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

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

.btn-subtle {
  background: transparent;
  color: var(--muted);
}

.btn-subtle:hover {
  color: var(--text);
  background: var(--surface);
}

.btn-lg {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: all 150ms ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.card-description {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text);
}

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

/* Lists */
.feature-list {
  list-style: none;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.feature-list .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--primary);
  margin-top: 2px;
}

/* Hero section */
.hero {
  text-align: center;
  padding: var(--space-10) 0 var(--space-8);
}

.hero h1 {
  margin-bottom: var(--space-3);
}

.hero p {
  font-size: var(--text-lg);
  color: var(--muted);
  margin-bottom: var(--space-5);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Grid layouts */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

@media (max-width: 640px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Section spacing */
.section {
  padding: var(--space-8) 0;
}

.section-sm { padding: var(--space-6) 0; }
.section-lg { padding: var(--space-12) 0; }

/* Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0 var(--space-4);
  margin-top: var(--space-12);
}

.footer-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.footer-brand {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

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

.footer-link {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color 150ms ease;
}

.footer-link:hover {
  color: var(--text);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* Animations (respect reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  .btn,
  .card,
  .nav-link,
  .footer-link,
  .theme-toggle {
    transition: all 150ms ease;
  }
  
  .card:hover {
    transform: translateY(-2px);
  }
  
  .btn-primary:hover {
    transform: translateY(-1px);
  }
}

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

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --muted: #666;
  }
  
  [data-theme="dark"] {
    --border: #fff;
    --muted: #ccc;
  }
}