/* ===== Variables ===== */
:root {
  --bg-page: #1E1E1E;
  --bg-surface: #2A2A2A;
  --text-main: #CFCFCF;
  --text-dim: #8A8A8A;
  --border-color: #3A3A3A;
  --accent: #66A182;
  --accent-hover: #7fb595;
  --radius-card: 0.5rem;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "Fira Code", monospace;
  --page-max-width: 1400px;
}

/* ===== General ===== */
body {
  margin: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}
.site-header-inner {
  max-width: var(--page-max-width);
  margin: auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== Botón Índice en la barra superior ===== */
.index-nav-btn {
  margin-left: 1rem;
  background: var(--accent);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-card);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s ease;
}
.index-nav-btn:hover {
  background: var(--accent-hover);
}

.site-brand {
  text-decoration: none;
  font-weight: 600;
  color: var(--text-main);
}
.site-brand span[aria-hidden="true"] {
  color: var(--accent);
}
.site-nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1rem;
}
.site-nav a {
  text-decoration: none;
  color: var(--text-main);
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Layout ===== */
.page-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  max-width: var(--page-max-width);
  margin: auto;
  padding: 2rem 1rem;
}

/* ===== Sidebar ocultable ===== */
.page-shell {
  display: flex;
  gap: 2rem;
  max-width: var(--page-max-width);
  margin: auto;
  padding: 2rem 1rem;
  transition: all 0.3s ease;
}

.sidebar {
  flex: 0 1 auto;
  width: fit-content;
  min-width: 220px;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1rem;
  overflow-y: auto;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.sidebar.collapsing {
  transition: all 0.3s ease;
  transform: translateX(-110%);
  opacity: 0;
}
.sidebar.hidden {
  display: none;
}

.content {
  flex: 1;
  transition: width 0.3s ease;
}

/* ===== Árbol tipo Obsidian ===== */
.tree-nav ul {
  list-style: none;
  margin: 0;
  padding-left: 1rem;
}
.tree-nav li {
  list-style: none;
  margin: 0.1rem 0;
}
.tree-nav summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-main);
  padding-left: 1rem;
  position: relative;
  list-style: none;
}
.tree-nav summary:hover {
  color: var(--accent);
}
.tree-nav summary::marker {
  display: none;
}
.tree-nav summary::before {
  content: "▶";
  position: absolute;
  left: 0;
  top: 0.15rem;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: var(--text-dim);
}
.tree-nav details[open] > summary::before {
  transform: rotate(90deg);
  color: var(--accent);
}
.tree-nav details {
  border-left: none;
  margin-left: .4rem;
  padding-left: .5rem;
}

.tree-nav a.tree-link {
  display: block;
  padding: .15rem 0 .15rem 1rem;
  color: var(--accent);
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
}

/* Height limit */
.tree-nav a.tree-link {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tree-nav a.tree-link:hover {
  text-decoration: underline;
}

/* ===== Botón Índice ===== */
.index-toggle {
  position: fixed;
  top: 5rem;
  left: 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-card);
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 100;
  transition: background 0.2s ease;
}
.index-toggle:hover {
  background: var(--accent-hover);
}

/* ===== Cards ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  color: var(--text-dim);
  font-size: .8rem;
  padding: 2rem 1rem 4rem;
  text-align: center;
}
.site-footer pre.ascii {
  font-family: var(--font-mono);
  font-size: .6rem;
  color: var(--text-dim);
}

/* ===== MARKDOWN BODY ===== */
.markdown-body {
  font-family: system-ui, sans-serif;
  line-height: 1.6;
  padding: 2rem;
  color: #ddd;
  background-color: #1e1e1e;
  border-radius: 10px;
  max-width: 900px;
  margin: 0 auto;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  color: #fff;
  border-bottom: 1px solid #333;
  padding-bottom: 0.3em;
}

.markdown-body a {
  color: #79b8ff;
  text-decoration: none;
}
.markdown-body a:hover {
  text-decoration: underline;
}

/* === BLOQUES DE CÓDIGO === */
.markdown-body pre {
  background: #2d2d2d;
  padding: 1em;
  border-radius: 8px;
  overflow-x: auto;
}

.markdown-body pre code {
  background: transparent !important;
  padding: 0;
  font-family: 'Fira Code', monospace;
}

/* === INLINE CODE (FIX) === */
.markdown-body code {
  background: #2d2d2d;
  padding: 0.25em 0.45em;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  white-space: pre-wrap; /* FIX: código inline largo dentro de listas */
}

/* === LISTAS (FIX COMPLETO) === */
.markdown-body ol,
.markdown-body ul {
  padding-left: 1.6em;
  margin-top: 0.6em;
  margin-bottom: 0.6em;
}

.markdown-body li {
  margin: 0.4em 0;
}

.markdown-body li > p {
  margin: 0.25em 0; /* evita dobles saltos */
}

.markdown-body li pre {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

/* === BLOCKQUOTE === */
.markdown-body blockquote {
  border-left: 4px solid #555;
  padding-left: 1em;
  color: #aaa;
  font-style: italic;
}

/* === TABLAS === */
.markdown-body table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
}
.markdown-body th, .markdown-body td {
  border: 1px solid #444;
  padding: 0.5em;
}

