/* =========================================================
   Revenue-Gated Freedom Grant Escrow -- TIMxAI Labs
   Self-contained styles, no external assets.
   ========================================================= */

:root {
  --bg:           #0b0d11;
  --bg-elev:      #14171d;
  --bg-elev-2:    #1a1e26;
  --border:       #232831;
  --border-soft:  #1b1f27;
  --text:         #eef0f5;
  --text-dim:     #aab0bd;
  --text-mute:    #7a8090;
  --accent:       #6fd19c;
  --accent-dim:   #3e8a66;
  --accent-soft:  rgba(111, 209, 156, 0.16);
  --warn:         #f4b860;
  --warn-soft:    rgba(244, 184, 96, 0.16);
  --danger:       #e87b6a;
  --danger-soft:  rgba(232, 123, 106, 0.16);
  --info:         #8fb4ff;
  --info-soft:    rgba(143, 180, 255, 0.14);
  --focus:        #ffd166;

  --radius:       14px;
  --radius-sm:    10px;
  --radius-lg:    20px;

  --shadow-1:     0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
  --shadow-2:     0 1px 0 rgba(255,255,255,0.04) inset, 0 22px 48px rgba(0,0,0,0.45);

  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif:   "Iowan Old Style", "Apple Garamond", Georgia, "Times New Roman", serif;
  --font-mono:    ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --pad-wrap:     clamp(20px, 4vw, 56px);
  --gap-section:  clamp(64px, 9vw, 120px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f7f7f4;
    --bg-elev:      #ffffff;
    --bg-elev-2:    #fbfbf8;
    --border:       #e3e2dc;
    --border-soft:  #eeede7;
    --text:         #1b1f27;
    --text-dim:     #4d5564;
    --text-mute:    #7a8090;
    --accent:       #2f9866;
    --accent-dim:   #1f6a47;
    --accent-soft:  rgba(47, 152, 102, 0.14);
    --warn:         #b8761d;
    --warn-soft:    rgba(184, 118, 29, 0.14);
    --danger:       #c25040;
    --danger-soft:  rgba(194, 80, 64, 0.12);
    --info:         #3a66c8;
    --info-soft:    rgba(58, 102, 200, 0.12);
    --focus:        #ad5e00;
    --shadow-1:     0 1px 0 rgba(0,0,0,0.02) inset, 0 6px 18px rgba(20,28,40,0.06);
    --shadow-2:     0 1px 0 rgba(0,0,0,0.03) inset, 0 18px 38px rgba(20,28,40,0.10);
  }
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  background-image:
    radial-gradient(1100px 600px at 80% -200px, rgba(143,180,255,0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 120%, rgba(111,209,156,0.07), transparent 55%);
  background-attachment: fixed;
}
@media (prefers-color-scheme: light) {
  body {
    background-image:
      radial-gradient(900px 500px at 90% -150px, rgba(47,152,102,0.10), transparent 60%),
      radial-gradient(700px 400px at -5% 110%, rgba(58,102,200,0.08), transparent 60%);
  }
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.012em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
em { font-style: italic; color: var(--text); }
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0 0.18em;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); color: var(--text); }

.skip-link {
  position: absolute; top: -100px; left: 16px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: top .15s ease;
  z-index: 100;
}
.skip-link:focus { top: 16px; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--pad-wrap); }

.section { padding: var(--gap-section) 0; position: relative; }
.section + .section { border-top: 1px solid var(--border-soft); }

.section-head { max-width: 720px; margin: 0 0 48px; }
.section-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.section-head h2 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
  margin-bottom: 14px;
}
.section-sub {
  color: var(--text-dim);
  font-size: clamp(16px, 1.4vw, 18px);
  max-width: 60ch;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border-soft);
}
.header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.brand-text { display: inline-flex; align-items: baseline; gap: 8px; }
.brand-mono { font-family: var(--font-mono); letter-spacing: 0.06em; font-size: 14px; }
.brand-divider { color: var(--text-mute); }
.brand-tag { font-family: var(--font-serif); font-style: italic; color: var(--text-dim); }
.site-nav { display: flex; gap: 18px; }
.site-nav a {
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--text); border-bottom-color: var(--accent); }
@media (max-width: 640px) { .site-nav { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: clamp(80px, 12vw, 140px) 0 clamp(60px, 8vw, 100px); }
.hero-wrap { max-width: 900px; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
}
.hero-eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}
@media (prefers-reduced-motion: reduce) { .hero-eyebrow .dot { animation: none; } }

