/* /stocks — layout only. Everything with a visual identity is reused:
   header/nav (.landing-* in landing-styles.css), buttons (.btn .btn--secondary),
   chips (.filter-pill / .chain-pill), Decision Terminal panels and labels
   (.dt-* in pool-detail-styles.css, scoped by the .pool-detail-view wrapper that
   also remaps the --ui-* tokens to the 247-world paper/ink set). What lives here
   is the table / section grid, the status strip and the tooltip. Tokens only,
   no shadows except the overlay token on the tooltip, no gradients. */

/* .landing-app clips (overflow:hidden), which would pin the sticky header; clip
   only the x axis so the ornament layers still cannot cause horizontal scroll. */
.stocks-app {
  overflow: visible;
  overflow-x: clip;
  background: none;
}

.stocks-main {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  /* Same left/right edge as the header's content box (1200px - 2 x 20px padding). */
  width: min(1160px, calc(100% - 88px));
  margin: 0 auto;
  padding: 32px 0 56px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

/* ── Hero ── */
.stocks-hero { display: flex; flex-direction: column; gap: 10px; }
.stocks-eyebrow { margin: 0; }
.stocks-title {
  margin: 0;
  max-width: 760px;
  font-family: var(--font-family-display);
  font-size: clamp(32px, 4.4vw, 52px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ui-text);
}
.stocks-subhead {
  margin: 0;
  max-width: 680px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ui-text-secondary);
}

/* ── Market status strip ── */
.stocks-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  border: 1px solid var(--ui-border);
  border-radius: 2px;
  background: var(--ui-surface);
  font-size: 13px;
  color: var(--ui-text-secondary);
}
.stocks-status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ui-text-muted);
}
.stocks-status-dot.is-open { background: var(--ui-accent); }
.stocks-status-state { font-weight: 700; color: var(--ui-text); }
.stocks-status-next { min-width: 0; overflow-wrap: anywhere; }

/* ── Notice ── */
.stocks-notice p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ui-text); }

/* ── Aggregates ── */
.stocks-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.stocks-stats .dt-metric-val { white-space: nowrap; }

/* ── Sections ── */
.stocks-section { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stocks-h2 {
  margin: 0;
  font-family: var(--font-family-display);
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ui-text);
}
.stocks-h2--small { font-size: 18px; }
.stocks-section-sub { margin: 0 0 10px; max-width: 720px; font-size: 14px; line-height: 1.5; color: var(--ui-text-secondary); }

/* ── Spotlight ── */
.stocks-spot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stocks-spot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stocks-spot-ticker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--font-family-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ui-text);
}
.stocks-spot-facts { display: grid; gap: 8px; margin: 0; }
.stocks-spot-facts dt { font-size: 11px; color: var(--ui-text-secondary); }
.stocks-spot-facts dd { margin: 2px 0 0; font-size: 13px; color: var(--ui-text); overflow-wrap: anywhere; }
.stocks-spot-card .stocks-action { margin-top: auto; align-self: stretch; }

/* ── Live-data status line ── */
.stocks-live-note { margin: -4px 0 8px; font-size: 12px; line-height: 1.45; color: var(--ui-text-muted); }

/* ── Filters ── */
.stocks-filters { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.stocks-filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stocks-filter-label { min-width: 64px; }
.stocks-pill-count { margin-left: 6px; font-size: 12px; opacity: 0.7; }
@media (min-width: 961px) {
  /* Desktop sorts from the column headers; the pills are the small-screen control. */
  .stocks-sort-group { display: none; }
}

/* ── Tables ── */
.stocks-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.stocks-table th {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--ui-border-strong);
  vertical-align: bottom;
}
.stocks-table td {
  padding: 14px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--ui-row-border, var(--ui-border));
  font-size: 14px;
  color: var(--ui-text);
}
.stocks-table tbody tr:hover td { background: var(--ui-surface-muted); }
.stocks-th-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
}
.stocks-th-btn:hover, .stocks-th-btn.is-active { color: var(--ui-accent); }
.stocks-th-btn:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); border-radius: 2px; }

