/* ============================================================
   MedReady TCCC Learning Guide — Shared Stylesheet
   Matches index.html design system exactly
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary:        #f8f9fb;
  --bg-secondary:      #ffffff;
  --bg-card:           #ffffff;
  --bg-card-hover:     #f3f6fa;
  --accent:            #1a6bde;
  --accent-dim:        #1558b8;
  --accent-glow:       rgba(26,107,222,0.08);
  --accent-glow-strong:rgba(26,107,222,0.15);
  --text-primary:      #1a2332;
  --text-secondary:    #556373;
  --text-muted:        #8c99a8;
  --border:            #e2e7ee;
  --border-accent:     rgba(26,107,222,0.25);

  --sidebar-width:     272px;
  --topbar-height:     56px;
  --content-max:       780px;

  /* March colours */
  --m-color: #e84040;
  --a-color: #f07a2a;
  --r-color: #2a9d8f;
  --c-color: #457bc4;
  --h-color: #8b5cf6;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  /* Noise texture */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E"),
    linear-gradient(var(--bg-primary), var(--bg-primary));
}

/* ── Layout shell ──────────────────────────────────────────── */
.learn-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Topbar (mobile) ───────────────────────────────────────── */
.learn-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.learn-topbar .topbar-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1rem; color: var(--text-primary);
  text-decoration: none;
}
.learn-topbar .topbar-logo img { height: 24px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-home-btn {
  font-size: 0.8rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  padding: 5px 10px; border-radius: 6px;
  border: 1.5px solid var(--border-accent);
  transition: background 0.15s;
}
.topbar-home-btn:hover { background: var(--accent-glow); }
.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px; color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
}
.topbar-menu-btn svg { width: 22px; height: 22px; }

/* ── Sidebar ───────────────────────────────────────────────── */
.learn-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding-bottom: 32px;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text-primary);
  font-weight: 700; font-size: 1rem; margin-bottom: 4px;
}
.sidebar-logo img { height: 28px; }
.sidebar-guide-label {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-section-title {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  padding: 20px 20px 6px;
}

.sidebar-nav { list-style: none; padding: 0 8px; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar-nav a:hover {
  background: var(--accent-glow); color: var(--text-primary);
}
.sidebar-nav a.active {
  background: var(--accent-glow-strong); color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%; min-height: 16px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; font-size: 0.65rem; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-glow-strong); color: var(--accent);
  padding: 2px 6px; border-radius: 20px; letter-spacing: 0.04em;
}

.sidebar-divider {
  height: 1px; background: var(--border); margin: 12px 20px;
}

.sidebar-footer {
  margin-top: auto; padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}
.sidebar-back-link {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-decoration: none; padding: 8px 0;
  transition: color 0.15s;
}
.sidebar-back-link:hover { color: var(--accent); }
.sidebar-back-link svg { width: 14px; height: 14px; }

/* Language toggle in sidebar footer */
.sidebar-lang {
  display: flex; gap: 4px; margin-top: 12px;
}
.lang-btn {
  flex: 1; padding: 6px; border-radius: 6px; border: 1.5px solid var(--border);
  background: transparent; color: var(--text-secondary); font-size: 0.78rem;
  font-weight: 600; font-family: 'Instrument Sans', sans-serif;
  cursor: pointer; transition: all 0.15s; text-align: center;
}
.lang-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ── Main content ──────────────────────────────────────────── */
.learn-main {
  flex: 1;
  min-width: 0;
  padding: 48px 48px 80px;
}

.learn-content {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ── Page header ───────────────────────────────────────────── */
.page-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-glow); border: 1px solid var(--border-accent);
  padding: 4px 10px; border-radius: 20px; margin-bottom: 16px;
}
.page-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700; line-height: 1.2; color: var(--text-primary);
  margin-bottom: 12px;
}
.page-subtitle {
  font-size: 1.05rem; color: var(--text-secondary);
  max-width: 620px; line-height: 1.65; margin-bottom: 40px;
}
.page-header-divider {
  height: 1px; background: var(--border); margin-bottom: 40px;
}

