/* css/markdown.css
   Applied via .md-content class on any element that renders markdown.
   Designed to match the StudyAI navy + white design system.
*/

/* ----------------------------------------------------------------
   Base typography
---------------------------------------------------------------- */
.md-content {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--text-2);
  word-break: break-word;
}

.md-content > *:first-child { margin-top: 0 !important; }
.md-content > *:last-child  { margin-bottom: 0 !important; }

/* ----------------------------------------------------------------
   Headings
---------------------------------------------------------------- */
.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
  font-family: 'Bricolage Grotesque', sans-serif;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 1.4em 0 0.5em;
  font-weight: 800;
}
.md-content h1 { font-size: 1.25rem; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
.md-content h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.md-content h3 { font-size: 0.97rem; color: var(--accent); }
.md-content h4 { font-size: 0.88rem; color: var(--text); font-weight: 700; }
.md-content h5 { font-size: 0.83rem; font-weight: 700; }
.md-content h6 { font-size: 0.8rem;  font-weight: 700; color: var(--text-3); }

/* ----------------------------------------------------------------
   Paragraphs
---------------------------------------------------------------- */
.md-content p {
  margin: 0.75em 0;
  line-height: 1.8;
}

/* ----------------------------------------------------------------
   Bold / Italic / Strikethrough
---------------------------------------------------------------- */
.md-content strong { font-weight: 800; color: var(--text); }
.md-content em     { font-style: italic; color: var(--text-2); }
.md-content del    { text-decoration: line-through; color: var(--text-3); }

/* ----------------------------------------------------------------
   Inline code
---------------------------------------------------------------- */
.md-content code {
  font-size: 0.82em;
  font-family: 'Courier New', 'Consolas', monospace;
  background: rgba(10, 31, 78, 0.07);
  color: #1e40af;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(10, 31, 78, 0.1);
  white-space: nowrap;
}

/* ----------------------------------------------------------------
   Code blocks
---------------------------------------------------------------- */
.md-content pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.82em;
  line-height: 1.65;
  border: 1px solid rgba(255,255,255,0.06);
}
.md-content pre code {
  background: none;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}
/* Syntax highlight hints */
.md-content pre .keyword  { color: #93c5fd; }
.md-content pre .string   { color: #86efac; }
.md-content pre .comment  { color: #64748b; font-style: italic; }
.md-content pre .number   { color: #fbbf24; }

/* ----------------------------------------------------------------
   Blockquotes
---------------------------------------------------------------- */
.md-content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-muted);
  border-radius: 0 10px 10px 0;
  padding: 10px 16px;
  margin: 1em 0;
  color: var(--text-2);
  font-style: italic;
}
.md-content blockquote > p { margin: 0; }
.md-content blockquote strong { color: var(--accent); }

/* ----------------------------------------------------------------
   Unordered lists
---------------------------------------------------------------- */
.md-content ul {
  list-style: none;
  padding: 0;
  margin: 0.75em 0;
}
.md-content ul li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 3px 0;
  line-height: 1.7;
}
.md-content ul li::before {
  content: '›';
  color: var(--accent);
  font-weight: 900;
  font-size: 1.1em;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1.6;
}
/* Nested lists */
.md-content ul ul {
  padding-left: 16px;
  margin: 4px 0;
}
.md-content ul ul li::before {
  content: '–';
  color: var(--text-3);
  font-size: 0.9em;
}

/* ----------------------------------------------------------------
   Ordered lists
---------------------------------------------------------------- */
.md-content ol {
  list-style: none;
  padding: 0;
  margin: 0.75em 0;
  counter-reset: ol-counter;
}
.md-content ol li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  line-height: 1.7;
  counter-increment: ol-counter;
}
.md-content ol li::before {
  content: counter(ol-counter);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 3px;
}
.md-content ol ol {
  padding-left: 16px;
  margin: 4px 0;
}

/* Task lists (- [ ] / - [x]) */
.md-content ul li input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 4px;
  accent-color: var(--accent);
}
.md-content ul li:has(input[type="checkbox"])::before {
  display: none;
}

/* ----------------------------------------------------------------
   Tables
---------------------------------------------------------------- */
.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.83rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.md-content thead {
  background: var(--navy);
  color: #e2e8f0;
}
.md-content thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.md-content thead th:last-child { border-right: none; }
.md-content tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.md-content tbody tr:last-child { border-bottom: none; }
.md-content tbody tr:nth-child(even) { background: var(--bg-off, #f8f9fc); }
.md-content tbody tr:hover { background: var(--accent-muted); }
.md-content tbody td {
  padding: 9px 14px;
  vertical-align: top;
  border-right: 1px solid var(--border-light);
  line-height: 1.6;
}
.md-content tbody td:last-child { border-right: none; }

/* Column alignment */
.md-content table th[align="center"],
.md-content table td[align="center"] { text-align: center; }
.md-content table th[align="right"],
.md-content table td[align="right"]  { text-align: right; }

/* ----------------------------------------------------------------
   Horizontal rule
---------------------------------------------------------------- */
.md-content hr {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 1.5em 0;
}

/* ----------------------------------------------------------------
   Links
---------------------------------------------------------------- */
.md-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.md-content a:hover { opacity: 0.75; }

/* ----------------------------------------------------------------
   Images
---------------------------------------------------------------- */
.md-content img {
  max-width: 100%;
  border-radius: 10px;
  margin: 0.5em 0;
}

/* ----------------------------------------------------------------
   Definition lists (if supported)
---------------------------------------------------------------- */
.md-content dl { margin: 0.75em 0; }
.md-content dt { font-weight: 800; color: var(--text); margin-top: 10px; }
.md-content dd { margin-left: 20px; color: var(--text-2); margin-top: 2px; }

/* ----------------------------------------------------------------
   Keyboard keys
---------------------------------------------------------------- */
.md-content kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 0.75em;
  font-family: monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
}

/* ----------------------------------------------------------------
   Mark / Highlight
---------------------------------------------------------------- */
.md-content mark {
  background: #fef9c3;
  color: #713f12;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ----------------------------------------------------------------
   Superscript / Subscript
---------------------------------------------------------------- */
.md-content sup { font-size: 0.7em; vertical-align: super; }
.md-content sub { font-size: 0.7em; vertical-align: sub; }

/* ----------------------------------------------------------------
   Chat bubble override (user messages are dark)
---------------------------------------------------------------- */
.msg.user .md-content { color: rgba(255,255,255,0.92); }
.msg.user .md-content code { background: rgba(255,255,255,0.15); color: #bfdbfe; border-color: rgba(255,255,255,0.2); }
.msg.user .md-content strong { color: #fff; }
.msg.user .md-content ul li::before { color: #93c5fd; }
.msg.user .md-content ol li::before { background: rgba(255,255,255,0.25); color: #fff; }
.msg.user .md-content a { color: #bfdbfe; }
.msg.user .md-content blockquote { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
.msg.user .md-content pre { background: rgba(0,0,0,0.3); }
.msg.user .md-content h1,
.msg.user .md-content h2,
.msg.user .md-content h3,
.msg.user .md-content h4 { color: #fff; border-color: rgba(255,255,255,0.2); }

/* ----------------------------------------------------------------
   Note cards override (white background context)
---------------------------------------------------------------- */
.note-card .md-content { font-size: 0.83rem; }
.note-card .md-content h3 { font-size: 0.9rem; }

/* ----------------------------------------------------------------
   Summary card override
---------------------------------------------------------------- */
.sum-overview.md-content {
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.8;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