.stocks-pair-cell, .stocks-chain-cell, .stocks-score, .stocks-apy-cell, .stocks-price-cell, .stocks-tvl-cell, .stocks-clip-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}
.stocks-pair-name { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.stocks-sub { font-size: 12px; line-height: 1.4; color: var(--ui-text-secondary); }
.stocks-muted { font-size: 13px; color: var(--ui-text-muted); }
.stocks-chain, .stocks-tvl, .stocks-clip { font-weight: 600; }
.stocks-price { font-size: 15px; font-weight: 600; }
.stocks-drift { font-weight: 600; color: var(--ui-text-secondary); }
/* A move of 1.5% or more since the close: same hairline chip treatment, accent text, no glow. */
.stocks-drift.is-notable { color: var(--ui-accent); }
.stocks-score-num { font-size: 16px; font-weight: 700; }
.stocks-apy-num {
  font-family: var(--font-family-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ui-text);
}
.stocks-apy-num--plain { font-family: inherit; font-size: 16px; font-weight: 600; }
.stocks-band { max-width: 240px; }
.stocks-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stocks-badge { padding: 2px 8px; font-size: 10.5px; }
.stocks-badge--warn { color: var(--cert-amber); border-color: var(--cert-amber); }
.stocks-etf { margin-left: 0; }
.stocks-action { white-space: nowrap; }
.stocks-td-action { width: 1%; white-space: nowrap; }

/* ── Tooltip ── */
.stocks-tip { position: relative; display: inline-block; max-width: 100%; }
.stocks-tip-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: help;
  text-decoration: underline dotted var(--ui-text-muted);
  text-underline-offset: 3px;
}
.stocks-tip-btn:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); border-radius: 2px; }
.stocks-tip-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 2px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-overlay);
  color: var(--ui-text);
  font-family: var(--font-family-base);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  white-space: normal;
}

/* ── Notes / empty ── */
.stocks-notes ul { margin: 6px 0 0; padding-left: 18px; max-width: 820px; display: grid; gap: 6px; }
.stocks-notes li { font-size: 13px; line-height: 1.5; color: var(--ui-text-secondary); }
.stocks-empty { align-items: flex-start; }
.stocks-empty p { margin: 0; }

/* Crawler / no-JS fallback inside #stocks-root */
.stocks-static { max-width: 760px; margin: 0 auto; padding: 48px 24px; color: var(--ui-text); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stocks-spot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Under 960px the tables become stacked cards (no horizontal page scroll). The
   header row stays in the DOM, visually hidden, for assistive tech. */
@media (max-width: 960px) {
  .stocks-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .stocks-table, .stocks-table tbody, .stocks-table tr, .stocks-table td { display: block; }
  .stocks-table tr {
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--ui-border);
    border-radius: 2px;
    background: var(--ui-surface);
  }
  .stocks-table tbody tr:hover td { background: none; }
  .stocks-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 0;
    border-top: 1px dashed var(--ui-border);
  }
  .stocks-table td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ui-text-secondary);
  }
  .stocks-table td.stocks-td-pair { display: block; padding-top: 0; border-top: 0; }
  .stocks-table td.stocks-td-pair::before, .stocks-table td.stocks-td-action::before { content: none; }
  .stocks-table td.stocks-td-action { display: block; width: auto; padding-bottom: 0; }
  .stocks-table td.stocks-td-action .stocks-action { display: flex; width: 100%; }
  .stocks-table td:not(.stocks-td-pair) > div { align-items: flex-end; text-align: right; }
  .stocks-band { max-width: none; }
}

@media (max-width: 640px) {
  .stocks-main { width: min(560px, calc(100% - 72px)); padding-top: 20px; gap: 22px; }
  .stocks-spot-grid { grid-template-columns: minmax(0, 1fr); }
  .stocks-stats { gap: 8px; }
  .stocks-stats .dt-metric { padding: 10px; }
  .stocks-stats .dt-metric-val { font-size: 15px; }
  .stocks-filter-label { min-width: 0; flex-basis: 100%; }
}

@media (max-width: 440px) {
  .stocks-main { width: calc(100% - 64px); }
}

/* ── Token versions ── */
.stocks-v-picker { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.stocks-v-search {
  box-sizing: border-box;
  width: min(100%, 360px);
  padding: 10px 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface);
  color: var(--ui-text);
  font: inherit;
  font-size: 14px;
}
.stocks-v-search::placeholder { color: var(--ui-text-muted); }
.stocks-v-search:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); }
.stocks-v-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-height: 148px; overflow-y: auto; padding: 2px; }
.stocks-v-group-label { flex-basis: 100%; margin-top: 4px; }
.stocks-v-group-label:first-child { margin-top: 0; }
.stocks-v-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 6px; }
.stocks-v-name { font-family: var(--font-family-base); font-size: 14px; font-weight: 400; color: var(--ui-text-secondary); }
.stocks-v-market { display: inline-flex; align-items: center; gap: 8px; }
.stocks-v-static { margin: 0; font-size: 13px; }
.stocks-v-static a, .stocks-v-source, .stocks-v-pool { color: var(--ui-accent); }
.stocks-v-static a:focus-visible, .stocks-v-source:focus-visible, .stocks-v-pool:focus-visible,
.stocks-v-unv summary:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); border-radius: 2px; }
.stocks-v-ref { margin: 0; font-size: 14px; font-weight: 600; color: var(--ui-text); }

