/* ==========================================================================
   Compendium Guides — docs/tool shell
   Opaque, neutral, professional. No gradients, no glass, no emoji.
   ========================================================================== */

:root {
  /* Color tokens — native app palette (AppTheme dark mode) */
  --bg: #000000;
  --panel: #1C1C1E;
  --panel-2: #2C2C2E;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --text: #FFFFFF;
  --text-2: #8F8F94;
  --text-3: #7C7C82;
  --accent: #8B5CF6;
  --accent-hover: #A78BFA;
  --accent-muted: rgba(139, 92, 246, 0.14);

  /* Semantic — app accent colors */
  --tip: #00C753;
  --note: #0094FF;
  --warning: #FF9400;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Layout */
  --topbar-h: 56px;
  --sidebar-w: 260px;
  --rail-w: 220px;
  --content-max: 720px;
  --page-max: 1240px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* SVG icons */
.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   Testing banner
   ========================================================================== */
.testing-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1;
}
.testing-banner .icon {
  width: 14px;
  height: 14px;
  color: var(--warning);
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: block;
}
.topbar .wordmark {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar .brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid var(--border);
}
.topbar .hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 4px;
  margin-left: -6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 6px;
}
.topbar .hamburger:hover { background: var(--panel-2); color: var(--text); }
.topbar .hamburger .icon { width: 20px; height: 20px; }

/* ==========================================================================
   Page grid
   ========================================================================== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--rail-w);
  max-width: none;
  margin: 0;
  align-items: start;
}
/* Welcome / index: no right rail */
.layout.no-rail {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
}
.nav-group { margin-bottom: 22px; }
.nav-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 12px;
  margin: 0 0 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-2);
  position: relative;
}
.nav-item .icon { color: currentColor; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-muted);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-item.disabled {
  color: var(--text-3);
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
   Content column
   ========================================================================== */
.content {
  min-width: 0;
  padding: 32px;
  max-width: calc(var(--content-max) + 64px);
  margin: 0 auto;
  width: 100%;
}
.content-inner { max-width: var(--content-max); }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .current { color: var(--text); }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--text-3); }

/* Page header */
h1 {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  color: var(--text);
}
.lead {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 640px;
  margin: 0 0 24px;
}
.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0 0 32px;
}

/* Headings within body */
h2 {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--text);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
h2 .num {
  display: inline-block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
  margin-right: 12px;
  letter-spacing: 0;
}
h3 {
  font-size: 16px;
  line-height: 1.35;
  font-weight: 650;
  margin: 24px 0 12px;
  color: var(--text);
}

/* Major section separation */
.section {
  margin-top: 40px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

/* ==========================================================================
   Steps — ordered list with counter circles
   ========================================================================== */
ol.steps {
  list-style: none;
  counter-reset: step;
  margin: 12px 0;
  padding: 0;
}
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
  margin-bottom: 12px;
}
ol.steps > li:last-child { margin-bottom: 0; }
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
ol.steps .step-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.4;
}
ol.steps p {
  font-size: 15px;
  color: var(--text-2);
  margin: 0;
}

/* ==========================================================================
   Definition-style sub-procedure rows
   ========================================================================== */
.deflist { margin: 12px 0; }
.deflist .row {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.deflist .row:last-child { border-bottom: 1px solid var(--border); }
.deflist .term {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.deflist .desc {
  font-size: 15px;
  color: var(--text-2);
}

/* Simple bulleted list */
ul.bullets { margin: 12px 0; padding-left: 18px; }
ul.bullets li { margin-bottom: 8px; color: var(--text-2); line-height: 1.6; }
ul.bullets li:last-child { margin-bottom: 0; }
ul.bullets li::marker { color: var(--text-3); }
ul.bullets b { color: var(--text); font-weight: 600; }

/* ==========================================================================
   Figures
   ========================================================================== */
figure.figure {
  margin: 16px 0 24px;
}
figure.figure .frame {
  display: inline-block;
  max-width: 280px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.6);
}
figure.figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
figure.figure figcaption {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 8px;
  text-align: left;
}
figure.figure figcaption b { color: var(--text); font-weight: 600; }

/* Placeholder (preview only) — shown when image missing */
figure.figure .placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 240px;
  height: 360px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-3);
  text-align: center;
  padding: 16px;
}
figure.figure .placeholder .icon {
  width: 28px;
  height: 28px;
  color: var(--text-3);
}
figure.figure .placeholder .ptitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
figure.figure .placeholder code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: transparent;
  padding: 0;
  color: var(--text-3);
  word-break: break-all;
}
/* Missing image: hide the img, show the placeholder */
figure.figure img.is-missing { display: none; }
figure.figure img.is-missing + .placeholder { display: flex; }

