/* Balík C2 (parity/ux/motion_v3_design.md) -- styling for src/lib/motion-charts.tsx.
   Own file per the "new CSS/JS go in their own files, not style.css" rule
   (parallel-agent hygiene). Reuses the same design tokens style.css already
   defines on :root (--good, --bad, --live, --instrument-accent, --text-dim,
   --motion-draw, --motion-hover, --border, --bg-raised) -- this file must be
   loaded on the same page as style.css (see layout.tsx's hasMotionCharts
   prop), never standalone. */

.mc-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 12px 0;
}

.mc-svg-wrap {
  width: 100%;
}

.mc-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.mc-gridline {
  stroke: var(--instrument-border, var(--border));
  stroke-width: 1;
}

.mc-axis-text {
  fill: var(--text-dim);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
}

.mc-year-label {
  font-size: 8px;
}

.mc-caption {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
}

/* --- YearByYearBars ------------------------------------------------- */

.mc-bar {
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(1);
}

.mc-bar-stated {
  fill: var(--text-dim);
  opacity: 0.55;
}

.mc-bar-actual {
  fill: var(--instrument-accent, var(--accent));
}

.mc-bar-unreportable {
  fill: url(#mc-hatch);
  opacity: 0.6;
}

/* Live calibration (src/lib/live-calibration.ts): 95% whisker on the
   actual bar. */
.mc-ci-whisker line {
  stroke: var(--text);
  stroke-width: 1.5;
  opacity: 0.8;
}

.mc-hatch-line {
  stroke: var(--text-dim);
  stroke-width: 1.5;
}

/* Set by motion-charts.js only, before the chart scrolls into view -- the
   no-JS / prefers-reduced-motion state is the plain rule above (final,
   grown bars). */
.mc-bar.mc-pre-anim {
  transition: none;
  transform: scaleY(0);
}

.mc-bar.mc-grow {
  transition: transform var(--motion-draw, 1000ms) cubic-bezier(0.22, 1, 0.36, 1);
  transform: scaleY(1);
}

/* --- CalibrationDrawLine --------------------------------------------- */

.mc-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mc-line-predicted {
  stroke: var(--text-dim);
}

.mc-line-realized {
  stroke: var(--instrument-accent, var(--live));
}

.mc-band {
  fill: var(--instrument-accent, var(--accent));
  opacity: 0.12;
  stroke: none;
}

.mc-line.mc-pre-anim {
  transition: none;
}

.mc-line.mc-js-draw {
  transition: stroke-dashoffset var(--motion-draw, 1000ms) ease;
}

.mc-band.mc-pre-anim {
  opacity: 0;
  transition: none;
}

.mc-band.mc-js-reveal {
  transition: opacity var(--motion-draw, 1000ms) ease;
  opacity: 0.12;
}

.mc-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.mc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mc-legend-item::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2.5px;
  border-radius: 2px;
}

.mc-legend-predicted::before {
  background: var(--text-dim);
}

.mc-legend-realized::before {
  background: var(--instrument-accent, var(--live));
}

/* --- CountUp ----------------------------------------------------------- */

.mc-countup {
  font-variant-numeric: tabular-nums;
}

/* --- MarketHitSparkline / "Hit rate by market" cards (feat/ranges-market-hit-chart) */