.stocks-table--versions th { padding: 10px 8px; }
.stocks-table--versions td { padding: 12px 8px; font-size: 13px; }
.stocks-v-num { font-weight: 600; }
.stocks-v-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.stocks-v-facts-cell { max-width: 240px; }
.stocks-v-facts { font-size: 12px; line-height: 1.4; color: var(--ui-text-secondary); overflow-wrap: anywhere; }
.stocks-v-fact-label { font-weight: 600; color: var(--ui-text); }
.stocks-v-yields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stocks-v-yield { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.stocks-v-yield + .stocks-v-yield { padding-top: 10px; border-top: 1px dashed var(--ui-border); }
.stocks-v-apy { font-family: var(--font-family-display); font-size: 18px; font-weight: 600; line-height: 1.1; color: var(--ui-text); }
.stocks-v-pool { font-size: 12px; font-weight: 600; }
.stocks-v-yline { white-space: nowrap; }
.stocks-v-pillar-details { width: 100%; font-size: 12px; color: var(--ui-text-secondary); }
.stocks-v-pillar-details summary { cursor: pointer; }
.stocks-v-pillars { margin: 4px 0 2px; padding: 0; list-style: none; display: grid; gap: 3px; width: 100%; font-size: 12px; color: var(--ui-text-secondary); }
.stocks-v-pillars li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stocks-v-tier { display: inline-flex; align-items: center; gap: 6px; color: var(--ui-text); font-weight: 600; }
.stocks-v-meter { display: inline-flex; gap: 2px; }
.stocks-v-meter span { width: 8px; height: 8px; border-radius: 1px; background: var(--ui-border-strong); }
.stocks-v-meter span.is-on { background: var(--ui-accent); }

.stocks-v-unv { margin-top: 12px; padding: 10px 14px; border: 1px solid var(--ui-border); border-radius: 2px; background: var(--ui-surface); }
.stocks-v-unv summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ui-text); }
.stocks-v-unv p { margin: 8px 0; }
.stocks-v-unv-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.stocks-v-unv-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding-top: 8px; border-top: 1px dashed var(--ui-border); }

/* Cards instead of a wide table below 1180px (the 10-column table needs the full 1160px content box);
   two columns of cards from 641px, one below. Same pattern as the 960px rule above. */
@media (max-width: 1180px) {
  .stocks-table--versions thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stocks-table--versions, .stocks-table--versions tr, .stocks-table--versions td { display: block; }
  .stocks-table--versions tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stocks-table--versions tr { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--ui-border); border-radius: 2px; background: var(--ui-surface); }
  .stocks-table--versions tbody tr:hover td { background: none; }
  .stocks-table--versions td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 9px 0; border-bottom: 0; border-top: 1px dashed var(--ui-border); min-width: 0;
  }
  .stocks-table--versions td::before {
    content: attr(data-label); flex: 0 0 34%;
    font-family: var(--font-mono, monospace); font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--ui-text-secondary);
  }
  .stocks-table--versions td.stocks-td-pair { display: block; padding-top: 0; border-top: 0; }
  .stocks-table--versions td.stocks-td-pair::before { content: none; }
  .stocks-table--versions td:not(.stocks-td-pair) > div, .stocks-table--versions td > ul { align-items: flex-end; text-align: right; }
  .stocks-table--versions td.stocks-v-wide { flex-direction: column; align-items: stretch; gap: 8px; }
  .stocks-table--versions td.stocks-v-wide > div, .stocks-table--versions td.stocks-v-wide > ul { align-items: flex-start; text-align: left; }
  .stocks-table--versions td.stocks-v-wide .stocks-v-yield { align-items: flex-start; }
  .stocks-v-facts-cell { max-width: none; }
}
@media (max-width: 640px) {
  .stocks-table--versions tbody { grid-template-columns: minmax(0, 1fr); }
  .stocks-v-search { width: 100%; }
}
.stocks-table--versions .stocks-pair-name { white-space: nowrap; }
.stocks-table--versions .stocks-chain { white-space: nowrap; }
