/* qs-overview.css — design pass for the Overview dashboard screen.
 *
 * Hand-authored source, not build output. Loads after visual-overhaul.css, so
 * rules here win without needing !important; reach for a higher-specificity
 * selector before reaching for the flag.
 *
 * Scope every rule to this screen. Shared token changes belong in
 * visual-overhaul.css and must be raised rather than duplicated here, so two
 * screens cannot drift apart on the same value.
 *
 * Bump the ?v=qs-overview-N key in scripts/build-static.js whenever this file changes,
 * or browsers keep serving the previous copy.
 *
 * ---------------------------------------------------------------------------
 * DIRECTION — "one instrument, one light"
 *
 * The overview is a reading instrument for money, and its weakness was that
 * every surface sat on the same plane with the same 1px line around it: seven
 * panels, one rule weight, no light. This pass gives the screen a single light
 * source and three rule weights, so a panel reads as a lit card with a masthead
 * and its rows recede into a ledger beneath it.
 *
 * The class hooks these rules bind to are added by the "Overview elevate pass"
 * in scripts/build-static.js, which also strips the static inline properties
 * this sheet took over. Every {{ }} binding is still inline and untouched — bar
 * widths, tint colours, flex ratios and the gauge marker offset all come from
 * the same expressions they always did. No figure or label is restyled into a
 * different meaning here.
 *
 * Colours are expressed against the --qt-* tokens rather than literals so the
 * theme switch being built in visual-overhaul.css carries through this screen
 * without a second edit.
 * ---------------------------------------------------------------------------
 */