.mc-hit-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mc-hit-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.mc-hit-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.mc-hit-n,
.mc-hit-ci {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.mc-hit-spark-wrap {
  margin-top: 6px;
}

/* Compact variant (home page's 6-up row): tighter type, and when the card
   is itself a link (<a class="card mc-hit-card mc-hit-compact">) it should
   look/behave like the site's other linked stat cards. */
.mc-hit-compact .mc-hit-value {
  font-size: 1.4rem;
}
.mc-hit-compact .mc-hit-n {
  font-size: 0.72rem;
}
a.mc-hit-card {
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
a.mc-hit-card:hover {
  border-color: var(--accent);
}

/* Home page's compact row: 2 columns on mobile (no horizontal scroll at
   375px), 3 on tablet, 6 on desktop -- overrides the base .card-grid's
   single-column default, same breakpoints as .card-grid.cols-3 (700px) plus
   one more step at 900px for the full 6-across layout. */
.mc-hit-home-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 700px) {
  .mc-hit-home-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 900px) {
  .mc-hit-home-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* /s/<slug>: one full card at card size, comparison text beside it */
.mc-hit-symbol {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
}
.mc-hit-symbol .mc-hit-card {
  max-width: 380px;
}
@media (min-width: 700px) {
  .mc-hit-symbol {
    grid-template-columns: minmax(0, 380px) 1fr;
    gap: 20px;
  }
}

.mc-line-market {
  stroke: var(--instrument-accent, var(--live));
}

.mc-line-aggregate {
  stroke: var(--text-dim);
  stroke-dasharray: 4 3;
}

.mc-hit-card {
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}
.mc-hit-card.mc-pre-anim {
  opacity: 0;
  transform: translateY(10px);
}

/* 95 % CI on the 50-100 % scale, with the point estimate as a dot */
.mc-hit-cibar {
  position: relative;
  height: 6px;
  margin: 4px 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--text-dim) 18%, transparent);
}
.mc-hit-cibar-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: color-mix(in srgb, var(--instrument-accent, var(--live)) 45%, transparent);
  transform-origin: center;
  transition: transform 0.6s ease-out;
}
.mc-hit-card.mc-pre-anim .mc-hit-cibar-seg {
  transform: scaleX(0);
}
.mc-hit-cibar-dot {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--instrument-accent, var(--live));
}

.mc-hit-last {
  fill: var(--instrument-accent, var(--live));
}
.mc-hit-halo {
  fill: var(--instrument-accent, var(--live));
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.mc-hit-live .mc-hit-halo {
  animation: mc-hit-halo 2.4s ease-out infinite;
}
@keyframes mc-hit-halo {
  0% { opacity: 0.5; transform: scale(1); }
  70% { opacity: 0; transform: scale(3.2); }
  100% { opacity: 0; transform: scale(3.2); }
}

/* --- ResultStrip --------------------------------------------------------- */

.mc-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mc-chip-item {
  opacity: 1;
  transform: none;
}

.mc-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text);
  transition: transform var(--motion-hover, 180ms) ease, border-color var(--motion-hover, 180ms) ease;
}

a.mc-chip:hover,
a.mc-chip:focus-visible {
  transform: translateY(-1px);
  border-color: currentColor;
  text-decoration: none;
}

.mc-chip-mark {
  font-weight: 700;
  font-size: 13px;
}

.mc-chip-label {
  color: var(--text);
}

.mc-chip-status {
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.mc-chip-item.mc-pre-anim {
  transition: none;
  opacity: 0;
  transform: translateY(4px);
}

.mc-chip-item.mc-reveal {
  transition: opacity var(--motion-hover, 180ms) ease, transform var(--motion-hover, 180ms) ease;
  opacity: 1;
  transform: none;
}

.mc-chip-hit {
  background: color-mix(in srgb, var(--good) 14%, transparent);
  color: var(--good);
}

.mc-chip-miss {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
}

.mc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- RaceBar --------------------------------------------------------------- */

.mc-race {
  width: 100%;
}

.mc-race-track {
  position: relative;
  height: 40px;
  border-radius: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--instrument-border, var(--border));
}

.mc-race-inv,
.mc-race-target {
  position: absolute;
  top: 2px;
  font-size: 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-dim);
  white-space: nowrap;
}

.mc-race-inv {
  left: 0;
  padding-left: 4px;
}

.mc-race-target {
  right: 0;
  transform: translateX(-100%);
  padding-right: 4px;
}

.mc-race-entry {
  position: absolute;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mc-race-entry-mark {
  width: 2px;
  flex: 1;
  background: var(--text-dim);
}

.mc-race-entry-label {
  position: absolute;
  bottom: -16px;
  font-size: 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-dim);
  white-space: nowrap;
}

.mc-race-pointer {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0;
  transition: left var(--motion-hover, 180ms) ease;
}

.mc-race-pointer-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 30%, transparent);
}

.mc-race-pointer.mc-pulse .mc-race-pointer-dot {
  animation: mc-pulse-anim 1.6s ease-in-out infinite;
}

@keyframes mc-pulse-anim {
  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 30%, transparent);
  }
  50% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--live) 12%, transparent);
  }
}

/* --- MarketHitWide: full-width symbol-page panel (feat/ranges-market-hit-
   chart follow-up, replaces the narrow MarketHitCard on /s/<slug>). Axis
   labels are plain HTML (see motion-charts.tsx's comment on
   renderMarketHitWideSvg for why), positioned with left%/top% that track
   the SVG's own coordinate space regardless of rendered pixel size. */

