/* ============================================
   Oregon Trail Pedagogy Theme
   Light + Dark mode with pixel-art flair
   ============================================ */

/* --- Custom Properties (Light Mode) --- */
:root,
[data-theme="light"] {
  --bg: #f5f0e6;
  --bg-alt: #ebe4d4;
  --text: #2c2416;
  --text-muted: #6b5d4d;
  --heading: #3a2a14;
  --link: #5b6e28;
  --link-hover: #3d4a1a;
  --accent: #7a8b3c;
  --accent-soft: #c8d4a0;
  --border: #c9bfa8;
  --code-bg: #e8e0ce;
  --table-stripe: #ede7d8;
  --header-bg: #2c3e10;
  --header-text: #c8d89a;
  --header-glow: #a0c040;
  --canvas-sky: #87a96b;
  --canvas-ground: #5b6e28;
  --canvas-trail: #c9b882;
  --canvas-sun: #e8c84a;
  --canvas-wagon: #c9b882;
  --canvas-mountain: #6b7d3a;
  --canvas-tree: #4a5e20;
  --canvas-cloud: rgba(255,255,255,0.4);
  --footer-bg: #3a2a14;
  --footer-text: #c8d89a;
  --shadow: rgba(44, 36, 22, 0.1);
  --toggle-bg: #3a2a14;
  --toggle-text: #f5f0e6;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --bg: #1a1a12;
  --bg-alt: #242418;
  --text: #c8c0a8;
  --text-muted: #8a8068;
  --heading: #d8d0b0;
  --link: #a0c040;
  --link-hover: #c8e060;
  --accent: #7a8b3c;
  --accent-soft: #3a4420;
  --border: #3e3a2c;
  --code-bg: #2a2a1e;
  --table-stripe: #222218;
  --header-bg: #0e1408;
  --header-text: #a0c040;
  --header-glow: #c8e060;
  --canvas-sky: #1a2810;
  --canvas-ground: #2a3a14;
  --canvas-trail: #5a5030;
  --canvas-sun: #c8a830;
  --canvas-wagon: #8a7a50;
  --canvas-mountain: #2a3a18;
  --canvas-tree: #1e2e10;
  --canvas-cloud: rgba(100,120,80,0.2);
  --footer-bg: #0e1408;
  --footer-text: #a0c040;
  --shadow: rgba(0, 0, 0, 0.3);
  --toggle-bg: #a0c040;
  --toggle-text: #1a1a12;
}

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

html {
  scroll-behavior: smooth;
  font-size: 18px;
}

body {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header & Trail Scene --- */
.site-header {
  position: relative;
  background: var(--header-bg);
  overflow: hidden;
  border-bottom: 4px solid var(--accent);
}

.trail-scene {
  position: relative;
  width: 100%;
  height: 200px;
}

#trail-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.header-content {
  position: relative;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  z-index: 1;
}

.site-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: var(--header-text);
  text-shadow: 0 0 20px var(--header-glow), 0 2px 0 rgba(0,0,0,0.5);
  letter-spacing: 0.05em;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.title-pixel {
  display: inline-block;
  animation: blink 1.2s step-end infinite;
  color: var(--header-glow);
  font-size: 0.7em;
  vertical-align: middle;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.site-tagline {
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  color: var(--header-text);
  opacity: 0.8;
  letter-spacing: 0.1em;
}

.site-nav {
  margin-top: 1rem;
}

.nav-link {
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  color: var(--header-text);
  text-decoration: none;
  padding: 0.3em 1em;
  border: 2px solid var(--header-text);
  transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--header-text);
  color: var(--header-bg);
}

/* --- Theme Toggle --- */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: var(--toggle-bg);
  color: var(--toggle-text);
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 0.4em 0.6em;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: background 0.3s, color 0.3s;
}

.theme-toggle:hover {
  background: var(--accent);
  color: var(--bg);
}

[data-theme="light"] .dark-icon { display: none; }
[data-theme="dark"] .light-icon { display: none; }

/* --- Main Content --- */
.content-wrap {
  flex: 1;
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  width: 100%;
}

.page-content {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
  color: var(--heading);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 { font-size: 1.8rem; border-bottom: 3px solid var(--accent); padding-bottom: 0.4rem; }
h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.3rem; }
h3 { font-size: 1.25rem; color: var(--accent); }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1rem; }

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

strong { color: var(--heading); }

blockquote {
  border-left: 4px solid var(--accent);
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

code {
  font-family: 'VT323', 'Courier New', monospace;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.95em;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

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

hr {
  border: none;
  border-top: 2px dashed var(--border);
  margin: 2rem 0;
}

/* --- Lists --- */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

li > ul, li > ol {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

thead {
  background: var(--accent);
  color: #fff;
}

th {
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 700;
  padding: 0.6rem 0.8rem;
  text-align: left;
}

td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

tbody tr:hover {
  background: var(--accent-soft);
}

/* --- Week headings (h3) pixel marker --- */
.page-content h3::before {
  content: '> ';
  font-family: 'VT323', monospace;
  color: var(--accent);
}

/* --- Footer --- */
.site-footer {
  background: var(--footer-bg);
  border-top: 4px solid var(--accent);
  padding: 2rem 1rem;
  text-align: center;
}

.trail-message {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: var(--footer-text);
  opacity: 0.9;
  margin-bottom: 0.8rem;
  letter-spacing: 0.05em;
  animation: typewriter 2s steps(40) 0.5s both;
  overflow: hidden;
  white-space: nowrap;
  max-width: max-content;
  margin-left: auto;
  margin-right: auto;
}

@keyframes typewriter {
  from { max-width: 0; }
  to { max-width: 100%; }
}

.footer-copy {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  color: var(--footer-text);
  opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  html { font-size: 16px; }

  .site-title {
    font-size: 0.75rem;
  }

  .trail-scene {
    height: 140px;
  }

  .content-wrap {
    padding: 1.5rem 1rem 2rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.4rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .site-title {
    font-size: 0.6rem;
  }

  .trail-scene {
    height: 110px;
  }

  .trail-message {
    font-size: 0.5rem;
    white-space: normal;
    animation: none;
  }
}

/* --- Print --- */
@media print {
  .site-header, .site-footer, .theme-toggle { display: none; }
  .content-wrap { max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}