.hero-title {
  font-size: clamp(40px, 6.4vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 24px;
  font-weight: 600;
}
.hero-title-em {
  display: block;
  font-style: italic;
  color: var(--text-dim);
  font-weight: 500;
}
.hero-lede {
  font-size: clamp(17px, 1.6vw, 21px);
  color: var(--text-dim);
  max-width: 65ch;
  margin-bottom: 36px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 56px; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  border-top: 1px solid var(--border-soft);
  padding-top: 28px;
}
.hero-stats div { display: flex; flex-direction: column; gap: 4px; }
.hero-stats dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.hero-stats dd { margin: 0; color: var(--text); font-size: 16px; }
@media (max-width: 640px) {
  .hero-stats { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 100px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, color .15s ease;
  will-change: transform;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: #0b0d11;
  border-color: var(--accent);
}
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 86%, white); color: #0b0d11; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-elev); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.btn .btn-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.btn[aria-busy="true"] .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn .btn-spinner { animation: none; border-right-color: currentColor; opacity: 0.5; }
}

.link-btn {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); text-decoration-color: var(--accent); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

/* ---------- Concept grid ---------- */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  counter-reset: concept;
}
@media (max-width: 980px) { .concept-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .concept-grid { grid-template-columns: 1fr; } }
.concept-card { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.concept-card h3 { font-size: 19px; font-family: var(--font-sans); font-weight: 600; letter-spacing: -0.005em; }
.concept-card p { color: var(--text-dim); font-size: 15px; }
.card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
}

/* ---------- Simulator ---------- */
.sim-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1020px) {
  .sim-grid { grid-template-columns: 1fr; }
}

.sim-controls { padding: 22px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 88px; }
@media (max-width: 1020px) { .sim-controls { position: static; } }
.sim-controls-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sim-controls-head h3 { font-size: 17px; font-family: var(--font-sans); font-weight: 600; }

.control-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.control-group legend {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border-soft);
  margin-bottom: 4px;
  width: 100%;
}

.control { display: flex; flex-direction: column; gap: 6px; }
.control label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}
.control .num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 84px;
  text-align: right;
  white-space: nowrap;
}
.control-hint { font-size: 12px; color: var(--text-mute); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--val, 0%), var(--border) var(--val, 0%), var(--border) 100%);
  border-radius: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  margin-top: -6px;
  transition: transform .12s ease, box-shadow .12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-soft); }
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  background: var(--accent);
  border-radius: 4px;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
}

