/* bernardohoelz.com.br — Design Editorial v3 (Home 2 colunas 72rem + Leitura 40rem) */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #16212c;
  --muted: #5b6672;
  --line: #d9dee4;
  --accent: #2447b8;
  --accent-soft: #eef2ff;
  --chip: #e6e9ee;
  --code-bg: #111827;
  --code-text: #e5e7eb;
  --inline-code-bg: #e9edf3;
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151b;
    --surface: #161d26;
    --ink: #e8ecf0;
    --muted: #98a3ae;
    --line: #27313b;
    --accent: #8fb0ff;
    --accent-soft: rgba(143, 176, 255, 0.14);
    --chip: #1a222b;
    --code-bg: #0a0f15;
    --code-text: #e2e8f0;
    --inline-code-bg: #1d2733;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #10151b;
  --surface: #161d26;
  --ink: #e8ecf0;
  --muted: #98a3ae;
  --line: #27313b;
  --accent: #8fb0ff;
  --accent-soft: rgba(143, 176, 255, 0.14);
  --chip: #1a222b;
  --code-bg: #0a0f15;
  --code-text: #e2e8f0;
  --inline-code-bg: #1d2733;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 4rem; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a {
  color: inherit;
  text-decoration-color: var(--line);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.2em;
}
a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width 0.08s linear;
}

/* Containers */
.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.wrap-narrow {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.brand-name {
  font-family: var(--sans);
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-nav {
  font-family: var(--sans);
  font-size: 0.95rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.35em;
}

.theme-toggle {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  display: grid;
  place-items: center;
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* Home — Layout 2 Colunas (72rem) */
.home-layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: 4.5rem;
  padding: 3.5rem 0 4.5rem;
  align-items: start;
}
.home-intro {
  position: sticky;
  top: 2.25rem;
}
.avatar {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--chip);
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-weight: 650;
  font-size: 1.1rem;
  color: var(--muted);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-intro h1 {
  font-size: clamp(1.6rem, 2.35vw, 2.08rem);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0 0 1rem;
  text-wrap: balance;
}
.home-intro p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1rem;
}
.inline-links {
  font-family: var(--sans);
  font-size: 0.94rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

/* Lista de Artigos com Capa 16:10 */
.articles-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.articles-feed li {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.75rem;
  padding: 0 0 2.25rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.articles-feed li:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}
.cover {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  overflow: hidden;
  background: var(--chip);
  border: 1px solid var(--line);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.articles-feed li:hover .cover img {
  transform: scale(1.025);
}
.articles-feed h2 {
  font-size: 1.38rem;
  line-height: 1.26;
  font-weight: 600;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
.articles-feed h2 a { text-decoration: none; }
.articles-feed h2 a:hover { color: var(--accent); }
.articles-feed p {
  margin: 0 0 0.75rem;
  color: var(--muted);
}
.meta {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0;
}
.feed-note {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
  margin: 2.25rem 0 0;
}

@media (max-width: 60rem) {
  .home-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
    padding-top: 2.25rem;
  }
  .home-intro { position: static; }
}
@media (max-width: 40rem) {
  .articles-feed li {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }
}

/* Páginas de Índice (/artigos/, /sobre/) */
.page-shell {
  padding: 2.75rem 0 4rem;
}
.page-intro {
  padding-bottom: 2rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--line);
}
.page-intro h1 {
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}
.page-intro p {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.facet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.facet-btn {
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.facet-btn:hover { color: var(--ink); border-color: var(--muted); }
.facet-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Página de Artigo (Coluna de leitura 40rem + TOC lateral) */
.article-shell {
  padding: 2.5rem 0 4.5rem;
}
.doc-head {
  max-width: 48rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.5rem;
}
.breadcrumb {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.doc-head h1 {
  font-size: clamp(1.75rem, 3.8vw, 2.4rem);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 0.85rem;
  text-wrap: balance;
}
.bluf-note {
  margin: 1.5rem 0 0;
  padding: 0.95rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-size: 0.98rem;
}
.bluf-kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.bluf-note p { margin: 0 0 0.55rem; color: var(--muted); }
.bluf-note p:last-child { margin-bottom: 0; color: var(--ink); }

.doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 42rem) minmax(0, 15rem);
  justify-content: space-between;
  gap: 3.5rem;
  align-items: start;
}
@media (max-width: 60rem) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .doc-toc { order: -1; position: static; border-bottom: 1px solid var(--line); padding-bottom: 1.25rem; }
}

.doc-toc {
  position: sticky;
  top: 2.25rem;
  font-family: var(--sans);
  font-size: 0.84rem;
}
.toc-title {
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.65rem;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-list li { margin-bottom: 0.42rem; line-height: 1.38; }
.toc-list li.toc-h3 { padding-left: 0.85rem; font-size: 0.8rem; }
.toc-list a { color: var(--muted); text-decoration: none; }
.toc-list a:hover { color: var(--accent); text-decoration: underline; }

/* Tipografia de Leitura (65-75 caracteres) */
.prose {
  min-width: 0;
  font-size: 1.125rem;
  line-height: 1.7;
}
.prose h2 {
  font-size: 1.45rem;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.9rem;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  font-size: 1.18rem;
  line-height: 1.35;
  font-weight: 600;
  margin: 1.85rem 0 0.65rem;
}
.prose h4 { font-size: 1.04rem; margin: 1.4rem 0 0.5rem; }
.heading-anchor {
  margin-left: 0.4rem;
  opacity: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.82em;
  text-decoration: none;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor { opacity: 0.75; }

.prose p { margin: 0 0 1.2rem; }
.prose ul, .prose ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
.prose li { margin-bottom: 0.45rem; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.25rem 0; }
.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.15rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.prose blockquote p { margin: 0; }
.prose code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--inline-code-bg);
  padding: 0.12rem 0.34rem;
  border-radius: 4px;
}

.concept-term {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--muted);
  text-underline-offset: 0.22em;
  cursor: help;
}
.wikilink {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.22em;
}
.wikilink:hover { background: var(--accent-soft); text-decoration-style: solid; }
.repo-ref { border-bottom: 1px dotted var(--muted); cursor: help; }
.math-inline { font-family: var(--serif); font-style: italic; }

/* Blocos de Código */
.code-block {
  margin: 1.5rem 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--line);
}
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.copy-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 0.14rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.1); }
.code-block pre {
  margin: 0;
  padding: 0.95rem 1.05rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
}
.code-block pre code {
  background: transparent;
  color: var(--code-text);
  padding: 0;
  font-size: inherit;
}

/* Tabelas */
.table-wrap {
  overflow-x: auto;
  margin: 1.6rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.5;
}
th, td {
  padding: 0.68rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
thead th { font-weight: 650; color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }

/* Diagramas Editoriais SVG & Mermaid */
.diagram-box {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}
.diagram-svg .editorial-svg {
  width: 100%;
  min-width: 540px;
  height: auto;
  display: block;
}
.diagram-box figcaption {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Metadados de Rodapé do Artigo e Série */
.doc-footer-meta {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--muted);
}
.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.doc-tag {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--inline-code-bg);
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
}

.related-block {
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.related-block h2 {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--muted);
  margin: 0 0 1rem;
}
.related-block ul,
.related-block ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.98rem;
}
.related-block li { margin-bottom: 0.45rem; }

/* Rodapé Global */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 0 2.5rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }
