/* Homepage: heatmap hero and the interactive graphics that explain each
   feature. Real screenshots open from the "In the app" thumbnails. */

.home-page {
  --lab-note: #c0caf5;
  --lab-peak: #ff9e64;
  --lab-fast: #7aa2f7;
  --lab-slow: #e0af68;
  --lab-up: #9ece6a;
  --lab-down: #f7768e;
}

[data-theme="light"] .home-page {
  --lab-note: #2d3748;
  --lab-peak: #c05621;
  --lab-fast: #305f99;
  --lab-slow: #b7791f;
  --lab-up: #2f855a;
  --lab-down: #c53030;
}

.home-page .home-title-accent {
  color: var(--home-link);
}

/* =========================================================
   Hero: one column of copy, then the surface
   ========================================================= */

.home-page .hh-hero {
  padding-block: 76px 0;
}

.home-page .hh-top h1 {
  font-size: 3.5rem;
  line-height: 1.12;
}

.home-page .hh-top .home-hero-lede {
  max-width: 640px;
  margin: 24px 0 0;
  font-size: 1.1875rem;
  line-height: 1.6;
}

.home-page .hh-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 30px;
}

.home-page .hh-actions .home-hero-actions {
  justify-content: flex-start;
}

.home-page .hh-actions .home-hero-note {
  max-width: 300px;
  margin: 0;
}

.home-page .hm {
  margin-top: 52px;
}

/* =========================================================
   Shared surface
   ========================================================= */

.lab-surface {
  position: relative;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.hm.lab-surface {
  box-shadow: 0 40px 90px -45px rgba(0, 0, 0, 0.75);
}

[data-theme="light"] .hm.lab-surface {
  box-shadow: 0 30px 70px -45px rgba(30, 40, 60, 0.35);
}

.lab-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-height: 42px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lab-dots {
  display: inline-flex;
  gap: 6px;
  margin-right: 4px;
}

.lab-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
}

.lab-bar-title {
  color: var(--text);
  font-weight: 700;
}

.lab-bar-meta {
  color: var(--text-muted);
}

.lab-bar-tab {
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
}

.lab-badge {
  padding: 3px 8px;
  border: 1px dashed var(--amber);
  border-radius: 3px;
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lab-badge[hidden] {
  display: none;
}

.lab-plot {
  position: relative;
}

.lab-plot svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.lab-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 10px 18px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.lab-caption {
  flex: 1 1 260px;
  max-width: none;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.lab-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}

.lab-ramp {
  width: 140px;
  height: 8px;
  border-radius: 2px;
}

/* SVG text and guides */
.lab-tick,
.lab-axis-title {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.lab-grid {
  stroke: var(--divider);
  stroke-width: 1;
  opacity: 0.5;
}

.lab-zero {
  stroke: var(--text-muted);
  stroke-width: 1;
  opacity: 0.6;
}

/* Reveal: cells fill in sweep order, annotations follow */
.lab-cells rect {
  opacity: 0;
  transition: opacity 260ms ease-out;
}

.is-ready .lab-cells rect {
  opacity: 1;
}

.lab-notes {
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease 1150ms;
}

.is-ready .lab-notes {
  opacity: 1;
}

.lab-halo {
  fill: none;
  stroke: var(--surface);
  stroke-width: 4.5;
}

.hm-region {
  fill: none;
  stroke: var(--lab-note);
  stroke-width: 1.5;
}

.hm-peak {
  fill: none;
  stroke: var(--lab-peak);
  stroke-width: 2;
}

.lab-label rect {
  fill: var(--surface);
  opacity: 0.92;
}

.lab-label text {
  fill: var(--lab-note);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.lab-label.is-peak text {
  fill: var(--lab-peak);
}

/* Tooltip */
.lab-tip {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: 3px;
  min-width: 200px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.45;
  pointer-events: none;
}

.lab-tip[hidden] {
  display: none;
}

.lab-tip span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.lab-tip em {
  color: var(--text-muted);
  font-style: normal;
}

/* Segmented toggle */
.lab-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lab-bar .lab-toggle {
  margin-left: auto;
}

.lab-toggle button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.lab-toggle button[hidden] {
  display: none;
}

.lab-toggle button span {
  color: inherit;
  opacity: 0.75;
}

.lab-toggle button:hover {
  color: var(--text);
}

.lab-toggle button[aria-pressed="true"] {
  border-color: var(--home-link);
  background: var(--accent-hover);
  color: var(--text);
}

/* Readouts under a graphic */
.lab-readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0;
  border-top: 1px solid var(--border);
}

.lab-readout > div {
  padding: 10px 16px;
  border-right: 1px solid var(--border);
}

.lab-readout > div:last-child {
  border-right: 0;
}

.lab-readout dt {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.lab-readout dd {
  margin: 2px 0 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.key-region,
.key-peak,
.key-front {
  display: inline-block;
  margin-right: 7px;
  vertical-align: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--lab-note);
  border-radius: 2px;
}

.key-peak {
  border-color: var(--lab-peak);
}

.key-front {
  border-color: var(--home-link);
  border-radius: 50%;
  background: var(--home-link);
}

/* "In the app" proof thumbnail, opens the real screenshot */
.home-page .home-shot.lab-proof {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  margin-left: auto;
  padding: 4px 10px 4px 4px;
  outline: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.3;
}

.home-page .home-shot.lab-proof:hover {
  border-color: var(--home-link);
}

.home-page .lab-proof-img {
  display: block;
  width: 72px;
  height: 44px;
  overflow: hidden;
  border-radius: 2px;
}

.home-page .home-shot.lab-proof img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left top;
}

.home-page .lab-proof-text {
  display: grid;
}

.home-page .lab-proof-text small {
  color: var(--text-muted);
  font-size: 0.6875rem;
}

/* =========================================================
   Hero heatmap
   ========================================================= */

.hm-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
}

.hm-plot {
  padding: 16px 18px 8px 8px;
}

.hm-plot svg {
  cursor: pointer;
}

.hm.is-hovering .lab-cells rect {
  opacity: 0.7;
  transition-delay: 0ms !important;
}

.hm.is-hovering .lab-notes {
  transition-delay: 0ms;
}

.hm.is-hovering .lab-halo,
.hm.is-hovering .hm-region,
.hm.is-hovering .hm-peak,
.hm.is-hovering .lab-label {
  opacity: 0.25;
}

.hm-hover {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.hm-hover-cell {
  fill: none;
  stroke: var(--text);
  stroke-width: 2;
}

.hm-pin {
  fill: none;
  stroke: var(--home-link);
  stroke-width: 2.5;
}

.hm-readout {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.hm-card {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.hm-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.hm-card h3::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid var(--lab-note);
  border-radius: 2px;
}

.hm-card[data-hm-card="peak"] h3::before {
  border-color: var(--lab-peak);
}

.hm-card p {
  margin: 4px 0 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.hm-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin: 0;
  font-size: 0.8125rem;
}

.hm-card dt {
  color: var(--text-paragraph);
}

.hm-card dd {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hm-card-hint {
  margin-top: auto;
  padding: 16px 18px;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* =========================================================
   Trade replay
   ========================================================= */

.home-page .lab-section .home-section-heading {
  margin-bottom: 32px;
}

.tr-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.tr-stats > div {
  padding: 12px 18px;
  border-right: 1px solid var(--border);
}

.tr-stats > div:last-child {
  border-right: 0;
}

.tr-stats dt {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.tr-stats dd {
  margin: 2px 0 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.tr-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.tr-chart {
  padding: 8px 4px 0 8px;
}

.tr-list {
  max-height: 340px;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.tr-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  padding: 6px 14px;
  color: var(--text-paragraph);
  cursor: default;
}

.tr-list li.is-active,
.tr-list li:focus-visible {
  background: var(--accent-hover);
  outline: 0;
}

.tr-n {
  color: var(--text-muted);
}

.tr-ret {
  font-variant-numeric: tabular-nums;
}

.tr-ret.is-up {
  color: var(--lab-up);
}

.tr-ret.is-down {
  color: var(--lab-down);
}

.tr-empty {
  display: block !important;
  color: var(--text-muted);
}

.tr-span {
  opacity: 0.09;
  transition: opacity 120ms ease;
}

.tr-span.is-up {
  fill: var(--lab-up);
}

.tr-span.is-down {
  fill: var(--lab-down);
}

.tr-span.is-active {
  opacity: 0.22;
}

.tr-span.is-muted {
  opacity: 0.04;
}

.tr-wick {
  stroke-width: 1;
}

.tr-wick.is-up,
.tr-candle.is-up {
  stroke: var(--lab-up);
  fill: var(--lab-up);
  opacity: 0.55;
}

.tr-wick.is-down,
.tr-candle.is-down {
  stroke: var(--lab-down);
  fill: var(--lab-down);
  opacity: 0.55;
}

.tr-candle {
  stroke-width: 0;
}

.tr-sma {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
}

.tr-sma-fast {
  stroke: var(--lab-fast);
}

.tr-sma-slow {
  stroke: var(--lab-slow);
}

.tr-buy,
.tr-buy-key {
  fill: var(--lab-up);
  color: var(--lab-up);
}

.tr-sell,
.tr-sell-key {
  fill: var(--lab-down);
  color: var(--lab-down);
}

.tr-buy-key,
.tr-sell-key {
  margin-right: 4px;
  font-size: 0.625rem;
}

.tr-sell-key {
  margin-left: 10px;
}

.tr-cross {
  stroke: var(--text-muted);
  stroke-dasharray: 3 3;
}

.tr-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
}

.tr-key i {
  width: 16px;
  height: 2px;
  border-radius: 1px;
}

.tr-key i.is-fast {
  background: var(--lab-fast);
}

.tr-key i.is-slow {
  background: var(--lab-slow);
}

.tr-key i.is-band {
  height: 10px;
  background: var(--lab-fast);
  opacity: 0.2;
}

/* =========================================================
   Analysis graphics
   ========================================================= */

.home-page .home-research-feature .lab-surface {
  margin: 20px 0 14px;
}

.rg-control {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.rg-control label {
  flex: none;
  color: var(--text-muted);
}

.rg-control output {
  display: inline-block;
  min-width: 44px;
  margin-left: 6px;
  color: var(--text);
}

.rg-control input {
  flex: 1;
  accent-color: var(--home-link);
}

.rg .lab-plot,
.st-panes {
  padding: 12px 12px 4px 4px;
}

.rg .lab-cells rect {
  transition: opacity 260ms ease-out, fill 160ms ease;
}

.to .lab-toggle {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.to .lab-plot {
  padding: 8px 8px 0 4px;
}

.to-dot {
  fill: var(--text-muted);
  opacity: 0.4;
}

.to-front-line {
  fill: none;
  stroke: var(--home-link);
  stroke-width: 1.5;
}

.to-front {
  fill: var(--home-link);
  stroke: var(--surface);
  stroke-width: 2;
}

.to-peak,
.to-region {
  fill: none;
  stroke-width: 2;
}

.to-peak {
  stroke: var(--lab-peak);
}

.to-region {
  stroke: var(--lab-note);
}

/* Drivers */
.home-page .lab-drivers {
  margin-top: 56px;
}

.home-page .lab-drivers > p {
  max-width: 720px;
  margin: 0 0 20px;
}

.dr-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dr-panel {
  padding: 14px 14px 6px 6px;
}

.dr-panel + .dr-panel {
  border-left: 1px solid var(--border);
}

.dr-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 6px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.dr-head h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.75rem;
}

.dr-head span {
  color: var(--text-muted);
}

.dr-panel.is-strong .dr-head span {
  color: var(--home-link);
}

.dr-band {
  fill: var(--lab-fast);
  opacity: 0.16;
}

.dr-line {
  fill: none;
  stroke: var(--lab-fast);
  stroke-width: 2;
}

.dr-dot {
  fill: var(--lab-fast);
  stroke: var(--surface);
  stroke-width: 2;
}

.home-page .lab-notes-row {
  grid-template-columns: 1fr;
  margin-top: 28px;
}

/* Study */
.st-panes {
  display: grid;
  gap: 10px;
}

.st-pane h4 {
  margin: 0 0 2px 34px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
}

.home-page .home-study-visual .lab-surface + .home-evidence-note {
  margin-top: 12px;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 960px) {
  .hm-body,
  .tr-body {
    grid-template-columns: 1fr;
  }

  .hm-readout {
    flex-direction: row;
    flex-wrap: wrap;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .hm-card {
    flex: 1 1 220px;
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }

  .hm-card-hint {
    flex-basis: 100%;
    border-top: 1px solid var(--border);
  }

  .tr-list {
    max-height: 220px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  .home-page .hh-hero {
    padding-top: 40px;
  }

  .home-page .hh-top h1 {
    font-size: 2.375rem;
  }

  .home-page .hh-top .home-hero-lede {
    font-size: 1.0625rem;
  }

  .home-page .hm {
    margin-top: 36px;
  }

  .lab-bar {
    padding-inline: 12px;
  }

  .lab-dots,
  .lab-bar-tab {
    display: none;
  }

  .lab-bar .lab-toggle {
    margin-left: 0;
  }

  .hm-plot {
    padding: 8px 6px 2px 0;
  }

  .hm-card {
    flex-basis: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .tr-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tr-stats > div:nth-child(2) {
    border-right: 0;
  }

  .tr-stats > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .dr-panels {
    grid-template-columns: 1fr;
  }

  .dr-panel + .dr-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .home-page .hh-actions .home-hero-actions,
  .home-page .hh-actions .home-hero-actions .button-large {
    width: 100%;
  }

  .home-page .hh-actions .home-hero-note {
    max-width: none;
  }

  .lab-readout {
    grid-template-columns: 1fr;
  }

  .lab-readout > div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .lab-readout > div:last-child {
    border-bottom: 0;
  }

  .home-page .home-shot.lab-proof {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-cells rect,
  .lab-notes {
    transition: none;
  }
}
