/* Growth of $1 — uses the Dhan-X tokens from styles.css throughout. The
   reference prototypes shipped their own palette and fonts; none of that is
   carried over, only the layout and behaviour. */

.cr-wrap { display: flex; flex-direction: column; gap: 20px; width: 100%; min-width: 0; max-width: 1600px; overflow-x: hidden; }

/* ── header ─────────────────────────────────────────────────────────────── */
.cr-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 32px; }
.cr-head-text { min-width: 0; }
.cr-eyebrow {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
}
.cr-title {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em;
  font-size: clamp(26px, 4vw, 40px); line-height: 1.05; margin: 6px 0 6px; color: var(--sage-pale);
}
.cr-dek { margin: 0; color: var(--text-muted); max-width: 62ch; font-size: 14px; }

/* The clock is the only thing that changes every animated month. Fixed width
   and tabular figures so nothing around it reflows, and min-heights so the
   event line appearing cannot shift the layout. */
.cr-clock { flex: 0 0 auto; width: 11ch; text-align: right; }
.cr-clock-yr {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(36px, 6vw, 64px);
  line-height: .92; color: var(--sage-pale); font-variant-numeric: tabular-nums; min-height: 1em;
}
.cr-clock-mo {
  font-family: var(--font-mono); font-size: 13px; color: var(--text-body);
  font-variant-numeric: tabular-nums; min-height: 1.4em;
}
.cr-clock-ev { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); min-height: 3.2em; }

/* ── toolbars ───────────────────────────────────────────────────────────── */
.cr-toolbar, .cr-addbar, .cr-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-md); padding: 10px 12px;
}
.cr-seg { display: inline-flex; border: 1px solid var(--stone); border-radius: var(--radius-sm); overflow: hidden; }
.cr-seg button {
  border: 0; border-radius: 0; background: transparent; color: var(--text-body);
  font: 500 13.5px var(--font-body); padding: 7px 13px; cursor: pointer;
}
.cr-seg button:hover { color: var(--sage-pale); background: rgba(var(--wash-rgb),.04); }
.cr-seg button[aria-pressed="true"] { background: var(--parchment); color: var(--sage-pale); font-weight: 600; }
.cr-seg button[hidden] { display: none; }

.cr-play {
  background: var(--forest); color: var(--on-accent); border: 1px solid var(--forest);
  border-radius: var(--radius-sm); font: 600 13.5px var(--font-body);
  padding: 8px 14px; min-width: 104px; cursor: pointer;
}
.cr-play:hover { background: var(--forest-light); }
.cr-scrub { flex: 1 1 220px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.cr-scrub input { flex: 1; min-width: 0; accent-color: var(--forest); }
/* Fixed width so the date label cannot nudge the slider as the text changes. */
.cr-scrub-lbl {
  flex: 0 0 9ch; text-align: right; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.cr-speed-lbl { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.cr-controls select {
  background: transparent; color: var(--text-body); border: 1px solid var(--stone);
  border-radius: var(--radius-sm); font: 500 13px var(--font-body); padding: 7px 10px; cursor: pointer;
}

/* ── add stock ──────────────────────────────────────────────────────────── */
.cr-add-label { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.cr-add-field { position: relative; flex: 1 1 260px; min-width: 0; }
.cr-add-field input {
  width: 100%; background: var(--cream-dark); color: var(--ink);
  border: 1px solid var(--stone); border-radius: var(--radius-sm);
  font: 400 14px var(--font-body); padding: 8px 11px;
}
.cr-add-field input::placeholder { color: var(--text-faint); }
.cr-add-results {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--stone);
  border-radius: var(--radius-sm); box-shadow: 0 10px 28px var(--shadow-deep);
}
.cr-add-results li {
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; color: var(--text-body);
}
.cr-add-results li:hover, .cr-add-results li[aria-selected="true"] { background: var(--parchment); color: var(--sage-pale); }
.cr-add-results li .cr-add-sym { font-family: var(--font-mono); color: var(--forest); margin-right: 8px; }
.cr-add-results li .cr-add-ex { float: right; font-size: 11.5px; color: var(--text-faint); }
.cr-add-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }

/* ── show chips ─────────────────────────────────────────────────────────── */
.cr-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cr-chips-lbl { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); align-self: center; }
.cr-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px;
  border: 1px solid var(--stone); border-radius: 999px; background: transparent;
  color: var(--text-body); font: 500 12.5px var(--font-body); cursor: pointer; max-width: 100%;
}
.cr-chip:hover { border-color: var(--moss); }
.cr-chip i { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.cr-chip[aria-pressed="true"] { background: var(--parchment); border-color: var(--moss); color: var(--sage-pale); }
.cr-chip.cr-chip-quick { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.cr-chip .cr-chip-note { color: var(--gold); font-size: 11px; }
.cr-chip .cr-chip-x { color: var(--text-faint); font-size: 14px; line-height: 1; }
.cr-chip .cr-chip-x:hover { color: var(--amber); }

/* ── chart + leaderboard ────────────────────────────────────────────────── */
.cr-main { display: grid; grid-template-columns: minmax(0, 1fr) 306px; gap: 18px; align-items: start; min-width: 0; }
.cr-chartbox {
  position: relative; min-width: 0; background: var(--white);
  border: 1px solid var(--parchment); border-radius: var(--radius-lg); padding: 8px;
}
.cr-chartbox canvas { display: block; width: 100%; height: clamp(340px, 56vh, 600px); }
.cr-chart-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--text-muted); font-size: 14px;
  background: var(--white); border-radius: var(--radius-lg);
}
.cr-chart-status[hidden] { display: none; }