:root {
  /* Spacing — one rhythm, so panel padding and row padding cannot drift. */
  --ov-pad-x: 24px;
  --ov-pad-y: 16px;
  --ov-row-y: 12px;

  /* Rules, three weights. The edge bounds a surface, the head separates a
   * masthead from its contents, the row is the faintest thing that still
   * separates two numbers. */
  --ov-rule-edge: var(--qt-line, #24313b);
  --ov-rule-head: color-mix(in oklab, var(--qt-line, #24313b) 82%, var(--qt-text, #f0f4f7) 18%);
  --ov-rule-row: color-mix(in oklab, var(--qt-line, #24313b) 58%, transparent);

  /* One light source, from above: a lit top edge and a shadow tinted with the
   * page ground rather than black. */
  --ov-edge-lit: color-mix(in oklab, var(--qt-text, #f0f4f7) 7%, transparent);
  --ov-shade: color-mix(in oklab, var(--qt-bg, #070b0f) 85%, transparent);
  --ov-lift:
    inset 0 1px 0 var(--ov-edge-lit),
    0 1px 1px -1px var(--ov-shade),
    0 14px 30px -20px var(--ov-shade);

  --ov-fast: var(--qt-motion-fast, 160ms);
  --ov-ease: var(--qt-ease-out, cubic-bezier(.16, 1, .3, 1));
  --ov-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------------------
 * 1. The digit grid
 *
 * Every figure a reader could compare sits on one set of digit widths, so a
 * column of numbers lines up whatever the values are. This changes glyph
 * advance only — never a value, a sign or a label.
 * ------------------------------------------------------------------------- */

.qs-hero-band,
.qs-overview-equity,
.qs-ov-grid,
.qs-ov-insights,
.qs-ov-activity {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
 * 2. Panels — the lit card
 * ------------------------------------------------------------------------- */

.qs-ov-panel {
  border: 1px solid var(--ov-rule-edge);
  box-shadow: var(--ov-lift);
}

.qs-ov-head {
  padding: var(--ov-pad-y) var(--ov-pad-x) calc(var(--ov-pad-y) - 2px);
  border-bottom: 1px solid var(--ov-rule-head);
  flex-wrap: wrap;
  row-gap: 6px;
}

/* Long panel meta ("7 HOLDINGS · 27.6% CASH") used to wrap mid-phrase against
 * the title. Let each side keep its own line instead of shredding both. */
.qs-ov-head > * {
  min-width: 0;
}

/* ---------------------------------------------------------------------------
 * 3. Accounts ledger
 * ------------------------------------------------------------------------- */

.qs-ov-arow {
  padding: var(--ov-row-y) var(--ov-pad-x);
}

.qs-ov-arow-head {
  padding-block: 10px;
  border-bottom: 1px solid var(--ov-rule-head);
}

.qs-ov-arow-data {
  position: relative;
  border-bottom: 1px solid var(--ov-rule-row);
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--ov-fast) var(--ov-ease);
}

.qs-ov-accounts > .qs-ov-arow-data:last-child {
  border-bottom: 0;
}

/* frontend-qa.css gives every button a focus ring, but with outline-offset:3px
 * and !important — and the ledger clips its own overflow, so that ring is cut
 * off on the panel's left and right edges and on the first and last rows. This
 * bar sits inside the row, so hover and keyboard focus are visible whatever the
 * outline does. It is the row's state, not a decoration. */
.qs-ov-arow-data::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 2px;
  background: var(--qt-cyan, #62c3d9);
  transform: scaleY(0);
  transition: transform var(--ov-fast) var(--ov-ease);
}

.qs-ov-arow-data:hover {
  background-color: var(--qt-panel-hover, #14202a);
}

.qs-ov-arow-data:hover::before,
.qs-ov-arow-data:focus-visible::before {
  transform: scaleY(1);
}

.qs-ov-dot {
  display: block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* ---------------------------------------------------------------------------
 * 4. Sparklines
 *
 * Never a pixel width on an SVG here — that inflates the grid track it sits in.
 * The 84px TREND column sizes the line; the line fills it.
 * ------------------------------------------------------------------------- */

.qs-ov-spark {
  display: block;
  width: 100%;
  height: 26px;
}

.qs-ov-spark path {
  stroke-width: 1.75px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qs-ov-spark-empty {
  display: block;
  height: 1px;
  background: var(--ov-rule-row);
}

/* ---------------------------------------------------------------------------
 * 5. Weight bars — donut legend and sector list
 *
 * The fill's width is bound to its own label's percentage and is set inline;
 * nothing here touches it. These rules set the track and the cap only. A very
 * small weight keeps a visible 3px stub so the row still reads as a mark
 * rather than an empty track.
 * ------------------------------------------------------------------------- */

.qs-ov-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--qt-line, #24313b) 72%, transparent);
  overflow: hidden;
}

.qs-ov-bar-lg {
  height: 8px;
}

.qs-ov-barfill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
}

/* ---------------------------------------------------------------------------
 * 6. Biggest holdings — donut and legend
 * ------------------------------------------------------------------------- */

.qs-ov-donut {
  display: block;
}

/* The ring's own track, drawn before any segment. */
.qs-ov-donut > circle:first-child {
  stroke: color-mix(in oklab, var(--qt-line, #24313b) 85%, transparent);
}

/* Segments already carry cursor:pointer but gave no feedback. Brightness is
 * used rather than opacity on purpose: each segment's opacity is bound to the
 * legend's selected state, and a CSS opacity here would silently overwrite that
 * encoding. */
.qs-ov-donut > circle:not(:first-child) {
  transition: filter var(--ov-fast) var(--ov-ease);
}

.qs-ov-donut > circle:not(:first-child):hover {
  filter: brightness(1.2);
}

.qs-ov-lhead {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--ov-rule-head);
}

.qs-ring-row {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* The provenance line. It explains what WEIGHT and ALL-TIME each mean, so it is
 * set as a readable note rather than fine print — same size, more air, and a
 * measure that stops it running the full width of the panel. */
.qs-ov-prov {
  margin: 0;
  padding: 14px var(--ov-pad-x) 18px;
  border-top: 1px solid var(--ov-rule-row);
  max-width: 68ch;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--qt-faint, #788993);
  text-wrap: pretty;
}

/* ---------------------------------------------------------------------------
 * 7. Diversification gauge
 *
 * The ramp is a status scale (concentrated → diversified), not a rainbow used
 * for magnitude, so it keeps its three stops. What changes is the volume: at
 * full chroma it was the loudest thing on the page and pulled the eye away from
 * the reading it exists to support. Mixing each stop toward the panel calms it
 * without losing the direction.
 *
 * No tick marks are drawn on the track. The band thresholds are not published
 * anywhere in the data, and a tick would assert a boundary this screen cannot
 * stand behind.
 * ------------------------------------------------------------------------- */

.qs-ov-gauge-band {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-wrap: balance;
}

.qs-ov-gauge-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--qt-red, #ff6b73) 74%, var(--qt-panel, #0d141b)) 0%,
    color-mix(in oklab, var(--qt-amber, #e8b45f) 74%, var(--qt-panel, #0d141b)) 50%,
    color-mix(in oklab, var(--qt-green, #57d38b) 74%, var(--qt-panel, #0d141b)) 100%
  );
}

/* The marker's halo used to hard-code the panel background, so it would have
 * gone wrong the moment the panel changed colour. It reads the token instead. */
.qs-ov-gauge-marker {
  position: absolute;
  top: -5px;
  width: 3px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--qt-text, #f0f4f7);
  box-shadow: 0 0 0 3px var(--qt-panel, #0d141b);
}

.qs-ov-gauge-bands {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--ov-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--qt-faint, #788993);
}

/* ---------------------------------------------------------------------------
 * 8. Holdings treemap
 *
 * Cell height is proportional to weight, which starved the smallest cells:
 * below about 40px the weight and the all-time figure were clipped away
 * entirely and the cell showed a ticker over blank tint. A cell that cannot
 * show its numbers is not encoding anything, so cells now have a floor and the
 * panel grows to hold them. Above that floor the proportions are unchanged.
 *
 * The two figures also sit on one baseline rather than stacked, which is what
 * makes the floor low enough to keep the map compact.
 * ------------------------------------------------------------------------- */

.qs-ov-treemap {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  padding: 18px var(--ov-pad-x) 20px;
  min-height: 236px;
}

.qs-ov-tcol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.qs-ov-tcell {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid;
  border-radius: 8px;
  /* The floor has to clear the cell's own content -- 9 + 13 + 5 + 12.5 + 9 --
   * or the flex item is held at the floor and clips the ticker off the top. */
  padding: 9px 12px;
  min-height: 52px;
}

/* A long symbol used to be hard-clipped mid-glyph by the cell's own overflow. */
.qs-ov-tticker {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.qs-ov-tvals {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 9px;
  line-height: 1;
}

.qs-ov-tweight {
  font-family: var(--ov-mono);
  font-size: 12.5px;
  color: var(--qt-text, #f0f4f7);
}

.qs-ov-tplpc {
  font-family: var(--ov-mono);
  font-size: 11.5px;
}

/* ---------------------------------------------------------------------------
 * 9. Recent activity
 * ------------------------------------------------------------------------- */

.qs-ov-actrow {
  padding: 11px var(--ov-pad-x);
}

.qs-ov-actrow-head {
  border-bottom: 1px solid var(--ov-rule-head);
}

.qs-ov-actrow-data {
  padding-block: var(--ov-row-y);
  border-bottom: 1px solid var(--ov-rule-row);
  transition: background-color var(--ov-fast) var(--ov-ease);
}

.qs-ov-actrow-data:hover {
  background-color: color-mix(in oklab, var(--qt-panel-hover, #14202a) 60%, transparent);
}

.qs-ov-activity > .qs-ov-actrow-data:last-child {
  border-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * 10. Needs attention — rows and severity chips
 *
 * The two severities keep exactly the treatment they had: RISK is a filled red
 * chip, DATA is an outlined one. Those three colours are bound inline and are
 * not touched here; this only supplies the box they sit in, so the chip stops
 * depending on a hard-coded 40x19 in the markup.
 * ------------------------------------------------------------------------- */

.qs-ov-attnrow {
  display: flex;
  gap: 12px;
  padding: 13px var(--ov-pad-x);
  border-bottom: 1px solid var(--ov-rule-row);
}

.qs-ov-panel > .qs-ov-attnrow:last-child,
.qs-ov-attnrow-ok {
  border-bottom: 0;
}

.qs-ov-attnrow > div {
  min-width: 0;
}

/* A long broker nickname used to wrap the panel open. */
.qs-ov-attnrow > div > div:last-child {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-wrap: pretty;
}

.qs-ov-chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 19px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-family: var(--ov-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.qs-ov-chip-ok {
  border-color: var(--ov-rule-head);
  color: var(--qt-muted, #8999a4);
}

/* ---------------------------------------------------------------------------
 * 11. Empty states
 *
 * These panels say what is absent rather than printing a number they cannot
 * stand behind — the benchmarks panel in particular. That is the right
 * behaviour and the copy is left exactly as written; it just gets the air and
 * the measure of something deliberate instead of reading as a failure.
 *
 * No rule or glyph is drawn above the line. A short dash sitting over a
 * benchmarks panel reads as a missing value rather than as decoration, and this
 * screen cannot afford that ambiguity.
 * ------------------------------------------------------------------------- */

.qs-ov-empty {
  padding: 18px var(--ov-pad-x) 22px;
  max-width: 56ch;
  font-size: 12px;
  line-height: 1.6;
  color: var(--qt-faint, #788993);
  text-wrap: pretty;
}

/* ---------------------------------------------------------------------------
 * 12. Text buttons — MANAGE, and the activity show-more toggle
 *
 * These had no hover state at all. They get a real hit area too: the padding is
 * cancelled by an equal negative margin, so the control grows without moving
 * anything around it. The focus ring comes from frontend-qa.css, which already
 * covers every <button> with !important.
 * ------------------------------------------------------------------------- */

.qs-ov-linkbtn {
  padding: 4px 7px;
  margin: -4px -7px;
  border-radius: var(--qt-radius-sm, 6px);
  font-family: var(--ov-mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  color: var(--accent, var(--qt-cyan, #62c3d9));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--ov-fast) var(--ov-ease),
    color var(--ov-fast) var(--ov-ease);
}

.qs-ov-linkbtn:hover {
  background-color: color-mix(in oklab, var(--qt-cyan, #62c3d9) 15%, transparent);
  color: var(--qt-focus, #8bd7e8);
}

.qs-ov-actfoot {
  padding: 12px var(--ov-pad-x);
  text-align: center;
  border-top: 1px solid var(--ov-rule-head);
  background: color-mix(in oklab, var(--qt-bg, #070b0f) 45%, transparent);
}

/* ---------------------------------------------------------------------------
 * 13. Hero band — the accounts scope control
 *
 * A native select with no explicit background-color and color renders with
 * Windows' own dark-mode chrome, which is why this one looked like a form
 * control dropped onto a dashboard. Both are set explicitly. The native arrow
 * is deliberately kept: replacing it needs a data: URI background, which this
 * page's CSP is entitled to refuse, and that would leave the control with no
 * affordance at all.
 * ------------------------------------------------------------------------- */

.qs-hero-band select {
  background-color: var(--qt-panel-strong, #111a22);
  color: var(--qt-text, #f0f4f7);
  border: 1px solid var(--ov-rule-edge);
  border-radius: var(--qt-radius-sm, 6px);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color var(--ov-fast) var(--ov-ease),
    border-color var(--ov-fast) var(--ov-ease);
}

.qs-hero-band select:hover {
  background-color: var(--qt-panel-hover, #14202a);
  border-color: var(--qt-line-strong, #3a4a56);
}

.qs-hero-band select:focus-visible {
  outline: 2px solid var(--qt-focus, #8bd7e8);
  outline-offset: 2px;
}

/* The popup's options inherit nothing from the closed control, so they are set
 * explicitly rather than left to the platform. */
.qs-hero-band select option {
  background-color: var(--qt-panel-strong, #111a22);
  color: var(--qt-text, #f0f4f7);
}

/* ---------------------------------------------------------------------------
 * 14. Motion
 *
 * Everything above animates background-color and transform only. Under reduced
 * motion the states still change — they just arrive without travel.
 * ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .qs-ov-arow-data,
  .qs-ov-arow-data::before,
  .qs-ov-actrow-data,
  .qs-ov-linkbtn,
  .qs-ov-donut > circle:not(:first-child),
  .qs-hero-band select {
    transition-duration: 1ms;
  }

  .qs-ov-arow-data::before {
    transform: scaleY(1);
    opacity: 0;
  }

  .qs-ov-arow-data:hover::before,
  .qs-ov-arow-data:focus-visible::before {
    opacity: 1;
  }
}

/* ---------------------------------------------------------------------------
 * 15. Narrow widths
 *
 * The component's own <style> block sets the 900px and 760px overview rules
 * with !important, from inside the .bin. These match those breakpoints rather
 * than inventing a third.
 * ------------------------------------------------------------------------- */

@media (max-width: 760px) {
  :root {
    --ov-pad-x: 16px;
    --ov-pad-y: 14px;
  }

  /* Title and meta each get their own line instead of both wrapping. */
  .qs-ov-head {
    align-items: flex-start;
  }

  .qs-ov-gauge-band {
    font-size: 22px;
  }

  .qs-ov-prov {
    max-width: none;
  }

  /* Stacked columns already give every cell room; the floor can relax. */
  .qs-ov-treemap {
    min-height: 0;
    padding-block: 16px 18px;
  }

  .qs-ov-tcell {
    min-height: 54px;
  }
}
