/* The public market overview (sector rotation plan).
 *
 * Colour, type, spacing, radius and motion come only from tokens.css
 * custom properties: no hex, rgb()/hsl() or named colour literal lives
 * here, and no raw length equals a token value.
 *
 * The blue/orange of the activity bars are --series-1 / --series-2 — the
 * app's DATA palette, deliberately not the green/red of --up / --down,
 * which mean PRICE here. The price move is its own signed number.
 */

.market {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-block: var(--space-5) var(--space-6);
}

.mk-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.mk-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.mk-title {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.mk-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-body);
}

.mk-benchmarks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mk-section-title {
  margin: 0;
  font-size: var(--fs-section);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.mk-bench-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.mk-bench {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

.mk-bench-label {
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.mk-bench-value {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.mk-bench-value.is-muted {
  color: var(--text-muted);
  opacity: 0.7;
}

.mk-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.mk-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.mk-panel-titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.mk-panel-title {
  margin: 0;
  font-size: var(--fs-section);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.mk-panel-sub {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.mk-seg {
  flex: 0 0 auto;
}

.mk-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mk-resort {
  min-height: var(--hit-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.mk-resort:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mk-scope {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.mk-chart {
  min-height: var(--chart-h-md);
}

.mk-table {
  min-height: var(--space-8);
}

.mk-caption,
.mk-caveat,
.mk-feed {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.45;
}

.mk-caption {
  color: var(--text-soft);
}

.mk-caveat {
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  padding-left: var(--space-3);
}

.mk-feed {
  color: var(--text-muted);
  font-style: italic;
}

.mk-state:empty {
  display: none;
}

.mk-live:empty {
  display: none;
}

.mk-live {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.mk-note {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* The phone row: a label line and a bar/value line. The bar's width comes
 * from the caller as a custom property (a runtime value, never a literal),
 * and its colour is the data palette — never the price palette. */
.mk-bar {
  position: relative;
  height: var(--space-2);
  margin-top: var(--space-1);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mk-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--mk-bar, 0%);
  background: var(--series-1);
}

.mk-bar-fill.is-down {
  left: auto;
  right: 50%;
  background: var(--series-2);
}

.mk-row-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.mk-row-name {
  font-size: var(--fs-body);
  color: var(--text);
}

.mk-row-price {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.mk-row-value {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-soft);
}

/* The details (a modal): a definition list of the exact numbers. */
.mk-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin: 0;
}

.mk-detail-name {
  color: var(--text-muted);
  font-size: var(--fs-small);
}

.mk-detail-value {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
}

/* A hidden part must REALLY disappear: the class rules above set `display`,
 * which would otherwise beat the user agent's [hidden] rule. */
.mk-chart[hidden],
.mk-table[hidden],
.mk-scope[hidden],
.mk-state[hidden],
.mk-live[hidden] {
  display: none;
}

@media (max-width: 767.98px) {
  .market {
    padding-block: var(--space-4) var(--safe-bottom);
  }

  /* On a phone the canvas plot is replaced by the ROWS: each sector row
   * carries its own label line and its own bar, which is what the design
   * asks for (a readable label line and a bar/value line per row). The
   * canvas keeps the desktop label column, which a 320 px viewport cannot
   * show without clipping. */
  .mk-chart {
    display: none;
  }

  .mk-panel {
    padding: var(--space-3);
  }

  /* The title and the window control stack: the control keeps its full
   * touch targets and the title keeps its line. */
  .mk-panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .mk-seg {
    width: 100%;
  }

  /* The window control and the re-sort action stack: the control keeps its
   * full touch targets and nothing ever forces a horizontal scroll. */
  .mk-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .mk-resort {
    align-self: flex-start;
  }

  .mk-detail {
    grid-template-columns: minmax(0, 1fr);
  }
}
