/* ============================================================
   CandleStrike Strategy Builder — User Documentation
   Design system matched to the CandleStrike product:
   Inter font, light gray-100 layout, red-600 (#DC2626) brand,
   builder section colors yellow-600 / green-600 / red-600.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #F4F5F7;
  --bg-panel: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-soft: #E5E7EB;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #1F2937;
  --text-strong: #111827;
  --text-muted: #6B7280;
  --brand: #DC2626;
  --brand-600: #DC2626;
  --brand-500: #EF4444;
  --brand-dark: #B91C1C;
  --brand-soft: #FEF2F2;
  --brand-grad: linear-gradient(135deg, #DC2626 0%, #EF4444 60%, #F87171 100%);
  --green: #16A34A;
  --green-soft: #F0FDF4;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --yellow: #CA8A04;
  --yellow-soft: #FEFCE8;
  --blue: #2563EB;
  --blue-soft: #EFF6FF;
  --code-bg: #14181F;
  --code-head: #1D232C;
  --code-inline-bg: #F3F4F6;
  --sidebar-w: 248px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 4px 14px rgba(17, 24, 39, 0.10);
  --shadow-brand: 0 8px 24px rgba(220, 38, 38, 0.18);
  font-size: 15px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(220, 38, 38, 0.045), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
nav.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px 24px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 50;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  padding: 2px 8px 0;
  text-decoration: none;
}
.sidebar .logo img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 36px;
}
.sidebar .logo span { color: var(--brand); }
.sidebar .logo-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 4px 0 12px;
  padding: 0 8px;
}

/* Search */
.sidebar .doc-search {
  position: relative;
  margin: 0 4px 18px;
}
.sidebar .doc-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  font: inherit;
  font-size: 0.86rem;
  color: var(--text);
  background: #F9FAFB;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.sidebar .doc-search input:focus {
  background: #fff;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.sidebar .doc-search::before {
  content: "";
  position: absolute;
  left: 11px; top: 50%;
  width: 12px; height: 12px;
  margin-top: -7px;
  border: 2px solid #9CA3AF;
  border-radius: 50%;
}
.sidebar .doc-search::after {
  content: "";
  position: absolute;
  left: 21px; top: 50%;
  width: 6px; height: 2px;
  margin-top: 4px;
  background: #9CA3AF;
  border-radius: 2px;
  transform: rotate(45deg);
}

.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 1px; }
.sidebar a {
  position: relative;
  display: block;
  padding: 8px 12px 8px 14px;
  border-radius: 8px;
  color: #4B5563;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  transition: background .15s, color .15s, padding .15s;
}
.sidebar a:hover { background: #F3F4F6; color: var(--text-strong); padding-left: 17px; }
.sidebar a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.sidebar a.active::before {
  content: "";
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 3.5px;
  border-radius: 4px;
  background: var(--brand-grad);
}
.sidebar .nav-group {
  margin: 20px 0 7px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #9CA3AF;
  padding-left: 14px;
}
.sidebar li.search-hidden { display: none; }

/* ============================================================
   Main column
   ============================================================ */
main {
  margin-left: var(--sidebar-w);
  padding: 28px 40px 64px;
  max-width: 860px;
  width: 100%;
}

/* ---------- Hero (index page) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--brand-grad);
  color: #fff;
  padding: 28px 32px 72px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-brand);
}
.hero h1 { color: #fff; border: none; margin: 0 0 8px; font-size: 1.7rem; letter-spacing: -0.03em; }
.hero p {
  color: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
  max-width: 58ch;
  margin-bottom: 14px;
}
.hero .hero-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.hero .hero-badges span {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 30px;
}
/* decorative candlestick chart along hero bottom */
.hero .candles {
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 64px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0 36px;
  opacity: 0.5;
  pointer-events: none;
}
.hero .candles i {
  position: relative;
  flex: 1;
  max-width: 26px;
  border-radius: 3px 3px 0 0;
  background: rgba(255, 255, 255, 0.85);
}
.hero .candles i::after {           /* wick */
  content: "";
  position: absolute;
  left: 50%; top: -14px;
  width: 2px; height: 14px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.7);
}
.hero .candles i.dn { background: rgba(31, 41, 55, 0.38); }
.hero .candles i:nth-child(1)  { height: 34%; }
.hero .candles i:nth-child(2)  { height: 52%; }
.hero .candles i:nth-child(3)  { height: 40%; }
.hero .candles i:nth-child(4)  { height: 64%; }
.hero .candles i:nth-child(5)  { height: 48%; }
.hero .candles i:nth-child(6)  { height: 76%; }
.hero .candles i:nth-child(7)  { height: 58%; }
.hero .candles i:nth-child(8)  { height: 86%; }
.hero .candles i:nth-child(9)  { height: 66%; }
.hero .candles i:nth-child(10) { height: 94%; }
.hero .candles i:nth-child(11) { height: 72%; }
.hero .candles i:nth-child(12) { height: 100%; }

