/* SolStake+ — shared foundation: tokens, type, chrome, controls. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-var.woff2") format("woff2");
  font-weight: 300 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Night sky */
  --sky-0: #03050b;
  --sky-1: #070b16;
  --sky-2: #0c1221;
  --sky-3: #141c30;
  --line: rgba(168, 186, 255, 0.1);
  --line-strong: rgba(168, 186, 255, 0.2);

  /* Ink */
  --ink: #f2f4fa;
  --ink-2: #b6bfd4;
  --ink-3: #8a96b0;

  /* Light sources */
  --polaris: #7cf0c4;
  --polaris-2: #2fd699;
  --polaris-ink: #032619;
  --warn: #f6cf7c;              /* pending / caution, never the accent */
  --trail-violet: #8f7bff;
  --trail-blue: #5aa9ff;
  --signal: #19f0a0;          /* money arriving; used for credits only */
  --danger: #ff8a80;

  /* Chart palette (validated for CVD on --sky-1) */
  --chart-usd: #2ea87b;
  --chart-violet: #8f7bff;
  --chart-blue: #3f8ef0;

  /* Type */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Space (one rhythm) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;
  --s-9: 7rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  --max: 76rem;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;

  /* Motion: critically damped feel, exponential ease-out */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --nav-h: 64px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 1rem);
  background: var(--sky-0);
}
html:not(.lenis) { scroll-behavior: smooth; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--sky-0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ol, ul, dl, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

::selection { background: rgba(124, 240, 196, 0.28); color: #fff; }
input, textarea { caret-color: var(--polaris); }

/* Scrollbars carry the palette */
* { scrollbar-width: thin; scrollbar-color: var(--sky-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--sky-3); border-radius: 10px; border: 2px solid var(--sky-0); }
::-webkit-scrollbar-track { background: transparent; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--polaris);
  outline-offset: 3px;
  border-radius: 6px;
}
/* Sections focused by in-page links (tabindex="-1") should not draw a ring. */
[tabindex="-1"]:focus { outline: none; }

a { color: inherit; text-decoration-color: rgba(124, 240, 196, 0.45); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--polaris); }

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  background: var(--polaris);
  color: var(--polaris-ink);
  border-radius: var(--radius-s);
  font-weight: 600;
}
.skip-link:focus { top: var(--s-4); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

/* ---------- Type ---------- */

.display {
  font-family: var(--font-display);
  font-weight: 620;
  font-variation-settings: "opsz" 96;
  font-size: clamp(2.6rem, 7.2vw, 6rem);
  line-height: 0.96;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 72;
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 32;
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.lede {
  font-size: clamp(1.06rem, 1.4vw, 1.25rem);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 38rem;
  text-wrap: pretty;
}
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.gain { color: var(--signal); }

/* ---------- Brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 650;
  font-variation-settings: "opsz" 24;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}
.brand img { width: 30px; height: 30px; }
.brand .plus { color: var(--polaris); }

/* ---------- Navigation: a translucent layer, content scrolls beneath ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--nav-h);
  background: rgba(3, 5, 11, 0.5);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  transition: background 300ms var(--ease-out);
}
/* Scroll edge effect instead of a hard divider */
.nav::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto 0;
  height: 18px;
  background: linear-gradient(rgba(3, 5, 11, 0.45), rgba(3, 5, 11, 0));
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms var(--ease-out);
}
.nav.is-scrolled::after { opacity: 1; }
.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-5);
}
.nav-links {
  display: flex;
  gap: var(--s-1);
  margin-left: var(--s-4);
}
.nav-links a {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.94rem;
  transition: color 160ms, background 160ms;
}
.nav-links a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.nav-links a[aria-current="page"] { color: var(--ink); background: rgba(255, 255, 255, 0.07); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.nav-user { color: var(--ink-3); font-size: 0.9rem; margin-right: var(--s-2); }

.btn.menu-btn { display: none; }
.nav-links .show-sm { display: none; }

@media (max-width: 860px) {
  .nav-links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: var(--s-3) var(--gutter) var(--s-5);
    background: rgba(5, 8, 16, 0.94);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
    transform-origin: top right;
    transform: translateY(-8px) scale(0.98);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms var(--ease-out), transform 320ms var(--ease-out), visibility 0s linear 320ms;
  }
  .nav-links a { padding: 0.85rem 0.25rem; border-radius: 0; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
  .nav.is-open .nav-links {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity 220ms var(--ease-out), transform 320ms var(--ease-out), visibility 0s;
  }
  .btn.menu-btn { display: inline-flex; }
  .nav-links .show-sm { display: flex; }
  .nav-user { display: none; }
  .nav-actions .btn-ghost.hide-sm { display: none; }
}

/* ---------- Buttons: a lit object, not a pill ---------- */

.btn {
  --h: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  height: var(--h);
  padding: 0 1.15rem;
  border: 0;
  border-radius: 11px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 110ms ease-out, box-shadow 240ms var(--ease-out), background-color 200ms, color 200ms, opacity 200ms;
}
/* Feedback on press, instantly */
.btn:active { transform: scale(0.97); transition-duration: 60ms; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-sm { --h: 38px; padding: 0 0.85rem; font-size: 0.9rem; border-radius: 9px; }
.btn-lg { --h: 54px; padding: 0 1.5rem; font-size: 1.02rem; border-radius: 13px; }

.btn-primary {
  background: var(--polaris);
  color: var(--polaris-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -1px 0 rgba(10, 120, 80, 0.35),
    0 10px 30px -12px rgba(60, 220, 160, 0.55);
}
.btn-primary:hover {
  background: #a3f7d8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(10, 120, 80, 0.3),
    0 0 0 5px rgba(124, 240, 196, 0.1),
    0 14px 36px -10px rgba(60, 220, 160, 0.65);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(200, 212, 255, 0.3); }
.btn-quiet { background: transparent; color: var(--ink-2); padding: 0 0.6rem; }
.btn-quiet:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn.is-busy { pointer-events: none; opacity: 0.75; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 0.4rem; }
.field label { font-size: 0.9rem; font-weight: 550; color: var(--ink-2); }
.field .hint { font-size: 0.84rem; color: var(--ink-3); }
.field .err { font-size: 0.86rem; color: var(--danger); }
.input {
  height: 50px;
  width: 100%;
  padding: 0 0.95rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  transition: border-color 160ms, box-shadow 200ms var(--ease-out), background 160ms;
}
.input::placeholder { color: #7d89a3; }
.input:hover { border-color: rgba(200, 212, 255, 0.3); }
.input:focus { outline: none; border-color: rgba(124, 240, 196, 0.7); box-shadow: 0 0 0 4px rgba(124, 240, 196, 0.12); background: rgba(255, 255, 255, 0.05); }
.input[aria-invalid="true"] { border-color: rgba(255, 138, 128, 0.7); }

.input-affix { position: relative; }
.input-affix .input { padding-left: 1.9rem; }
.input-affix span { position: absolute; left: 0.95rem; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--polaris-2) var(--fill, 50%), var(--sky-3) var(--fill, 50%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--sky-3); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--polaris-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--polaris);
  box-shadow: 0 0 0 5px rgba(124, 240, 196, 0.12), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform 120ms ease-out;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--polaris);
  box-shadow: 0 0 0 5px rgba(124, 240, 196, 0.12), 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ---------- Surfaces ---------- */

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 28, 48, 0.55), rgba(10, 15, 28, 0.55));
  border-radius: var(--radius-l);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 24px 60px -30px rgba(0, 0, 0, 0.8);
}

