/* Nous — Markdown element styles
 * These are the actual specs a theme author would implement.
 */

.md {
  font-family: var(--ff-serif);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--nous-ink);
  max-width: var(--measure);
}

/* Headings */
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  font-family: var(--ff-display);
  color: var(--nous-ink);
  line-height: 1.15;
  margin: 2.2em 0 0.6em;
  letter-spacing: -0.005em;
}
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }

.md h1 { font-size: 2.6em; font-weight: 400; letter-spacing: -0.015em; }
.md h2 { font-size: 1.9em; font-weight: 400; }
.md h3 { font-size: 1.45em; font-weight: 500; }
.md h4 { font-size: 1.15em; font-weight: 500; font-style: italic; color: var(--nous-ink-2); }
.md h5 { font-size: 1em; font-family: var(--ff-sc); letter-spacing: 0.18em; text-transform: uppercase; color: var(--nous-ink-3); font-weight: 500; }
.md h6 { font-size: 0.85em; font-family: var(--ff-sc); letter-spacing: 0.22em; text-transform: uppercase; color: var(--nous-ink-4); font-weight: 500; }

/* Heading numerical prefix (optional CSS counter for Obsidian/Typora) */
.md.numbered { counter-reset: h2; }
.md.numbered h2 { counter-increment: h2; counter-reset: h3; }
.md.numbered h2::before {
  content: counter(h2, upper-roman) ".  ";
  color: var(--nous-terracotta);
  font-family: var(--ff-sc);
  font-size: 0.7em;
  letter-spacing: 0.08em;
  vertical-align: 0.15em;
}
.md.numbered h3 { counter-increment: h3; }
.md.numbered h3::before {
  content: "§ " counter(h3) ".  ";
  color: var(--nous-ink-4);
  font-family: var(--ff-serif);
  font-style: italic;
  font-size: 0.8em;
}

/* Body paragraphs */
.md p {
  margin: 0 0 1em 0;
  hyphens: auto;
  text-wrap: pretty;
}

/* First-paragraph drop cap (opt-in) */
.md.dropped > p:first-of-type::first-letter,
.md .dropped::first-letter {
  font-family: var(--ff-display);
  font-weight: 400;
  font-size: 4.6em;
  line-height: 0.82;
  float: left;
  padding: 0.06em 0.12em 0 0;
  color: var(--nous-terracotta);
}

/* Links */
.md a {
  color: var(--nous-aegean);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--nous-aegean) 40%, transparent);
  transition: border-color 140ms ease, color 140ms ease;
}
.md a:hover {
  color: var(--nous-terracotta);
  border-bottom-color: var(--nous-terracotta);
}

/* Obsidian wikilinks */
.md .wikilink {
  color: var(--nous-aegean);
  border-bottom: 1px dashed color-mix(in oklab, var(--nous-aegean) 50%, transparent);
}
.md .wikilink::before { content: ""; }
.md .tag {
  color: var(--nous-olive);
  font-family: var(--ff-mono);
  font-size: 0.82em;
  padding: 1px 6px;
  border-radius: 2px;
  background: color-mix(in oklab, var(--nous-olive) 10%, transparent);
  border-bottom: 0;
}

/* Emphasis */
.md em { font-style: italic; }
.md strong { font-weight: 600; color: var(--nous-ink); }
.md del { color: var(--nous-ink-4); }
.md mark {
  background: color-mix(in oklab, var(--nous-ochre) 25%, transparent);
  color: inherit;
  padding: 0 2px;
}

/* Blockquote */
.md blockquote {
  margin: 1.6em 0;
  padding: 0.2em 0 0.2em 1.6em;
  border-left: 2px solid var(--nous-terracotta);
  font-family: var(--ff-display);
  font-style: italic;
  font-size: 1.12em;
  line-height: 1.55;
  color: var(--nous-ink-2);
  position: relative;
}
.md blockquote::before {
  content: "\201C";
  position: absolute;
  left: 0.15em;
  top: -0.15em;
  font-family: var(--ff-display);
  font-size: 2.4em;
  line-height: 1;
  color: var(--nous-terracotta);
  opacity: 0.35;
}
.md blockquote p { margin: 0 0 0.4em; }
.md blockquote p:last-child { margin-bottom: 0; }
.md blockquote cite, .md blockquote footer {
  display: block;
  margin-top: 0.6em;
  font-family: var(--ff-sc);
  font-size: 0.78em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--nous-ink-3);
  font-style: normal;
}
.md blockquote cite::before { content: "— "; color: var(--nous-ink-4); }

