/* chart-card.css — the shadow-root stylesheet of . * * Extracted from the two \3c style> blocks chart-card-element.ts used to inject * (STY-3.4a, styles.md §3.4). STY-3.4b then repainted it onto the design * tokens; the CSS before that was never linted, which is how it came to carry * 104 raw hex, two font stacks and twelve z-index literals. * * The card has two variants and only one block is ever in the shadow root, so * the file keeps them apart behind two sentinel comments and the component * adopts the one its variant needs. Nothing may be inserted between a sentinel * and the block that follows it. * * What the repaint changed, and why each value moved: * - `:host` and the chart canvas were `#000`, a hole punched in the darkest * app surface. They are `var(--bg)` now (STY-3.4b). * - `#4fc3f7` (Material Light Blue 300) and `#ff6f61` (salmon) appeared * nowhere else in the app: `--info` and `--negative` own those roles. * - `#666`, `#888` and `#ccc` were one-off greys darker than the text ramp * allows on a dark surface: `--text-muted` and `--text-secondary`. * - Every `var(--token, #literal)` fallback went. The literals were not app * values, so a failing token rendered a third colour nobody chose. * - `system-ui` in two spellings is `var(--font-sans)`; the card was the one * place the app rendered in something other than Inter. * - The z-index literals became tokens in the same order: overlay 10, * compact header 12, cluster 20 and the expanded host 1000. * - The data badges became the app's badge (tinted fill, coloured ink) * instead of a solid fill with white text. * * Two rules stay disabled below, and only these two: the compact and full * variants deliberately repeat selectors (one stylesheet, two blocks), and the * hardcoded pixel lengths the card was authored with are not this wave's debt. */ /* stylelint-disable no-duplicate-selectors, lt/no-raw-length -- the compact and full variants repeat selectors by design, and the pixel lengths are the card's authored values (see header) */ /* @@variant compact */ :host { display: block; background: var(--bg); min-height: 240px; height: 100%; } /* The document owns this rule for every other inline icon; a shadow tree inherits the custom property but not the selector, so the card repeats it. See common.css `svg[stroke="currentColor"]`. */ .body { padding: 0; position: relative; height: 100%; } .chart-container { height: 100%; min-height: 200px; width: 100%; background: var(--bg); } /* The retry button of a failed load. It was a style.cssText string on the element (five values no linter could see, and no hover or focus state at all); the overlay sets pointer-events: none, so this re-enables them. */ .retry-btn { pointer-events: auto; margin-left: var(--space-sm); padding: 2px var(--space-sm); font-family: var(--font-sans); font-size: var(--font-xs); background: var(--bg-tertiary); border: 1px solid var(--border-focus); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; } .retry-btn:hover { background: var(--bg-secondary); } .retry-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } .overlay { position: absolute; top: 12px; left: 12px; z-index: var(--z-10); pointer-events: none; background: rgb(var(--black-rgb) / 85%); backdrop-filter: blur(4px); padding: 3px 7px; border-radius: var(--radius-md); border: 1px solid var(--border); font-family: var(--font-sans); font-size: var(--font-xs); color: var(--text-muted); } /* One cluster, one button style. Absolute offsets per button (4/26/48px) put the controls in the corner but left them three different sizes and two different looks; a flex row keeps them contiguous and exactly as wide as what it shows. */ .corner { position: absolute; top: 4px; right: 4px; z-index: var(--z-100); display: flex; gap: 2px; align-items: center; } /* The three card-owned corner controls read as a column: fullscreen on top, then the page's star, then notes. The four study buttons stay a horizontal row beside them, so the cluster is a row with one column at its end. The star is slotted, so the column wraps the slot rather than restyling the slotted node -- which no shadow rule could reach anyway. */ .corner-stack { display: flex; flex-direction: column; gap: 2px; align-items: center; } /* Same box as .corner-btn in common.css (which the card cannot read from inside its shadow root); tests/chart/test_chart_flip.py pins the two together. */ .corner-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--icon-size); height: var(--icon-size); padding: 0; background: color-mix(in srgb, var(--black) 70%, transparent); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-muted); font-size: var(--font-xs); line-height: 1; cursor: pointer; } .corner-btn:hover { background: var(--text); color: var(--bg); } /* Only a wrapped card can flip, so the Notes button appears once the flip wrapper has claimed it: it lives in the shadow root and cannot otherwise see the wrapper it now sits in. */ .notes-btn { display: none; } :host([flippable]) .notes-btn { display: inline-flex; } /* Expanded, the card is fullscreen and its wrapper is not on screen, so the star and the notes face are unreachable. */ :host(.expanded) .notes-btn { display: none; } :host(.expanded) slot[name="corner"] { display: none; } /* The overlay-study buttons join the corner cluster (compact template only). They flow, so the row is exactly as wide as the buttons it currently shows; hidden until expanded, as before. */ .levels-btn, .retest-btn, .confluence-btn, .reversal-btn { width: 20px; height: 20px; justify-content: center; font-size: var(--font-xs); } .levels-btn { background: rgb(var(--black-rgb) / 70%); border: 1px solid var(--border); color: var(--text-muted); padding: 0; border-radius: var(--radius-md); cursor: pointer; z-index: var(--z-100); line-height: 1; display: none; align-items: center; } .levels-btn:hover { background: var(--text); color: var(--bg); } .levels-btn.active { color: var(--info-text); border-color: rgb(var(--info-rgb) / 50%); background: var(--info-bg); } .levels-btn.active:hover { background: rgb(var(--info-rgb) / 20%); color: var(--info-text); } .retest-btn { background: rgb(var(--black-rgb) / 70%); border: 1px solid var(--border); color: var(--text-muted); padding: 0; border-radius: var(--radius-md); cursor: pointer; z-index: var(--z-100); line-height: 1; display: none; align-items: center; } .retest-btn:hover { background: var(--text); color: var(--bg); } .retest-btn.active { color: var(--info-text); border-color: rgb(var(--info-rgb) / 50%); background: var(--info-bg); } .retest-btn.active:hover { background: rgb(var(--info-rgb) / 20%); color: var(--info-text); } .confluence-btn { background: rgb(var(--black-rgb) / 70%); border: 1px solid var(--border); color: var(--text-muted); padding: 0; border-radius: var(--radius-md); cursor: pointer; z-index: var(--z-100); line-height: 1; display: none; align-items: center; } .confluence-btn:hover { background: var(--text); color: var(--bg); } .confluence-btn.active { color: var(--warning); border-color: rgb(var(--warning-rgb) / 50%); background: var(--warning-bg); } .confluence-btn.active:hover { background: rgb(var(--warning-rgb) / 20%); color: var(--warning); } .reversal-btn { background: rgb(var(--black-rgb) / 70%); border: 1px solid var(--border); color: var(--text-muted); padding: 0; border-radius: var(--radius-md); cursor: pointer; z-index: var(--z-100); line-height: 1; display: none; align-items: center; } .reversal-btn:hover { background: var(--text); color: var(--bg); } .reversal-btn.active { color: var(--negative-text); border-color: rgb(var(--negative-rgb) / 50%); background: var(--negative-bg); } .reversal-btn.active:hover { background: rgb(var(--negative-rgb) / 20%); color: var(--negative-text); } .compact-header { left: 12px; z-index: var(--z-50); display: flex; gap: 4px; align-items: center; font-size: var(--font-lg); line-height: 1; } .reversal-btn.active { color: var(--negative-text); border-color: rgb(var(--negative-rgb) / 50%); background: var(--negative-bg); } .reversal-btn.active:hover { background: rgb(var(--negative-rgb) / 20%); color: var(--negative-text); } .compact-header { position: absolute; top: 4px; left: 12px; z-index: var(--z-50); display: flex; gap: 4px; align-items: center; font-size: var(--font-lg); line-height: 1; } :host(.expanded) { position: fixed; inset: 0; z-index: var(--z-1000); margin: 0; background: var(--bg); } :host(.expanded) .chart-container { height: 100vh !important; } :host(.expanded) .levels-btn { display: inline-flex; } :host(.expanded) .retest-btn { display: inline-flex; } :host(.expanded) .confluence-btn { display: inline-flex; } :host(.expanded) .reversal-btn { display: inline-flex; } /* Same [fill] contract as the full template below, and for the same reason: :host is display:block here, .body claims height:100%, and _updatePressRelease() inserts .pr-bar as .body's next SIBLING — so the pair sums past the host and the pr-bar is clipped by the caller's overflow:hidden. A flex column host lets .body flex to whatever is left. This template had no [fill] rules at all, so pairing compact+fill (the scanner calendar sidebar) laid out exactly like that bug. Placed after the :host(.expanded) group on purpose: [fill]'s height:100% then wins over the expanded 100vh, which is what the full template already does — the expanded host is position:fixed inset:0, so .body flexing to the viewport minus a pr-bar beats a hard 100vh. */ :host([fill]) { min-height: 0 !important; height: 100% !important; display: flex !important; flex-direction: column !important; } :host([fill]) .body { flex: 1 !important; min-height: 0 !important; height: auto !important; } :host([fill]) .chart-container { height: 100% !important; min-height: 0 !important; } :host([data-active="true"]) { outline: 2px solid var(--accent); outline-offset: -1px; } .pr-bar { display: flex; align-items: center; gap: 8px; padding: 3px 12px; background: var(--bg-elevated); border-top: 1px solid var(--border); font-family: var(--font-sans); font-size: var(--font-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; transition: background var(--transition-base); } .pr-bar:hover { background: var(--surface-raised); } .pr-link { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; overflow: hidden; flex: 1; min-width: 0; } .pr-ai-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 1px 4px; border-radius: var(--radius-sm); cursor: pointer; font-size: 10px; line-height: 1; flex-shrink: 0; transition: all 0.15s; } .pr-ai-btn:hover { background: var(--bg-tertiary); color: var(--text); border-color: var(--border-focus); } .pr-date { color: var(--accent); font-weight: 600; flex-shrink: 0; } .pr-title { overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); } .cursor-help { cursor: help; } /* @@variant full */ :host { display: block; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; font-family: var(--font-sans); min-height: 340px; } /* The document owns this rule for every other inline icon; a shadow tree inherits the custom property but not the selector, so the card repeats it. See common.css `svg[stroke="currentColor"]`. */ .header { padding: var(--space-sm) var(--space-md); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); } /* A real anchor: the ticker is the most-clicked thing on the card, and a span has no tab stop, no focus ring and no middle-click. The reset undoes the user-agent link styling so it still reads as the accent label it was. */ .symbol { color: var(--accent); font-size: var(--font-lg); font-weight: 700; white-space: nowrap; cursor: pointer; text-decoration: none; transition: opacity var(--transition-base); } .symbol:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); } .symbol:hover { opacity: 0.8; } .date { font-size: var(--font-xs); color: var(--text-muted); font-weight: 600; } .body { padding: var(--space-sm); position: relative; } .chart-container { height: 240px; min-height: 200px; width: 100%; background: var(--bg); border-radius: var(--radius-md); } /* :host is display:block, so .header/.body/.footer stack in normal flow — NOT flex. A plain "height: 100%" on .body ignores how much space .header/.footer already take, so .body ends up taller than the host and its overflow gets clipped by the outer container (the time axis + footer metrics disappear, silently, no console error). Keep this flex column: .header/.footer stay flex-shrink:0 at their natural height, .body:flex 1 takes only what's left. !important below is deliberate: a page's own CSS can (and has, twice) set display/height on the stock-chart-card host from the light DOM (e.g. '.foo stock-chart-card { display: block }'), which silently wins over this shadow-DOM rule and collapses .body/.chart-container to 0 height with no error -- a chart that "has data" but renders on a ~2px canvas. Do not remove these !important -- they are the only thing standing between a page author's unrelated CSS and a fully broken [fill] chart. See resizeChartToFit()/the ResizeObserver below for the runtime warning that catches this if it recurs. */ :host([fill]) { min-height: 0 !important; height: 100% !important; display: flex !important; flex-direction: column !important; } :host([fill]) .header, :host([fill]) .footer { flex-shrink: 0 !important; } :host([fill]) .body { flex: 1 !important; min-height: 0 !important; height: auto !important; } :host([fill]) .chart-container { height: 100% !important; min-height: 0 !important; } /* The retry button of a failed load. It was a style.cssText string on the element (five values no linter could see, and no hover or focus state at all); the overlay sets pointer-events: none, so this re-enables them. */ .retry-btn { pointer-events: auto; margin-left: var(--space-sm); padding: 2px var(--space-sm); font-family: var(--font-sans); font-size: var(--font-xs); background: var(--bg-tertiary); border: 1px solid var(--border-focus); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; } .retry-btn:hover { background: var(--bg-secondary); } .retry-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } .overlay { position: absolute; top: 12px; left: 12px; z-index: var(--z-10); pointer-events: none; background: rgb(var(--black-rgb) / 85%); backdrop-filter: blur(4px); padding: 3px 7px; border-radius: var(--radius-md); border: 1px solid var(--border); font-family: var(--font-sans); font-size: var(--font-xs); color: var(--text-muted); } .footer { padding: var(--space-sm) var(--space-md); display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); } .metrics { display: flex; gap: var(--space-md); align-items: center; } .price { font-weight: 600; font-size: var(--font-md); color: var(--text); } .change { font-weight: 600; font-size: var(--font-sm); } .volume { font-weight: 600; font-size: var(--font-xs); color: var(--text-muted); } .positive { color: var(--positive); } .negative { color: var(--negative); } .date-left { font-size: var(--font-xs); color: var(--text-muted); font-weight: 600; } .tf-selector { display: flex; gap: 4px; background: var(--bg); padding: 2px; border-radius: var(--radius-md); } .tf-btn { background: transparent; border: none; color: var(--text-muted); min-height: var(--control-height); padding: 0 var(--space-sm); font-size: var(--font-xs); font-weight: 600; border-radius: var(--radius-md); cursor: pointer; } .tf-btn.active { background: var(--accent); color: var(--bg); } .tf-btn-stale { opacity: 0.3; cursor: help; } .data-value.positive { color: var(--positive); } .data-value.negative { color: var(--negative); } .filing-date { color: var(--text-muted); margin-right: 6px; } /* One cluster, one button style. Absolute offsets per button (4/26/48px) put the controls in the corner but left them three different sizes and two different looks; a flex row keeps them contiguous and exactly as wide as what it shows. */ .corner { position: absolute; top: 4px; right: 4px; z-index: var(--z-100); display: flex; gap: 2px; align-items: center; } /* The three card-owned corner controls read as a column: fullscreen on top, then the page's star, then notes. The four study buttons stay a horizontal row beside them, so the cluster is a row with one column at its end. The star is slotted, so the column wraps the slot rather than restyling the slotted node -- which no shadow rule could reach anyway. */ .corner-stack { display: flex; flex-direction: column; gap: 2px; align-items: center; } /* Same box as .corner-btn in common.css (which the card cannot read from inside its shadow root); tests/chart/test_chart_flip.py pins the two together. */ .corner-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; background: color-mix(in srgb, var(--black) 70%, transparent); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-muted); font-size: var(--font-xs); line-height: 1; cursor: pointer; } .corner-btn:hover { background: var(--text); color: var(--bg); } /* Only a wrapped card can flip, so the Notes button appears once the flip wrapper has claimed it: it lives in the shadow root and cannot otherwise see the wrapper it now sits in. */ .notes-btn { display: none; } :host([flippable]) .notes-btn { display: inline-flex; } /* Expanded, the card is fullscreen and its wrapper is not on screen, so the star and the notes face are unreachable. */ :host(.expanded) .notes-btn { display: none; } :host(.expanded) slot[name="corner"] { display: none; } .levels-btn { background: transparent; border: none; color: var(--text-muted); padding: 2px 6px; border-radius: var(--radius-md); cursor: pointer; line-height: 1; display: none; align-items: center; } .levels-btn:hover { background: var(--accent); color: var(--bg); } .levels-btn.active { color: var(--info-text); background: var(--info-bg); } .levels-btn.active:hover { background: rgb(var(--info-rgb) / 20%); color: var(--info-text); } .retest-btn { background: transparent; border: none; color: var(--text-muted); padding: 2px 6px; border-radius: var(--radius-md); cursor: pointer; line-height: 1; display: none; align-items: center; } .retest-btn:hover { background: var(--accent); color: var(--bg); } .retest-btn.active { color: var(--info-text); background: var(--info-bg); } .retest-btn.active:hover { background: rgb(var(--info-rgb) / 20%); color: var(--info-text); } .confluence-btn { background: transparent; border: none; color: var(--text-muted); padding: 2px 6px; border-radius: var(--radius-md); cursor: pointer; line-height: 1; display: none; align-items: center; } .confluence-btn:hover { background: var(--accent); color: var(--bg); } .confluence-btn.active { color: var(--warning); background: var(--warning-bg); } .confluence-btn.active:hover { background: rgb(var(--warning-rgb) / 20%); color: var(--warning); } .reversal-btn { background: transparent; border: none; color: var(--text-muted); padding: 2px 6px; border-radius: var(--radius-md); cursor: pointer; line-height: 1; display: none; align-items: center; } .reversal-btn:hover { background: var(--accent); color: var(--bg); } .reversal-btn.active { color: var(--negative-text); background: var(--negative-bg); } .reversal-btn.active:hover { background: rgb(var(--negative-rgb) / 20%); color: var(--negative-text); } :host(.expanded) { position: fixed; inset: 0; z-index: var(--z-1000); margin: 0; background: var(--bg); } :host(.expanded) .chart-container { height: calc(100vh - 60px) !important; } :host(.expanded) .levels-btn { display: inline-flex; } :host(.expanded) .retest-btn { display: inline-flex; } :host(.expanded) .confluence-btn { display: inline-flex; } :host(.expanded) .reversal-btn { display: inline-flex; } :host([data-active="true"]) { outline: 2px solid var(--accent); outline-offset: -1px; } .pr-bar { display: flex; align-items: center; gap: 8px; padding: 3px 12px; background: var(--bg-elevated); border-top: 1px solid var(--border); font-family: var(--font-sans); font-size: var(--font-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; transition: background var(--transition-base); } .pr-bar:hover { background: var(--surface-raised); } .pr-link { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; overflow: hidden; flex: 1; min-width: 0; } .pr-ai-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 1px 4px; border-radius: var(--radius-sm); cursor: pointer; font-size: 10px; line-height: 1; flex-shrink: 0; transition: all 0.15s; } .pr-ai-btn:hover { background: var(--bg-tertiary); color: var(--text); border-color: var(--border-focus); } .pr-date { color: var(--accent); font-weight: 600; flex-shrink: 0; } .pr-title { overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); } .cursor-help { cursor: help; } .tf-selector-wrap { display: flex; align-items: center; gap: var(--space-sm); } /* Touch screens: the corner buttons are 36px targets (the shadow copy of the shared corner-btn rule). */ @media (pointer: coarse), (width <= 600px) { .corner-btn { width: 36px; height: 36px; } }