/* === IMÁGENES === */
.markdown-body img {
  display: block;
  margin: 1em auto;
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

/* === INDICE === */
.tree-nav a.tree-link.current-page {
  background-color: rgba(102,161,130,0.15);
  color: var(--accent);
  border-radius: 4px;
  padding-left: 1rem;
  font-weight: 600;
}

/* ===== Botón Índice estilo enlace ===== */
.site-left { display: flex; align-items: center; gap: 1rem; }

.site-link { 
  text-decoration: none; 
  color: var(--text-main); 
  font-weight: 500;
  border-bottom: 2px solid transparent; 
  transition: color 0.2s ease, border-color 0.2s ease; 
}

.site-link:hover { 
  color: var(--accent);
  border-color: var(--accent);
}

.site-link.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Full width ===== */
.page-shell.full-width .content,
.page-shell.full-width .markdown-body {
  margin: 0 auto;
  max-width: 1000px;
  flex: 1 1 100%;
  transition: all 0.3s ease;
}

.page-shell.full-width {
  justify-content: center;
}

.page-shell.full-width .markdown-body {
  max-width: 1100px;
  padding: 2rem 3rem;
}

/* ===== Sidebar ===== */
.page-shell {
  align-items: flex-start;
}

.sidebar {
  height: auto;
  max-height: 90vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ===== Navegación entre notas ===== */
.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.nav-buttons button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.nav-buttons button:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  word-break: break-word;
}

/* ======= Árbol tipo Obsidian mejorado ======= */
.tree-nav {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
}

.tree-nav details {
  border-left: none;
  margin-left: 0.6rem;
  padding-left: 0.8rem;
}

.tree-nav summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  list-style: none;
  position: relative;
  margin: 0.3rem 0;
  user-select: none;
  display: flex;
  align-items: center;
}

.tree-nav summary::marker {
  display: none;
}

.tree-nav summary::before {
  content: "▶";
  position: absolute;
  left: -1rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.tree-nav details[open] > summary::before {
  transform: rotate(90deg);
  color: var(--accent);
}

/* ===== Links ===== */
.tree-nav .tree-children {
  margin-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tree-nav a.tree-leaf {
  display: block;
  color: var(--accent);
  text-decoration: none;
  padding: 0.15rem 0.3rem;
  margin-left: 0.8rem;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
  word-wrap: break-word;
}

.tree-nav a.tree-leaf:hover {
  background: rgba(102, 161, 130, 0.1);
  text-decoration: underline;
}

.tree-nav a.tree-leaf.current-page {
  background-color: rgba(102, 161, 130, 0.2);
  color: var(--accent);
  font-weight: 700;
}

.tree-dir {
  margin-bottom: 0.4rem;
}

.tree-nav a.tree-leaf + a.tree-leaf {
  margin-top: 0.15rem;
}

/* ===== Buscador ===== */
.search-container {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 2rem 0;
}

.site-search {
  display: flex;
  align-items: center;
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.site-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  outline: none;
}

.site-search-input::placeholder {
  color: var(--text-dim);
  opacity: 0.8;
}

.site-search-button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.site-search-button:hover,
.site-search-button:focus {
  color: var(--accent);
}

.site-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(102, 161, 130, 0.3);
}

/* Responsivo */
@media (max-width: 700px) {
  .search-container {
    justify-content: center;
    padding: 0.75rem 1rem 0;
  }

  .site-search {
    width: 100%;
    max-width: 400px;
  }

  .site-search-input {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
  }
}

/* ===== Resultados ===== */
.search-content {
  padding-bottom: 3rem;
}

.results-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  margin: 2rem auto;
  width: min(90%, 800px);
}

.search-result-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1.2rem 1.5rem;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-result-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.search-result-card h3 {
  margin-top: 0;
}

.search-result-card a {
  text-decoration: none;
  color: var(--text-main);
}

.search-result-card a:hover {
  color: var(--accent);
}

.search-result-card .breadcrumb {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.search-result-card .snippet {
  line-height: 1.5;
}

.search-result-card .snippet mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.search-result-card .extra {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.8rem;
}

/* ===== Resaltado uniforme ===== */
mark {
  background-color: rgba(102, 161, 130, 0.25);
  color: #66a182;
  font-weight: 600;
  padding: 1px 3px;
  border-radius: 3px;
  text-shadow: none;
}

.search-result-card mark,
.content mark {
  background-color: rgba(102, 161, 130, 0.25) !important;
  color: #66a182 !important;
  font-weight: 600 !important;
}

/* ===== Últimos apuntes ===== */
#latest-posts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.latest-note {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.latest-note:hover {
  background: rgba(102, 161, 130, 0.08);
  border-color: var(--accent);
  transform: scale(1.01);
}

.latest-note-title {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.4rem;
}

.latest-note-title:hover {
  text-decoration: underline;
}