.mc-hit-wide {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 4px;
}

.mc-hit-wide-plot {
  position: relative;
  touch-action: pan-y; /* mobile: horizontal tap/drag drives the tooltip, vertical scroll still passes through */
  padding-left: 30px; /* room for the y-axis tick labels */
}

.mc-hit-wide-ytick {
  position: absolute;
  left: 0;
  transform: translateY(-50%);
  font-size: 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-dim);
  line-height: 1;
}

.mc-hit-wide-bartick {
  position: absolute;
  right: 0; /* right edge, clear of the 50 % y label on the left */
  transform: translateY(-50%);
  font-size: 9px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-dim);
  opacity: 0.75;
  line-height: 1;
}

/* Flex + space-between, NOT absolute left% positioning: with fixed-width
   text labels, percent-based x-positions that are fine on a wide desktop
   container crowd together and touch/overlap on a narrow phone (same 6
   labels, ~340px instead of ~700px to fit them in). Flexbox can't overlap --
   it always gives each label its own box and only distributes the
   LEFTOVER space between them -- at the cost of a label no longer sitting
   exactly under its own gridline, which the spec doesn't require ("a
   reasonable number of labels", not pixel-exact alignment). */
.mc-hit-wide-xaxis {
  display: flex;
  justify-content: space-between;
  height: 14px;
  margin-left: 30px;
  gap: 4px;
}

.mc-hit-wide-xtick {
  font-size: 10px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-dim);
  white-space: nowrap;
}
.mc-hit-wide-xtick[data-align="end"] {
  text-align: right;
}

.mc-hit-wide-bar {
  fill: var(--text-dim);
  opacity: 0.4;
}

.mc-hit-wide-barline {
  stroke: var(--instrument-border, var(--border));
  opacity: 0.6;
}

