/* tools.css — shared styling for the public /tools pages (expectancy,
   compound, risk-reward). Bespoke, framework-free, matched to the in-app
   Resources look. Pages link this after tokens.css. Page-specific bits stay
   inline on their own page. */

:root {
  --col: 64rem;
  --ink: var(--text-primary);
  --whisper: var(--text-faint);
  /* Match the in-app Resources font (Tailwind v3 default system sans). */
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  background: var(--bg-base);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  padding: 3.5rem 1.5rem 6rem;
}

/* Atmosphere. dot grid + scan line, same as the other public pages. */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 95%);
  pointer-events: none;
  z-index: 0;
}
.scan {
  position: fixed; left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(74,222,128,0.18) 50%, transparent 100%);
  pointer-events: none;
  z-index: 1;
  animation: scan 14s linear infinite;
  will-change: transform;
}
@keyframes scan {
  0%   { transform: translateY(-2vh); }
  100% { transform: translateY(102vh); }
}

main {
  position: relative;
  z-index: 2;
  width: var(--col);
  max-width: 100%;
  margin: 0 auto;
}

/* ── Top nav ───────────────────────────────────────────────────────────
   Sticky site nav shared with the landing page (brand + Tools/Learn/Sign in
   + green Join). Full-bleed. negative margins cancel the body padding so the
   bar runs edge-to-edge and sits flush at the top, while its inner row aligns
   to the centered content column. */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -3.5rem -1.5rem 1.6rem;
  padding: 0 1.5rem;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-sub);
}
.site-nav-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
  max-width: 80rem;
  margin: 0 auto;
}
.site-nav .brand { margin-bottom: 0; }
.site-nav-links { display: flex; align-items: center; gap: 1.5rem; }
.site-nav-links .lnk {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.site-nav-links .lnk:hover { color: var(--green); }
.site-nav-links a[aria-current="page"] { color: var(--green); }
.site-nav-links .nav-signin {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.site-nav-links .nav-signin:hover { color: var(--ink); }
.site-nav-links .nav-cta {
  background: var(--green);
  color: #0d0d0d;
  border: 1px solid var(--green);
  border-radius: var(--r);
  padding: 0.5rem 1.05rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.site-nav-links .nav-cta:hover { filter: brightness(1.08); }
.site-nav-links .nav-cta:active { transform: translateY(1px); }

@media (max-width: 600px) {
  .site-nav { margin: -2.5rem -1.1rem 1.4rem; padding: 0 1.1rem; }
  .site-nav-in { height: 3.5rem; gap: 0.6rem; }
  .site-nav .brand { font-size: 0.95rem; white-space: nowrap; }
  .site-nav-links { gap: 0.85rem; }
  .site-nav-links .lnk, .site-nav-links .nav-signin { letter-spacing: 0.03em; white-space: nowrap; }
  .site-nav-links .nav-cta { padding: 0.45rem 0.8rem; }
}

/* Wordmark link. */
.brand {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 1.6rem;
}
.brand .accent { color: var(--green); display: inline-block; margin-left: 0.04em; }

/* Breadcrumb. */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--whisper);
  margin-bottom: 1.4rem;
}
.crumbs a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.crumbs a:hover { color: var(--green); border-color: var(--green); }
.crumbs [aria-current] { color: var(--text-secondary); }

/* Title + lede. */
h1 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 0.75rem;
}
.lede {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 46rem;
}

/* ── Calculator. Sized to match the in-app Resources calculator. ──────── */
.calc {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: stretch;
  margin: 2rem 0 1rem;
}
.calc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
}
/* App proportions: a ~24rem calculator column, chart takes the rest. The
   2:1 grow ratio keeps the calculator near 24rem and gives the chart the
   width; both go full-width when they wrap on small screens. */
.calc-main  { flex: 1 1 22rem; }
.calc-graph { flex: 2 1 28rem; display: flex; flex-direction: column; position: relative; }

.exp-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.exp-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  letter-spacing: 0.01em;
}
.exp-input-wrap { position: relative; }
.exp-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
  transition: border-color 0.15s ease;
}
.exp-input:focus { outline: none; border-color: rgba(74,222,128,0.5); }
.exp-input.has-prefix { padding-left: 2rem; }
.exp-input.has-suffix { padding-right: 2.25rem; }
.exp-affix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: var(--text-muted);
  pointer-events: none;
}
.exp-affix.prefix { left: 0.85rem; }
.exp-affix.suffix { right: 0.85rem; }
/* Hide number spinners. */
.exp-input::-webkit-outer-spin-button,
.exp-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.exp-input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.exp-divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

.exp-headline { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.exp-value {
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
}
.exp-pill {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 1rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.exp-pill.pos { background: var(--green-pill-bg); color: var(--green); }
.exp-pill.neg { background: var(--red-pill-bg);   color: var(--red);   }

.exp-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.exp-row { display: flex; justify-content: space-between; font-size: 0.875rem; gap: 1rem; }
.exp-row .k { color: var(--text-muted); }
.exp-row .v { color: var(--text-primary); text-align: right; white-space: nowrap; }
.exp-row.total { font-weight: 500; }
.exp-row.total .k { color: var(--text-secondary); }

/* Equity / growth graph card. */
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.25rem; }
.graph-head h2 { font-family: var(--font-sans); font-size: 1.125rem; font-weight: 600; color: var(--text-primary); }
.exp-resimulate {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--rm);
  padding: 0.35rem 1rem;
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.exp-resimulate:hover { color: var(--green); border-color: var(--green); }
.graph-desc { font-size: 0.875rem; font-weight: 300; line-height: 1.65; color: var(--text-secondary); margin-bottom: 1rem; }
.graph-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.graph-meta label { font-size: 0.875rem; color: var(--text-muted); margin-right: 0.6rem; }
.graph-meta .exp-input { width: 5rem; padding: 0.375rem 0.75rem; display: inline-block; }
.graph-total { font-size: 0.875rem; }
.graph-total .k { color: var(--text-muted); margin-right: 0.4rem; }
.graph-total .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; flex: 1; min-height: 12rem; }