.latest-note-date {
  display: block;
  font-size: 0.85em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.latest-note-preview {
  font-size: 0.9em;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

/* ===== Sobre mí ===== */
.about-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.about-summary-content {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.about-summary-avatar {
  flex: 0 0 auto;
  border-radius: 50%;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 2px solid var(--border-color);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.about-summary-text h3 {
  margin: 0 0 0.4rem 0;
}

.about-summary-text p {
  margin: 0.25rem 0;
  color: var(--text-main);
}

.about-summary-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.about-summary-link:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}

.about-summary a {
  color: var(--accent);
  text-decoration: none;
}

.about-summary a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 700px) {
  .about-summary-content {
    flex-direction: column;
    text-align: center;
  }
  .about-summary-avatar {
    margin-bottom: 0.75rem;
  }
}

/* Callouts */
.callout {
  position: relative;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  margin: 1.4em 0;
  padding: 0.9em 1.2em 0.9em 2.8em;
  background: rgba(255, 255, 255, 0.04);
  color: #d6d6d6;
  font-weight: 500;
  line-height: 1.55;
  transition: background 0.2s ease;
}

.callout::before {
  content: "";
  position: absolute;
  top: 1.05em;
  left: 1em;
  width: 18px;
  height: 18px;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  background-color: currentColor;
  opacity: 0.9;
}

.callout-title {
  font-weight: 600;
  margin-bottom: 0.25em;
  color: inherit;
}

.callout-body {
  color: #c8c8c8;
}

/* Info */
.callout-info {
  --accent: #4589ff;
  background: rgba(69, 137, 255, 0.08);
  color: #a9c6ff;
}
.callout-info::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><circle cx='12' cy='12' r='9'/><path d='M12 16v-4M12 8h.01'/></svg>");
}

/* Note */
.callout-note {
  --accent: #5ac1ff;
  background: rgba(90, 193, 255, 0.08);
  color: #a8daff;
}
.callout-note::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><circle cx='12' cy='12' r='9'/><path d='M9 12h6'/></svg>");
}

/* Tip */
.callout-tip,
.callout-success {
  --accent: #2ecc71;
  background: rgba(46, 204, 113, 0.08);
  color: #9deabf;
}
.callout-tip::before,
.callout-success::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/></svg>");
}

/* Important */
.callout-important {
  --accent: #ffb74d;
  background: rgba(255, 183, 77, 0.08);
  color: #ffdca1;
}
.callout-important::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path d='M12 9v4m0 4h.01M5.07 19h13.86a2 2 0 0 0 1.73-3L13.73 4a2 2 0 0 0-3.46 0L3.34 16a2 2 0 0 0 1.73 3z'/></svg>");
}

/* Warning */
.callout-warning,
.callout-caution {
  --accent: #e8a32b;
  background: rgba(232, 163, 43, 0.08);
  color: #ffdc99;
}
.callout-warning::before,
.callout-caution::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' d='M12 9v4m0 4h.01M10.29 3.86L1.82 18a1 1 0 0 0 .86 1.5h18.64a1 1 0 0 0 .86-1.5L13.71 3.86a1 1 0 0 0-1.72 0z'/></svg>");
}

/* Danger */
.callout-danger,
.callout-failure {
  --accent: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
  color: #f3b2aa;
}
.callout-danger::before,
.callout-failure::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' d='M18 6L6 18M6 6l12 12'/></svg>");
}

/* Question */
.callout-question {
  --accent: #ff9800;
  background: rgba(255, 152, 0, 0.08);
  color: #ffd699;
}
.callout-question::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path stroke-linecap='round' stroke-linejoin='round' d='M12 8c-1.657 0-3 1.343-3 3h1a2 2 0 1 1 4 0c0 2-3 2-3 4h1m0 3h.01M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z'/></svg>");
}

/* Example */
.callout-example {
  --accent: #9370db;
  background: rgba(147, 112, 219, 0.08);
  color: #cdb5ff;
}
.callout-example::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path d='M4 6h16M4 12h16M4 18h7'/></svg>");
}

/* Quote */
.callout-quote {
  --accent: #9e9e9e;
  background: rgba(255, 255, 255, 0.03);
  color: #bcbcbc;
}
.callout-quote::before {
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2' viewBox='0 0 24 24'><path d='M7 9h4v4H7zm6 0h4v4h-4z'/></svg>");
}

.sidebar-link.current-page {
  background-color: rgba(102, 161, 130, 0.2);
  color: var(--accent);
  font-weight: 600;
  border-radius: 4px;
}
.md-img img {
  display: block;
  margin: 0.5rem auto;
  max-width: 100%;
  border-radius: 8px;
}
/* ============================
   Obsidian-like Ordered Lists
   ============================ */

.olist-item {
  position: relative;
  padding-left: 2rem;
  margin: 0.4rem 0;
}

.olist-item::before {
  content: attr(data-number) ".";
  position: absolute;
  left: 0;
  color: var(--text-dim);
  font-weight: 600;
}

.olist-level {
  margin-left: 1.2rem;
}


/* ============================
   Obsidian-like Unordered Lists
   ============================ */

.ulist-item {
  position: relative;
  padding-left: 1.4rem;
  margin: 0.3rem 0;
}

.ulist-item::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--text-dim);
}

