/* DnAi — Manifesto Estratégia · Premium Document Styles */

:root {
  --bg: #F8F4E9;
  --surface: #FFFFFF;
  --surface-alt: #F2EDE2;
  --text: #13171f;
  --muted: #5a6068;
  --accent: #D97F2E;
  --accent-light: rgba(217,127,46,0.10);
  --accent-hover: rgba(217,127,46,0.06);
  --green: #3B5544;
  --green-light: rgba(59,85,68,0.08);
  --border: #E4DCC8;
  --border-strong: #C8BFA8;
  --code-bg: #1a1e28;
  --code-text: #e8e3d8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.03);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 6px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Progress bar ─── */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  z-index: 9999;
  transition: width 80ms linear;
}

/* ─── Site header ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: rgba(248, 244, 233, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand img {
  height: 30px;
  width: auto;
  object-fit: contain;
}

.meta {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.btn-print {
  padding: 7px 16px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 150ms, transform 100ms;
}

.btn-print:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.btn-print:active {
  transform: translateY(0);
}

/* ─── Layout grid ─── */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 32px 80px;
  align-items: start;
}

/* ─── Sidebar TOC ─── */
.sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar h3 {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
  padding-left: 12px;
}

/* TOC generated by python-markdown */
.toc {
  font-size: 13px;
}

.toc div {
  padding: 0;
}

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

.toc ul ul {
  padding-left: 14px;
  margin-top: 2px;
}

.toc ul ul ul {
  padding-left: 12px;
}

.toc li {
  margin: 1px 0;
}

.toc a {
  display: block;
  padding: 5px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 120ms;
  border-left: 2px solid transparent;
  line-height: 1.4;
  font-size: 12.5px;
}

.toc ul ul a {
  font-size: 12px;
  color: #7a8088;
}

.toc a:hover {
  background: var(--accent-hover);
  color: var(--accent);
  border-left-color: rgba(217,127,46,0.3);
}

.toc a.active {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ─── Main content ─── */
.content {
  min-width: 0;
  max-width: 840px;
  background: var(--surface);
  padding: 56px 64px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

/* Typography */
.content h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 16px;
  color: var(--text);
}

.content h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(22px, 2.5vw, 32px);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin-top: 64px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  scroll-margin-top: 90px;
}

.content h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 500;
  line-height: 1.3;
  margin-top: 40px;
  margin-bottom: 12px;
  color: var(--text);
  scroll-margin-top: 90px;
}

.content h4 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  scroll-margin-top: 90px;
}

.content h5 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 6px;
  color: var(--muted);
  scroll-margin-top: 90px;
}

.content h6 {
  font-size: 13px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 6px;
  color: var(--muted);
  scroll-margin-top: 90px;
}

.content p {
  margin: 14px 0;
  line-height: 1.75;
}

.content strong {
  font-weight: 700;
  color: var(--text);
}

.content em {
  font-style: italic;
}

/* Lists */
.content ul,
.content ol {
  margin: 14px 0;
  padding-left: 28px;
}

.content li {
  margin: 6px 0;
  line-height: 1.65;
}

.content li > ul,
.content li > ol {
  margin: 6px 0;
}

/* Links */
.content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(217,127,46,0.3);
  transition: border-color 120ms;
}

.content a:hover {
  border-bottom-color: var(--accent);
}

/* Tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}

.content table th {
  background: var(--green);
  color: white;
  text-align: left;
  padding: 13px 18px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.content table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

.content table tr:last-child td {
  border-bottom: none;
}

.content table tr:nth-child(even) td {
  background: rgba(217, 127, 46, 0.03);
}

.content table tr:hover td {
  background: var(--accent-hover);
}

/* Blockquotes */
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 24px;
  margin: 20px 0;
  color: var(--muted);
  font-style: italic;
  background: rgba(217,127,46,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
}

.content blockquote p {
  margin: 6px 0;
}

/* Code */
.content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  color: var(--green);
}

.content pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 24px 28px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 20px 0;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* HR dividers */
.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 56px 0;
}

/* Callouts — bold annotations prefixed with emoji */
.content p > strong:first-child {
  display: inline;
}

/* Special: FALTA annotations */
.content p:has(> strong):not(:has(> a)) {
  background: transparent;
}

/* Section dividers for major sections */
.content h2:first-of-type {
  margin-top: 0;
}

/* ─── Site footer ─── */
.site-footer {
  text-align: center;
  padding: 48px 32px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.site-footer p + p {
  margin-top: 8px;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ─── Back to top ─── */
.back-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: all 200ms;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  z-index: 500;
}

.back-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-top:hover {
  background: var(--accent);
  transform: translateY(-2px);
}

/* ─── Section numbering ─── */
.content h2[id]::before {
  content: none;
}

/* ─── Highlight search anchor ─── */
:target {
  scroll-margin-top: 100px;
}

/* ─── Mobile responsive ─── */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 240px 1fr;
    gap: 24px;
    padding: 32px 24px 64px;
  }
  .content {
    padding: 40px 48px;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 0 64px;
  }

  .sidebar {
    position: static;
    max-height: none;
    background: var(--surface-alt);
    padding: 24px 24px 20px;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .sidebar details {
    cursor: pointer;
  }

  .content {
    padding: 32px 24px;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--border);
  }

  .content h1 {
    font-size: 28px;
  }

  .content h2 {
    font-size: 22px;
    margin-top: 48px;
  }

  .content h3 {
    font-size: 18px;
    margin-top: 32px;
  }

  .site-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .meta {
    font-size: 11px;
    gap: 12px;
  }

  .brand img {
    height: 24px;
  }

  .back-top {
    bottom: 20px;
    right: 16px;
  }

  /* Horizontal scroll on tables */
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 24px 16px;
  }
  .content h2 {
    margin-top: 40px;
  }
  .content pre {
    padding: 16px;
    font-size: 12px;
  }
  .meta span {
    display: none;
  }
}

/* ─── Print ─── */
@media print {
  .progress-bar,
  .site-header,
  .sidebar,
  .btn-print,
  .site-footer,
  .back-top {
    display: none !important;
  }

  .layout {
    display: block;
    padding: 0;
    max-width: 100%;
  }

  .content {
    box-shadow: none;
    padding: 20px 0;
    border-radius: 0;
    max-width: 100%;
  }

  body {
    background: white;
    font-size: 11pt;
    line-height: 1.5;
    color: black;
  }

  .content h1 { font-size: 22pt; }
  .content h2 { font-size: 16pt; margin-top: 24pt; page-break-after: avoid; }
  .content h3 { font-size: 13pt; margin-top: 16pt; page-break-after: avoid; }
  .content h4 { font-size: 11pt; page-break-after: avoid; }

  a {
    color: black !important;
    border: none !important;
    text-decoration: none !important;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
  }

  table,
  pre,
  blockquote {
    page-break-inside: avoid;
  }

  .content table th {
    background: #3B5544 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  pre {
    background: #f4f4f4 !important;
    color: black !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  hr {
    margin: 20pt 0;
  }

  @page {
    margin: 2cm 2.5cm;
    size: A4;
  }
}
