/* Página pública das regras — layout do GitBook (cabeçalho, barra lateral, conteúdo, "Nesta página"). */

.site {
  --hdr-h: 64px;
}
.site:has(.hdr.has-tabs) {
  --hdr-h: 109px;
}

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}
.skip:focus {
  top: 12px;
}

/* ---------- cabeçalho ---------- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: 0 1px 0 var(--header-line);
}
.hdr-in {
  height: 64px;
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 336px;
  flex: none;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}
.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}
.brand-name {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.025em;
  max-width: 24ch;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  height: 40px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--bg);
  color: var(--text-subtle);
  font-size: 14px;
  text-align: left;
  box-shadow: 0 1px 2px rgb(var(--tint-7) / 0.4);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-btn:hover {
  border-color: rgb(var(--tint-8));
  box-shadow: 0 2px 8px rgb(var(--tint-7) / 0.45);
}
.search-btn-txt {
  flex: 1;
}
.kbd-group {
  display: flex;
  gap: 4px;
}
.kbd-group kbd,
.kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgb(var(--tint-3));
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 1;
}
.hdr-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  flex: none;
}
.hdr-btn:hover {
  background: var(--hover);
}

/* abas das regras (quando há mais de uma) */
.tabs {
  border-top: 1px solid var(--header-line);
}
.tabs-in {
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  gap: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-in::-webkit-scrollbar {
  display: none;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  color: var(--accent-text);
  font-weight: 600;
}
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-text);
}
.tab-ico {
  font-family: var(--emoji);
}

/* ---------- layout ---------- */
.layout {
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: flex-start;
}

/* barra lateral */
.side {
  position: sticky;
  top: var(--hdr-h);
  width: 288px;
  height: calc(100vh - var(--hdr-h));
  height: calc(100dvh - var(--hdr-h));
  flex: none;
  padding: 24px 24px 16px 0;
  margin-right: 48px;
  font-size: 14px;
  line-height: 20px;
}
.side-box {
  height: 100%;
  margin-left: -20px;
  /* a cor de fundo pode ser trocada em Configurações (--side-*: ver render.js) */
  background: var(--side-bg, rgb(var(--tint-2)));
  color: var(--side-fg, var(--text));
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-mobile-head,
.side-foot {
  display: none;
}
.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 24px 8px;
  scrollbar-gutter: stable;
}
.nav,
.nav-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 6px 6px 6px 12px;
  border-radius: 16px;
  color: var(--side-fg-muted, var(--text-muted));
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link:hover {
  background: var(--side-hover, var(--hover));
  color: var(--side-fg, var(--text));
}
.nav-link.is-active {
  background: var(--side-active-bg, var(--accent-soft));
  color: var(--side-active-fg, var(--accent-text));
  font-weight: 600;
}
.nav-ico {
  width: 20px;
  height: 24px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--emoji);
  font-size: 17px;
  font-weight: 400;
}
.nav-txt {
  flex: 1;
  min-width: 0;
}
.nav-tog {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  border-radius: 8px;
  color: var(--side-fg-muted, var(--text-subtle));
  flex: none;
}
.nav-tog:hover {
  background: var(--side-hover, rgb(var(--tint-12) / 0.06));
}
.nav-tog .ico {
  transition: transform 0.2s;
}
.has-kids.is-open > .nav-link .nav-tog .ico {
  transform: rotate(90deg);
}
.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 8px 20px;
}
.has-kids.is-open > .nav-sub {
  display: flex;
}
.nav-sublink {
  min-height: 32px;
  padding-left: 20px;
  border-radius: 0 16px 16px 0;
}
.nav-sublink.is-active {
  border-radius: 16px;
}

/* conteúdo */
.main {
  flex: 1;
  min-width: 0;
  max-width: 768px;
  margin: 0 auto;
  padding: 32px 0 96px;
}
.page-head {
  margin-bottom: 28px;
}
.crumb {
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 16px;
}
.crumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-text);
  text-decoration: none;
}
.crumb a:hover {
  text-decoration: underline;
}
.crumb-ico {
  font-family: var(--emoji);
}

/* "Nesta página" */
.toc {
  position: sticky;
  top: var(--hdr-h);
  width: 224px;
  flex: none;
  margin-left: 48px;
  max-height: calc(100vh - var(--hdr-h));
  overflow-y: auto;
  padding: 32px 0 72px;
}
.toc-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-link {
  display: block;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-subtle);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.toc-link:hover {
  color: var(--text);
  background: var(--hover);
}
.toc-link.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  font-weight: 600;
}
.toc-l2 {
  padding-left: 24px;
}
.toc-l3 {
  padding-left: 36px;
}