.notice {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--radius);
  background: rgba(25, 240, 160, 0.07);
  box-shadow: inset 0 0 0 1px rgba(25, 240, 160, 0.22);
  color: #c8fbe6;
}
.notice.is-error { background: rgba(255, 138, 128, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 138, 128, 0.3); color: #ffd9d4; }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.5rem; vertical-align: 0.08em; flex: none; }
.dot-violet { background: var(--chart-violet); }
.dot-gold { background: var(--chart-usd); }
.dot-blue { background: var(--chart-blue); }
.small { font-size: 0.86rem; }

.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Odometer digits */
.odo { display: inline-flex; align-items: baseline; font-variant-numeric: tabular-nums; }
.odo-col { display: inline-block; height: 1.1em; overflow: hidden; line-height: 1.1; vertical-align: bottom; }
.odo-strip { display: flex; flex-direction: column; transition: transform 1100ms var(--ease-out); will-change: transform; }
.odo-strip span { height: 1.1em; }

/* ---------- Footer ---------- */

.footer {
  position: relative;
  padding: var(--s-8) 0 var(--s-6);
  color: var(--ink-3);
  font-size: 0.92rem;
  border-top: 1px solid var(--line);
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s-6); }
.footer h2 { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-bottom: var(--s-3); letter-spacing: 0.01em; }
.footer ul { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
.footer a { color: var(--ink-3); text-decoration: none; }
.footer a:hover { color: var(--ink); }
.footer .fine { margin-top: var(--s-7); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3); font-size: 0.84rem; }
.footer p { max-width: 34rem; margin-top: var(--s-3); }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* ---------- Reveal on scroll (only when JS runs; content visible otherwise) ---------- */