/* ==========================================================================
   Callouts
   ========================================================================== */
.callout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 4px;
  background: var(--panel);
  border-left: 3px solid var(--border-strong);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
  margin: 16px 0;
}
.callout .icon { margin-top: 1px; }
.callout b { color: var(--text); font-weight: 600; }
.callout.info {
  border-left-color: var(--note);
  background: var(--accent-muted);
}
.callout.info .icon { color: var(--note); }
.callout.tip { border-left-color: var(--tip); }
.callout.tip .icon { color: var(--tip); }
.callout.warning { border-left-color: var(--warning); }
.callout.warning .icon { color: var(--warning); }

/* ==========================================================================
   Inline UI label + code + kbd
   ========================================================================== */
.ui {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--panel-2);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}
kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

/* ==========================================================================
   Index / Welcome list
   ========================================================================== */
.guide-list { margin: 0; }
.guide-list .guide-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-list .guide-row:last-child { border-bottom: 1px solid var(--border); }
.guide-list .guide-row .icon {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--accent);
}
.guide-list .guide-row.disabled .icon { color: var(--text-3); }
.guide-list .row-text { min-width: 0; }
.guide-list .row-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.guide-list a.guide-row:hover .row-title { color: var(--accent); }
.guide-list .guide-row.disabled .row-title { color: var(--text-3); }
.guide-list .row-desc { font-size: 14px; color: var(--text-2); }
.guide-list .guide-row.disabled .row-desc { color: var(--text-3); }
.guide-list .soon-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-left: 8px;
  vertical-align: middle;
}

/* ==========================================================================
   "On this page" rail
   ========================================================================== */
.toc-rail {
  position: sticky;
  top: 80px;
  align-self: start;
  padding: 32px 20px 32px 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.toc-rail .toc-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
}
.toc-rail a {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  margin-bottom: 2px;
}
.toc-rail a.sub { padding-left: 24px; }
.toc-rail a:hover { color: var(--accent); }
.toc-rail a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Collapsed TOC (900–1100px) */
.toc-collapsed {
  display: none;
  margin: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}
.toc-collapsed summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.toc-collapsed summary::-webkit-details-marker { display: none; }
.toc-collapsed summary .icon { width: 14px; height: 14px; transition: transform 0.15s; }
.toc-collapsed[open] summary .icon { transform: rotate(180deg); }
.toc-collapsed .toc-collapsed-body { padding: 0 14px 12px; }
.toc-collapsed a {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  padding: 4px 0;
}
.toc-collapsed a.sub { padding-left: 14px; }
.toc-collapsed a:hover { color: var(--accent); }

/* ==========================================================================
   Drawer scrim (mobile)
   ========================================================================== */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.55);
}
body.drawer-open .scrim { display: block; }

/* ==========================================================================
   Footer
   ========================================================================== */
.guide-footer {
  border-top: 1px solid var(--border);
  padding: 20px 32px;
  color: var(--text-3);
  font-size: 13px;
  max-width: var(--page-max);
  margin: 0 auto;
}

/* ==========================================================================
   Platform switch
   ========================================================================== */
/* Show only the active platform's tagged content. Untagged content always shows. */
html.platform-ios     [data-platform="android"] { display: none !important; }
html.platform-android [data-platform="ios"]     { display: none !important; }

/* Section numbering via CSS counter, so platform-hidden sections never leave gaps.
   (Replaces the hard-coded 01/02 digits in each <span class="num">.) */
.content-inner { counter-reset: section; }
.content-inner .section { counter-increment: section; }
.content-inner .section > h2 .num::before { content: counter(section, decimal-leading-zero); }

/* Sidebar platform switch control */
.platform-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 22px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.platform-switch button {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.platform-switch button:hover { color: var(--text); }
.platform-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* Subtle crossfade for partial (pjax) navigation. The shell is identical
   across pages, so a root view-transition reads as a content-only fade. */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 120ms; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* 900–1100: drop right rail, show collapsed TOC */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc-rail { display: none; }
  .toc-collapsed { display: block; }
}

/* <900: sidebar becomes drawer, content full width */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topbar .hamburger { display: flex; }
  .topbar .brand-sub { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--border);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  .content { padding: 20px; }
}
