/* UX de leitura dos artigos (assets/js/post.js) */

/* ---------- Barra de progresso ---------- */
.post-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10000;
  background: transparent;
  pointer-events: none;
}
.post-progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #149ddd, #5cc6f5);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.1s linear;
}
.post-progress.no-motion .post-progress-fill { transition: none; }

.post-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Headings com espaço ao pular pelo sumário */
.post-body h2, .post-body h3,
.portfolio-description h2, .portfolio-description h3 { scroll-margin-top: 24px; }

/* ---------- Sumário ---------- */
.post-toc {
  background: #f5f8fd;
  border: 1px solid #e1e9f3;
  border-radius: 12px;
  margin: 0 0 28px;
  font-size: 14px;
}
.post-toc details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #173b6c;
  border-radius: 12px;
}
.post-toc details > summary::-webkit-details-marker { display: none; }
.post-toc details > summary::after {
  content: "";
  margin-left: auto;
  width: 8px; height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
}
.post-toc details[open] > summary::after { transform: rotate(-135deg); }
.post-toc details > summary i { color: #149ddd; font-size: 18px; }
.post-toc-list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 10px 12px;
}
.post-toc-list li { margin: 0; }
.post-toc-list a {
  display: block;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: #4a5568;
  line-height: 1.4;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.post-toc-list .post-toc-h3 a { padding-left: 24px; font-size: 13px; }
.post-toc-list a:hover { color: #0b76b3; background: rgba(20, 157, 221, 0.06); }
.post-toc-list a[aria-current] {
  color: #0b76b3; /* texto: tom escuro do azul para 4.5:1 (a borda segue #149ddd) */
  font-weight: 600;
  border-left-color: #149ddd;
  background: rgba(20, 157, 221, 0.08);
}
.post-toc a:focus-visible,
.post-toc summary:focus-visible,
.post-copy:focus-visible {
  outline: 2px solid #149ddd;
  outline-offset: 2px;
}

/* Sidebar sticky em telas largas */
@media (min-width: 1200px) {
  .post-toc-section { overflow: visible; overflow-x: clip; }
  .row.post-has-toc { flex-wrap: nowrap; }
  .row.post-has-toc > .post-main-col { flex: 0 1 auto; min-width: 0; }
  .post-toc-aside { flex: 0 0 250px; width: 250px; }
  .post-toc-aside .post-toc {
    position: sticky;
    top: 24px;
    margin: 0;
    background: transparent;
    border: 0;
    border-left: 1px solid #e1e9f3;
    border-radius: 0;
  }
  .post-toc-aside .post-toc-list {
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* ---------- Botão copiar ---------- */
.post-code { position: relative; }
.post-code > pre { padding-top: 40px !important; }
.post-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: #d4e6f5;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.post-copy i { font-size: 14px; }
.post-copy:hover { background: #149ddd; border-color: #149ddd; color: #fff; }
.post-copy.is-copied { background: #15803d; border-color: #15803d; color: #fff; }

/* ---------- Tema escuro ---------- */
.dark-theme .post-toc { background: #131c30; border-color: #25344f; }
.dark-theme .post-toc details > summary { color: #eaf2fb; }
.dark-theme .post-toc-list a { color: #9fb1c4; }
.dark-theme .post-toc-list a:hover { color: #5cc6f5; background: rgba(92, 198, 245, 0.08); }
.dark-theme .post-toc-list a[aria-current] { color: #5cc6f5; border-left-color: #5cc6f5; background: rgba(92, 198, 245, 0.1); }
@media (min-width: 1200px) {
  .dark-theme .post-toc-aside .post-toc { background: transparent; border-left-color: #25344f; }
}

@media (prefers-reduced-motion: reduce) {
  .post-progress-fill,
  .post-toc details > summary::after,
  .post-toc-list a,
  .post-copy { transition: none; }
}

@media print {
  .post-progress, .post-toc, .post-copy { display: none !important; }
}