html.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  filter: blur(6px);
  transition: opacity 900ms var(--ease-out), transform 1100ms var(--ease-out), filter 900ms var(--ease-out);
  transition-delay: var(--delay, 0ms);
}
html.js [data-reveal].is-in { opacity: 1; transform: none; filter: none; }

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] { opacity: 1; transform: none; filter: none; transition: none; }
  .odo-strip { transition: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .nav { background: rgba(3, 5, 11, 0.97); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(200, 212, 255, 0.35); --line-strong: rgba(200, 212, 255, 0.55); --ink-2: #d9dfee; --ink-3: #c0c8da; }
}

/* ---------- Leaderboards (landing, leaderboard page, dashboard) ---------- */

.boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.board { padding: var(--s-6); }
.board-head { display: grid; gap: 0.2rem; margin-bottom: var(--s-4); }
.board-head p { font-size: 0.86rem; }
.board-list { counter-reset: none; }
.board-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.board-row:first-child { border-top: 0; }
.rank {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.board-row:first-child .rank { color: var(--polaris-ink); background: var(--polaris); box-shadow: 0 0 18px rgba(124, 240, 196, 0.35); }
.who { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who em { font-style: normal; font-size: 0.75rem; font-weight: 600; color: var(--polaris); margin-left: 0.35rem; }
.board-row.is-you { background: linear-gradient(90deg, rgba(124, 240, 196, 0.06), transparent); }
.amt { display: grid; justify-items: end; line-height: 1.25; }
.amt strong { font-weight: 600; font-size: 1.02rem; }
.amt small { font-size: 0.78rem; }
.board-empty { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) 0 var(--s-2); color: var(--ink-3); }
.board-empty .icon { color: var(--polaris); flex: none; }
@media (max-width: 720px) { .boards { grid-template-columns: minmax(0, 1fr); } .board { padding: var(--s-5); } }

/* ---------- Planner (landing calculator + dashboard) ---------- */

.calc-value { font-weight: 600; font-size: 1.15rem; color: var(--ink); }
.calc-split { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-7); margin-bottom: var(--s-5); }
.calc-split dt { color: var(--ink-3); font-size: 0.88rem; display: flex; align-items: center; }
.calc-split dd { margin: 0.15rem 0 0; font-weight: 600; font-size: 1.1rem; }
/* Stacked bars, drawn by planner.js */
.bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  padding-top: var(--s-3);
  border-bottom: 1px solid var(--line-strong);
}
.bar {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  cursor: default;
}
.bar i { display: block; width: 100%; min-height: 0; }
.bar .b-int { background: var(--chart-usd); border-radius: 4px 4px 0 0; }
.bar .b-dep { background: var(--chart-blue); }
.bar:hover i, .bar:focus-visible i { filter: brightness(1.25); }
.bars-tip {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 8px);
  min-width: 170px;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(10, 14, 26, 0.96);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 14px 30px -12px rgba(0, 0, 0, 0.9);
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms, transform 200ms var(--ease-out);
  white-space: nowrap;
}
.bars-tip.is-on { opacity: 1; transform: none; }
.bars-tip b { display: block; margin-bottom: 0.25rem; color: var(--ink); }
.bars-tip span { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--ink-2); }


/* ---------- Icons in context ---------- */

.nav-links a { display: inline-flex; align-items: center; gap: 0.45rem; }
.nav-links a .icon { width: 16px; height: 16px; opacity: 0.7; transition: opacity 160ms; }
.nav-links a:hover .icon, .nav-links a[aria-current="page"] .icon { opacity: 1; color: var(--polaris); }
@media (max-width: 860px) { .nav-links a { display: flex; gap: var(--s-3); } .nav-links a .icon { width: 18px; height: 18px; } }

.h-with-icon { display: flex; align-items: center; gap: var(--s-3); }
.h-ico {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--polaris);
  background: rgba(124, 240, 196, 0.08);
  box-shadow: inset 0 0 0 1px rgba(124, 240, 196, 0.2);
}
.h-ico .icon { width: 17px; height: 17px; }
