/* ─────────────────────────────────────────
   nx-safe-suite Documentation — style.css
   ───────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens ── */
:root {
  --bg:          #0F1117;
  --bg-sidebar:  #0B0E15;
  --bg-surface:  #161B27;
  --bg-code:     #1A2236;
  --border:      #1E2940;
  --accent:      #3B82F6;
  --accent-soft: #1D3557;
  --text:        #DDE4EE;
  --text-muted:  #6B7A99;
  --text-dim:    #4A566E;
  --white:       #FFFFFF;

  --pkg-env:   #3B82F6;
  --pkg-api:   #8B5CF6;
  --pkg-guard: #EF4444;
  --pkg-cache: #10B981;
  --pkg-audit: #F59E0B;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-w: 260px;
  --header-h:  56px;
  --radius:    6px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ──────────────────────────────────────────
   HEADER
   ────────────────────────────────────────── */

header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  z-index: 200;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-mark svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: white;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo-text span { color: var(--accent); }

.header-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.header-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.header-link:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.header-link svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex-shrink: 0;
}

.header-link .link-label {
  display: inline;
}

/* Menu button — hidden on desktop */
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.menu-btn:hover {
  color: var(--text);
  background: var(--bg-surface);
}

/* ──────────────────────────────────────────
   OVERLAY (mobile sidebar backdrop)
   ────────────────────────────────────────── */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s;
}

.overlay.visible {
  display: block;
  opacity: 1;
}

/* ──────────────────────────────────────────
   LAYOUT
   ────────────────────────────────────────── */

.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ──────────────────────────────────────────
   SIDEBAR
   ────────────────────────────────────────── */

sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0 60px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  z-index: 160;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover { color: var(--text); background: var(--bg-surface); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-sub { padding-left: 27px; }

.nav-sub .nav-item {
  font-size: 12.5px;
  padding: 6px 10px;
}

/* ──────────────────────────────────────────
   MAIN CONTENT
   ────────────────────────────────────────── */

main {
  margin-left: var(--sidebar-w);
  flex: 1;
  max-width: 860px;
  padding: 48px 56px 120px;
  min-width: 0;
}

/* ── Sections ── */
.doc-section { display: none; }
.doc-section.visible { display: block; }

/* ──────────────────────────────────────────
   TYPOGRAPHY
   ────────────────────────────────────────── */

h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 12px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.01em;
  margin-top: 48px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 28px;
  margin-bottom: 10px;
}

p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

strong { color: var(--text); font-weight: 500; }

/* ── Lead ── */
.lead {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.75;
  border-left: 3px solid var(--accent);
  padding-left: 16px;
}

/* ── Package badge ── */
.pkg-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.pkg-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid;
}

.pkg-version {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-surface);
  padding: 3px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ──────────────────────────────────────────
   CODE BLOCKS
   ────────────────────────────────────────── */

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}

.pre-label {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-surface);
  color: #93C5FD;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-word;
}

/* Syntax highlight tokens */
.kw { color: #93C5FD; }
.fn { color: #86EFAC; }
.st { color: #FCA5A5; }
.cm { color: #4A566E; }
.ty { color: #F9A8D4; }
.nm { color: #FCD34D; }
.op { color: #A78BFA; }

/* ──────────────────────────────────────────
   CARDS
   ────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

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

.card:active { transform: translateY(0); }

.card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-bottom: 12px;
}

.card-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-all;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ──────────────────────────────────────────
   API TABLE
   ────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 480px;
}

.api-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  white-space: nowrap;
}

.api-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

.api-table tr:last-child td { border-bottom: none; }

.api-table td:first-child {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #93C5FD;
  white-space: nowrap;
}

.api-table td:nth-child(2) {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ──────────────────────────────────────────
   CALLOUTS
   ────────────────────────────────────────── */

.callout {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.callout.info  { border-left-color: var(--accent); }
.callout.warn  { border-left-color: var(--pkg-audit); }
.callout.tip   { border-left-color: var(--pkg-cache); }

.callout strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.callout.info  strong { color: var(--accent); }
.callout.warn  strong { color: var(--pkg-audit); }
.callout.tip   strong { color: var(--pkg-cache); }

/* ──────────────────────────────────────────
   STAT ROW
   ────────────────────────────────────────── */

.stat-row {
  display: flex;
  gap: 32px;
  margin: 28px 0;
  flex-wrap: wrap;
}

.stat { display: flex; flex-direction: column; gap: 4px; }

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

/* ──────────────────────────────────────────
   MOBILE BOTTOM NAV (≤ 480px)
   Shortcuts to main package sections
   ────────────────────────────────────────── */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  z-index: 140;
  padding: 0 4px env(safe-area-inset-bottom, 0);
  overflow-x: auto;
  scrollbar-width: none;
}

.mobile-bottom-nav::-webkit-scrollbar { display: none; }

.mobile-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  min-width: max-content;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn:hover,
.mobile-nav-btn.active { color: var(--accent); }

.mobile-nav-btn .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* ──────────────────────────────────────────
   RESPONSIVE — Tablet (≤ 900px)
   ────────────────────────────────────────── */

@media (max-width: 900px) {
  main {
    padding: 40px 36px 100px;
  }

  h1 { font-size: 24px; }
  h2 { font-size: 18px; }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ──────────────────────────────────────────
   RESPONSIVE — Mobile (≤ 768px)
   ────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Header */
  .header-sep   { display: none; }
  .header-meta  { display: none; }
  .header-link .link-label { display: none; }
  .header-link  { padding: 6px 8px; }
  .menu-btn     { display: flex; }

  /* Sidebar slides in from the left */
  sidebar {
    top: 0;
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw);
    z-index: 170;
    padding-top: calc(var(--header-h) + 12px);
  }

  sidebar.open { transform: translateX(0); }

  /* Main fills the screen */
  main {
    margin-left: 0;
    padding: 32px 20px 100px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 17px; margin-top: 36px; }

  .lead { font-size: 14.5px; }

  pre {
    padding: 16px 16px;
    font-size: 12px;
    border-radius: 4px;
  }

  pre code { font-size: 12px; }

  .pre-label { display: none; }

  .stat-row { gap: 20px; }
  .stat-value { font-size: 20px; }

  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .pkg-badge {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Show bottom nav */
  .mobile-bottom-nav { display: block; }

  /* Add bottom padding so content isn't hidden behind bottom nav */
  main { padding-bottom: 130px; }
}

/* ──────────────────────────────────────────
   RESPONSIVE — Small mobile (≤ 480px)
   ────────────────────────────────────────── */

@media (max-width: 480px) {
  header { padding: 0 14px; gap: 10px; }

  main { padding: 24px 16px 130px; }

  h1 { font-size: 20px; }
  h2 { font-size: 16px; margin-top: 28px; }

  .card-grid { grid-template-columns: 1fr; }

  .callout { padding: 12px 14px; font-size: 13px; }

  .api-table { font-size: 12.5px; }
  .api-table th, .api-table td { padding: 8px 10px; }

  .stat-row { gap: 16px; }
}

/* ──────────────────────────────────────────
   REDUCED MOTION
   ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, sidebar, .overlay, .card {
    transition: none !important;
    animation: none !important;
  }
}
