/* ==========================================================
   UNLu / DCB — Sistemas Distribuidos y Programación Paralela
   Branding aligned with pptx-unlu palette
   ========================================================== */

:root {
  --navy: #1E3A5F;
  --dark-blue: #2C5282;
  --mid-blue: #3182CE;
  --light-blue: #EBF4FF;
  --white: #FFFFFF;
  --off-white: #F7FAFC;
  --gray: #718096;
  --dark-gray: #2D3748;
  --light-gray: #E2E8F0;
  --accent: #E53E3E;
  --green: #38A169;
  --orange: #DD6B20;
  --purple: #805AD5;

  --content-max: 880px;
  --sidebar-w: 280px;
  --header-h: 96px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--dark-gray);
  background: var(--off-white);
  -webkit-font-smoothing: antialiased;
}

/* ============ HEADER ============ */
.unlu-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--dark-blue) 100%);
  color: var(--white);
  border-bottom: 4px solid var(--mid-blue);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(30, 58, 95, 0.18);
}

.unlu-header .brand {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 32px 10px;
  max-width: 1400px;
  margin: 0 auto;
}

.unlu-header .brand-link,
.unlu-header .course-bar-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.unlu-header .brand-link:hover {
  background: rgba(255, 255, 255, 0.04);
}

.unlu-header .course-bar-link:hover {
  background: rgba(0, 0, 0, 0.32);
}

.unlu-header .brand .logo {
  height: 56px;
  width: auto;
  flex-shrink: 0;
}

.unlu-header .brand .logo.unlu { height: 60px; }
.unlu-header .brand .logo.dcb  { height: 50px; }

.unlu-header .brand-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.unlu-header .institution {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.unlu-header .department {
  font-size: 13px;
  font-weight: 400;
  color: var(--light-blue);
  letter-spacing: 0.5px;
}

.unlu-header .course-bar {
  background: rgba(0, 0, 0, 0.22);
  padding: 8px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13px;
  max-width: 1400px;
  margin: 0 auto;
}

.unlu-header .course-bar .course {
  font-weight: 600;
  color: var(--white);
}

.unlu-header .course-bar .year {
  background: var(--mid-blue);
  color: var(--white);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.unlu-header .course-bar .instructor {
  color: var(--light-blue);
  margin-left: auto;
}

/* ============ LAYOUT ============ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
}

/* ============ SIDEBAR / TOC ============ */
.toc-sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 18px 24px 28px;
  border-right: 1px solid var(--light-gray);
  background: var(--white);
  font-size: 14px;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--mid-blue);
}

.toc-sidebar ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-sidebar ul ul {
  padding-left: 14px;
  margin-top: 4px;
  border-left: 2px solid var(--light-gray);
}

.toc-sidebar li {
  margin: 4px 0;
}

.toc-sidebar a {
  color: var(--dark-gray);
  text-decoration: none;
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  font-size: 13px;
  line-height: 1.4;
}

.toc-sidebar a:hover {
  background: var(--light-blue);
  color: var(--navy);
}

.toc-sidebar > ul > li > a {
  font-weight: 600;
  color: var(--navy);
}

/* ============ MAIN CONTENT ============ */
.content {
  padding: 40px 56px 80px;
  max-width: calc(var(--content-max) + 112px);
  background: var(--white);
  min-height: calc(100vh - var(--header-h));
}

.content > h1:first-child {
  margin-top: 0;
}

/* ============ TYPOGRAPHY ============ */
h1, h2, h3, h4, h5, h6 {
  color: var(--navy);
  font-weight: 700;
  line-height: 1.3;
  scroll-margin-top: calc(var(--header-h) + 20px);
}

h1 {
  font-size: 32px;
  border-bottom: 3px solid var(--mid-blue);
  padding-bottom: 12px;
  margin: 0 0 24px;
}

h2 {
  font-size: 24px;
  margin: 40px 0 16px;
  padding-left: 14px;
  border-left: 5px solid var(--mid-blue);
}

h3 {
  font-size: 19px;
  margin: 32px 0 12px;
  color: var(--dark-blue);
}