.mode-row { display: flex; gap: 8px; padding: 4px; background: var(--bg-elev-2); border-radius: 100px; border: 1px solid var(--border); }
.mode-pill { flex: 1; display: inline-flex; }
.mode-pill input { position: absolute; opacity: 0; pointer-events: none; }
.mode-pill span {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.mode-pill input:checked + span {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset;
}
.mode-pill input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Sim output ---------- */
.sim-output { display: flex; flex-direction: column; gap: 18px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 840px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.stat-value {
  font-family: var(--font-serif);
  font-size: clamp(24px, 2.4vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: color .25s ease;
}
.stat-value.is-good { color: var(--accent); }
.stat-value.is-warn { color: var(--warn); }
.stat-value.is-bad  { color: var(--danger); }
.stat-foot { font-size: 12px; color: var(--text-mute); }

.chart { padding: 18px 18px 14px; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chart-head h3 { font-family: var(--font-sans); font-size: 15px; font-weight: 600; }
.chart-sub { font-size: 12px; color: var(--text-mute); max-width: 56ch; }
.legend { display: inline-flex; gap: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-canvas { width: 100%; height: 280px; position: relative; }
.chart-canvas svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-small { height: 180px; }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .chart-pair { grid-template-columns: 1fr; } }

/* Chart elements */
.axis-text { font-family: var(--font-mono); font-size: 10px; fill: var(--text-mute); }
.axis-line { stroke: var(--border-soft); stroke-width: 1; }
.gridline { stroke: var(--border-soft); stroke-width: 1; stroke-dasharray: 2 4; }
.path-treasury { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.path-treasury-faint { fill: none; stroke: var(--accent); stroke-width: 1; opacity: 0.12; }
.band-treasury { fill: var(--accent-soft); }
.band-treasury-inner { fill: var(--accent); opacity: 0.22; }
.pause-band { fill: var(--danger-soft); }
.cursor-line { stroke: var(--text-mute); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.5; }
.treasury-dot { fill: var(--accent); stroke: var(--bg-elev); stroke-width: 1.5; }
.runway-line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 4; fill: none; }
.runway-resume { stroke: var(--info); stroke-width: 1; stroke-dasharray: 3 4; fill: none; }
.runway-label { font-family: var(--font-mono); font-size: 10px; fill: var(--warn); }
.runway-label-resume { font-family: var(--font-mono); font-size: 10px; fill: var(--info); }
.bar-revenue { fill: var(--info); opacity: 0.85; }
.bar-grant   { fill: var(--accent); opacity: 0.85; }
.bar-net     { fill: none; stroke: var(--text-dim); stroke-width: 1.5; }
.state-active { fill: var(--accent); opacity: 0.6; }
.state-paused { fill: var(--danger); opacity: 0.7; }

.tooltip {
  position: absolute;
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity .12s ease;
  white-space: nowrap;
  z-index: 5;
}
.tooltip.is-visible { opacity: 1; }
.tooltip-row { display: flex; gap: 10px; justify-content: space-between; }
.tooltip-row span:first-child { color: var(--text-mute); }
.tooltip-row span:last-child { font-family: var(--font-mono); }

.callouts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 760px) { .callouts { grid-template-columns: 1fr; } }
.callout { padding: 18px; }
.callout h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 8px;
  font-weight: 500;
}
.callout p { color: var(--text-dim); font-size: 14px; }
.callout-soft { background: var(--bg-elev-2); border-style: dashed; }

.sr-explainer {
  padding: 14px 18px;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
.sr-explainer summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}
.sr-explainer summary:hover { color: var(--text); }
.sr-explainer [data-sr-summary] { margin-top: 10px; font-size: 13px; color: var(--text-dim); line-height: 1.6; }

/* ---------- Rules ---------- */
.rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 980px) { .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .rules { grid-template-columns: 1fr; } }
.rule {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.rule-num {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.5;
}
.rule h3 { font-family: var(--font-sans); font-size: 17px; font-weight: 600; }
.rule p { color: var(--text-dim); font-size: 14px; }

/* ---------- Terms ---------- */
.terms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .terms-grid { grid-template-columns: 1fr; } }
.term-card { padding: 24px; }
.term-card h3 {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 14px;
  font-weight: 600;
}
.term-card ul { display: flex; flex-direction: column; gap: 10px; }
.term-card li {
  font-size: 15px;
  color: var(--text-dim);
  padding-left: 22px;
  position: relative;
}
.term-card li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 14px; height: 1px;
  background: var(--border);
}
.term-good { border-top: 2px solid var(--accent); }
.term-good h3 { color: var(--accent); }
.term-good li::before { background: var(--accent); }
.term-bad { border-top: 2px solid var(--danger); }
.term-bad h3 { color: var(--danger); }
.term-bad li::before { background: var(--danger); }
.terms-foot {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-mute);
  font-size: 14px;
  max-width: 70ch;
}

/* ---------- Footer ---------- */
.site-footer { padding: 48px 0; border-top: 1px solid var(--border-soft); }
.footer-wrap { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; flex-wrap: wrap; }
.footer-copy { font-size: 13px; color: var(--text-dim); }
.footer-meta { font-size: 12px; color: var(--text-mute); max-width: 56ch; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
