/* ============================================================
   nav.css — shared top-navigation for all site pages
   ============================================================ */

/* ---- Base reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Merriweather", ui-serif, Georgia, "Times New Roman", serif;
  color: #000;
  background: #fff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
}

/* ---- Design tokens ---- */
:root {
  --black: #000000;
  --white: #ffffff;
  --yellow: #f3d250;
  --gray: #d9d9d9;
  --compact-h: 71px;
  /* fixed compact nav height */
}

/* ============================================================
   HERO HEADER  — hidden; compact-nav is always shown instead
   ============================================================ */
.site-hero {
  display: none;
}

.hero-brand {
  flex: 0 0 397px;
  width: 397px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-title {
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

.hero-title strong {
  font-weight: 700;
}

.hero-rule {
  height: 1px;
  background: rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

.hero-credits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-credits p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.hero-tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

/* ============================================================
   MAIN TAB (used in both hero and compact nav)
   ============================================================ */
.main-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  color: var(--white);
  white-space: nowrap;
  text-decoration: none;
  border: none;
  background: transparent;
  transition: background 0.15s ease;
}

.main-tab__label {
  font-size: 12px;
  opacity: 0.5;
  line-height: 1;
}

.main-tab__name {
  font-size: 24px;
  line-height: normal;
}

.main-tab.is-active {
  background: var(--yellow);
  color: var(--black);
}

.main-tab.is-active .main-tab__label {
  opacity: 0.55;
}

.main-tab:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================================
   COMPACT STICKY NAV (fixed, slides in from top when scrolled)
   ============================================================ */
.compact-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--black);
  height: var(--compact-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.compact-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.compact-tabs::-webkit-scrollbar {
  display: none;
}

.compact-nav .main-tab__name {
  font-size: 18px;
}

.compact-nav .main-tab__label {
  font-size: 11px;
}

/* ============================================================
   SECONDARY NAV (yellow bar below main nav)
   ============================================================ */
.secondary-nav {
  background: var(--yellow);
  border-top: 1px solid var(--black);
  border-bottom: 1px solid var(--black);
  padding: 16px 24px;
  overflow: visible;
  /* horizontal scroll now lives on .sec-rail so the "more" balloon can escape below */
  display: flex;
  align-items: stretch;
  gap: 0;
  position: sticky;
  top: var(--compact-h);
  margin-top: var(--compact-h);
  /* push natural position to match sticky-top so content starts below */
  z-index: 100;
  scrollbar-width: none;
  min-height: 64px;
  transition: padding 0.22s ease, min-height 0.22s ease;
}

.secondary-nav::-webkit-scrollbar {
  display: none;
}

.secondary-nav.is-compact {
  padding: 8px 24px;
  min-height: 44px;
}

.secondary-nav.is-compact .chap-tab {
  padding: 5px 14px;
}

.secondary-nav.is-compact .flow-card {
  padding: 6px 14px;
}

/* ============================================================
   CHAPTER TABS  (Trabalho secondary nav)
   ============================================================ */
.chap-tab-group {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.chap-tab-group+.chap-tab-group {
  margin-left: 20px;
}

.chap-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  background: var(--white);
  border: 1px solid var(--black);
  color: var(--black);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
  margin-left: -1px;
  transition: background 0.15s ease, color 0.15s ease, padding 0.22s ease;
}

.chap-tab:first-child {
  margin-left: 0;
}

.chap-tab.is-active {
  background: var(--black);
  color: var(--white);
  position: relative;
  z-index: 1;
}

.chap-tab.is-sub {
  font-size: 13px;
  opacity: 0.9;
}

.chap-tab:hover:not(.is-active) {
  background: #f4f4f4;
}

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
  background: var(--black);
  color: var(--white);
  padding: 48px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 397px;
}

/* ============================================================
   FLOW CARDS  (Appendix secondary nav)
   ============================================================ */
.flow-card {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  background: var(--white);
  border: 1px solid var(--black);
  color: var(--black);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  margin-left: -1px;
  transition: background 0.15s ease, color 0.15s ease, padding 0.22s ease;
}

.flow-card:first-child {
  margin-left: 0;
}

.flow-card.is-active {
  background: var(--black);
  color: var(--white);
}

.flow-card:hover:not(.is-active) {
  background: #f4f4f4;
}

.flow-card__name {
  font-size: 15px;
  line-height: 1.1;
}

/* ============================================================
   SECONDARY-NAV SCROLL RAIL  (desktop side-arrows + "more" balloon)
   The chapter/flow row scrolls inside .sec-rail, which is capped to the
   width left over in the bar. Arrows flank it and a small balloon nudges
   first-time readers that there's more to the side.
   ============================================================ */

/* Fixed controls on the left never shrink — only the rail absorbs overflow. */
.secondary-nav>.view-toggle,
.secondary-nav>.sec-nav-mob {
  flex: 0 0 auto;
}

.sec-rail {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.sec-rail::-webkit-scrollbar {
  display: none;
}

.sec-arrow {
  flex: 0 0 auto;
  display: none;
  /* shown only when the row overflows on desktop (.sec-has-overflow) */
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  /* keep our background on :disabled instead of the UA dark-scheme control color */
  background: var(--white);
  border: 1px solid var(--black);
  color: var(--black);
  transition: background 0.15s ease, opacity 0.15s ease;
}

.sec-arrow svg {
  display: block;
}

.sec-arrow--left {
  margin-right: 8px;
}

.sec-arrow--right {
  margin-left: 8px;
}

.sec-arrow:hover:not(:disabled) {
  background: #f4f4f4;
}

.sec-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.secondary-nav.sec-has-overflow .sec-arrow {
  display: inline-flex;
}

/* "There's more" balloon, anchored just under the right arrow */
.sec-more-tip {
  position: absolute;
  top: calc(100% + 9px);
  right: 24px;
  z-index: 120;
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--black);
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  line-height: 1.3;
  padding: 8px 8px 8px 12px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
}

.secondary-nav.sec-tip-on .sec-more-tip {
  display: inline-flex;
}

.sec-more-tip::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 16px;
  width: 11px;
  height: 11px;
  background: var(--black);
  transform: rotate(45deg);
}

