/* ==========================================================================
   Guides: /plan-vs-bot, /trading-journal, /trading-plan-template, /stop-loss-on-candle-close and the
   /position-size-calculator (app/seo.py). Loaded on those pages only, after style.css, from its tokens.
   A white sheet on the paper, like the legal pages, with a compare table, a sample chart, the calculator and a
   printable plan template. No inline styles (strict CSP).
   ========================================================================== */

.page-guide { max-width: var(--site-max); }

.guide {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 18px 28px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.7;
}
@media (min-width: 640px) { .guide { padding: 40px 52px 44px; } }

.guide-head { margin-bottom: 8px; }
.guide-head h1 { margin: 2px 0 10px; color: var(--text); font-size: clamp(28px, 2.6vw + 16px, 40px); line-height: 1.12; letter-spacing: -0.03em; }
.guide-head .lead { margin: 0; color: var(--text); font-size: 17.5px; }
.guide h2 { margin: 36px 0 10px; color: var(--text); font-size: 21px; line-height: 1.3; letter-spacing: -0.015em; }
.guide h3 { margin: 22px 0 6px; color: var(--text); font-size: 16.5px; letter-spacing: -0.01em; }
.guide p, .guide ul, .guide ol { margin: 0 0 14px; }
.guide li { margin-bottom: 6px; }
.guide li::marker { color: var(--faint); }
.guide a:not(.button) { text-decoration: underline; text-decoration-color: var(--accent-line); }
.guide .mono { font-family: var(--font-mono); }

/* A short summary right under the title. */
.guide-tldr {
  margin: 22px 0 6px;
  padding: 14px 18px;
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--r) var(--r) 0;
  background: var(--surface-soft);
  color: var(--text);
}
.guide-tldr p:last-child, .guide-tldr ul:last-child { margin-bottom: 0; }

/* A side note: sample numbers, the honest caveat. */
.guide-aside {
  margin: 18px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text-2);
  font-size: 14.5px;
}
.guide-aside strong { color: var(--text); }
.guide-aside p:last-child { margin-bottom: 0; }

