/**
 * Applied Realities - Base Stylesheet
 * workspace.hadsed.com/assets/base.css
 * 
 * Scholarly elegance with warm, thoughtful palettes.
 * Inspired by gwern.net, Solarized, doodad.dev
 * 
 * Typography:
 *   - Headings: Source Serif 4
 *   - Body: Spectral
 *   - Mono: Space Mono
 */

/* ============================================
   Fonts
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,500&family=Spectral:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Space+Mono:wght@400;700&display=swap');

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

/* ============================================
   CSS Variables - Light Theme (Warm Cream)
   ============================================ */
:root {
  /* Typography */
  --font-heading: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'Spectral', Georgia, serif;
  --font-mono: 'Space Mono', 'SF Mono', Consolas, monospace;
  
  /* Font sizes - scholarly scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;  /* 17px - optimal for long-form */
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* Line heights */
  --leading-tight: 1.3;
  --leading-normal: 1.65;
  --leading-relaxed: 1.8;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  
  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;
  
  /* ============================================
     Light Theme - Warm Cream (default)
     Inspired by doodad.dev, scholarly papers
     ============================================ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.1);
  
  /* Backgrounds - warm cream paper */
  --bg-page: #faf8f5;
  --bg-primary: #fffefa;
  --bg-secondary: #f5f2ed;
  --bg-tertiary: #ebe7e0;
  --bg-hover: rgba(0, 0, 0, 0.03);
  --bg-panel: #fdfcf9;
  
  /* Text - warm dark */
  --text-primary: #2c2825;
  --text-secondary: #5c5652;
  --text-muted: #8a8279;
  --text-faint: #b5ada3;
  
  /* Borders - subtle warm */
  --border-light: #e8e3db;
  --border-medium: #d9d2c7;
  --border-dark: #c4bbb0;
  
  /* Accent: Solarized-inspired */
  --accent-blue: #268bd2;
  --accent-cyan: #2aa198;
  --accent-green: #859900;
  --accent-yellow: #b58900;
  --accent-orange: #cb4b16;
  --accent-red: #dc322f;
  --accent-magenta: #d33682;
  --accent-violet: #6c71c4;
  
  /* Semantic */
  --link-color: #1a6fa8;
  --link-hover: #cb4b16;
  
  /* Node colors - muted pastels for diagrams */
  --node-blue: #d4e5f7;
  --node-blue-border: #7badd4;
  --node-blue-text: #1a5a8a;
  
  --node-teal: #d4ebe9;
  --node-teal-border: #5fb3ac;
  --node-teal-text: #1a6b65;
  
  --node-purple: #e5dff2;
  --node-purple-border: #9b8bc4;
  --node-purple-text: #5a4a8a;
  
  --node-amber: #f5ead4;
  --node-amber-border: #d4a84a;
  --node-amber-text: #8a6a1a;
  
  --node-green: #dfebd4;
  --node-green-border: #8ab85a;
  --node-green-text: #4a6a2a;
  
  --node-red: #f5e0df;
  --node-red-border: #c97a77;
  --node-red-text: #8a3a37;
  
  --node-gray: #eae8e5;
  --node-gray-border: #a9a49d;
  --node-gray-text: #5a5652;
  
  --node-cyan: #d4ebef;
  --node-cyan-border: #5ab3c4;
  --node-cyan-text: #1a6b7a;
}

/* ============================================
   Dark Theme - Solarized Dark
   ============================================ */
[data-theme="dark"] {
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 3px 10px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.6);
  
  /* Solarized Dark backgrounds */
  --bg-page: #002b36;
  --bg-primary: #073642;
  --bg-secondary: #0a4050;
  --bg-tertiary: #0d4a5a;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-panel: #073642;
  
  /* Solarized Dark text */
  --text-primary: #93a1a1;
  --text-secondary: #839496;
  --text-muted: #657b83;
  --text-faint: #586e75;
  
  /* Solarized Dark borders */
  --border-light: #0d4a5a;
  --border-medium: #1a5a6a;
  --border-dark: #2a6a7a;
  
  /* Links */
  --link-color: #268bd2;
  --link-hover: #2aa198;
  
  /* Node colors - richer for dark mode */
  --node-blue: #0d3a5a;
  --node-blue-border: #268bd2;
  --node-blue-text: #93a1a1;
  
  --node-teal: #0d4a4a;
  --node-teal-border: #2aa198;
  --node-teal-text: #93a1a1;
  
  --node-purple: #2a2050;
  --node-purple-border: #6c71c4;
  --node-purple-text: #93a1a1;
  
  --node-amber: #3a2a0a;
  --node-amber-border: #b58900;
  --node-amber-text: #93a1a1;
  
  --node-green: #2a3a0a;
  --node-green-border: #859900;
  --node-green-text: #93a1a1;
  
  --node-red: #3a1a1a;
  --node-red-border: #dc322f;
  --node-red-text: #93a1a1;
  
  --node-gray: #1a2a30;
  --node-gray-border: #657b83;
  --node-gray-text: #93a1a1;
  
  --node-cyan: #0a3a4a;
  --node-cyan-border: #2aa198;
  --node-cyan-text: #93a1a1;
}

/* ============================================
   Base Styles
   ============================================ */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

h1 { 
  font-size: var(--text-4xl); 
  font-weight: 700;
  letter-spacing: -0.02em;
}
h2 { 
  font-size: var(--text-3xl); 
  letter-spacing: -0.01em;
}
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-5);
}

/* Links */
a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
}

/* Emphasis */
strong, b {
  font-weight: 600;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Code */
code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-secondary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

pre {
  background: var(--bg-secondary);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  overflow-x: auto;
  line-height: 1.5;
}

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

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

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

/* Blockquote */
blockquote {
  border-left: 3px solid var(--border-medium);
  padding-left: var(--space-5);
  margin: var(--space-6) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Horizontal rule */
hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: var(--space-8) 0;
}

/* ============================================
   Layout
   ============================================ */
.container {
  max-width: 720px;  /* Optimal reading width */
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.container-wide {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.container-full {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  text-align: center;
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: 1px solid var(--border-light);
}

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

.page-header .subtitle {
  font-family: var(--font-body);
  color: var(--text-muted);
  font-size: var(--text-lg);
  font-style: italic;
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

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

.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }

.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

/* Small caps for scholarly touches */
.small-caps {
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  
  .container,
  .container-wide,
  .container-full {
    padding: var(--space-5) var(--space-4);
  }
  
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
}
