/* ============================================================
   match/economy.css
   #m-economy. Prefix: .mt-eco-
   Layout and page tokens come from match.css and hub.css.
   ============================================================ */

.mt-eco { overflow: hidden; }

.mt-eco-header { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.mt-eco-subtitle { max-width: 56ch; }

.mt-eco-body { display: flex; flex-direction: column; gap: 14px; }

.mt-eco-legend { margin-top: -2px; }

.mt-eco-key {
  width: 10px; height: 10px; flex: 0 0 auto;
  background: var(--color-rdy-steel);
}
.mt-eco-key--fight {
  background: var(--color-rdy-yellow);
  transform: rotate(45deg);
  border-radius: 1px;
}
.mt-eco-key--tower { background: var(--color-rdy-turquoise); border-radius: 1px; width: 7px; height: 11px; }
.mt-eco-key--roshan { background: var(--color-rdy-gold); border-radius: 50%; }

/* ---------- the chart and its readout ---------- */

.mt-eco-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 226px;
  gap: 14px;
  align-items: stretch;
}

.mt-eco-plot {
  position: relative;
  min-width: 0;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--color-rdy-white) 2%, transparent), transparent 40%),
    var(--color-rdy-dark-sky);
  box-shadow: inset 0 0 0 1px var(--border-hair);
  overflow: hidden;
}

.mt-eco-svghost { display: block; line-height: 0; }
.mt-eco-svg { display: block; width: 100%; }

