/* ============================================================
   KHAN SNIPER PRO — Guide base layer
   Shared by every page in guide/. Owns tokens, base typography,
   page chrome (topbar / footer / series nav), tables, callouts,
   the library cards, and the print stylesheet.

   Component layers on top of this:
     plate.css   ICT lesson components (blueprint plates, timeline)
     course.css  Price Action course components

   Palette is the landing page's: dark #0a0e14 ground, one gold
   accent. Dark-only on purpose — index.html sets color-scheme:dark
   for the whole site, so there is no light palette and no theme
   toggle to keep in sync.
   ============================================================ */

:root {
  /* ---- KHAN brand tokens (mirror index.html :root) ---- */
  --bg:        #0a0e14;
  --gold:      #ff9c1a;
  --gold2:     #ffc266;
  --text:      rgba(255,255,255,.94);
  --muted:     rgba(255,255,255,.65);
  --muted2:    rgba(255,255,255,.42);
  --line:      rgba(255,255,255,.12);
  --line-soft: rgba(255,255,255,.07);
  --success:   #00d18f;
  --danger:    #f6465d;
  --info:      #4493f8;

  /* ---- structural tokens read by plate.css / course.css / chart.js ----
     These MUST hold literal colour values, never var() indirection:
     chart.js resolves them with getComputedStyle().getPropertyValue()
     to paint SVG fills, and a token whose value is another var() is
     not guaranteed to come back resolved. */
  --paper:       #0a0e14;
  --surface:     #111823;   /* opaque — figure grid gradients sit on it */
  --surface-2:   #182231;   /* opaque */
  --ink:         rgba(255,255,255,.94);
  --ink-2:       rgba(255,255,255,.65);
  --ink-3:       rgba(255,255,255,.42);
  --rule:        rgba(255,255,255,.12);
  --rule-soft:   rgba(255,255,255,.07);
  --accent:      #ff9c1a;
  --accent-soft: rgba(255,156,26,.10);
  --accent-line: rgba(255,156,26,.34);
  --bull:        #00d18f;
  --bear:        #f6465d;
  --amber:       #f59e0b;
  --grid:        rgba(255,255,255,.05);

  /* ---- type ---- */
  --f-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", Roboto, "Arial Unicode MS", sans-serif;
  --f-mono: "Cascadia Mono", ui-monospace, Consolas, "Liberation Mono", monospace;
  --measure: 70ch;

  /* ---- spacing scale ---- */
  --s1: .35rem; --s2: .7rem;  --s3: 1.1rem; --s4: 1.7rem;
  --s5: 2.6rem; --s6: 4rem;   --s7: 6rem;

  --r: 12px; --r2: 16px;
}

html { color-scheme: dark; scroll-behavior: smooth; }
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 18px 60px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 940px; margin: 0 auto; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.topbar .back {
  color: var(--gold); font-weight: 700; text-decoration: none;
  padding: 8px 14px; border: 1px solid var(--accent-line);
  border-radius: var(--r); background: var(--accent-soft);
}
.topbar .back:hover { background: rgba(255,156,26,.18); }
.topbar .brand {
  font-weight: 800; letter-spacing: .04em; font-size: 13px;
  color: rgba(255,255,255,.86);
}

/* ---------- headings ---------- */
h1 {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900; letter-spacing: -.025em; line-height: 1.1;
  color: var(--gold);
  border-bottom: 3px solid var(--gold);
  padding-bottom: 10px;
  margin: 0 0 10px;
  text-wrap: balance;
}
h1 em { font-style: italic; color: var(--gold2); }
h2 {
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 800; letter-spacing: -.015em; line-height: 1.22;
  color: var(--gold);
  border-left: 4px solid var(--gold);
  padding-left: 10px;
  margin: var(--s5) 0 var(--s2);
  text-wrap: balance;
}
h3 {
  font-size: 17px; font-weight: 750;
  color: rgba(255,255,255,.9);
  margin: var(--s4) 0 var(--s1);
}
h4 { font-size: 15px; font-weight: 700; color: var(--gold); margin: var(--s3) 0 var(--s1); }

.subtitle, .standfirst {
  color: var(--muted); font-size: 15px;
  max-width: var(--measure); margin: 0 0 14px;
}

