/* hl-twaps.css -- /hyperliquid/twaps/ (frontend/templates/hl_twaps/, static/js/hl-twaps.js).
   Tokens come from base.css / perps.css / table.css; the page reuses .kpi-row/.kpi-card, .financial-table,
   .glass-card, .pill-tabs and .positive/.negative. At <= 640px every table row becomes a card (the td's
   data-label is printed as its label), so nothing is wider than the viewport. */

.twap-page { padding: 0 12px 32px; min-width: 0; max-width: 100%; }
/* display:grid on the mobile cards would otherwise beat the hidden attribute the script sets */
.twap-page [hidden] { display: none !important; }
.twap-header { flex-wrap: wrap; gap: 8px; }
.twap-header .page-title { min-width: 0; flex-wrap: wrap; }
.twap-h1 { margin: 0; font-size: var(--fs-xl); line-height: 1.25; }
.twap-nav { max-width: 100%; overflow-x: auto; }

.twap-lede { margin: 6px 0 2px; max-width: 72ch; font-size: var(--fs-md); line-height: 1.5; color: var(--color-text-primary); }
.twap-links, .twap-note, .twap-legend, .twap-trunc, .twap-foot, .twap-asof {
  margin: 4px 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--color-text-placeholder);
}
.twap-links a, .twap-note a { color: var(--color-link); }
.twap-note, .twap-legend { max-width: 80ch; }
.twap-muted { color: var(--color-text-placeholder); }

.twap-section { margin-top: 1.75rem; min-width: 0; }
.twap-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.twap-h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 500; letter-spacing: 0.01em; }
.twap-h3 { margin: 16px 0 6px; font-size: var(--fs-md); font-weight: 500; }
.twap-count { margin-left: 6px; font-size: var(--fs-sm); font-weight: 400; color: var(--color-text-placeholder); }

/* banners: stale data, a quiet feed, unavailable */
.twap-banner {
  margin: 8px 0; padding: 8px 12px; border-radius: 6px; font-size: var(--fs-base);
  border: 1px solid var(--table_border); color: var(--color-text-primary);
}
.twap-banner--amber { background: hsl(38 92% 50% / 0.12); border-color: hsl(38 92% 50% / 0.45); }
.twap-amber { color: var(--color-warning); font-weight: 600; }

/* tiles (.kpi-row from perps.css) */
.twap-tiles { padding-left: 0; padding-right: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.twap-tiles .kpi-card { gap: 4px; }
/* the shared .kpi-label cuts a long label with an ellipsis; here the label is the content ("Ordered value, latest price") */
.twap-tiles .kpi-label { white-space: normal; overflow: visible; text-overflow: clip; }
.twap-pair { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.twap-sub { font-size: var(--fs-xs); line-height: 1.4; color: var(--color-text-placeholder); }

/* filters */
.twap-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin: 12px 0; font-size: var(--fs-sm); }
.twap-filters label { display: flex; flex-direction: column; gap: 2px; color: var(--color-text-placeholder); }
.twap-filters label.twap-check { flex-direction: row; align-items: center; gap: 6px; height: 1.75rem; }
.twap-filters select, .twap-filters input[type="search"] {
  height: 1.75rem; padding: 0 8px; border: 1px solid var(--table_border); border-radius: 6px;
  background-color: var(--table_bg); color: var(--table_text_color); font: inherit; min-width: 0;
}
.twap-filters input[type="search"] { width: 11rem; }
.twap-clear, .twap-showall {
  height: 1.75rem; padding: 0 12px; border: 1px solid var(--table_border); border-radius: 6px; background: transparent;
  color: var(--color-text-primary); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.twap-clear:hover, .twap-showall:hover { background: var(--color-surface-hover); }
.twap-showall { display: block; margin: 8px auto 0; }

/* tables */
.twap-table { width: 100%; max-width: 100%; }
.twap-table th { white-space: nowrap; padding: 6px 8px; }
.twap-table td.twap-coin, .twap-table td.twap-wallet, .twap-table td.twap-flags, .twap-table td.twap-barcell,
.twap-table th:first-child { text-align: left; }
.twap-table td.twap-wallet { white-space: normal; min-width: 9rem; }
.twap-table td.twap-flags { white-space: normal; }
.twap-table td.twap-wallet a, .twap-table td.twap-coin a { color: var(--color-link); text-decoration: none; }
.twap-table td.twap-wallet a:hover, .twap-table td.twap-coin a:hover { text-decoration: underline; }
.twap-coin-name { font-weight: 600; }
.twap-sym, .twap-none { color: var(--color-text-placeholder); font-size: var(--fs-sm); }
.twap-label { font-size: var(--fs-sm); color: var(--color-text-placeholder); }
.twap-badge, .twap-tier, .twap-flag {
  display: inline-block; margin-left: 4px; padding: 0 5px; border: 1px solid var(--table_border); border-radius: 4px;
  font-size: 0.6875rem; line-height: 1.5; color: var(--color-text-placeholder); vertical-align: middle; white-space: nowrap;
}
.twap-badge { text-transform: uppercase; letter-spacing: 0.04em; }
.twap-flag { margin: 0 4px 2px 0; }
.twap-tier { background: var(--color-surface-dim); }

/* time elapsed (not fills) */
.twap-bar { width: 96px; height: 6px; border-radius: 3px; overflow: hidden; background: hsl(0 0% 50% / 0.22); }
.twap-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--color-brand); }