/* ── Risk/Reward profitability matrix (risk-reward-ratio page) ─────────── */
.rr-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 1rem; font-size: 0.8125rem; color: var(--text-muted); }
.rr-legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.rr-swatch { width: 0.85rem; height: 0.85rem; border-radius: 0.25rem; border: 1px solid; display: inline-block; }
.rr-table { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 0.8125rem; }
.rr-table caption { caption-side: top; text-align: left; color: var(--text-muted); font-size: 0.75rem; margin-bottom: 0.6rem; }
.rr-table thead th { color: var(--text-muted); font-weight: 500; padding: 0.3rem; font-size: 0.75rem; }
.rr-table tbody th { color: var(--text-primary); font-weight: 500; text-align: right; padding-right: 0.6rem; white-space: nowrap; }
.rr-cell { border-radius: 0.25rem; border: 1px solid; padding: 0.45rem 0.3rem; text-align: center; font-size: 0.625rem; letter-spacing: 0.03em; text-transform: uppercase; }
.rr-cell.profitable,    .rr-swatch.profitable    { background: var(--green-pill-bg); border-color: var(--green); color: var(--green); }
.rr-cell.breakeven,     .rr-swatch.breakeven     { background: var(--orange-bg);     border-color: var(--orange); color: var(--orange); }
.rr-cell.notProfitable, .rr-swatch.notProfitable { background: var(--red-pill-bg);   border-color: var(--red);    color: var(--red); }

/* ── Long-form content ───────────────────────────────────────────────── */
/* Reading column stays narrow even when the tool above is full width. */
section { scroll-margin-top: 3rem; margin-top: 2.5rem; max-width: 46rem; }
section h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
  margin-bottom: 1rem;
}
section h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 1.4rem 0 0.4rem;
}
section p, section li {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
}
section p + p { margin-top: 0.875rem; }
section ul { list-style: none; padding: 0; margin-top: 0.5rem; }
section li { position: relative; padding-left: 1.25rem; margin-bottom: 0.7rem; }
section li::before { content: ''; position: absolute; left: 0; top: 0.75em; width: 0.4rem; height: 1px; background: var(--border); }
section li strong, section p strong { color: var(--text-primary); font-weight: 500; }

.formula {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--green);
  border-radius: var(--rm);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
}
.formula .alt { display: block; margin-top: 0.5rem; font-size: 0.8125rem; color: var(--text-muted); }

/* ── CTA ─────────────────────────────────────────────────────────────── */
.cta {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 2.25rem 1.75rem;
  text-align: center;
  margin: 3.5rem 0 1.5rem;
}
.cta h2 { font-family: var(--font-sans); font-weight: 700; font-size: 1.4rem; color: var(--ink); margin-bottom: 0.75rem; }
.cta p { color: var(--text-secondary); font-size: 0.9375rem; line-height: 1.65; max-width: 36rem; margin: 0 auto 1.5rem; }
.cta-actions { display: flex; align-items: center; justify-content: center; gap: 1.25rem; flex-wrap: wrap; }
.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--green);
  color: #0d0d0d;
  border: 1px solid var(--green);
  border-radius: var(--rm);
  padding: 0.8rem 1.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.cta-primary:hover { filter: brightness(1.1); }
.cta-primary:active { transform: translateY(1px); }
.cta-primary .arrow { transition: transform 0.15s ease; }
.cta-primary:hover .arrow { transform: translateX(3px); }
.cta-secondary { color: var(--text-muted); font-size: 0.8125rem; text-decoration: none; border-bottom: 1px solid var(--border); padding-bottom: 1px; transition: color 0.15s ease, border-color 0.15s ease; }
.cta-secondary:hover { color: var(--green); border-color: var(--green); }

.disclaimer { font-size: 0.6875rem; color: var(--whisper); line-height: 1.7; letter-spacing: 0.02em; margin-top: 2rem; text-align: center; }

/* ── Footer ──────────────────────────────────────────────────────────── */
footer {
  position: relative;
  z-index: 2;
  width: var(--col);
  max-width: 100%;
  margin: 2.5rem auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-sub);
  font-size: 0.625rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--whisper);
}
footer nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
footer a { color: var(--text-muted); text-decoration: none; letter-spacing: 0.04em; text-transform: none; border-bottom: 1px solid transparent; transition: color 0.15s ease, border-color 0.15s ease; }
footer a:hover { color: var(--green); border-color: var(--green); }

/* ── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { padding: 2.5rem 1.1rem 4rem; }
  .calc-card { padding: 1.1rem; }
  .exp-inputs { grid-template-columns: 1fr; }
  footer { justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .scan { display: none; }
}