.cr-board {
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-lg); padding: 14px 14px 10px; min-width: 0;
}
.cr-board h2 {
  font: 600 12px var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 8px;
}
.cr-row {
  display: grid; grid-template-columns: 18px 10px minmax(0, 1fr) auto;
  align-items: baseline; gap: 8px; padding: 7px 0;
  border-top: 1px solid var(--parchment); font-variant-numeric: tabular-nums;
}
.cr-row:first-of-type { border-top: 0; }
.cr-row .cr-rk { font: 500 11.5px var(--font-mono); color: var(--text-muted); }
.cr-row .cr-sw { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.cr-row .cr-nm { min-width: 0; }
.cr-row .cr-nm b { font-weight: 600; font-size: 13px; color: var(--sage-pale); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-row .cr-nm span { display: block; font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-row .cr-val { text-align: right; font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.cr-row .cr-val span { display: block; font-size: 11px; color: var(--text-muted); }
.cr-row.cr-off { opacity: .38; }
.cr-board-note { margin: 10px 0 2px; font-size: 11.5px; color: var(--text-muted); }

/* ── one stock at a time ────────────────────────────────────────────────── */
#crOneView { display: flex; flex-direction: column; gap: 16px; }
#crOneView[hidden], #crRaceView[hidden] { display: none; }

.cr-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px; }
.cr-tile {
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-md); padding: 11px 13px; min-width: 0;
}
.cr-tile-k {
  font: 500 10.5px var(--font-mono); letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
}
/* Tabular figures: these change as the single-stock animation plays, and must
   not re-wrap their tile while doing so. */
.cr-tile-v {
  font: 700 23px/1.15 var(--font-display); color: var(--sage-pale);
  font-variant-numeric: tabular-nums; margin-top: 3px;
}
.cr-tile-v.cr-up { color: var(--forest); }
.cr-tile-v.cr-down { color: var(--amber); }
.cr-tile-s { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }

.cr-card {
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-lg); padding: 12px 14px 8px; min-width: 0;
}
.cr-card h3 { font: 600 13px var(--font-body); color: var(--sage-pale); margin: 2px 0 3px; }
.cr-card-note { font-size: 11.5px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.55; }
.cr-card canvas { display: block; width: 100%; height: 220px; }
.cr-card-big canvas { height: clamp(300px, 46vh, 460px); }

.cr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11.5px; color: var(--text-muted); margin: 0 0 8px; }
.cr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cr-legend i { width: 18px; height: 0; border-top: 2.5px solid currentColor; display: inline-block; }
.cr-legend i.cr-dash { border-top-style: dashed; }

.cr-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.cr-tablewrap { overflow-x: auto; }
.cr-table {
  border-collapse: collapse; width: 100%; min-width: 520px;
  font-variant-numeric: tabular-nums; font-size: 13px;
}
.cr-table th {
  font: 500 10.5px var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--stone);
}
.cr-table th:first-child, .cr-table td:first-child { text-align: left; }
.cr-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--parchment);
  text-align: right; font-family: var(--font-mono); color: var(--text-body);
}
.cr-table td.cr-strong { font-weight: 600; color: var(--sage-pale); }
.cr-table tr.cr-today td { color: var(--text-muted); }

@media (max-width: 1000px) {
  .cr-grid3 { grid-template-columns: 1fr; }
}

/* ── notes ──────────────────────────────────────────────────────────────── */
.cr-notes {
  background: var(--white); border: 1px solid var(--parchment);
  border-radius: var(--radius-lg); padding: 16px 18px;
}
.cr-notes h2 { font: 600 12px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 10px; }
.cr-notes h3 { font: 600 13px var(--font-body); color: var(--sage-pale); margin: 14px 0 4px; }
.cr-notes p, .cr-notes li { font-size: 12.5px; line-height: 1.6; color: var(--text-muted); margin: 0 0 6px; }
.cr-notes ul { margin: 0 0 6px; padding-left: 18px; }
.cr-notes b { color: var(--text-body); font-weight: 600; }
.cr-disclaimer { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--parchment); color: var(--text-faint); font-size: 11.5px; }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .cr-main { grid-template-columns: 1fr; }
}
/* Phones. The control groups are the thing that overflows: each .cr-seg is an
   inline-flex of two buttons whose labels ("Years since listing") are wider
   than the viewport allows, so below this breakpoint every group goes
   full-width and its buttons share the row equally. Without this the page
   scrolls sideways, which §6.5 forbids. */
@media (max-width: 640px) {
  .cr-wrap { min-width: 0; }
  .cr-clock { width: 100%; text-align: left; }
  .cr-clock-yr { font-size: 40px; }
  .cr-clock-ev { min-height: 0; }
  .cr-toolbar, .cr-addbar, .cr-controls { gap: 8px; padding: 10px; }
  .cr-seg { width: 100%; }
  .cr-seg button { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: 12.5px; white-space: nowrap; }
  .cr-scrub { flex: 1 1 100%; }
  .cr-add-field { flex: 1 1 100%; }
  .cr-play { flex: 1 1 auto; }
  .cr-chartbox canvas { height: clamp(300px, 52vh, 420px); }
  .cr-tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .cr-table { min-width: 420px; }
}

/* Honour the OS setting: the race starts paused at its end state, so the page
   is useful without any motion at all. */
@media (prefers-reduced-motion: reduce) {
  .cr-chip, .cr-seg button, .cr-play { transition: none !important; }
}
