/* ═══════════════════════════════════════════════════════════
   AutoLock Knowledge Base — Style
   Matches the AutoLock app: dark-first, Electric Blue #2563EB
   ═══════════════════════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-padding-top: 2rem;
}

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Dark (default — matches autolock app) */
  --bg:          hsl(222 47% 6%);
  --surface:     hsl(222 47% 8%);
  --surface-2:   hsl(222 47% 10%);
  --sidebar-bg:  hsl(222 47% 7%);
  --border:      hsl(222 30% 14%);
  --border-2:    hsl(222 30% 18%);
  --text:        hsl(215 20% 91%);
  --text-muted:  hsl(215 15% 55%);
  --text-faint:  hsl(215 10% 35%);
  --primary:     hsl(221 83% 53%);
  --primary-dim: hsla(221, 83%, 53%, 0.12);
  --primary-border: hsla(221, 83%, 53%, 0.3);
  --success:     hsl(161 58% 44%);
  --warning:     hsl(43 74% 55%);
  --danger:      hsl(0 72% 55%);
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:   0 10px 32px rgba(0,0,0,.5);
  --sidebar-w:   260px;
}

[data-theme="light"] {
  --bg:          hsl(220 20% 97%);
  --surface:     hsl(0 0% 100%);
  --surface-2:   hsl(220 14% 95%);
  --sidebar-bg:  hsl(220 15% 96%);
  --border:      hsl(220 13% 88%);
  --border-2:    hsl(220 13% 82%);
  --text:        hsl(222 47% 10%);
  --text-muted:  hsl(222 15% 45%);
  --text-faint:  hsl(222 10% 62%);
  --primary:     hsl(221 83% 48%);
  --primary-dim: hsla(221, 83%, 53%, 0.10);
  --primary-border: hsla(221, 83%, 53%, 0.25);
  --success:     hsl(161 58% 38%);
  --warning:     hsl(43 74% 45%);
  --danger:      hsl(0 72% 48%);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:   0 10px 32px rgba(0,0,0,.12);
}

body {
  font-family: var(--font-sans);
  font-size: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.layout {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  transition: margin-left .2s ease;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform .2s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
.sidebar-logo-text {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sidebar-logo-sub {
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.sidebar-close:hover { color: var(--text); background: var(--surface-2); }

.sidebar-search {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.sidebar-search .search-icon {
  position: absolute;
  left: 1.3rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.42rem 0.75rem 0.42rem 2.1rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  outline: none;
  transition: border-color .15s;
}
.sidebar-search input::placeholder { color: var(--text-faint); }
.sidebar-search input:focus { border-color: var(--primary); }

nav.sidebar > div.nav-section-label,
.nav-section-label {
  padding: 0.85rem 1rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  flex-shrink: 0;
}

.nav-list {
  list-style: none;
  padding: 0 0.5rem;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 450;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.nav-item svg { flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  color: var(--primary);
  background: var(--primary-dim);
  font-weight: 500;
}
.nav-item.active svg { opacity: 1; color: var(--primary); }

/* Scrollable nav area */
.sidebar > .nav-section-label,
.sidebar > .nav-list {
  /* handled inline below */
}
.sidebar {
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-app-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color .15s;
}
.sidebar-app-link:hover { color: var(--primary); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-2); }

/* ── MOBILE HEADER ────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}
.menu-toggle, .theme-toggle-mobile {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.menu-toggle:hover, .theme-toggle-mobile:hover { color: var(--text); }
.mobile-header-title { font-size: 0.9rem; font-weight: 600; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem);
}

/* ── PAGE SECTIONS ─────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* Hero */
.hero {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-dim);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
}
.hero h1 {
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.9rem;
  color: var(--text);
}
.hero-lead {
  font-size: clamp(0.95rem, 0.85rem + 0.5vw, 1.1rem);
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.7;
}

/* Page title (non-hero) */
.page-title {
  font-size: clamp(1.3rem, 1rem + 1.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.page-lead {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 600px;
  line-height: 1.65;
}

/* Section heading */
h2 {
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.9rem;
}
h2:first-child { margin-top: 0; }

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.9rem;
  max-width: 68ch;
}
p strong { color: var(--text); font-weight: 600; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-dim);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 0.9rem;
}
.card h3 {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.25rem;
}
.card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  max-width: none;
}

/* ── FEATURE BLOCKS ────────────────────────────────────────── */
.feature-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  margin: 1.25rem 0;
}
.feature-block h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.7rem;
}
.feature-block h3 svg { color: var(--primary); flex-shrink: 0; }
.feature-block p {
  margin: 0 0 0.5rem;
}
.feature-block p:last-child { margin: 0; }

/* ── STEPS ─────────────────────────────────────────────────── */
.steps {
  counter-reset: step;
  margin: 1.25rem 0;
}
.step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  position: relative;
}
.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: -1.25rem;
  width: 1px;
  background: var(--border);
}
.step-num {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  background: var(--primary-dim);
  border: 1px solid var(--primary-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  counter-increment: step;
  z-index: 1;
}
.step-body h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.step-body p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  max-width: none;
}