h4 {
  font-size: 16px;
  margin: 24px 0 10px;
  color: var(--dark-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

p {
  margin: 12px 0;
}

strong { color: var(--navy); font-weight: 700; }

a {
  color: var(--mid-blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

a:hover { border-bottom-color: var(--mid-blue); }

/* ============ LISTS ============ */
ul, ol { padding-left: 24px; margin: 12px 0; }
li { margin: 6px 0; }
li > p { margin: 4px 0; }

ul li::marker { color: var(--mid-blue); }
ol li::marker { color: var(--navy); font-weight: 700; }

/* ============ CODE ============ */
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--light-blue);
  color: var(--navy);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--light-gray);
}

pre {
  background: #1A1A2E;
  color: #E2E8F0;
  padding: 18px 22px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
  border-left: 4px solid var(--mid-blue);
  margin: 18px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* Pandoc highlight (skylighting / tango-ish) overrides for dark bg */
pre.sourceCode { background: #1A1A2E; }
code.sourceCode > span { color: #E2E8F0; }
.sourceCode .kw { color: #FF79C6; }   /* keywords */
.sourceCode .dt { color: #8BE9FD; }   /* data types */
.sourceCode .st { color: #F1FA8C; }   /* strings */
.sourceCode .co { color: #6272A4; font-style: italic; }
.sourceCode .dv, .sourceCode .fl { color: #BD93F9; }
.sourceCode .fu { color: #50FA7B; }   /* functions */
.sourceCode .op { color: #FF79C6; }
.sourceCode .va { color: #F8F8F2; }
.sourceCode .cf { color: #FF79C6; }   /* control flow */
.sourceCode .bu { color: #8BE9FD; }   /* built-in */
.sourceCode .at { color: #50FA7B; }
.sourceCode .er { color: #FF5555; }

/* ============ TABLES ============ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-radius: 6px;
  overflow: hidden;
}

th {
  background: var(--navy);
  color: var(--white);
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--light-gray);
  vertical-align: top;
}

tr:nth-child(even) td { background: var(--off-white); }
tr:hover td { background: var(--light-blue); }

/* ============ BLOCKQUOTE ============ */
blockquote {
  margin: 18px 0;
  padding: 14px 22px;
  background: var(--light-blue);
  border-left: 5px solid var(--mid-blue);
  color: var(--dark-gray);
  border-radius: 0 6px 6px 0;
}

blockquote p { margin: 6px 0; }

/* ============ HORIZONTAL RULES ============ */
hr {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--mid-blue), transparent);
  margin: 36px 0;
}

/* ============ IMAGES ============ */
img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ============ FOOTER ============ */
.unlu-footer {
  background: var(--navy);
  color: var(--light-blue);
  padding: 24px 32px;
  text-align: center;
  font-size: 13px;
  border-top: 4px solid var(--mid-blue);
}

.unlu-footer a { color: var(--light-blue); }

/* ============ INDEX / LANDING ============ */
.tp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 28px;
}

.tp-card {
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-left: 5px solid var(--mid-blue);
  border-radius: 8px;
  padding: 22px;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.tp-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(30, 58, 95, 0.15);
  border-left-color: var(--accent);
  border-bottom-color: transparent;
}

.tp-card .tp-num {
  display: inline-block;
  background: var(--navy);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.tp-card h3 {
  margin: 6px 0 8px;
  font-size: 17px;
  color: var(--navy);
}

.tp-card .tp-desc {
  font-size: 13px;
  color: var(--gray);
  line-height: 1.5;
  margin: 0;
}

.tp-card .tp-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--light-gray);
  font-size: 12px;
  color: var(--gray);
  display: flex;
  justify-content: space-between;
}

.coming-soon {
  opacity: 0.55;
  border-left-color: var(--gray);
  cursor: not-allowed;
  pointer-events: none;
}

.coming-soon .tp-num { background: var(--gray); }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .toc-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--light-gray);
    padding: 18px 24px;
  }
  .content { padding: 28px 24px 60px; }
  .unlu-header .brand { padding: 12px 20px 8px; }
  .unlu-header .institution { font-size: 16px; }
  .unlu-header .department { font-size: 12px; }
  .unlu-header .course-bar { padding: 8px 20px; font-size: 12px; }
  .unlu-header .course-bar .instructor { margin-left: 0; width: 100%; }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
}

@media (max-width: 560px) {
  .unlu-header .brand .logo.unlu { height: 44px; }
  .unlu-header .brand .logo.dcb  { height: 38px; }
  .unlu-header .brand-text { font-size: 13px; }
  .unlu-header .institution { font-size: 14px; }
  .content { padding: 20px 16px 40px; }
}

/* ============ SIDEBAR TOGGLE ============ */
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.toc-header .toc-title { margin: 0; }

.sidebar-toggle-btn {
  font-family: inherit;
  cursor: pointer;
  background: white;
  border: 1px solid var(--light-gray);
  color: var(--gray);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: all 0.12s ease;
}
.sidebar-toggle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Floating "show" button — bottom-left FAB, only visible when sidebar is hidden.
   Lives ABOVE the sticky header (which is z-index 100). */
.sidebar-toggle-btn.sidebar-show {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 200;
  display: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  color: white;
  background: var(--mid-blue);
  border: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
}
.sidebar-toggle-btn.sidebar-show:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.sidebar-toggle-btn.sidebar-show.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* When sidebar is hidden, collapse the layout grid */
.layout.sidebar-hidden { grid-template-columns: 1fr !important; }
.layout.sidebar-hidden .toc-sidebar { display: none; }

/* ============ INLINE TOC (Índice del documento) ============ */
.toc-inline {
  background: #f7faff;
  border: 1px solid var(--light-gray);
  border-left: 4px solid var(--mid-blue);
  border-radius: 6px;
  padding: 14px 20px;
  margin: 20px 0 32px;
  font-size: 14px;
}
.toc-inline > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--navy);
  font-size: 15px;
  padding: 4px 0;
  list-style: none;
  user-select: none;
}
.toc-inline > summary::-webkit-details-marker { display: none; }
.toc-inline > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  transition: transform 0.15s ease;
}
.toc-inline[open] > summary::before { transform: rotate(90deg); }
.toc-inline ul {
  margin: 12px 0 4px;
  padding-left: 20px;
  list-style: none;
}
.toc-inline ul ul { margin: 4px 0; padding-left: 14px; }
.toc-inline li { margin: 4px 0; }
.toc-inline a {
  color: var(--dark-blue);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.toc-inline a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.toc-inline > ul > li > a { font-weight: 600; }

.toc-controls {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--light-gray);
  font-size: 12px;
}
.toc-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray);
  background: transparent;
  border: 0;
  border-bottom: 1px dotted var(--gray);
  padding: 0 0 1px 0;
  margin: 0;
  cursor: pointer;
  line-height: 1.4;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.toc-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}
.toc-btn::before {
  display: inline-block;
  margin-right: 4px;
  font-size: 11px;
  color: inherit;
  vertical-align: baseline;
}
.toc-btn[data-action="expand-all"]::before { content: '＋'; }
.toc-btn[data-action="collapse-all"]::before { content: '−'; }

/* ============ COLLAPSIBLE H2 SECTIONS ============ */
details.section-collapsible {
  margin: 40px 0 16px;
}
details.section-collapsible > summary {
  cursor: pointer;
  list-style: none;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  padding: 6px 0 6px 14px;
  border-left: 5px solid var(--mid-blue);
  position: relative;
  user-select: none;
}
details.section-collapsible > summary::-webkit-details-marker { display: none; }
details.section-collapsible > summary::after {
  content: '▾';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--gray);
  transition: transform 0.15s ease;
}
details.section-collapsible:not([open]) > summary::after {
  transform: translateY(-50%) rotate(-90deg);
}
details.section-collapsible > summary:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}
details.section-collapsible:not([open]) > summary {
  border-left-color: var(--gray);
  margin-bottom: 0;
}
/* Avoid double-margin on first h3 inside details */
details.section-collapsible > h3:first-of-type,
details.section-collapsible > p:first-of-type {
  margin-top: 16px;
}

/* ============ PRINT ============ */
@media print {
  .unlu-header { position: static; box-shadow: none; }
  .toc-sidebar, .toc-inline { display: none; }
  .layout { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: 100%; }
  pre { box-shadow: none; }
  body { background: white; font-size: 11pt; }
  a { color: var(--navy); }
  /* Force all collapsibles open when printing */
  details.section-collapsible { display: block !important; }
  details.section-collapsible > summary { list-style: none; pointer-events: none; }
  details.section-collapsible > summary::after { display: none; }
}
