/*
 * Market selector (button, star, dialog) and statistics band of the pro terminal top bar.
 */

/* ---------- market button and favourite star ---------- */
.mkt { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.mkt-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 0; height: 36px; padding: 0 8px 0 10px; cursor: pointer;
  font: 700 15px var(--font-sans); letter-spacing: 0.01em; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.mkt-perp { color: var(--dim); font-weight: 600; }
.mkt-chg { display: none; margin-left: 8px; font-size: 11.5px; font-weight: 600; }
.mkt-caret { margin-left: 6px; color: var(--mute); transition: transform var(--t-fast); }
.mkt-btn[aria-expanded="true"] { border-color: var(--acc); }
.mkt-btn[aria-expanded="true"] .mkt-caret { transform: rotate(180deg); }
.fav-btn {
  appearance: none; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; cursor: pointer;
  color: var(--dim); background: none; border: 0; border-radius: var(--r-sm);
}
.fav-btn[aria-pressed="true"], .pk-star[aria-pressed="true"] { color: var(--warn); }
.fav-btn[aria-pressed="true"] svg path, .pk-star[aria-pressed="true"] svg path { fill: currentColor; }
@media (hover: hover) {
  .mkt-btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
  .fav-btn:hover, .pk-star:hover { color: var(--warn); background: var(--surface-3); }
}
body[data-mode="live"] .quote h1 #symbol { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body[data-mode="live"] .quote .stamp { display: none; }
body[data-mode="live"] .quote .price { font-size: 21px; }

/* ---------- statistics band: one line, never wraps. It always gets the room it needs: on a narrow desk it moves to a
   second row of the top bar (see pro.css, 760-1219 px) instead of squeezing the price; scrolling sideways is only the
   last resort (a very long account name, a phone) and then the band fades on the side that has more (stats-bar.js:
   data-edge), it is focusable and the arrow keys scroll it. The price keeps its own width and never goes under a stat. */
body[data-mode="live"] .top-main.quote { flex: 0 0 auto; }
.mstats {
  display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 auto; margin: 0; overflow-x: auto;
  scrollbar-width: none; white-space: nowrap;
}
.mstats[data-edge="end"] { --ms-fade: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.mstats[data-edge="start"] { --ms-fade: linear-gradient(270deg, #000 calc(100% - 28px), transparent); }
.mstats[data-edge="both"] { --ms-fade: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.mstats[data-edge] { -webkit-mask-image: var(--ms-fade); mask-image: var(--ms-fade); }
.mstats:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: var(--r-sm); }
.mstats::-webkit-scrollbar { display: none; }
.ms { display: grid; gap: 1px; flex: 0 0 auto; }
.ms dt { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; color: var(--dim); }
.ms dd { margin: 0; font-size: 12.5px; font-weight: 550; color: var(--text); }
.ms dd[data-tone="up"], .ms-tone[data-tone="up"] { color: var(--up); }
.ms dd[data-tone="down"], .ms-tone[data-tone="down"] { color: var(--down); }
.ms-cd { margin-left: 6px; color: var(--mute); }
.mstats[data-state="off"] dd { color: var(--dim); }

/* ---------- phone Info panel: the statistics and the steps of the market, two columns ---------- */
.inf-at { font-size: 10.5px; color: var(--dim); white-space: nowrap; }
.inf-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin: 0; }
.inf { display: grid; gap: 3px; min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.inf:nth-child(odd) { border-right: 1px solid var(--line); }
.inf.inf-wide { grid-column: 1 / -1; border-right: 0; border-bottom: 0; }
.inf dt { font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--dim); }
.inf dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; color: var(--text); }
.inf dd[data-tone="up"] { color: var(--up); }
.inf dd[data-tone="down"] { color: var(--down); }
.inf dd[data-tone="warn"] { color: var(--warn); }

/* ---------- selector dialog ---------- */
.picker {
  position: fixed; inset: auto; top: var(--pk-top, 64px); left: var(--pk-left, 16px); margin: 0;
  width: min(680px, calc(100vw - 24px)); max-height: min(560px, calc(100dvh - var(--pk-top, 64px) - 16px));
  display: none; flex-direction: column; overflow: hidden;
}
.picker[open] { display: flex; }
.picker::backdrop { background: rgb(2 4 8 / 0.35); backdrop-filter: none; -webkit-backdrop-filter: none; }
.pk-head { display: grid; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.pk-search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; color: var(--dim);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}
.pk-search:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.pk-input { flex: 1; min-width: 0; height: 100%; padding: 0; font: 500 14px var(--font-sans); color: var(--text); background: none; border: 0; outline: none; }
.pk-input::-webkit-search-cancel-button { filter: invert(0.6); }
.pk-tabs { justify-self: start; }
.pk-tab { display: inline-flex; align-items: center; gap: 6px; }
.pk-tab[aria-selected="true"] { color: var(--text); background: var(--surface-4); }
.pk-scroll { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.pk-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pk-table th {
  position: sticky; top: 0; z-index: 1; padding: 0; text-align: right; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pk-table th.pk-th-sym { text-align: left; }
.pk-sort {
  appearance: none; width: 100%; padding: 8px 10px; cursor: pointer; text-align: inherit; white-space: nowrap;
  font: 650 10.5px var(--font-sans); letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); background: none; border: 0;
}
th[aria-sort="ascending"] .pk-sort, th[aria-sort="descending"] .pk-sort { color: var(--text); }
th[aria-sort="ascending"] .pk-sort::after { content: " \2191"; color: var(--acc); }
th[aria-sort="descending"] .pk-sort::after { content: " \2193"; color: var(--acc); }
.pk-row { cursor: pointer; }
.pk-row td { padding: 0 10px; height: 36px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.pk-row td:nth-child(2) { text-align: left; }
.pk-row.active td { background: var(--surface-3); }
.pk-row.current td:nth-child(2) { box-shadow: inset 2px 0 0 var(--acc); }
.pk-star-cell { width: 34px; padding: 0 0 0 6px !important; }
.pk-star {
  appearance: none; display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; cursor: pointer;
  color: var(--dim); background: none; border: 0; border-radius: 6px;
}
.pk-pick { appearance: none; display: inline-flex; align-items: baseline; gap: 0; padding: 0; cursor: pointer; font: 650 13px var(--font-sans); color: var(--text); background: none; border: 0; }
.pk-perp { color: var(--dim); font-weight: 550; }
.pk-frozen {
  display: none; margin-left: 8px; padding: 1px 7px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--warn); background: var(--warn-soft); border-radius: var(--r-pill);
}
.pk-row.frozen .pk-frozen { display: inline-block; }
.pk-row td[data-tone="up"] { color: var(--up); }
.pk-row td[data-tone="down"] { color: var(--down); }
.pk-empty { padding: 22px 12px; text-align: center; color: var(--dim); }
@media (hover: hover) {
  .pk-row:hover td { background: var(--surface-2); }
  .pk-sort:hover { color: var(--text); }
}

/* ---------- phone: compact header and a full-screen selector ---------- */
@media (max-width: 759px) {
  .page-terminal .top .mkt { grid-area: markets; }
  .mkt-btn { height: 34px; font-size: 14px; white-space: nowrap; }
  .mkt-chg { display: inline; }
  .mstats { grid-column: 1 / -1; grid-row: 3; gap: 14px; }
  body[data-mode="live"] .quote .stamp { display: block; }
  .picker { inset: 0; top: 0; left: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .pk-table td:nth-child(n+6), .pk-table th:nth-child(n+6) { display: none; }
}