.sec-more-tip__txt {
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

.sec-more-tip__close {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  line-height: 1;
  padding: 0;
}

.sec-more-tip__close:hover {
  color: var(--white);
}

[data-theme="dark"] .sec-arrow {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .sec-arrow:hover:not(:disabled) {
  background: #252525;
}

[data-theme="dark"] .sec-more-tip {
  background: #e8e8e8;
  color: #111;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .sec-more-tip::before {
  background: #e8e8e8;
}

[data-theme="dark"] .sec-more-tip__close {
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .sec-more-tip__close:hover {
  color: #000;
}

/* On mobile the whole bar scrolls as before — no separate rail scroll, no arrows. */
@media (max-width: 960px) {
  .secondary-nav {
    overflow-x: auto;
  }

  .sec-rail {
    overflow: visible;
    flex: 0 0 auto;
  }
}

/* ============================================================
   DARK MODE TOGGLE BUTTON
   ============================================================ */
.dark-toggle {
  margin-left: auto;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--white);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dark-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
}

.dark-toggle .icon-sun {
  display: none;
}

.dark-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .dark-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .dark-toggle .icon-moon {
  display: none;
}

/* ============================================================
   DARK MODE THEME — [data-theme="dark"] on <html>
   ============================================================ */
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] .check-item.is-checked .check-text {
  color: rgba(255, 255, 255, 0.65);
}

[data-theme="dark"] body {
  background: #111111;
  color: #e8e8e8;
}

/* Secondary nav border */
[data-theme="dark"] .secondary-nav {
  border-color: #333;
}

/* Chapter tabs */
[data-theme="dark"] .chap-tab {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .chap-tab.is-active {
  background: #e0e0e0;
  color: #111;
  border-color: #3a3a3a;
}

[data-theme="dark"] .chap-tab:hover:not(.is-active) {
  background: #252525;
}

/* Flow cards */
[data-theme="dark"] .flow-card {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .flow-card.is-active {
  background: #e0e0e0;
  color: #111;
}

[data-theme="dark"] .flow-card:hover:not(.is-active) {
  background: #252525;
}

/* Sidebar — trabalho page */
[data-theme="dark"] .sidebar {
  background: #111;
  border-color: #2e2e2e;
}

[data-theme="dark"] .toc-chap-label {
  color: rgba(232, 232, 232, 0.38);
  border-color: #2a2a2a;
}

[data-theme="dark"] .toc-chap-title {
  color: #e8e8e8;
}

[data-theme="dark"] .sub-item {
  color: rgba(232, 232, 232, 0.62);
}

[data-theme="dark"] .sub-item:hover {
  background: #1e1e1e;
  color: #e8e8e8;
}

[data-theme="dark"] .sub-item.is-active {
  color: #111;
  background: var(--yellow);
}

/* Prose — trabalho page */
[data-theme="dark"] .prose {
  color: #e8e8e8;
}

[data-theme="dark"] .prose a {
  color: #e8e8e8;
}

[data-theme="dark"] .prose blockquote {
  color: rgba(232, 232, 232, 0.75);
}

[data-theme="dark"] .prose hr {
  border-color: #2e2e2e;
}

[data-theme="dark"] .prose tbody td {
  border-color: #2e2e2e;
}

[data-theme="dark"] .prose tbody tr:nth-child(even) {
  background: #1a1a1a;
}

[data-theme="dark"] .doc-kicker {
  color: rgba(232, 232, 232, 0.75);
}

[data-theme="dark"] .ed-note {
  background: #1e1c0a;
}

[data-theme="dark"] .fn-notes {
  border-color: #2e2e2e;
}

[data-theme="dark"] .fn-notes li {
  color: rgba(232, 232, 232, 0.75);
}

[data-theme="dark"] .fn-back {
  color: rgba(232, 232, 232, 0.75);
}

[data-theme="dark"] .fn-back:hover {
  color: #e8e8e8;
}

[data-theme="dark"] .foot-btn {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .foot-btn:hover {
  background: #222;
}

[data-theme="dark"] .foot-btn-dir {
  color: rgba(232, 232, 232, 0.75);
}

/* Platform viewer — appendix pages */
[data-theme="dark"] .viewer-detail {
  background: #111111;
  border-color: #2e2e2e;
  color: #e8e8e8;
}

[data-theme="dark"] .viewer-image-wrap {
  background: #111111;
}

[data-theme="dark"] .viewer-loading,
[data-theme="dark"] .viewer-empty {
  color: rgba(232, 232, 232, 0.45);
}

[data-theme="dark"] .doc-head-rule {
  height: 2px;
  background: #fff;
  width: 100%;
}

[data-theme="dark"] .fig-cap {
  color: #fff !important;
}

[data-theme="dark"] .fig-cap .fig-label {
  color: #fff !important;
}

.fig-cap .fig-label {
  color: #000 !important;
}

[data-theme="dark"] sup.fn-ref a {
  color: #000 !important;
}

[data-theme="dark"] sup.fn-ref a:hover {
  color: #fff !important;
}

[data-theme="dark"] .fig-source {
  color: rgba(255, 255, 255, 0.5) !important;
}

[data-theme="dark"] .viewer-footer {
  border-color: #2e2e2e;
}

[data-theme="dark"] .detail-title {
  color: #e8e8e8;
}

[data-theme="dark"] .detail-desc {
  color: rgba(232, 232, 232, 0.75);
}

[data-theme="dark"] .detail-rule {
  background: #2e2e2e;
}

[data-theme="dark"] .detail-dp-label {
  color: rgba(232, 232, 232, 0.38);
}

[data-theme="dark"] .ficha-label {
  color: rgba(232, 232, 232, 0.38);
}

[data-theme="dark"] .hv-sevlabel {
  color: rgba(232, 232, 232, 0.7);
}

[data-theme="dark"] .hv-name {
  color: #e8e8e8;
}

[data-theme="dark"] .step-num {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .step-num:hover {
  background: #252525;
}

/* Dados page */
[data-theme="dark"] .view-toggle button {
  background: #1a1a1a;
  border-color: #3a3a3a;
  color: #e8e8e8;
}

[data-theme="dark"] .view-toggle button.is-active {
  background: #e0e0e0;
  color: #111;
}

/* ============================================================
   RESPONSIVE — mobile
   ============================================================ */
@media (max-width: 960px) {

  /* Hero is hidden on mobile */
  .site-hero {
    display: none;
  }

  /* Compact nav becomes sticky in-flow (not fixed) */
  /* compact-nav is sticky on mobile (in flow), so no margin-top needed */
  .secondary-nav {
    margin-top: 0;
  }

  .compact-nav {
    position: sticky;
    top: 0;
    transform: none !important;
    transition: none;
  }

  /* Secondary nav sits below sticky compact nav */
  .secondary-nav,
  body.nav-scrolled .secondary-nav {
    top: var(--compact-h);
  }

  .main-tab__name {
    font-size: 16px;
  }

  .main-tab__label {
    font-size: 10px;
  }
}

@media (max-width: 600px) {
  .compact-nav {
    padding: 0 16px;
  }

  .secondary-nav {
    padding: 12px 16px;
  }

  .main-tab {
    padding: 4px 8px;
  }

  .main-tab__name {
    font-size: 14px;
  }
}