/* ============================================================
   GitIntel Wiki — Styles
   ============================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand palette */
  --color-bg: #0d1117;
  --color-bg-alt: #161b22;
  --color-bg-card: #1c2129;
  --color-border: #30363d;
  --color-text: #e6edf3;
  --color-text-muted: #8b949e;
  --color-accent: #58a6ff;
  --color-accent-2: #3fb950;
  --color-accent-3: #d2a8ff;
  --color-accent-4: #f78166;
  --color-accent-5: #ff7b72;
  --color-accent-6: #79c0ff;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;

  /* Spacing */
  --gap: 1.5rem;
  --gap-lg: 3rem;
  --radius: 8px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  overflow-x: hidden;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
a:hover {
  color: #79c0ff;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  line-height: 1.5;
}

/* ---------- Layout ---------- */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--color-bg-alt);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 0;
  z-index: 100;
  transition: transform 0.3s var(--ease);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-3));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(88, 166, 255, 0.25);
}

/* --- Sidebar nav --- */
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.75rem 1rem;
}

.toc-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.25rem 0 0.65rem;
  background: var(--color-bg-alt);
}

.toc-search-input {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: rgba(13, 17, 23, 0.85);
  color: var(--color-text);
  font-size: 0.83rem;
  padding: 0 0.75rem;
}

.toc-search-input::placeholder {
  color: var(--color-text-muted);
}

.toc-search-input:focus {
  outline: 2px solid rgba(88, 166, 255, 0.35);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

.sidebar nav > .nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s var(--ease);
  margin-bottom: 0.25rem;
}

.nav-group {
  margin-bottom: 0.25rem;
}

.nav-group-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 0.85rem 0.75rem 0.35rem;
  user-select: none;
}

.nav-group .nav-link {
  display: block;
  padding: 0.35rem 0.75rem 0.35rem 1rem;
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 0.84rem;
  font-weight: 400;
  transition: all 0.15s var(--ease);
  position: relative;
}

.nav-link:hover {
  background: rgba(88, 166, 255, 0.08);
  color: var(--color-text);
}

.nav-link.active {
  background: rgba(88, 166, 255, 0.12);
  color: var(--color-accent);
  font-weight: 500;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 3px;
  border-radius: 2px;
  background: var(--color-accent);
}

/* --- Sidebar footer --- */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 1rem 1rem;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.sidebar-ext-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all 0.15s var(--ease);
}

.sidebar-ext-link:hover {
  background: rgba(88, 166, 255, 0.08);
  color: var(--color-accent);
}

.sidebar-ext-link svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s var(--ease);
}

.sidebar-ext-link:hover svg {
  opacity: 1;
}

.sidebar-credit {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  padding: 0.25rem 0.6rem 0;
  opacity: 0.7;
}

.sidebar-credit a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sidebar-credit a:hover {
  color: var(--color-accent);
}

/* --- Main --- */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 2rem 3rem 4rem;
  max-width: 960px;
  margin-right: auto;
  /* Center within the space right of the sidebar:
     total remaining = 100vw - 280px; offset = (remaining - 960px) / 2 */
  margin-left: max(280px, calc((100vw - 960px + 280px) / 2));
}

/* --- Mobile toggle --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 14px;
}

.sidebar-toggle-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.sidebar-toggle-line:nth-child(1) {
  top: 0;
}

.sidebar-toggle-line:nth-child(2) {
  top: 6px;
}

.sidebar-toggle-line:nth-child(3) {
  top: 12px;
}

.toc-filter-hidden {
  display: none !important;
}

/* ----- Tablet: collapse sidebar ----- */
@media (max-width: 1024px) {
  .main-content {
    max-width: 100%;
    padding: 2rem 2rem 4rem;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .main-content {
    margin-left: 0;
    margin-right: 0;
    padding: 2rem 1.25rem 3rem;
    max-width: 100%;
  }

  .hero h1 {
    font-size: 2rem;
  }
  .hero .tagline {
    font-size: 1rem;
  }

  .feature-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
  }
  .cards {
    grid-template-columns: 1fr;
  }

  .mermaid-wrapper {
    padding: 1rem 0.75rem;
  }
  .mermaid-wrapper svg {
    max-width: 100%;
    height: auto !important;
  }

  section h2 {
    font-size: 1.35rem;
  }
  section h3 {
    font-size: 1.05rem;
  }

  table {
    font-size: 0.82rem;
  }
  thead th,
  tbody td {
    padding: 0.45rem 0.5rem;
  }
}

