/*
  Isolated visual polish layer.
  Keep shared product behavior in app.css/app.js; this file only adjusts
  presentation so concurrent feature work can merge without touching it.
*/

/* Put chart identity before the graphic so users know what each line means. */
.chart {
  display: flex;
  flex-direction: column;
}

.chart-viewport { order: 2; }

.legend {
  order: 1;
  margin: 0 0 11px;
}

.legend-item { color: var(--fg-muted); }
.legend-item.s0::before { background: var(--c0); }
.legend-item.s1::before { background: var(--c1); }
.legend-item.s2::before { background: var(--c2); }
.legend-item.s3::before { background: var(--c3); }
.legend-item.s4::before { background: var(--c4); }
.legend-item.s5::before { background: var(--c5); }

/* Turn the 404 into a useful recovery state without changing route behavior. */
.error {
  min-height: min(560px, calc(100vh - 150px));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.error > p {
  max-width: 52ch;
  margin: 0;
  color: var(--fg-muted);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.error-actions .btn {
  margin: 0;
  text-decoration: none;
}

/* External-link icons follow the button foreground. The shared app rule
   paints them blue, which hides the icon on the blue primary CTA. */
.referral-item .exchange-signup .ph {
  color: currentColor;
}

@media (max-width: 720px) {
  /* The four primary links remain visible, but now meet a comfortable
     touch height instead of behaving like small inline text links. */
  .nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding-block: 9px 8px;
  }

  .nav a::after { bottom: 2px; }

  .lang-menu summary {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  /* Keep the chooser clearly scrollable without a heavy native scrollbar. */
  .tool-chooser {
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }

  .tool-chooser::-webkit-scrollbar { height: 4px; }
  .tool-chooser::-webkit-scrollbar-track { background: transparent; }
  .tool-chooser::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
  }

  .tool-chooser a { scroll-snap-align: start; }

  /* Compact long calculators while preserving every field and label. */
  .calc-form { margin-top: 24px; }

  .calc-form fieldset {
    padding: 18px 18px 20px;
  }

  .calc-form legend {
    color: var(--fg);
    font-weight: 720;
  }

  .fields { gap: 14px; }
  .btn { min-height: 44px; }

  /* Mobile list views prioritize the columns used for scanning. Full symbol
     and outbound-link details remain available on the asset detail page. */
  .listings-table th:nth-child(4),
  .listings-table td:nth-child(4),
  .listings-table th:nth-child(5),
  .listings-table td:nth-child(5) {
    display: none;
  }

  .listings-table {
    table-layout: fixed;
    font-size: .84rem;
  }

  .listings-table th:nth-child(1) { width: 39%; }
  .listings-table th:nth-child(2) { width: 29%; }
  .listings-table th:nth-child(3) { width: 32%; }

  /* Detail rows keep the exchange link but omit the redundant raw symbol. */
  .listing-detail-table th:nth-child(4),
  .listing-detail-table td:nth-child(4) {
    display: none;
  }

  .listing-detail-table {
    table-layout: fixed;
    font-size: .8rem;
  }

  .listing-detail-table th,
  .listing-detail-table td {
    padding-inline: 7px;
  }

  .listing-detail-table th:nth-child(1) { width: 24%; }
  .listing-detail-table th:nth-child(2) { width: 27%; }
  .listing-detail-table th:nth-child(3) { width: 18%; }
  .listing-detail-table th:nth-child(5) { width: 31%; }

  .listing-detail-table .ext {
    font-size: .76rem;
    white-space: normal;
    line-height: 1.3;
  }

  .listing-detail-table .pill {
    display: block;
    width: fit-content;
    margin-top: 4px;
    padding-inline: 6px;
  }

  /* On preset liquidation pages, distance is the decision-making result.
     Hide implementation columns on small screens so that result stays visible. */
  .liqtier-table .col-mmr,
  .liqtier-table .col-maint {
    display: none;
  }

  .liqtier-table {
    table-layout: fixed;
    font-size: .82rem;
  }

  .liqtier-table th,
  .liqtier-table td {
    padding-inline: 7px;
  }

  .liqtier-table .col-tier { width: 12%; }
  .liqtier-table .col-band { width: 38%; }
  .liqtier-table .col-maxlev { width: 20%; }
  .liqtier-table .col-distance { width: 30%; }

  .liqtier-table .col-distance.strong { font-size: .92rem; }

  .site-footer p {
    font-size: .77rem;
    line-height: 1.62;
  }

  .error {
    min-height: auto;
    padding-block: 74px 88px;
  }

  .error-actions .btn {
    flex: 1 1 140px;
    text-align: center;
  }
}