/* ---------- text ---------- */
p  { margin: 8px 0; max-width: var(--measure); }
ul, ol { margin: 6px 0 var(--s3); padding-left: 22px; max-width: var(--measure); }
li { margin-bottom: 4px; }
li::marker { color: var(--gold); }
b, strong { color: rgba(255,255,255,.96); font-weight: 700; }
em { font-style: italic; }
a  { color: var(--gold); text-underline-offset: .18em; }
a:hover { color: var(--gold2); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }

code {
  font-family: var(--f-mono); font-size: .88em;
  background: rgba(255,156,26,.12); color: var(--gold);
  padding: 1px 6px; border-radius: 4px;
}
pre {
  font-family: var(--f-mono); font-size: 13px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s3); margin: var(--s3) 0; overflow-x: auto;
}
pre code { background: none; padding: 0; color: var(--text); }

/* ---------- tables ---------- */
.tbl-scroll {
  overflow-x: auto; margin: var(--s3) 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r);
}
table {
  width: 100%; border-collapse: collapse;
  margin: 10px 0 16px; font-size: 14px;
}
.tbl-scroll table { margin: 0; min-width: 560px; }
th {
  background: #141a24; color: var(--gold);
  padding: 8px 10px; text-align: left; font-weight: 700;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 7px 10px; vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
tbody tr:last-child td { border-bottom: 0; }
tr:nth-child(even) td { background: rgba(255,255,255,.04); }
td.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------- callouts ---------- */
.note, .tip, .danger, .callout {
  border-radius: 6px; padding: 10px 14px; margin: 14px 0;
  font-size: 15px; max-width: var(--measure);
}
.note   { background: rgba(68,147,248,.12); border-left: 4px solid var(--info); }
.tip    { background: rgba(0,209,143,.12);  border-left: 4px solid var(--success); }
.danger { background: rgba(246,70,93,.12);  border-left: 4px solid var(--danger); }
.note > :last-child, .tip > :last-child, .danger > :last-child { margin-bottom: 0; }
.note .tag, .tip .tag, .danger .tag {
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase;
  display: block; margin-bottom: var(--s1);
}
.note .tag { color: var(--info); }
.tip  .tag { color: var(--success); }
.danger .tag { color: var(--danger); }

/* inline emphasis words, not boxes */
.warn { color: var(--danger); font-weight: 700; }
.ok   { color: var(--success); font-weight: 700; }
.hot  { color: var(--gold); font-weight: 700; }

.formula {
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 8px; padding: 10px 14px; margin: 12px 0;
  font-family: var(--f-mono); font-size: 14px;
  color: rgba(255,224,170,.95);
  overflow-x: auto;
}
.big { font-size: 19px; font-weight: 800; color: var(--gold); }

.badge {
  display: inline-block; vertical-align: middle;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--gold);
  border: 1px solid var(--accent-line);
}

/* ---------- series nav (prev / current / next lesson) ---------- */
nav.series {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s3); flex-wrap: wrap;
  margin-top: var(--s6); padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
nav.series a {
  color: var(--gold); text-decoration: none; font-weight: 700;
  padding: 7px 12px; border: 1px solid var(--accent-line);
  border-radius: var(--r); background: var(--accent-soft);
}
nav.series a:hover { background: rgba(255,156,26,.18); }
nav.series span { color: var(--muted2); }
nav.series .cur { color: var(--muted); font-weight: 700; }

/* ---------- footer ---------- */
footer, .footer {
  margin-top: var(--s6); padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted2); font-size: 12.5px;
  letter-spacing: .04em;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s2);
}
.footer { text-align: center; justify-content: center; }

/* ============================================================
   LIBRARY  (guide/index.html)
   Mirrors index.html's .guide-card so the library reads as the
   same component family as the landing page's Guides slide.
   ============================================================ */
.lib-group { margin: var(--s5) 0 0; }
.lib-eyebrow {
  font-size: 11px; font-weight: 900; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted2);
  display: flex; align-items: center; gap: var(--s2);
  margin-bottom: var(--s3);
}
.lib-eyebrow::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.lib-note { color: var(--muted); font-size: 14px; margin: -6px 0 var(--s3); max-width: var(--measure); }

