/* ROI.fyi design tokens. Rules and usage: DESIGN.md. Use a token, never a raw value. */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-2: #fbfbfd;
  --text: #1d1d1f;
  --text-body: #333336;
  --text-2: #6e6e73;
  --line: #e5e5ea;
  --line-strong: #d2d2d7;
  --accent: #14706e;
  --accent-hover: #0f5c5a;
  --accent-soft: #e4f3f2;
  --gain: #2bb39a;
  --loss: #c8483f;
  --danger: #b42318;
  --on-accent: #ffffff;
  --glass: rgba(255, 255, 255, 0.82);
  --focus-ring: 0 0 0 3px var(--accent-soft);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  --radius-pill: 999px;
  --radius: 18px;
  --radius-sm: 12px;
  --control-sm: 36px;
  --control-lg: 48px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --max: 1080px;
  --reading: 720px;
  --gutter: 20px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.55; }
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--space-3); top: var(--space-3); z-index: 20; background: var(--bg); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.icon { width: 18px; height: 18px; flex: none; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--glass); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo img { display: block; height: 30px; width: auto; }
.menu summary { list-style: none; display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-sm); padding: 0 var(--space-4); border-radius: var(--radius-pill); background: var(--surface); font-size: 15px; font-weight: 500; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--line); }
.menu-panel { position: absolute; left: 0; right: 0; top: 58px; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); padding: var(--space-5) var(--gutter) var(--space-6); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-5); max-height: calc(100vh - 58px); overflow-y: auto; }
.menu-col { display: flex; flex-direction: column; gap: var(--space-1); font-size: 14px; }
.menu-col a { color: var(--text-body); }
.menu-col .menu-head { font-weight: 600; color: var(--text); margin-bottom: var(--space-1); }

/* Hero and calculator */
.hero { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: var(--space-6) 0 var(--space-7); }
.hero-plain { padding-bottom: var(--space-6); }
.crumbs { font-size: 14px; color: var(--text-2); margin-bottom: var(--space-3); }
.crumbs a { color: var(--text-2); }
h1 { font-family: var(--font-display); font-size: clamp(28px, 4.5vw, 48px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.08; margin: 0 0 var(--space-5); }
h1.eyebrow { font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--accent); margin-bottom: var(--space-2); }
.hero-title { font-family: var(--font-display); font-size: clamp(30px, 5.5vw, 56px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.06; margin: 0 0 var(--space-5); }
.hero-sub { color: var(--text-2); margin: 0; }

.calc { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5) var(--space-6); box-shadow: var(--shadow); }
.sentence { font-family: var(--font-display); font-size: clamp(22px, 3.2vw, 32px); line-height: 1.75; letter-spacing: -0.015em; margin: 0; }
.sentence .part { margin-right: 0.2em; }
.sentence input[type="hidden"] { display: none; }
.sentence input[type="date"] { font-size: 0.8em; }
#durN { margin-right: 0; }
.sentence input, .sentence select {
  font: inherit; font-weight: 600; letter-spacing: inherit; color: var(--accent); background: var(--accent-soft); border: 0; border-bottom: 2px solid var(--accent); border-radius: 8px 8px 0 0;
  padding: 0 0.3em; margin: 0 0.05em; field-sizing: content; min-width: 2ch; max-width: 100%; height: 1.45em; vertical-align: baseline; transition: background 0.15s ease;
}
.sentence select { cursor: pointer; }
.sentence input:hover, .sentence select:hover { background: var(--line); }
.sentence input:focus, .sentence select:focus { outline: 0; box-shadow: var(--focus-ring); background: var(--bg); }
.result { font-weight: 700; color: var(--text); border-bottom: 2px solid var(--gain); white-space: nowrap; }
#coinIcon { width: 0.9em; height: 0.9em; vertical-align: -0.08em; margin: 0 0.1em 0 0.1em; border-radius: 50%; }
.combo { position: relative; display: inline-block; }
.suggest { position: absolute; left: 0; top: 100%; z-index: 5; min-width: 280px; margin: var(--space-1) 0 0; padding: var(--space-1); list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 15px; line-height: 1.3; letter-spacing: 0; font-family: var(--font); }
.suggest li { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: 8px; cursor: pointer; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--accent-soft); }
.suggest small { margin-left: auto; color: var(--text-2); }

.formula-ctrls { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); padding-bottom: var(--space-4); border-bottom: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin: var(--space-5) 0 0; }
.stats div { background: var(--surface); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); min-width: 0; }
.stats dt { font-size: 13px; color: var(--text-2); }
.stats dd { margin: 0; font-family: var(--font-display); font-size: clamp(19px, 2.4vw, 24px); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#line .hover-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
#line svg { touch-action: pan-y; }
.formula-ctrl, .inline-field { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--text-2); }
.formula-ctrl select, .inline-field select, #markets-filter { height: var(--control-sm); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; padding: 0 var(--space-3); }
.calc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }
.calc-status { font-size: 14px; color: var(--text-2); }
.btn-quiet { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-sm); padding: 0 var(--space-4); border: 0; border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.15s ease; }
.btn-quiet:hover { background: var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; height: var(--control-lg); padding: 0 var(--space-5); border: 0; border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; transition: background 0.15s ease; }
.btn:hover { background: var(--accent-hover); }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; padding: var(--space-1); }

