/* The Payoff Curve — Box Spread tool
   Shares design tokens with the homepage. 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;
  --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 (§3b of spec — literal) ---------- */

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);
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--faint); font-family: var(--mono); font-size: 11px;
     text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 12px;
     border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); }

.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; }

a.card {
  text-decoration: none;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
a.card:hover { background: var(--surface-hover); border-color: rgba(63, 182, 139, 0.45); }
a.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ---------- Expiration pills ---------- */
.exp-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.exp-pill {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}
.exp-pill:hover { border-color: rgba(63, 182, 139, 0.45); color: var(--ink); }
.exp-pill[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.exp-pill .rel { color: var(--faint); font-size: 10.5px; margin-left: 6px; }
.exp-pill[aria-pressed="true"] .rel { color: var(--accent); opacity: 0.75; }

/* ---------- Headline rate ---------- */
.headline-rate {
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.headline-rate .pct { color: var(--accent); }
.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;
}

/* ---------- 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;
}

/* ---------- Calculator ---------- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.calc-inputs, .calc-outputs { min-width: 0; }

.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 { color: var(--faint); font-size: 11.5px; margin-top: 4px; }

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

/* Side toggle */
.side-toggle { display: flex; gap: 8px; }
.side-toggle button {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  padding: 9px 0;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}
.side-toggle button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* 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;
}
.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); }

.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); }

/* ---------- Legs table ---------- */
.legs-table, .book-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
}
.legs-table th, .book-table th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.legs-table td, .book-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.legs-table tr:last-child td, .book-table tr:last-child td { border-bottom: none; }
.legs-table .sell { color: var(--red); }
.legs-table .buy { color: var(--accent); }
.book-table .num { text-align: right; }
.book-table th.num { text-align: right; }

.table-scroll { overflow-x: auto; }

.book-status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 12px;
}

/* Loading / empty state */
.state-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--faint);
  font-size: 13.5px;
}
.state-empty .spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- FAQ / prose pages ---------- */
.prose h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  margin: 36px 0 12px;
}
.prose h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
}
.prose p { color: var(--muted); font-size: 14.5px; margin-bottom: 12px; max-width: 68ch; }
.prose p strong { color: var(--ink); }
.prose code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.prose ul { margin: 0 0 12px 20px; color: var(--muted); font-size: 14.5px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }

/* Expired archive */
.month-group { margin-bottom: 28px; }
.month-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}
.exp-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.exp-line .d { font-family: var(--mono); color: var(--ink); }
.exp-line .r { font-family: var(--mono); color: var(--muted); }

/* ---------- 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) {
  .calc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .wrap { padding-top: 40px; }
  .card { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .exp-pill, .side-toggle button, a.card, .backlink, .subnav a { transition: none; }
  .state-empty .spinner { animation: none; }
}