.mt-eco-svg.is-sweeping .mt-eco-series,
.mt-eco-svg.is-sweeping .mt-eco-marks {
  animation: mt-eco-sweep .72s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes mt-eco-sweep {
  from { clip-path: inset(0 100% 0 0); opacity: .2; }
  to { clip-path: inset(0 0 0 0); opacity: 1; }
}

/* bands, grid, axes */
.mt-eco-band--laning { fill: var(--phase-laning); }
.mt-eco-band--mid { fill: var(--phase-mid); }
.mt-eco-band--late { fill: var(--phase-late); }

.mt-eco-band-label {
  fill: var(--color-rdy-white-45);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
}

.mt-eco-plot[data-phase-hover="laning"] .mt-eco-band--laning,
.mt-eco-plot[data-phase-hover="mid"] .mt-eco-band--mid,
.mt-eco-plot[data-phase-hover="late"] .mt-eco-band--late {
  fill: color-mix(in srgb, var(--color-rdy-white) 9%, transparent);
}

.mt-eco-gridline { stroke: var(--match-grid); stroke-width: 1; }
.mt-eco-gridline--zero { stroke: var(--color-rdy-white-25); stroke-width: 1; }

.mt-eco-ylabel {
  fill: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--color-rdy-dark-sky);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.mt-eco-ylabel--zero { fill: var(--text-secondary); }

/* series */
.mt-eco-area--dire { fill: var(--spark-dire-fill); }
.mt-eco-area--radiant { fill: var(--spark-radiant-fill); }
.mt-eco-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mt-eco-line--dire { stroke: var(--side-dire); }
.mt-eco-line--radiant { stroke: var(--side-radiant); }

/* markers */
.mt-eco-mark-stem { stroke: var(--color-rdy-white-10); stroke-width: 1; }
.mt-eco-mark--obj .mt-eco-glyph { fill: var(--color-rdy-turquoise); }
.mt-eco-mark--obj.is-radiant .mt-eco-glyph { fill: var(--side-radiant); }
.mt-eco-mark--obj.is-dire .mt-eco-glyph { fill: var(--side-dire); }
.mt-eco-mark--roshan .mt-eco-glyph,
.mt-eco-mark--aegis .mt-eco-glyph { fill: var(--color-rdy-gold); }
.mt-eco-mark--tormentor .mt-eco-glyph { fill: var(--color-rdy-steel); }
.mt-eco-mark--courier .mt-eco-glyph,
.mt-eco-mark--firstblood .mt-eco-glyph { fill: var(--color-rdy-steel); }
.mt-eco-mark--ancient .mt-eco-glyph { fill: var(--color-rdy-white); }
.mt-eco-glyph-inner { fill: var(--color-rdy-dark-sky); }

.mt-eco-mark-count {
  fill: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mt-eco-fight { fill: var(--color-rdy-yellow); stroke: var(--color-rdy-dark-sky); stroke-width: 1.5; }
.mt-eco-mark--fight.is-dire .mt-eco-fight { fill: var(--side-dire); }
.mt-eco-mark--fight.is-radiant .mt-eco-fight { fill: var(--side-radiant); }
.mt-eco-fight-halo { fill: color-mix(in srgb, var(--color-rdy-gold) 22%, transparent); }
.mt-eco-mark--fight.is-featured .mt-eco-fight { stroke: var(--color-rdy-light-gold); stroke-width: 1.6; }

.mt-eco-mark { transition: transform .14s ease; }
.mt-eco-mark.is-captured .mt-eco-glyph {
  fill: var(--match-magnet);
  stroke: var(--color-rdy-white);
  stroke-width: 1.4;
}
.mt-eco-mark.is-captured .mt-eco-mark-stem { stroke: var(--match-magnet); }

.mt-eco-featlabel-line { stroke: var(--color-rdy-white-25); stroke-width: 1; stroke-dasharray: 2 3; }
.mt-eco-featlabel-time {
  fill: var(--color-rdy-light-gold); font-size: 12px; font-weight: 700;
  paint-order: stroke; stroke: var(--color-rdy-dark-sky); stroke-width: 3px; stroke-linejoin: round;
}
.mt-eco-featlabel-text {
  fill: var(--text-secondary); font-size: 11px; font-weight: 600;
  paint-order: stroke; stroke: var(--color-rdy-dark-sky); stroke-width: 3px; stroke-linejoin: round;
}

/* ruler */
.mt-eco-ruler-rule { stroke: var(--border-soft); stroke-width: 1; }
.mt-eco-rtick { stroke: var(--color-rdy-white-15); stroke-width: 1; }
.mt-eco-rtick--major { stroke: var(--color-rdy-white-25); }
.mt-eco-rlabel { fill: var(--text-tertiary); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* cursor and the snapped dot */
.mt-eco-cursor { z-index: 3; }

.mt-eco-dot {
  position: absolute;
  left: calc(var(--dx, 1) * 100%);
  top: calc(var(--dy, .5) * 100%);
  width: 0; height: 0;
  pointer-events: none;
  z-index: 4;
}
.mt-eco-dot-ring {
  position: absolute;
  left: -5px; top: -5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-rdy-dark-sky);
  box-shadow: 0 0 0 2px var(--match-cursor);
}
.mt-eco-dot--radiant .mt-eco-dot-ring { box-shadow: 0 0 0 2px var(--side-radiant); }
.mt-eco-dot--dire .mt-eco-dot-ring { box-shadow: 0 0 0 2px var(--side-dire); }
.mt-eco-dot--adv.is-dire .mt-eco-dot-ring { box-shadow: 0 0 0 2px var(--side-dire); }
.mt-eco-dot--adv.is-radiant .mt-eco-dot-ring { box-shadow: 0 0 0 2px var(--side-radiant); }

.mt-eco-dot-flag {
  position: absolute;
  left: 10px;
  top: -10px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-rdy-starry-night);
  box-shadow: 0 0 0 1px var(--border-soft);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.mt-eco-dot.is-right .mt-eco-dot-flag { left: auto; right: 10px; }

.mt-eco.is-playing .mt-eco-dot-ring { box-shadow: 0 0 0 2px var(--color-rdy-fresh-green); }

/* the hover preview, drawn inside this chart's own SVG */
.mt-eco-ghost-line { stroke: var(--color-rdy-white-25); stroke-width: 1; stroke-dasharray: 3 3; }
.mt-eco-ghost-dot { fill: var(--color-rdy-white-45); }
.mt-eco-ghost-box {
  fill: color-mix(in srgb, var(--color-rdy-dark-sky) 92%, transparent);
  stroke: var(--color-rdy-white-25); stroke-width: 1;
}
.mt-eco-ghost-clock {
  fill: var(--text-primary);
  font-family: var(--font-sans); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mt-eco-ghost-value {
  fill: var(--text-secondary);
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mt-eco-edge {
  position: absolute; top: 0; bottom: 0; width: 22px;
  pointer-events: none; opacity: 0; transition: opacity .18s ease;
}
.mt-eco-edge--start {
  left: 0;
  background: linear-gradient(90deg, var(--color-rdy-white-15), transparent);
  opacity: var(--rubber-start, 0);
}
.mt-eco-edge--end {
  right: 0;
  background: linear-gradient(270deg, var(--color-rdy-white-15), transparent);
  opacity: var(--rubber-end, 0);
}

/* ---------- readout ---------- */

.mt-eco-readout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--border-hair);
  min-width: 0;
}

.mt-eco-ro-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.mt-eco-phasechip { background: var(--color-rdy-bright-night); color: var(--text-primary); }
.mt-eco-phasechip--laning { background: color-mix(in srgb, var(--color-rdy-turquoise) 22%, var(--color-rdy-bright-night)); }
.mt-eco-phasechip--late { background: color-mix(in srgb, var(--color-rdy-gold) 22%, var(--color-rdy-bright-night)); }

.mt-eco-state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.mt-eco-state.is-final { color: var(--color-rdy-light-gold); }

.mt-eco-ro-grid { gap: 10px 14px; }
.mt-eco-ro-item { flex: 1 1 92px; min-width: 0; }
.mt-eco-ro-item .m-readout-value { font-size: 16px; }
.mt-eco-ro-item .kills-pair { font-size: 14px; }

.mt-eco-moment-label { margin-top: 2px; }
.mt-eco-moment {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
  min-height: 34px;
}
.mt-eco-moment-time { color: var(--text-primary); font-weight: 700; flex: 0 0 auto; }
.mt-eco-moment-text { min-width: 0; }

/* ---------- phase tiles ---------- */

.mt-eco-phases {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mt-eco-phase {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--border-hair);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 0;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.mt-eco-phase:hover { background: var(--color-rdy-light-sky-hover); border-color: var(--border-soft); }
.mt-eco-phase:focus-visible { outline: 2px solid var(--color-rdy-turquoise); outline-offset: 2px; }
.mt-eco-phase.is-on {
  border-color: color-mix(in srgb, var(--color-rdy-gold) 45%, transparent);
  background: color-mix(in srgb, var(--color-rdy-gold) 8%, var(--surface-raised));
}

.mt-eco-phase-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mt-eco-phase-name { font-size: 13px; font-weight: 800; color: var(--text-primary); }
.mt-eco-phase-win { font-size: 11px; color: var(--text-tertiary); }

.mt-eco-phase-main { display: flex; align-items: baseline; gap: 6px; }
.mt-eco-phase-gold { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.mt-eco-phase-gold.is-dire { color: var(--side-dire-text); }
.mt-eco-phase-gold.is-radiant { color: var(--side-radiant-text); }
.mt-eco-phase-to { font-size: 11px; color: var(--text-tertiary); }

.mt-eco-phase-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.mt-eco-phase-stat { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.mt-eco-phase-stat-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--match-label-quiet);
}
.mt-eco-phase-stat .kills-pair { font-size: 12px; }

.mt-eco-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-tertiary);
  max-width: 78ch;
}

/* ---------- widths ---------- */

/* under 1180 the main column is too narrow to give the chart away to a
   side rail, so the readout becomes a strip under the plot */
@media (max-width: 1180px) {
  .mt-eco-main { grid-template-columns: minmax(0, 1fr); }
  .mt-eco-readout { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
  .mt-eco-ro-head { flex: 0 0 auto; gap: 10px; }
  .mt-eco-ro-grid { flex: 1 1 320px; gap: 8px 16px; }
  .mt-eco-ro-item .m-readout-value { font-size: 15px; }
  .mt-eco-moment-label { display: none; }
  .mt-eco-moment { flex: 1 1 100%; min-height: 0; }
}

@media (max-width: 900px) {
  .mt-eco-phases { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .mt-eco-svg.is-sweeping .mt-eco-series,
  .mt-eco-svg.is-sweeping .mt-eco-marks { animation: none; }
  .mt-eco-mark, .mt-eco-phase, .mt-eco-edge { transition: none; }
}