/* Compare table: scrolls sideways on a phone, never the page. */
.guide-table { margin: 16px 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); -webkit-overflow-scrolling: touch; }
.guide-table table { min-width: 560px; font-size: 14px; line-height: 1.5; }
.guide-table th, .guide-table td { vertical-align: top; }
.guide-table thead th { color: var(--muted); font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.guide-table tbody th { color: var(--text); font-weight: 600; }
.guide-table tbody tr:first-child th, .guide-table tbody tr:first-child td { border-top: 1px solid var(--border); }
.guide-table .is-ours { background: var(--surface-soft); }

/* Questions at the end. */
.guide-faq dt { margin: 18px 0 4px; color: var(--text); font-weight: 600; }
.guide-faq dd { margin: 0 0 8px; }

/* The sample chart on the candle-close guide. */
.guide-figure { margin: 20px 0 22px; }
.guide-figure svg { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); }
.guide-figure figcaption { margin-top: 8px; color: var(--muted); font-size: 13px; }
.gf-grid { stroke: var(--paper-line); stroke-width: 1; }
.gf-axis { fill: var(--faint); font-family: var(--font-mono); font-size: 12px; }
.gf-up line, .gf-down line { stroke: var(--ink); stroke-width: 1.5; }
.gf-up rect { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.gf-down rect { fill: var(--ink); stroke: var(--ink); stroke-width: 1.5; }
.gf-stop { stroke: var(--ln-stop); stroke-width: 2; stroke-dasharray: 7 5; }
.gf-estop { stroke: var(--ln-estop); stroke-width: 2; }
.gf-label { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.gf-label.stop { fill: var(--tx-stop); }
.gf-label.estop { fill: var(--tx-estop); }
.gf-ring { fill: none; stroke: var(--ln-trigger); stroke-width: 2; }
.gf-ring.sell { stroke: var(--ln-stop); }
.gf-badge circle { fill: var(--ln-trigger); }
.gf-badge.sell circle { fill: var(--tx-stop); }
.gf-badge text { fill: #fff; font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.gf-notes { margin: 0 0 6px !important; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.gf-notes li { margin-bottom: 2px; }
.gf-notes li::marker { color: var(--text); font-family: var(--font-mono); font-weight: 600; }

/* The CTA band and "Read next". */
.guide-cta {
  margin: 36px 0 0;
  padding: 26px 22px;
  border-radius: var(--r-xl);
  background: var(--ink);
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}
.guide-cta h2 { margin: 0 0 8px; color: #fff; font-size: clamp(21px, 2vw + 12px, 26px); }
.guide-cta p { max-width: 520px; margin: 0 auto 18px; }
.guide-cta .hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.guide-cta .button { background: var(--highlight); color: var(--ink); box-shadow: none; }
.guide-cta .button:hover { background: #e2ff5c; color: var(--ink); }
.guide-cta .button.secondary { border-color: transparent; background: #fff; color: var(--ink); }
.guide-cta .button.secondary:hover { background: var(--surface-2); }
.guide-more { margin-top: 28px; }
.guide-more h2 { margin: 0 0 8px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }
.guide-more ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.guide-more li { margin: 0; }
.guide-more a:not(.button) {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}
.guide-more a:not(.button):hover { border-color: var(--ink); text-decoration: none; }
.guide-note { margin: 22px 0 0 !important; padding-top: 16px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---- the position size calculator -------------------------------------------------------------------------------- */
.calc { display: grid; gap: 18px; margin: 22px 0 8px; }
@media (min-width: 760px) { .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.calc-form { padding: 18px; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface-soft); }
.calc-form .field { margin-bottom: 14px; }
.calc-form .field > label { font-size: 14px; }
.calc-form input { font-family: var(--font-mono); }
.calc-form .button { margin-top: 4px; }
.calc-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.calc-out { padding: 18px; border: 1px solid var(--ink); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.calc-out h2 { margin: 0 0 12px; font-size: 13px; color: var(--muted); font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.calc-out[data-state="empty"] .calc-nums { opacity: 0.45; }
.calc-nums { display: grid; gap: 0; margin: 0; }
.calc-nums > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.calc-nums > div:first-child { border-top: 0; padding-top: 0; }
.calc-nums dt { color: var(--text-2); font-size: 14px; }
.calc-nums dd { margin: 0; color: var(--text); font-family: var(--font-mono); font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.calc-nums .is-size dd { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.calc-nums .is-loss dd { color: var(--tx-stop); }
.calc-nums .calc-sub { display: block; color: var(--muted); font-size: 12.5px; }
.calc-nums .calc-sub span { font-family: var(--font-mono); }
.calc-warn { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--warn-line); border-radius: var(--r); background: var(--warn-soft); color: var(--warn-strong); font-size: 13.5px; }
.calc-formula { margin: 12px 0 0; color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; }
.calc [hidden] { display: none !important; }

/* ---- the trading plan template ----------------------------------------------------------------------------------- */
.tpl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 6px; }
.tpl-actions .hint { margin: 0; }
.tpl { margin: 20px 0 0; border: 1.5px solid var(--ink); border-radius: var(--r-lg); background: var(--surface); }
.tpl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 14px 18px; border-bottom: 1.5px solid var(--ink); }
.tpl-head p { margin: 0; color: var(--text); font-weight: 600; }
.tpl-head span { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.tpl-part { padding: 14px 18px 6px; border-top: 1px solid var(--border); break-inside: avoid; }
.tpl-head + .tpl-part { border-top: 0; }
.tpl-part h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 4px; font-size: 15px; }
.tpl-part h3 .num { color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.tpl-part .hint { margin: 0 0 6px; font-size: 13px; }
.tpl-lines { display: grid; gap: 0; margin: 0 0 8px; padding: 0; list-style: none; }
.tpl-lines li { display: flex; align-items: flex-end; gap: 10px; min-height: 34px; margin: 0; border-bottom: 1px solid var(--border-strong); color: var(--text-2); font-size: 14px; }
.tpl-lines li span { flex: 0 1 auto; min-width: 0; padding-bottom: 3px; overflow-wrap: anywhere; }  /* wraps on a phone */
.tpl-lines.boxes li::before { content: ""; flex: none; width: 14px; height: 14px; margin-bottom: 5px; border: 1.5px solid var(--ink); border-radius: 3px; }
.tpl-grid .tpl-lines { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 18px; }

/* Printing: a guide without the page around it; the template's sheet on one A4 or Letter page. */
@page { margin: 12mm; }
@media print {
  .site-footer, .guide-cta, .guide-more, .tpl-actions, .skip-link, .print-hide { display: none !important; }
  .page, .page-guide { max-width: none; padding: 0; }
  .guide { max-width: none; padding: 0; border: 0; border-radius: 0; font-size: 10.5pt; line-height: 1.45; }
  .guide-note { border-top-color: #999; color: #333; font-size: 8pt; }
  .page-template .guide-head { display: none !important; }
  .page-template .guide { line-height: 1.4; }
  .tpl { margin-top: 0; border-color: #000; }
  .tpl-head { padding: 6px 12px; }
  .tpl-part { padding: 4px 12px 1px; break-inside: avoid; }
  .tpl-part h3 { margin-bottom: 0; font-size: 10.5pt; }
  .tpl-part .hint { margin: 0; font-size: 8.5pt; }
  .tpl-lines { margin-bottom: 4px; }
  .tpl-lines li { min-height: 19px; border-bottom-color: #999; font-size: 9.5pt; }
  .page-template .guide-note { display: none !important; }  /* a blank sheet; the page itself carries the line */
}