.mc-hit-wide-cursor {
  position: absolute;
  top: 0;
  bottom: 14px; /* stop above the bar strip's own baseline, matches MHW_BARS_BOTTOM roughly */
  width: 1px;
  background: var(--text-dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.mc-hit-wide-cursor.mc-visible {
  opacity: 0.7;
}

/* floating readout box that follows the cursor line (positioned by motion-charts.js) */
.mc-hit-wide-tooltip {
  position: absolute;
  top: 2px;
  left: 0;
  margin: 0;
  padding: 6px 9px;
  max-width: 260px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  font-family: var(--font-mono, ui-monospace, monospace);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: pre-line;
  z-index: 2;
}
.mc-hit-wide-tooltip[hidden] {
  display: none;
}

/* --- Tier breakdown table (symbol page) --------------------------------- */

.mc-hit-tier-table {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 4px 0 8px;
}
.mc-hit-tier-table th,
.mc-hit-tier-table td {
  padding: 6px 10px 6px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.mc-hit-tier-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.78rem;
}
.mc-hit-tier-table td.mc-num {
  font-variant-numeric: tabular-nums;
}

/* --- Symbol page's stat-tile row (card-grid variant, 2x2 mobile / 4-across desktop) */

.mc-hit-tiles {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 700px) {
  .mc-hit-tiles {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --- Global reduced-motion override -------------------------------------
   Belt and braces on top of motion-charts.js checking matchMedia before it
   ever adds a *.mc-pre-anim class: even if that check were ever bypassed,
   nothing here can visually collapse/hide the server-rendered final state. */
@media (prefers-reduced-motion: reduce) {
  .mc-bar,
  .mc-line,
  .mc-band,
  .mc-chip-item,
  .mc-race-pointer,
  .mc-race-pointer-dot,
  .mc-hit-wide-cursor {
    transition: none !important;
    animation: none !important;
  }
  .mc-bar.mc-pre-anim {
    transform: scaleY(1);
  }
  .mc-line.mc-pre-anim {
    stroke-dashoffset: 0 !important;
  }
  .mc-band.mc-pre-anim {
    opacity: 0.12 !important;
  }
  .mc-chip-item.mc-pre-anim {
    opacity: 1 !important;
    transform: none !important;
  }
  .mc-hit-card,
  .mc-hit-cibar-seg,
  .mc-hit-halo {
    transition: none !important;
    animation: none !important;
  }
  .mc-hit-card.mc-pre-anim {
    opacity: 1 !important;
    transform: none !important;
  }
  .mc-hit-card.mc-pre-anim .mc-hit-cibar-seg {
    transform: none !important;
  }
}

/* home compact cards: the sparkline is drawn ~2.5x smaller, so thicken strokes */
.mc-hit-home-grid .mc-line {
  stroke-width: 5;
}
.mc-hit-home-grid .mc-hit-last,
.mc-hit-home-grid .mc-hit-halo {
  r: 6;
}

/* --- Calibration reliability chart (FX/stocks/crypto, feat/calibration-
   charts) -- same mc-svg/mc-line/mc-gridline/mc-legend chrome as the
   futures charts above, plus a CSS-only sector switcher and a floating
   hover/focus tooltip anchored to a scatter point instead of a vertical
   scan line (predicted% and realized% both vary, unlike the time-series
   charts' fixed x-axis). */

.mc-cal-tiles {
  margin-bottom: 10px;
}

/* held_window / by_scope_note text can be a full sentence-ish fragment
   ("2018-2026 (out-of-sample, futures/fx)") -- far too long for the site's
   usual 2.1rem stat-card number, so this tile gets its own smaller size. */
.mc-cal-window {
  font-size: 1.05rem !important;
  line-height: 1.25;
  font-variant-numeric: normal !important;
}

.mc-cal-diagonal {
  stroke: var(--text-dim);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0.6;
}

.mc-cal-point {
  fill: var(--bg-raised);
  stroke: var(--instrument-accent, var(--live));
  stroke-width: 2;
  cursor: pointer;
}
.mc-cal-point:hover,
.mc-cal-point:focus-visible {
  fill: var(--instrument-accent, var(--live));
  outline: none;
}

/* --- CSS-only tab switcher: hidden radios + label buttons + a plain `~`
   sibling selector. No JS is required for switching -- every scope's panel
   is rendered server-side, motion-charts.js only adds animation/tooltip on
   top of whichever panel is currently shown. Scope key strings are unique
   across every asset class (fx_majors/cfd_ostatni/etf/megacap/high_beta/
   btc_eth/alt_l1 never collide), and only one calibration section ever
   renders per page, so these ids/rules are written once and reused as-is
   by src/lib/calibration-view.tsx on all three pages -- keep this list in
   sync with ASSET_SCOPE_KEYS in src/lib/calibration-data.ts. */
.mc-cal-tabswitch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.mc-cal-tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mc-cal-tab {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.mc-cal-tab-input:checked + .mc-cal-tab {
  background: var(--instrument-accent, var(--accent));
  border-color: transparent;
  /* #fff, not a --bg token -- there is no --bg variable in style.css (only
     --bg-raised), and the site's own accent-background controls (button,
     form.subscribe button) use plain #fff on this same accent color in both
     themes -- see public/style.css. */
  color: #fff;
  font-weight: 600;
}
.mc-cal-tab-input:focus-visible + .mc-cal-tab {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mc-cal-tabpanel {
  display: none;
  flex-basis: 100%;
  width: 100%;
}
#cal-scope-pooled:checked ~ .mc-cal-tabpanel[data-panel="pooled"],
#cal-scope-fx_majors:checked ~ .mc-cal-tabpanel[data-panel="fx_majors"],
#cal-scope-cfd_ostatni:checked ~ .mc-cal-tabpanel[data-panel="cfd_ostatni"],
#cal-scope-etf:checked ~ .mc-cal-tabpanel[data-panel="etf"],
#cal-scope-megacap:checked ~ .mc-cal-tabpanel[data-panel="megacap"],
#cal-scope-high_beta:checked ~ .mc-cal-tabpanel[data-panel="high_beta"],
#cal-scope-btc_eth:checked ~ .mc-cal-tabpanel[data-panel="btc_eth"],
#cal-scope-alt_l1:checked ~ .mc-cal-tabpanel[data-panel="alt_l1"] {
  display: block;
}

.mc-cal-plot {
  position: relative;
}

.mc-cal-cursor {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--instrument-accent, var(--live));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.mc-cal-cursor.mc-visible {
  opacity: 0.55;
}

.mc-cal-tooltip {
  position: absolute;
  margin: 0;
  padding: 6px 9px;
  max-width: 240px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  font-family: var(--font-mono, ui-monospace, monospace);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}
.mc-cal-tooltip[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .mc-cal-cursor {
    transition: none !important;
  }
}

@media (max-width: 420px) {
  .mc-cal-tooltip {
    max-width: 200px;
    white-space: normal;
  }
}