/* ---------- Headings ---------- */
h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--text-strong);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.98rem;
  margin-bottom: 22px;
}

h2 {
  position: relative;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 32px 0 10px;
  padding-bottom: 8px;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border);
}
h2::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  width: 52px; height: 3px;
  border-radius: 3px;
  background: var(--brand-grad);
}
h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 22px 0 8px;
  color: var(--text-strong);
}
h3::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--brand-grad);
  margin-right: 9px;
  vertical-align: 1px;
}
h4 { font-size: 1rem; margin: 20px 0 8px; }

p { margin-bottom: 10px; max-width: 68ch; }
p.muted, span.muted { color: var(--text-muted); }

ul, ol { margin: 0 0 16px 24px; }
li { margin-bottom: 4px; }

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

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

/* ============================================================
   Tables
   ============================================================ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0 20px;
  font-size: 0.95rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #F0F1F3;
  vertical-align: top;
}
th {
  background: #FAFBFC;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td, table tr:hover td { background: #FBF9F9; }
td code { white-space: nowrap; }

/* ============================================================
   Code
   ============================================================ */
code {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-inline-bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1.5px 7px;
  color: var(--brand-dark);
  font-weight: 500;
}

pre {
  position: relative;
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 44px 20px 18px;
  overflow-x: auto;
  margin: 16px 0 26px;
  box-shadow: var(--shadow-md);
}
/* mac-style window header */
pre::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  background: var(--code-head);
  border-radius: var(--radius) var(--radius) 0 0;
}
pre::after {
  content: "";
  position: absolute;
  top: 9px; left: 16px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #FF5F57;
  box-shadow: 18px 0 0 #FEBC2E, 36px 0 0 #28C840;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: #E6E9EF;
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
}
pre .k { color: #FF8A8A; }
pre .v { color: #8FC2FF; }
pre .n { color: #FFD479; }
pre .s { color: #97E8B5; }
pre .c { color: #8B95A3; font-style: italic; }

/* copy button (injected by script.js) */
.copy-btn {
  position: absolute;
  top: 5px; right: 10px;
  z-index: 2;
  font: 600 0.72rem 'Inter', sans-serif;
  letter-spacing: 0.5px;
  color: #C8CDD5;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 3px 11px;
  cursor: pointer;
  transition: all .15s;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.copy-btn.copied { background: var(--green); border-color: var(--green); color: #fff; }

/* ============================================================
   Callouts
   ============================================================ */
.callout {
  position: relative;
  border-radius: var(--radius);
  padding: 12px 16px 12px 48px;
  margin: 14px 0 18px;
  border: 1px solid;
  font-size: 0.95rem;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
.callout::before {
  position: absolute;
  left: 16px; top: 15px;
  width: 26px; height: 26px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.callout .title {
  font-weight: 800;
  display: block;
  margin-bottom: 3px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.callout.tip    { background: var(--green-soft);  border-color: #BBF7D0; }
.callout.tip::before    { content: "✓"; background: var(--green); }
.callout.tip .title     { color: #15803D; }
.callout.warn   { background: var(--yellow-soft); border-color: #FDE68A; }
.callout.warn::before   { content: "!"; background: var(--yellow); }
.callout.warn .title    { color: #A16207; }
.callout.danger { background: var(--red-soft);    border-color: #FECACA; }
.callout.danger::before { content: "✕"; background: var(--red); }
.callout.danger .title  { color: var(--brand-dark); }
.callout.info   { background: var(--blue-soft);   border-color: #BFDBFE; }
.callout.info::before   { content: "i"; background: var(--blue); font-style: italic; font-family: Georgia, serif; }
.callout.info .title    { color: #1D4ED8; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2.5px 11px;
  border-radius: 20px;
  letter-spacing: 0.4px;
  vertical-align: middle;
}
.badge.green  { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.badge.red    { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.badge.yellow { background: #FEF9C3; color: #A16207; border: 1px solid #FDE68A; }
.badge.blue   { background: #DBEAFE; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge.gray   { background: #F3F4F6; color: #4B5563; border: 1px solid #E5E7EB; }

/* ============================================================
   Cards
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: hidden;
  transition: border-color .18s, transform .18s, box-shadow .18s;
  box-shadow: var(--shadow-sm);
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3.5px;
  background: var(--brand-grad);
  opacity: 0;
  transition: opacity .18s;
}
.card:hover {
  border-color: #FCA5A5;
  transform: translateY(-3px);
  box-shadow: var(--shadow-brand);
}
.card:hover::before { opacity: 1; }
.card h3 { margin: 0 0 7px; font-size: 1.03rem; color: var(--text-strong); }
.card h3::before { display: none; }
.card p { font-size: 1rem; color: var(--text-muted); margin: 0; max-width: none; }
.card a { display: block; color: inherit; text-decoration: none; }
.card a::after {
  content: "→";
  position: absolute;
  right: 18px; bottom: 14px;
  color: var(--brand);
  font-weight: 700;
  opacity: 0;
  transform: translateX(-6px);
  transition: all .18s;
}
.card:hover a::after { opacity: 1; transform: translateX(0); }

/* ============================================================
   Steps (numbered with connecting rail)
   ============================================================ */
.steps { counter-reset: step; list-style: none; margin-left: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 22px 52px;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -2px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.25);
  z-index: 1;
}
.steps > li::after {                /* connecting rail */
  content: "";
  position: absolute;
  left: 15px; top: 32px; bottom: -2px;
  width: 2px;
  background: linear-gradient(#FECACA, #FEE2E2);
}
.steps > li:last-child { padding-bottom: 4px; }
.steps > li:last-child::after { display: none; }

/* ============================================================
   Section chips (builder colors)
   ============================================================ */
.section-chip {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3.5px;
  margin-right: 7px;
  vertical-align: -1px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.18);
}
.section-chip.pre   { background: #CA8A04; }
.section-chip.entry { background: #16A34A; }
.section-chip.exit  { background: #DC2626; }

/* ============================================================
   FAQ
   ============================================================ */
details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .15s;
}
details:hover { border-color: #FCA5A5; }
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-strong);
  outline: none;
  padding: 11px 40px 11px 14px;
  position: relative;
  list-style: none;
  transition: background .12s;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: "+";
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
}
details[open] summary { color: var(--brand); background: #FFFBFB; }
details[open] summary::after { content: "–"; transform: translateY(-50%); background: var(--brand); color: #fff; }
details > *:not(summary) { padding: 0 20px; }
details > p:last-child, details > ul:last-child { padding-bottom: 16px; }
details p, details ul { font-size: 1rem; }
details[open] > p:first-of-type, details[open] > ul:first-of-type { margin-top: 6px; }

/* ============================================================
   Footer page nav
   ============================================================ */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
}
.page-nav a {
  flex: 1;
  max-width: 330px;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow: var(--shadow-sm);
}
.page-nav a:last-child { text-align: right; margin-left: auto; }
.page-nav a:hover {
  border-color: #FCA5A5;
  box-shadow: var(--shadow-brand);
  transform: translateY(-2px);
}
.page-nav .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--brand);
  margin-bottom: 2px;
}
.page-nav .title { font-size: 0.98rem; color: var(--text-strong); font-weight: 700; }

/* ============================================================
   On-this-page TOC (right rail, injected by script.js)
   ============================================================ */
.toc-rail {
  position: fixed;
  top: 48px;
  right: 28px;
  width: 200px;
  font-size: 0.8rem;
  display: none;
}
@media (min-width: 1460px) { .toc-rail { display: block; } }
.toc-rail .toc-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #9CA3AF;
  margin-bottom: 10px;
}
.toc-rail a {
  display: block;
  color: var(--text-muted);
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
  text-decoration: none;
  line-height: 1.4;
  transition: color .15s, border-color .15s;
}
.toc-rail a:hover { color: var(--text-strong); }
.toc-rail a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }

/* ============================================================
   Back-to-top (injected by script.js)
   ============================================================ */
.back-top {
  position: fixed;
  right: 26px; bottom: 26px;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  z-index: 60;
}
.back-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-top:hover { transform: translateY(-2px); }

/* ============================================================
   Reveal animation
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  main > h2, main > table, main > .callout, main > pre,
  main > .card-grid, main > details, main > .steps {
    animation: fadeUp .45s ease both;
  }
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 880px) {
  nav.sidebar { position: static; width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  body { flex-direction: column; }
  main { margin-left: 0; padding: 22px 16px 48px; }
  .hero { padding: 24px 20px 72px; }
  .hero h1 { font-size: 1.45rem; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: none; }
}
