/**
 * Modern Design System for Thermo Spoken Here
 * Phase 3: Design Modernization
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Typography */
  --font-display: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  
  /* Font Sizes - Modular Scale (1.25) */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  
  /* Colors - Refined Palette */
  --color-slate-50: #f8fafc;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;
  --color-slate-300: #cbd5e1;
  --color-slate-400: #94a3b8;
  --color-slate-500: #64748b;
  --color-slate-600: #475569;
  --color-slate-700: #334155;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;
  
  /* Accent Colors */
  --color-primary: #1e40af;       /* Deep blue */
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1e3a8a;
  --color-accent: #dc2626;        /* Thermo red */
  --color-accent-light: #ef4444;
  
  /* Semantic Colors */
  --color-text: var(--color-slate-800);
  --color-text-muted: var(--color-slate-600);
  --color-text-light: var(--color-slate-500);
  --color-bg: #ffffff;
  --color-bg-alt: var(--color-slate-50);
  --color-bg-subtle: var(--color-slate-100);
  --color-border: var(--color-slate-200);
  --color-border-strong: var(--color-slate-300);
  
  /* Panel Colors (Updated from legacy) */
  --color-panel-even: #f8faf5;    /* Subtle green tint */
  --color-panel-odd: #f5f5f5;     /* Neutral gray */
  --color-panel-header: #e8e8e8;
  --color-panel-notice: #fef9c3;  /* Warm yellow */
  
  /* Spacing Scale */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --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);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* Layout */
  --max-width-content: 960px;
  --max-width-prose: 65ch;
}

/* ============================================
   Base Typography Improvements
   ============================================ */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+3:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap');

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-slate-900);
  margin-top: 0;
}

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

/* Override panel headings to use modern typography */
.panel h1, .panel h2, .panel h3 {
  font-family: var(--font-display);
}

/* Paragraphs */
p {
  margin-top: 0;
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

a:visited {
  color: var(--color-primary-dark);
}

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

li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

/* ============================================
   Responsive Wrapper Override
   ============================================ */
#wrapper {
  width: 100% !important;
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--space-4);
  background: var(--color-bg) !important;
}

/* ============================================
   Panel Improvements
   ============================================ */
.panel {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.text_even, .text {
  background: var(--color-panel-even) !important;
  padding: var(--space-5);
  border-radius: var(--radius-md);
}

.text_odd {
  background: var(--color-panel-odd) !important;
  padding: var(--space-5);
  border-radius: var(--radius-md);
}

.panel_header {
  background: var(--color-panel-header) !important;
  border-radius: var(--radius-md);
}

.panel_notice {
  background: var(--color-panel-notice) !important;
  border-left: 4px solid #eab308;
  border-radius: var(--radius-md);
}

/* ============================================
   Navigation Improvements
   ============================================ */
.toplinks, nav.toplinks {
  background: var(--color-bg-subtle);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.toplinks a {
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.toplinks a:hover {
  background: var(--color-bg-alt);
  text-decoration: none;
}

/* ============================================
   Table Improvements
   ============================================ */
table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--space-4);
}

table.simple {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

table.simple th {
  background: var(--color-bg-subtle);
  font-weight: 600;
  text-align: left;
}

table.simple th,
table.simple td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
}

table.simple tbody tr:hover {
  background: var(--color-bg-alt);
}

/* ============================================
   Image Improvements
   ============================================ */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

img.center {
  display: block;
  margin: var(--space-4) auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Equation images - no border/shadow */
img[src*="gif"],
img[alt*="Equation"],
img[alt*="equation"] {
  border: none;
  box-shadow: none;
  border-radius: 0;
}

/* ============================================
   Code & Pre Blocks
   ============================================ */
code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

pre {
  background: var(--color-slate-800);
  color: var(--color-slate-100);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

code {
  background: var(--color-bg-subtle);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* ============================================
   Footer Improvements
   ============================================ */
footer, #footer {
  margin-top: var(--space-8);
  padding: var(--space-6) var(--space-4);
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

footer a {
  font-weight: 600;
}

/* ============================================
   Index Page Special Styling
   ============================================ */
body#index-page {
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body#index-page #main-content .container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  margin: var(--space-8) auto;
}

body#index-page table.simple {
  background: white;
}

body#index-page h1 {
  font-size: var(--text-3xl);
  text-align: center;
}

/* ============================================
   Leftbar (Sidebar) Improvements
   ============================================ */
.leftbar {
  background: var(--color-bg-alt);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border-right: 3px solid var(--color-primary);
}

.leftbar a {
  display: block;
  padding: var(--space-2) 0;
  color: var(--color-text);
  transition: color var(--transition-fast);
}

.leftbar a:hover {
  color: var(--color-primary);
}

/* ============================================
   Equation Display
   ============================================ */
.layout.cols-2 {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-4) 0;
  padding: var(--space-3);
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
}

.layout.cols-2 .cell:first-child {
  flex: 1;
  text-align: center;
}

.layout.cols-2 .cell:last-child {
  flex: 0 0 auto;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ============================================
   Utility Classes for Font Replacement
   ============================================ */
.text-red, .font-red { color: var(--color-accent) !important; }
.text-blue, .font-blue { color: var(--color-primary) !important; }
.text-green, .font-green { color: #16a34a !important; }
.text-gray, .font-gray { color: var(--color-text-muted) !important; }
.text-black, .font-black { color: var(--color-text) !important; }

.text-sm, .font-small { font-size: var(--text-sm) !important; }
.text-lg, .font-large { font-size: var(--text-lg) !important; }
.text-xl, .font-xlarge { font-size: var(--text-xl) !important; }

.font-bold, .text-bold { font-weight: 700 !important; }
.font-italic, .text-italic { font-style: italic !important; }

/* Legacy font face overrides */
.font-arial { font-family: var(--font-body) !important; }
.font-times { font-family: var(--font-display) !important; }
.font-courier { font-family: var(--font-mono) !important; }

/* ============================================
   Print Improvements
   ============================================ */
@media print {
  :root {
    --color-bg: white;
    --color-text: black;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  .leftbar, nav, .toplinks, .skip-link {
    display: none !important;
  }
  
  .text_even, .text_odd, .text {
    background: white !important;
    padding: 0;
  }
  
  a {
    color: black;
    text-decoration: underline;
  }
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
  :root {
    --text-4xl: 1.875rem;
    --text-3xl: 1.5rem;
    --text-2xl: 1.25rem;
  }
  
  #wrapper {
    padding: var(--space-3);
  }
  
  .panel {
    margin-left: 0;
    margin-right: 0;
  }
  
  .text_even, .text_odd, .text {
    padding: var(--space-4);
  }
  
  body#index-page #main-content .container {
    margin: var(--space-4);
    padding: var(--space-4);
  }
}

/* ============================================
   Utility Classes (for deprecated attr removal)
   ============================================ */

/* Text alignment */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* Vertical alignment */
.align-top { vertical-align: top !important; }
.align-middle { vertical-align: middle !important; }
.align-bottom { vertical-align: bottom !important; }
.align-baseline { vertical-align: baseline !important; }

/* Text colors */
.text-red { color: #dc2626 !important; }
.text-blue { color: #1e40af !important; }
.text-green { color: #16a34a !important; }

/* Font styles */
.font-bold { font-weight: 700 !important; }
.font-italic { font-style: italic !important; }

/* Equation reference styling */
.eq-ref {
  color: var(--color-primary);
  font-weight: 600;
  cursor: default;
}