/* seletor de tema (canto) */
.theme-switch {
  position: fixed;
  right: 24px;
  bottom: 16px;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 2px;
  border-radius: 20px;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.theme-switch button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-subtle);
}
.theme-switch button:hover {
  color: var(--text);
}
.theme-switch button[aria-checked='true'] {
  color: var(--text);
  background: rgb(var(--tint-12) / 0.06);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* botão "Editar" (só para quem está logado no editor) */
.edit-fab {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.edit-fab:hover {
  filter: brightness(1.1);
}

.scrim {
  display: none;
}

/* ---------- busca ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgb(var(--tint-12) / 0.28);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade-in 0.12s ease-out;
}
html.dark .search-overlay {
  background: rgb(0 0 0 / 0.5);
}
.search-panel {
  width: 100%;
  max-width: 640px;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in 0.14s ease-out;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  color: var(--text-subtle);
}
.search-field input {
  flex: 1;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}
.search-field input::placeholder {
  color: var(--text-subtle);
}
.search-results {
  overflow-y: auto;
  padding: 8px;
}
.search-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 14px;
}
.sr-group {
  padding: 10px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}
.sr-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}
.sr-item.is-active {
  background: var(--accent-soft);
}
.sr-ico {
  width: 20px;
  flex: none;
  display: flex;
  justify-content: center;
  padding-top: 1px;
  font-family: var(--emoji);
  color: var(--text-subtle);
}
.sr-body {
  min-width: 0;
  flex: 1;
}
.sr-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}
.sr-path {
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 16px;
}
.sr-snip {
  margin-top: 2px;
  font-size: 13px;
  line-height: 19px;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sr-snip mark,
.sr-title mark {
  background: rgb(var(--primary-9) / 0.16);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.search-foot {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-subtle);
}
.search-foot span {
  display: flex;
  align-items: center;
  gap: 6px;
}

@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
}

/* ---------- página não encontrada ---------- */
.nf {
  max-width: 560px;
  margin: 0 auto;
  padding: 96px 16px;
  text-align: center;
}
.nf-title {
  margin: 0;
  font-size: 30px;
  line-height: 36px;
  font-weight: 600;
  letter-spacing: -0.0125em;
}
.nf-text {
  margin: 8px 0 40px;
  color: var(--text-subtle);
  font-size: 15px;
}
.nf-box {
  text-align: left;
  background: rgb(var(--tint-2));
  border-radius: 16px;
  padding-bottom: 16px;
}
.nf-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--bg);
  color: var(--text-subtle);
  font-size: 15px;
}
.nf-search span {
  flex: 1;
  text-align: left;
}
.nf-label {
  margin: 16px 20px 8px;
  font-size: 14px;
  color: var(--text-muted);
}
.nf-list {
  list-style: none;
  margin: 0;
  padding: 0 20px;
}
.nf-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: rgb(var(--primary-9) / 0.3);
}
.nf-ico {
  font-family: var(--emoji);
}
.nf-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 48px;
  font-size: 14px;
  color: var(--text-subtle);
  text-decoration: none;
}
.nf-home:hover {
  color: var(--text);
}

/* ---------- telas menores ---------- */
@media (max-width: 1279px) {
  .toc {
    display: none;
  }
}

@media (max-width: 1023px) {
  .hdr-in {
    padding: 0 12px;
    gap: 4px;
  }
  .brand {
    width: auto;
    flex: 1;
  }
  .brand-name {
    font-size: 16px;
  }
  .search-btn {
    display: none;
  }
  .hdr-btn {
    display: flex;
  }
  .tabs-in {
    padding: 0 16px;
    gap: 20px;
  }
  .layout {
    padding: 0 20px;
    display: block;
  }
  .main {
    padding: 28px 0 96px;
  }
  .side {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: min(320px, 86vw);
    margin: 0;
    padding: 8px;
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    visibility: hidden;
  }
  .side-box {
    margin-left: 0;
  }
  .side-mobile-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 8px 12px;
  }
  .side-mobile-head .brand-logo {
    width: 28px;
    height: 28px;
  }
  .menu-open .side {
    transform: none;
    visibility: visible;
  }
  .menu-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgb(0 0 0 / 0.35);
  }
  .edit-fab {
    left: auto;
    right: 16px;
    bottom: 16px;
  }
  .theme-switch {
    display: none;
  }
  .side-foot {
    display: flex;
    justify-content: center;
    padding: 10px;
    border-top: 1px solid var(--side-line, var(--border));
  }
  .theme-switch.side-theme {
    display: flex;
    position: static;
    background: transparent;
  }
  .search-overlay {
    padding-top: 8px;
  }
}

@media (max-width: 480px) {
  .layout {
    padding: 0 16px;
  }
  .search-foot {
    display: none;
  }
}

@media print {
  .hdr,
  .side,
  .toc,
  .theme-switch,
  .edit-fab {
    display: none !important;
  }
  .main {
    padding: 0;
  }
}

/* ---------- troca de página sem recarregar ---------- */
/* a barra de rolagem da janela sempre reserva o espaço: a página não "pula"
   para o lado quando uma categoria é mais curta que a outra */
html:has(body.site) {
  scrollbar-gutter: stable;
}
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  height: 2px;
  width: 0;
  background: var(--accent-text);
  opacity: 0;
  pointer-events: none;
}
.nav-bar.busy {
  opacity: 1;
  width: 80%;
  transition: width 4s cubic-bezier(0.1, 0.6, 0.2, 1), opacity 0.1s;
}
.nav-bar.done {
  width: 100%;
  opacity: 0;
  transition: width 0.15s ease-out, opacity 0.25s 0.15s;
}