/* ----- Small phones ----- */
@media (max-width: 480px) {
  .main-content {
    padding: 1rem 0.75rem 2rem;
  }

  .hero {
    padding: 2rem 0 1.5rem;
  }
  .hero h1 {
    font-size: 1.6rem;
  }
  .hero .tagline {
    font-size: 0.9rem;
  }

  .badge-row {
    gap: 0.35rem;
  }
  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .feature-item {
    padding: 0.75rem 0.5rem;
  }
  .feature-item .fi-icon {
    font-size: 1.4rem;
  }
  .feature-item h5 {
    font-size: 0.82rem;
  }
  .feature-item p {
    font-size: 0.72rem;
  }

  pre {
    font-size: 0.78rem;
    padding: 0.75rem;
  }

  .code-block .lang-label {
    font-size: 0.6rem;
    top: 0.35rem;
    right: 0.5rem;
  }

  .callout {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  .scroll-top {
    width: 36px;
    height: 36px;
    bottom: 1rem;
    right: 1rem;
    font-size: 1rem;
  }

  section h2 {
    font-size: 1.2rem;
  }
  section h3 {
    font-size: 1rem;
  }
  section h4 {
    font-size: 0.9rem;
  }

  .card {
    padding: 1rem;
  }
  .card h4 {
    font-size: 0.9rem;
  }
  .card p {
    font-size: 0.8rem;
  }

  footer {
    font-size: 0.75rem;
    padding: 1.5rem 0;
  }
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.hero .tagline {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ---------- Sections ---------- */
section {
  margin-bottom: var(--gap-lg);
  scroll-margin-top: 2rem;
}

section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

section h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--color-accent-6);
}

section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
}

p,
li {
  margin-bottom: 0.5rem;
}

ul,
ol {
  padding-left: 1.5rem;
}

/* ---------- Cards Grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition:
    border-color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.card h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--color-accent);
}

.card p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin: 0;
}

.card .card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.tag-change {
  background: rgba(88, 166, 255, 0.15);
  color: var(--color-accent);
}
.tag-team {
  background: rgba(63, 185, 80, 0.15);
  color: var(--color-accent-2);
}
.tag-risk {
  background: rgba(247, 129, 102, 0.15);
  color: var(--color-accent-4);
}
.tag-dep {
  background: rgba(210, 168, 255, 0.15);
  color: var(--color-accent-3);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  background: var(--color-bg-alt);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

tbody tr:hover {
  background: rgba(88, 166, 255, 0.04);
}

/* ---------- Mermaid ---------- */
.mermaid-wrapper {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
}

.mermaid-wrapper .mermaid {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.mermaid-wrapper .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.mermaid-wrapper::-webkit-scrollbar,
pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
.mermaid-wrapper::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.mermaid-wrapper::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

/* Ensure images and SVGs never overflow */
img,
svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Feature Highlight ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.feature-item {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.feature-item .fi-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.feature-item h5 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.feature-item p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* ---------- Callout ---------- */
.callout {
  border-left: 4px solid var(--color-accent);
  background: rgba(88, 166, 255, 0.06);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-size: 0.92rem;
}

.callout.warn {
  border-left-color: var(--color-accent-4);
  background: rgba(247, 129, 102, 0.06);
}

.callout.success {
  border-left-color: var(--color-accent-2);
  background: rgba(63, 185, 80, 0.06);
}

/* ---------- Code blocks ---------- */
.code-block {
  position: relative;
}

.code-block .lang-label {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}

.tabs button {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s var(--ease);
}

.tabs button:hover {
  color: var(--color-text);
}

.tabs button.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ---------- Scroll to top ---------- */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.2s var(--ease);
}

.scroll-top.visible {
  display: flex;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--color-accent);
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-sep {
  color: var(--color-border);
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.5s var(--ease) forwards;
  opacity: 0;
}

/* Stagger children */
.stagger > * {
  opacity: 0;
}
.stagger.visible > *:nth-child(1) {
  animation: fadeInUp 0.4s 0s var(--ease) forwards;
}
.stagger.visible > *:nth-child(2) {
  animation: fadeInUp 0.4s 0.05s var(--ease) forwards;
}
.stagger.visible > *:nth-child(3) {
  animation: fadeInUp 0.4s 0.1s var(--ease) forwards;
}
.stagger.visible > *:nth-child(4) {
  animation: fadeInUp 0.4s 0.15s var(--ease) forwards;
}
.stagger.visible > *:nth-child(5) {
  animation: fadeInUp 0.4s 0.2s var(--ease) forwards;
}
.stagger.visible > *:nth-child(6) {
  animation: fadeInUp 0.4s 0.25s var(--ease) forwards;
}
.stagger.visible > *:nth-child(7) {
  animation: fadeInUp 0.4s 0.3s var(--ease) forwards;
}
.stagger.visible > *:nth-child(8) {
  animation: fadeInUp 0.4s 0.35s var(--ease) forwards;
}

/* ---------- Utility ---------- */
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--color-text-muted);
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.mb-3 {
  margin-bottom: 1.5rem;
}