/* Results */
.results { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-4); margin-top: var(--space-4); }
.chart-card { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); min-width: 0; }
.chart-card:only-child { grid-column: 1 / -1; }
.chart-card figcaption { font-size: 14px; font-weight: 600; margin-bottom: var(--space-3); }
.donut { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.donut svg { width: 136px; height: 136px; flex: none; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 150px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) 0; }
.legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend span { color: var(--text-2); }
.legend strong { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
#line svg { display: block; width: 100%; height: auto; }
#line .grid { stroke: var(--line); stroke-width: 1; }
#line .tick { fill: var(--text-2); font-size: 12px; }
#line .area { fill: var(--accent-soft); }
#line .stroke { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.sheet { margin-top: var(--space-4); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4) var(--space-5); }
.sheet summary { font-weight: 600; font-size: 15px; cursor: pointer; }
.sheet-tools { display: flex; gap: var(--space-2); margin: var(--space-3) 0; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.sheet-head h2 { font-size: 15px; font-weight: 600; letter-spacing: 0; margin: 0 auto 0 0; }
.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; color: var(--text-2); background: var(--bg); }
.tall th { position: sticky; top: 0; }
th, td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.prose td, .prose th { white-space: normal; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
.coin-cell img { vertical-align: -3px; margin-right: var(--space-1); border-radius: 50%; }
.coin-cell small { color: var(--text-2); }
.up { color: var(--accent); }
.down { color: var(--loss); }

/* Ads */
.ad { margin: var(--space-5) 0; min-height: 120px; }

/* Directory */
.directory { padding: var(--space-6) 0; }
.directory-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.directory-head h2 { margin: 0; }
.search { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-lg); padding: 0 var(--space-4); background: var(--surface); border-radius: var(--radius-pill); color: var(--text-2); flex: 0 1 300px; }
.search input { border: 0; background: none; font: inherit; color: var(--text); width: 100%; }
.search input:focus { outline: 0; }
.search:focus-within { box-shadow: var(--focus-ring); }
.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.section-card { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
.section-card h3 { font-size: 19px; margin: 0 0 var(--space-1); letter-spacing: -0.01em; }
.section-card p { font-size: 14px; color: var(--text-2); margin: 0 0 var(--space-3); }
.section-card ul { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.section-card li { padding: 2px 0; }

/* Related */
.related { padding: var(--space-5) 0; }
.related h2 { font-size: 22px; margin: 0 0 var(--space-3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { display: inline-flex; align-items: center; height: var(--control-sm); padding: 0 var(--space-4); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font-size: 14px; }
.chip:hover { background: var(--accent-soft); color: var(--accent-hover); text-decoration: none; }

/* Article */
.prose { max-width: var(--reading); padding: var(--space-5) 0; color: var(--text-body); }
.prose h2 { font-family: var(--font-display); font-size: clamp(24px, 3vw, 30px); letter-spacing: -0.02em; line-height: 1.15; color: var(--text); margin: var(--space-6) 0 var(--space-3); }
.prose h3 { font-size: 19px; color: var(--text); margin: var(--space-5) 0 var(--space-2); }
.prose h4 { font-size: 17px; color: var(--text); margin: var(--space-4) 0 var(--space-2); }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-4); }
.prose li { margin-bottom: var(--space-1); }
.formula { margin: var(--space-4) 0; padding: var(--space-3) var(--space-4); background: var(--surface); border-radius: var(--radius-sm); overflow-x: auto; }

/* Contact form */
.contact-form { margin-top: var(--space-5); }
.field { display: block; margin-bottom: var(--space-4); }
.field span { display: block; font-size: 14px; font-weight: 500; margin-bottom: var(--space-1); color: var(--text); }
.field input, .field select, .field textarea { width: 100%; min-height: var(--control-lg); padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--accent); box-shadow: var(--focus-ring); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-status { font-size: 15px; margin: var(--space-3) 0 0; min-height: 1.5em; }
.hp { position: absolute; left: -9999px; }

/* Footer */
.site-footer { background: var(--surface); margin-top: var(--space-6); padding: var(--space-6) 0; font-size: 13px; color: var(--text-2); }
.site-footer p { margin: 0 0 var(--space-3); }
.foot-links a { margin-left: var(--space-3); color: var(--text-2); text-decoration: underline; }

@media (max-width: 900px) {
  .results { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  body { font-size: 16px; }
  .hero { padding: var(--space-5) 0 var(--space-6); }
  .calc { padding: var(--space-4); }
  .sentence { line-height: 1.8; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .stats div { padding: var(--space-3); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .foot-links a { margin-left: 0; margin-right: var(--space-3); display: inline-block; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