/* Lists */
.md ul, .md ol { padding-left: 1.6em; margin: 0.8em 0 1.2em; }
.md li { margin: 0.3em 0; }
.md ul > li::marker { color: var(--nous-terracotta); content: "· "; }
.md ul > li { list-style: none; position: relative; }
.md ul > li::before {
  content: "·";
  position: absolute;
  left: -1em;
  color: var(--nous-terracotta);
  font-weight: 700;
}
.md ol { list-style: none; counter-reset: ol; }
.md ol > li { counter-increment: ol; position: relative; }
.md ol > li::before {
  content: counter(ol) ".";
  position: absolute;
  left: -1.8em;
  color: var(--nous-ink-4);
  font-family: var(--ff-sc);
  font-feature-settings: "onum";
}

/* Task list */
.md .task { list-style: none; padding-left: 0; }
.md .task li {
  position: relative;
  padding-left: 1.8em;
}
.md .task li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.32em;
  width: 14px; height: 14px;
  border: 1px solid var(--nous-ink-3);
  border-radius: 2px;
  background: transparent;
}
.md .task li.done { color: var(--nous-ink-3); text-decoration: line-through; text-decoration-color: var(--nous-ink-4); }
.md .task li.done::before {
  background: var(--nous-ink-2);
  border-color: var(--nous-ink-2);
}
.md .task li.done::after {
  content: "";
  position: absolute;
  left: 3px; top: 0.5em;
  width: 8px; height: 4px;
  border-left: 1.5px solid var(--nous-paper);
  border-bottom: 1.5px solid var(--nous-paper);
  transform: rotate(-45deg);
}

/* Code */
.md code, .md kbd {
  font-family: var(--ff-mono);
  font-size: 0.86em;
}
.md :not(pre) > code {
  background: color-mix(in oklab, var(--nous-ink) 5%, transparent);
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--nous-wine);
  border: 1px solid color-mix(in oklab, var(--nous-ink) 6%, transparent);
}
[data-mode="dark"] .md :not(pre) > code {
  background: color-mix(in oklab, var(--nous-ink) 8%, transparent);
  color: var(--nous-terracotta);
}
.md kbd {
  padding: 1px 6px;
  border: 1px solid var(--nous-rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-size: 0.78em;
  background: var(--nous-paper-2);
}

.md pre {
  background: var(--syn-bg);
  color: var(--syn-fg);
  padding: 1.2em 1.4em;
  border-radius: 2px;
  border: 1px solid var(--nous-rule-soft);
  border-left: 2px solid var(--nous-aegean);
  overflow-x: auto;
  font-size: 0.82em;
  line-height: 1.7;
  margin: 1.4em 0;
  position: relative;
}
.md pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--ff-sc);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--nous-ink-4);
}
.md pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: 0;
}

/* Syntax tokens */
.tok-c  { color: var(--syn-comment); font-style: italic; }
.tok-k  { color: var(--syn-keyword); }
.tok-s  { color: var(--syn-string); }
.tok-n  { color: var(--syn-number); }
.tok-f  { color: var(--syn-func); }
.tok-p  { color: var(--syn-punct); }
.tok-v  { color: var(--syn-fg); }

/* Tables */
.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.94em;
  font-variant-numeric: oldstyle-nums tabular-nums;
}
.md thead th {
  text-align: left;
  font-family: var(--ff-sc);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--nous-ink-3);
  font-weight: 500;
  padding: 10px 12px 10px 0;
  border-bottom: 1.5px solid var(--nous-ink-2);
}
.md tbody td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--nous-rule-soft);
  vertical-align: top;
}
.md tbody tr:last-child td { border-bottom: 1.5px solid var(--nous-ink-2); }