/* ── Prose typography ──────────────────────────────────────── */
.prose h2 {
  font-size: 1.35rem; font-weight: 700; color: var(--text-primary);
  margin: 40px 0 12px;
}
.prose h3 {
  font-size: 1.05rem; font-weight: 700; color: var(--text-primary);
  margin: 28px 0 8px;
}
.prose p {
  color: var(--text-secondary); margin-bottom: 16px; line-height: 1.72;
}
.prose ul, .prose ol {
  color: var(--text-secondary); padding-left: 20px;
  margin-bottom: 16px; line-height: 1.72;
}
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em; background: var(--accent-glow);
  color: var(--accent); padding: 2px 6px; border-radius: 4px;
}
.prose blockquote {
  border-left: 3px solid var(--accent); padding: 12px 16px;
  background: var(--accent-glow); border-radius: 0 8px 8px 0;
  margin: 24px 0; color: var(--text-secondary); font-style: italic;
}

/* ── Info / warning / tip callouts ────────────────────────── */
.callout {
  display: flex; gap: 12px; padding: 16px;
  border-radius: 10px; margin: 24px 0; border: 1px solid;
}
.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; }
.callout-title { font-weight: 700; font-size: 0.875rem; margin-bottom: 4px; }
.callout-text { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }
.callout.info    { background: var(--accent-glow); border-color: var(--border-accent); }
.callout.info .callout-title { color: var(--accent); }
.callout.warning { background: rgba(240,122,42,0.08); border-color: rgba(240,122,42,0.3); }
.callout.warning .callout-title { color: #c85a00; }
.callout.danger  { background: rgba(232,64,64,0.08); border-color: rgba(232,64,64,0.3); }
.callout.danger .callout-title  { color: #c42020; }
.callout.tip     { background: rgba(42,157,143,0.08); border-color: rgba(42,157,143,0.3); }
.callout.tip .callout-title     { color: #1f7a6e; }

/* ── Cards & grids ─────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin: 24px 0;
}
.info-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.info-card:hover {
  border-color: var(--border-accent); box-shadow: 0 4px 20px var(--accent-glow);
}
.info-card-icon { font-size: 1.5rem; margin-bottom: 10px; }
.info-card-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.info-card-text  { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.55; }

/* ── Step list ─────────────────────────────────────────────── */
.step-list { list-style: none; padding: 0; margin: 24px 0; }
.step-item {
  display: flex; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.step-item:last-child { border-bottom: none; }
.step-number {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 0.85rem; font-family: 'JetBrains Mono', monospace;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-body {}
.step-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.step-text  { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* ── MARCH letter blocks ───────────────────────────────────── */
.march-block {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; margin: 24px 0;
  transition: box-shadow 0.2s;
}
.march-block:hover { box-shadow: 0 6px 32px rgba(0,0,0,0.07); }
.march-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.march-letter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem; font-weight: 700; line-height: 1;
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.march-header-text { flex: 1; }
.march-word { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.march-tagline { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.march-chevron {
  width: 20px; height: 20px; color: var(--text-muted);
  transition: transform 0.25s; flex-shrink: 0;
}
.march-block.open .march-chevron { transform: rotate(180deg); }
.march-body { padding: 24px; display: none; }
.march-block.open .march-body { display: block; }

/* M — red */
.march-block[data-letter="M"] .march-letter { background: rgba(232,64,64,0.12); color: var(--m-color); }
.march-block[data-letter="M"] .march-header { border-left: 4px solid var(--m-color); }
/* A — orange */
.march-block[data-letter="A"] .march-letter { background: rgba(240,122,42,0.12); color: var(--a-color); }
.march-block[data-letter="A"] .march-header { border-left: 4px solid var(--a-color); }
/* R — teal */
.march-block[data-letter="R"] .march-letter { background: rgba(42,157,143,0.12); color: var(--r-color); }
.march-block[data-letter="R"] .march-header { border-left: 4px solid var(--r-color); }
/* C — blue */
.march-block[data-letter="C"] .march-letter { background: rgba(69,123,196,0.12); color: var(--c-color); }
.march-block[data-letter="C"] .march-header { border-left: 4px solid var(--c-color); }
/* H — purple */
.march-block[data-letter="H"] .march-letter { background: rgba(139,92,246,0.12); color: var(--h-color); }
.march-block[data-letter="H"] .march-header { border-left: 4px solid var(--h-color); }

/* ── 9-Line field table ─────────────────────────────────────── */
.field-table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.field-table th {
  text-align: left; padding: 10px 14px; font-size: 0.78rem;
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); background: var(--bg-primary);
  border-bottom: 2px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}
.field-table td {
  padding: 12px 14px; vertical-align: top; font-size: 0.9rem;
  border-bottom: 1px solid var(--border); color: var(--text-secondary);
}
.field-table tr:last-child td { border-bottom: none; }
.field-table tr:hover td { background: var(--accent-glow); }
.field-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 0.85rem; color: var(--accent);
}
.field-name { font-weight: 600; color: var(--text-primary); }
.field-example {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem; background: var(--accent-glow);
  color: var(--accent); padding: 2px 6px; border-radius: 4px;
  display: inline-block; margin-top: 2px;
}

/* ── Mistake cards ─────────────────────────────────────────── */
.mistake-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin: 16px 0;
  border-left: 4px solid var(--m-color);
}
.mistake-card.fix { border-left-color: var(--r-color); }
.mistake-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 6px;
}
.mistake-card:not(.fix) .mistake-label { color: var(--m-color); }
.mistake-card.fix .mistake-label { color: var(--r-color); }
.mistake-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.mistake-text  { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* ── Kit item list ─────────────────────────────────────────── */
.kit-category {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 24px; margin: 16px 0;
}
.kit-category-title {
  font-weight: 700; font-size: 1rem; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.kit-items { list-style: none; padding: 0; }
.kit-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.kit-item:last-child { border-bottom: none; }
.kit-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--border); flex-shrink: 0;
  margin-top: 1px; cursor: pointer; position: relative;
  transition: all 0.15s; background: var(--bg-card);
}
.kit-check.checked {
  background: var(--accent); border-color: var(--accent);
}
.kit-check.checked::after {
  content: '';
  position: absolute; left: 4px; top: 1px;
  width: 6px; height: 10px;
  border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg);
}
.kit-item-name { font-weight: 600; color: var(--text-primary); }
.kit-item-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.kit-priority {
  margin-left: auto; font-size: 0.68rem; font-weight: 700;
  font-family: 'JetBrains Mono', monospace; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 20px; flex-shrink: 0;
}
.kit-priority.critical { background: rgba(232,64,64,0.12); color: var(--m-color); }
.kit-priority.high     { background: rgba(240,122,42,0.12); color: var(--a-color); }
.kit-priority.standard { background: var(--accent-glow);   color: var(--accent); }

/* ── Progress bar (top of page) ─────────────────────────────── */
.learn-progress {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0;
  height: 3px; background: var(--border); z-index: 100;
}
.learn-progress-bar {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 0.1s; border-radius: 0 2px 2px 0;
}

/* ── Prev/Next navigation ──────────────────────────────────── */
.page-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 32px 0 0; margin-top: 48px; border-top: 1px solid var(--border);
  gap: 16px;
}
.page-nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg-card); text-decoration: none; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 600; transition: all 0.15s;
  max-width: 260px;
}
.page-nav-btn:hover {
  border-color: var(--border-accent); color: var(--accent);
  background: var(--accent-glow); box-shadow: 0 2px 12px var(--accent-glow);
}
.page-nav-btn.next { margin-left: auto; text-align: right; flex-direction: row-reverse; }
.page-nav-label { font-size: 0.72rem; color: var(--text-muted); display: block; margin-bottom: 2px; font-weight: 500; }
.page-nav-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Pill tags ─────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 20px;
  background: var(--accent-glow); color: var(--accent);
  border: 1px solid var(--border-accent);
}

/* ── Mobile overlay ────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 150;
}
.sidebar-overlay.visible { display: block; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .learn-topbar { display: flex; }
  .learn-progress { top: var(--topbar-height); left: 0; }

  .learn-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 160; transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .learn-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.15);
  }

  .learn-main {
    padding: calc(var(--topbar-height) + 32px) 20px 80px;
    width: 100%;
  }
  .learn-content { max-width: 100%; }

  .card-grid { grid-template-columns: 1fr 1fr; }
  .field-table { font-size: 0.82rem; }
}

@media (max-width: 480px) {
  .learn-main { padding: calc(var(--topbar-height) + 24px) 16px 80px; }
  .page-title { font-size: 1.6rem; }
  .card-grid { grid-template-columns: 1fr; }
  .march-header { padding: 16px; }
  .march-letter { width: 44px; height: 44px; font-size: 1.6rem; }
  .page-nav { flex-direction: column; }
  .page-nav-btn { max-width: 100%; width: 100%; }
  .page-nav-btn.next { flex-direction: row; text-align: left; }
}