/* ── CALLOUTS ─────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  font-size: 0.86rem;
  line-height: 1.6;
}
.callout svg { flex-shrink: 0; margin-top: 0.1rem; }
.callout-body { color: var(--text-muted); }
.callout-body strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 0.15rem; }

.callout-info  { background: var(--primary-dim); border-left: 3px solid var(--primary); }
.callout-info svg { color: var(--primary); }

.callout-warning { background: hsla(43, 74%, 55%, 0.1); border-left: 3px solid var(--warning); }
.callout-warning svg { color: var(--warning); }

.callout-danger { background: hsla(0, 72%, 55%, 0.1); border-left: 3px solid var(--danger); }
.callout-danger svg { color: var(--danger); }

.callout-success { background: hsla(161, 58%, 44%, 0.1); border-left: 3px solid var(--success); }
.callout-success svg { color: var(--success); }

/* ── TABLE ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
table { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
thead { background: var(--surface); }
th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
td strong { color: var(--text); }
tr:hover td { background: var(--surface-2); }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
}
.badge-blue    { background: hsla(221,83%,53%,.12); border: 1px solid hsla(221,83%,53%,.3); color: hsl(221 83% 66%); }
.badge-green   { background: hsla(161,58%,44%,.12); border: 1px solid hsla(161,58%,44%,.3); color: hsl(161 58% 60%); }
.badge-amber   { background: hsla(43,74%,55%,.12);  border: 1px solid hsla(43,74%,55%,.3);  color: hsl(43 74% 65%); }
.badge-red     { background: hsla(0,72%,55%,.12);   border: 1px solid hsla(0,72%,55%,.3);   color: hsl(0 72% 70%); }
.badge-orange  { background: hsla(27,87%,58%,.12);  border: 1px solid hsla(27,87%,58%,.3);  color: hsl(27 87% 70%); }
.badge-purple  { background: hsla(262,73%,65%,.12); border: 1px solid hsla(262,73%,65%,.3); color: hsl(262 73% 75%); }
.badge-neutral { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* ── CODE ──────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  color: var(--primary);
}

/* ── KEYBOARD SHORTCUTS ─────────────────────────────────────── */
kbd {
  font-family: var(--font-mono);
  font-size: 0.78em;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 0.15em 0.45em;
  color: var(--text);
  white-space: nowrap;
}

/* ── DIVIDER ─────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── QUICK NAV ───────────────────────────────────────────────── */
.quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0;
}
.quick-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  font-family: var(--font-sans);
}
.quick-nav-btn:hover { color: var(--primary); border-color: var(--primary-border); }

/* ── ICON LIST ───────────────────────────────────────────────── */
.icon-list {
  list-style: none;
  margin: 0.75rem 0;
}
.icon-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.icon-list li:last-child { border-bottom: none; }
.icon-list li svg { flex-shrink: 0; margin-top: 0.1rem; color: var(--primary); }
.icon-list li strong { color: var(--text); }

/* ── SEARCH OVERLAY ─────────────────────────────────────────── */
.search-overlay {
  display: none;
  position: fixed;
  top: 60px;
  left: var(--sidebar-w);
  right: 0;
  z-index: 200;
  padding: 0.5rem 1rem;
}
.search-overlay.active { display: block; }
.search-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  max-width: 600px;
}
.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-2); }
.search-result-title { font-size: 0.86rem; font-weight: 600; color: var(--text); }
.search-result-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.search-no-results { padding: 1rem; font-size: 0.85rem; color: var(--text-muted); text-align: center; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex !important; }
  .mobile-header { display: flex; }
  .sidebar-overlay.active { display: block; }
  .search-overlay { left: 0; top: 56px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 1.5rem 1rem; }
}
@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
}

/* ── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page.active { animation: fadeIn .2s ease; }

/* ── FOOTER NAV ─────────────────────────────────────────────── */
.doc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.doc-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 1rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  font-family: var(--font-sans);
  text-align: left;
}
.doc-footer-btn:hover { color: var(--primary); border-color: var(--primary-border); }
.doc-footer-btn small { display: block; font-size: 0.72rem; color: var(--text-faint); font-weight: 400; }
.doc-footer-btn.next { text-align: right; margin-left: auto; }