.twap-nomatch { padding: 14px 12px; text-align: center !important; color: var(--color-text-placeholder); white-space: normal !important; }
.twap-nomatch .twap-clear { margin-left: 8px; }

/* 24h / 7d / 30d */
.twap-pills { display: inline-flex; gap: 2px; padding: 2px; border-radius: 0.5rem; background: var(--color-surface-dim); }
.twap-pill {
  height: 1.5rem; padding: 0 0.875rem; border: 0; border-radius: 0.375rem; background: transparent;
  color: var(--color-text-placeholder); font: inherit; font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.twap-pill:hover { color: var(--color-text-primary); }
.twap-pill.active { background: var(--color-surface-hover); color: var(--color-text-primary); font-weight: 600; }

/* waiting / outcome not seen, FAQ */
.twap-details > summary, .twap-faq > summary { cursor: pointer; padding: 8px 4px; font-size: var(--fs-md); font-weight: 500; }
.twap-faq { border-bottom: 1px solid var(--table_border); }
.twap-faq p { margin: 2px 4px 12px; max-width: 75ch; font-size: var(--fs-base); line-height: 1.55; color: var(--color-text-placeholder); }

/* how to read, status words, mechanics */
.twap-notices { margin: 6px 0; padding-left: 1.25rem; max-width: 80ch; font-size: var(--fs-base); line-height: 1.55; }
.twap-notices li { margin: 4px 0; }
.twap-plain td, .twap-plain th { white-space: normal; text-align: left; vertical-align: top; padding: 6px 10px; }
.twap-plain th[scope="row"] { width: 9rem; font-size: var(--fs-base); font-weight: 600; color: var(--color-text-primary); }
.twap-word { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-base); }

@media (max-width: 640px) {
  .twap-page { padding: 0 16px 24px; }
  .twap-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* three selects on one row, the search box on its own, then Reduce-only and Clear: nothing is clipped or scrolls */
  .twap-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .twap-filters label.twap-q { grid-column: 1 / -1; }
  .twap-filters select, .twap-filters input[type="search"] { width: 100%; }
  /* the section pills wrap onto a second row instead of being cut at the right edge */
  .twap-nav { height: auto; flex-wrap: wrap; padding: 3px; row-gap: 2px; overflow: visible; }
  .twap-nav a { white-space: nowrap; }

  .twap-table, .twap-table tbody { display: block; width: 100%; min-width: 0 !important; }
  .twap-table thead { display: none; }
  .twap-table tr.twap-row, .twap-table tr.twap-coin-row, .twap-table tr.twap-outcome-row {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 10px 12px;
    border-bottom: 1px solid var(--table_border);
  }
  .twap-table td {
    display: block; min-width: 0; padding: 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere;
  }
  .twap-table td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-xs); color: var(--color-text-placeholder); }
  /* line 1: coin and side; then the labelled figures; wallet and flags span the card */
  .twap-table td.twap-coin::before, .twap-table td.twap-side::before { display: none; }
  .twap-table td.twap-side { text-align: right; }
  .twap-table td.twap-wallet, .twap-table td.twap-flags, .twap-table td.twap-barcell { grid-column: 1 / -1; min-width: 0; }
  .twap-table tr.twap-outcome-row td.twap-coin { grid-column: 1 / -1; }
  .twap-bar { width: 100%; }
  .twap-nomatch { display: block; }
  .twap-plain, .twap-plain tbody, .twap-plain tr, .twap-plain th, .twap-plain td { display: block; width: auto !important; }
  .twap-plain tr { padding: 8px 12px; border-bottom: 1px solid var(--table_border); }
  .twap-plain th, .twap-plain td { padding: 0; }
}
