/* The Payoff Curve — Payoff Diagram Builder
   Shares design tokens with the homepage, /boxspread and /wheel. Do not fork colors. */

:root {
  --bg: #0a0e13;
  --surface: #10161e;
  --surface-hover: #141c26;
  --ink: #e8ecef;
  --muted: #8a94a6;
  --faint: #77839a; /* min color for text on --bg/--surface: ≥4.5:1 (WCAG AA) */
  --line: rgba(232, 236, 239, 0.09);
  --accent: #3fb68b;
  --accent-dim: rgba(63, 182, 139, 0.12);
  --red: #d97a7a;
  --red-dim: rgba(217, 122, 122, 0.10);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

/* ---------- Base element styles ---------- */

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

h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.01em; }

input, select, button {
  font-family: var(--sans);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  padding: 11px 14px;
  font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--accent);
  color: #06130d;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #4cc79b; }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover { background: var(--surface-hover); border-color: rgba(63, 182, 139, 0.45); }

.disclaimer { color: var(--faint); font-size: 12px; line-height: 1.6; }

.payoff-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 880px;
  padding: 56px 0 56px;
}

/* ---------- Top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.backlink {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.18s ease;
}
.backlink:hover { color: var(--accent); }
.subnav { display: flex; gap: 18px; }
.subnav a {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  text-decoration: none;
  transition: color 0.18s ease;
}
.subnav a:hover, .subnav a[aria-current="page"] { color: var(--accent); }

/* ---------- Header ---------- */
header.tool-head { margin-bottom: 40px; }

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.08;
  margin-bottom: 12px;
}

.tagline { color: var(--muted); font-size: 15px; max-width: 62ch; }

.hero-rule {
  margin-top: 28px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 56px, var(--line) 56px, var(--line) 100%);
  border: none;
}

/* ---------- Sections ---------- */
.section { margin-bottom: 44px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head .idx {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.1em;
}
.section-head h2 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Cards ---------- */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px 24px;
  color: var(--ink);
}
.card + .card { margin-top: 12px; }

.card--primary {
  border-color: rgba(63, 182, 139, 0.35);
  background: linear-gradient(135deg, var(--accent-dim) 0%, var(--surface) 55%);
}

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field .hint, .legs-actions .hint { color: var(--faint); font-size: 11.5px; margin-top: 4px; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---------- Leg rows ---------- */
.legs-head {
  display: grid;
  grid-template-columns: 88px 92px 1fr 1fr 60px 34px;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.leg-row {
  display: grid;
  grid-template-columns: 88px 92px 1fr 1fr 60px 34px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.leg-row select, .leg-row input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
}
.leg-row select:focus, .leg-row input:focus { outline: none; border-color: var(--accent); }
.leg-row select.side-buy { color: var(--accent); }
.leg-row select.side-sell { color: var(--red); }
.leg-row input:disabled { color: var(--faint); background: var(--surface); cursor: not-allowed; }

.leg-remove {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  padding: 8px 0;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.leg-remove:hover { background: transparent; color: var(--red); border-color: var(--red); }

.legs-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.legs-actions button { padding: 9px 16px; font-size: 13px; }

/* ---------- Outputs ---------- */
.out-rate {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.out-rate-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}
.asof {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 8px;
}
.asof .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: 1px;
}
.out-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.out-row:last-child { border-bottom: none; }
.out-row .k { color: var(--muted); }
.out-row .v { font-family: var(--mono); color: var(--ink); text-align: right; }
.out-row .v.neg { color: var(--red); }
.out-row .v.pos { color: var(--accent); }

.plain-english {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--accent-dim);
  border: 1px solid rgba(63, 182, 139, 0.3);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
}
.plain-english strong { color: var(--accent); }

.math-detail {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-x: auto;
}
details.show-math summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 14px;
}
details.show-math summary:hover { color: var(--accent); }

/* ---------- Time-decay controls ---------- */
.decay-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-top: 18px;
}
.decay-row .field { margin-bottom: 0; }
.decay-slider { flex: 1; }
.decay-iv { width: 130px; }
.decay-slider #days-label { color: var(--accent); }

input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
  height: 28px;
  cursor: pointer;
}
input[type="range"]:focus { outline: none; }

@media (max-width: 480px) {
  .decay-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .decay-iv { width: 100%; }
}

/* ---------- Chart ---------- */
.chart-box { margin-top: 20px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-note {
  color: var(--faint);
  font-size: 12px;
  margin-top: 10px;
  line-height: 1.6;
}

/* ---------- Prose ---------- */
.prose h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--ink);
}
.prose p { color: var(--muted); font-size: 14.5px; margin-bottom: 12px; max-width: 68ch; }
.prose p strong { color: var(--ink); }

/* ---------- Footer ---------- */
footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.disclaimer {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 20px;
  max-width: 72ch;
}
.colophon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--faint);
  text-transform: uppercase;
}
.colophon a { color: var(--faint); text-decoration: none; }
.colophon a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .preset-row { flex-direction: column; gap: 0; }
  .legs-head { display: none; }
  .leg-row {
    grid-template-columns: 1fr 1fr 34px;
    grid-template-areas:
      "side type remove"
      "strike prem qty";
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .leg-row .l-side { grid-area: side; }
  .leg-row .l-type { grid-area: type; }
  .leg-row .l-strike { grid-area: strike; }
  .leg-row .l-prem { grid-area: prem; }
  .leg-row .l-qty { grid-area: qty; }
  .leg-row .leg-remove { grid-area: remove; }
}
@media (max-width: 480px) {
  .wrap { padding-top: 40px; }
  .card { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .backlink, .subnav a, .leg-remove { transition: none; }
}
