/* ============================================================
   BASE.CSS — Reset, Custom Properties, Type Scale
   LearnShrooms Design System
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES — LIGHT MODE (DEFAULT)
   ============================================================ */
:root {
  /* Brand Colors */
  --cap-red: #C41E2A;
  --mycelium-crimson: #8B1520;
  --spore-coral: #E8544E;

  /* Surfaces */
  --substrate-dark: #F8F6F2;
  --midnight-loam: #FFFFFF;
  --dark-grain: #F0EDE8;

  /* Text */
  --cream: #1A1A1D;
  --spore-dust: #6B6560;
  --clean-white: #1A1A1D;

  /* Status */
  --flush-green: #3A9D5C;
  --caution-gold: #D4A843;
  --alert-vermillion: #E63946;

  /* Typography */
  --font-heading: 'DM Serif Display', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-data: 'JetBrains Mono', 'Courier New', monospace;

  /* Type Scale (1.25 ratio, base 16px) */
  --text-xs: 0.8rem;       /* 12.8px */
  --text-sm: 0.875rem;     /* 14px  — data */
  --text-base: 1rem;       /* 16px  — body */
  --text-h4: 1.25rem;      /* 20px */
  --text-h3: 1.563rem;     /* 25px */
  --text-h2: 1.953rem;     /* 31px */
  --text-h1: 2.441rem;     /* 39px */

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Layout */
  --max-width: 1200px;
  --sidebar-width: 300px;
  --header-height: 64px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* ── Token aliases for inline page styles ──────────────────────────────── */
  /* These map the inline-style token system used by home/forum/directory/
     people/societies/channels pages onto the main design system.           */
  --surface-1:      var(--substrate-dark);   /* page background     */
  --surface-2:      var(--dark-grain);       /* card / panel surface */
  --border:         rgba(0,0,0,0.1);         /* subtle border on light */
  --accent-green:   var(--flush-green);      /* green accent (CTA, stat) */
  --text-primary:   var(--cream);            /* #1A1A1D — near-black */
  --text-secondary: var(--spore-dust);       /* #6B6560 — medium grey */
  --text-muted:     #9A948F;                 /* lighter label text   */
  --text-lg:        var(--text-h4);          /* 1.25rem              */
  --text-2xl:       var(--text-h2);          /* 1.953rem             */
  --text-3xl:       2.25rem;                 /* large stat number    */
  --space-5:        1.25rem;                 /* between space-4/space-6 */
}

/* ============================================================
   DARK MODE OVERRIDES
   ============================================================ */
html.dark-mode {
  --substrate-dark: #1A1A1D;
  --midnight-loam: #242428;
  --dark-grain: #2E2E33;
  --cream: #F5F0E8;
  --spore-dust: #A8A29E;
  --clean-white: #FFFFFF;

  /* token aliases — dark overrides */
  --border:         rgba(255,255,255,0.08);
  --text-muted:     var(--spore-dust);
}

/* ============================================================
   RESET & BASE STYLES
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--substrate-dark);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ccircle cx='23' cy='41' r='6' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='89' cy='17' r='4' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='157' cy='63' r='7' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='51' cy='112' r='5' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='133' cy='138' r='4' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='178' cy='19' r='3' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='7' cy='171' r='5' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='112' cy='187' r='6' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='71' cy='73' r='3' fill='%23000000' opacity='0.06'/%3E%3Ccircle cx='190' cy='101' r='4' fill='%23000000' opacity='0.06'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

html.dark-mode body {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Ccircle cx='23' cy='41' r='6' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='89' cy='17' r='4' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='157' cy='63' r='7' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='51' cy='112' r='5' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='133' cy='138' r='4' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='178' cy='19' r='3' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='7' cy='171' r='5' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='112' cy='187' r='6' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='71' cy='73' r='3' fill='%23ffffff' opacity='0.04'/%3E%3Ccircle cx='190' cy='101' r='4' fill='%23ffffff' opacity='0.04'/%3E%3C/svg%3E");
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--clean-white);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-h1); line-height: 1.15; }
h2 { font-size: var(--text-h2); line-height: 1.2; }
h3 { font-size: var(--text-h3); line-height: 1.25; }
h4 { font-size: var(--text-h4); line-height: 1.3; font-family: var(--font-body); font-weight: 600; color: var(--clean-white); }
h5, h6 { font-family: var(--font-body); font-weight: 600; color: var(--clean-white); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--spore-coral);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--cap-red); }
a:focus-visible {
  outline: 2px solid var(--cap-red);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong { font-weight: 600; }
em { font-style: italic; }

small, .text-small {
  font-size: var(--text-xs);
  line-height: 1.5;
}

code, kbd, samp, pre {
  font-family: var(--font-data);
  font-size: var(--text-sm);
}

code {
  background: var(--dark-grain);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  color: var(--spore-coral);
}

pre {
  background: var(--dark-grain);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  background: transparent;
  padding: 0;
  color: var(--cream);
}

blockquote {
  border-left: 3px solid var(--cap-red);
  padding-left: var(--space-6);
  margin-left: 0;
  margin-bottom: var(--space-4);
  color: var(--spore-dust);
  font-style: italic;
}

ul, ol { padding-left: var(--space-6); margin-bottom: var(--space-4); }
li { margin-bottom: var(--space-2); }

hr {
  border: none;
  margin: var(--space-8) 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
}

hr::before {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--spore-dust));
}

hr::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(to left, transparent, var(--spore-dust));
}

/* Dot divider — use <div class="dot-divider"> instead of <hr> */
.dot-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-8) 0;
}

.dot-divider::before,
.dot-divider::after {
  content: '• • •';
  color: var(--spore-dust);
  letter-spacing: 0.5em;
  font-size: var(--text-xs);
  opacity: 0.5;
}

/* ============================================================
   IMAGES & MEDIA
   ============================================================ */
img, video, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

figure { margin: 0 0 var(--space-4); }
figcaption {
  font-size: var(--text-xs);
  color: var(--spore-dust);
  margin-top: var(--space-2);
  text-align: center;
}

/* ============================================================
   TABLES
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-6);
  font-family: var(--font-data);
  font-size: var(--text-sm);
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--dark-grain);
  color: var(--clean-white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  color: var(--cream);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.03); }

html.dark-mode th { border-bottom: 1px solid rgba(255,255,255,0.1); }
html.dark-mode td { border-bottom: 1px solid rgba(255,255,255,0.05); }
html.dark-mode tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================================================
   FORMS (base)
   ============================================================ */
input, textarea, select {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--dark-grain);
  color: var(--cream);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder, textarea::placeholder { color: var(--spore-dust); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--cap-red);
  box-shadow: 0 0 0 3px rgba(196, 30, 42, 0.2);
}

label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--spore-dust);
  margin-bottom: var(--space-2);
}

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
  border-color: rgba(255,255,255,0.1);
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
.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;
}

:focus-visible {
  outline: 2px solid var(--cap-red);
  outline-offset: 2px;
}

@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;
  }
}