/* HR */
.md hr {
  border: 0;
  height: 16px;
  margin: 2.4em auto;
  width: 64px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='16' viewBox='0 0 64 16'><g fill='%239a9081'><circle cx='8' cy='8' r='1.4'/><circle cx='32' cy='8' r='1.8'/><circle cx='56' cy='8' r='1.4'/></g></svg>");
  background-repeat: no-repeat;
  background-position: center;
}
[data-mode="dark"] .md hr {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='16' viewBox='0 0 64 16'><g fill='%235e5844'><circle cx='8' cy='8' r='1.4'/><circle cx='32' cy='8' r='1.8'/><circle cx='56' cy='8' r='1.4'/></g></svg>");
}

/* Footnotes */
.md .fn-ref {
  font-feature-settings: "sups";
  font-size: 0.72em;
  vertical-align: super;
  color: var(--nous-terracotta);
  margin-left: 1px;
}
.md .footnotes {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--nous-rule);
  font-size: 0.88em;
  color: var(--nous-ink-2);
}
.md .footnotes ol { padding-left: 1.4em; }
.md .footnotes li { margin: 0.5em 0; font-family: var(--ff-serif); }

/* Callouts / Admonition */
.callout {
  margin: 1.6em 0;
  padding: 1em 1.2em 1em 1.4em;
  border-left: 2px solid var(--nous-ink-3);
  background: color-mix(in oklab, var(--nous-ink) 3%, transparent);
  border-radius: 0 2px 2px 0;
  font-size: 0.96em;
}
.callout__title {
  font-family: var(--ff-sc);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--nous-ink-3);
  margin: 0 0 0.3em 0;
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.callout__title::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  background: currentColor;
  transform: rotate(45deg);
}
.callout p:last-child { margin-bottom: 0; }

.callout--note     { border-color: var(--nous-aegean);     color: var(--nous-ink); }
.callout--note     .callout__title { color: var(--nous-aegean); }
.callout--warn     { border-color: var(--nous-terracotta); }
.callout--warn     .callout__title { color: var(--nous-terracotta); }
.callout--quote    { border-color: var(--nous-wine); }
.callout--quote    .callout__title { color: var(--nous-wine); }
.callout--aside    { border-color: var(--nous-olive); }
.callout--aside    .callout__title { color: var(--nous-olive); }
.callout--question { border-color: var(--nous-ochre); }
.callout--question .callout__title { color: var(--nous-ochre); }

/* Math (LaTeX) */
.md .math-block {
  margin: 1.4em 0;
  padding: 0.6em 0;
  font-family: 'Cormorant Garamond', 'Latin Modern Math', serif;
  font-size: 1.15em;
  text-align: center;
  color: var(--nous-ink);
  font-style: italic;
  line-height: 1.6;
}
.md .math-block .eq-num {
  float: right;
  font-family: var(--ff-sc);
  font-style: normal;
  font-size: 0.7em;
  color: var(--nous-ink-4);
  letter-spacing: 0.1em;
}
.md .math-inline {
  font-family: 'Cormorant Garamond', 'Latin Modern Math', serif;
  font-style: italic;
  font-size: 1.05em;
}

/* Image / figure */
.md figure { margin: 1.6em 0; }
.md figure img,
.md figure .placeholder {
  width: 100%;
  display: block;
  border: 1px solid var(--nous-rule);
}
.md figure .placeholder {
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(135deg,
      color-mix(in oklab, var(--nous-ink) 5%, transparent) 0 1px,
      transparent 1px 10px),
    var(--nous-paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--nous-ink-4);
}
.md figcaption {
  font-family: var(--ff-serif);
  font-style: italic;
  font-size: 0.88em;
  color: var(--nous-ink-3);
  text-align: center;
  margin-top: 0.6em;
}
.md figcaption::before { content: "Fig. "; font-family: var(--ff-sc); font-style: normal; letter-spacing: 0.15em; font-size: 0.85em; }