/* auto-FIT, not auto-fill: a group holding one or two lessons (Түвшин 0,
   Лавлах) then stretches to fill the row instead of leaving dead tracks,
   while the nine-card ICT group still lays out three-up. */
.lib-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.lib-card {
  display: flex; flex-direction: column;
  padding: 16px; border-radius: var(--r2);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  text-decoration: none; color: inherit;
  transition: border-color .16s, transform .16s, background .16s;
}
a.lib-card:hover {
  border-color: var(--accent-line); background: rgba(255,156,26,.06);
  transform: translateY(-3px);
}
.lib-card .n {
  font-family: var(--f-mono); font-size: 12px; font-weight: 700;
  letter-spacing: .12em; color: var(--gold); margin-bottom: 8px;
}
.lib-card .icon { font-size: 24px; margin-bottom: 8px; line-height: 1; }
.lib-card .h { font-weight: 850; font-size: 15px; line-height: 1.3; margin-bottom: 6px; }
.lib-card .p { font-size: 13px; color: var(--muted); line-height: 1.55; flex: 1; margin: 0; max-width: none; }
.lib-card .meta {
  margin-top: 12px; font-size: 11.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted2);
}

/* not-yet-written lessons: shown so the series reads whole, but inert */
.lib-card.soon { opacity: .48; border-style: dashed; }
.lib-card.soon .meta { color: var(--amber); }

/* ---------- a11y ---------- */
:focus-visible { outline: 2px solid rgba(255,156,26,.9); outline-offset: 3px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  body { padding: 18px 14px 48px; font-size: 15.5px; }
  .topbar { padding-bottom: 12px; margin-bottom: 14px; }
  nav.series { flex-direction: column; align-items: stretch; }
  nav.series a, nav.series span { text-align: center; }
}

/* ============================================================
   PRINT
   Several of these pages started life as A4 handouts, so printing
   has to stay first-class: white stock, black ink, no chrome.
   ============================================================ */
@media print {
  @page { size: A4; margin: 16mm 14mm; }

  html { color-scheme: light; }
  body {
    background: #fff; color: #000;
    padding: 0; font-size: 10.5pt; line-height: 1.45;
  }
  .wrap { max-width: none; }

  .topbar, nav.series, nav.toc, #prog, #themeBtn { display: none !important; }

  h1 { font-size: 19pt; color: #0b3d91; border-bottom-color: #d4af37; }
  h2 { font-size: 13pt; color: #0b3d91; border-left-color: #d4af37; margin-top: 14pt; }
  h3 { font-size: 11.5pt; color: #333; }
  h4 { color: #0b3d91; }
  a  { color: #0b3d91; }
  b, strong { color: #000; }
  .subtitle, .standfirst, p, li { color: #1a1a1a; }
  .big, .badge { color: #0b3d91; }
  .badge { background: none; border-color: #d4af37; }

  table { font-size: 9.5pt; }
  /* Browsers omit background graphics from print by default, so a filled
     header with white text would come out invisible. Carry the header on ink
     instead: it reads the same whether or not backgrounds are enabled. */
  th {
    background: none !important; color: #0b3d91 !important;
    border-bottom: 2px solid #0b3d91;
  }
  td { border-bottom: 1px solid #ccc; color: #1a1a1a; }
  tr:nth-child(even) td { background: none !important; }
  .tbl-scroll { border: 0; overflow: visible; }
  .tbl-scroll table { min-width: 0; }

  code { background: #f3f3f3; color: #0b3d91; }
  pre  { background: #f8f8f8; border-color: #ddd; color: #000; }
  .formula { background: #fffbe9; border-color: #d4af37; color: #000; }
  .note   { background: #eef4ff; border-left-color: #0b3d91; }
  .tip    { background: #eefaf4; border-left-color: #0a7f5a; }
  .danger { background: #fdeef0; border-left-color: #a1202f; }
  .warn { color: #a1202f; }
  .ok   { color: #0a7f5a; }
  .hot  { color: #b34700; }

  footer, .footer { color: #666; border-top-color: #ccc; }

  h1, h2, h3, h4 { break-after: avoid; }
  table, figure, .formula, .note, .tip, .danger { break-inside: avoid; }
}
