impeccable 3.2.1 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,8 +24,15 @@ const DETECTOR_IS_BROWSER = typeof window !== 'undefined';
24
24
 
25
25
  // ─── Section 3: Pure Detection ──────────────────────────────────────────────
26
26
 
27
- function checkBorders(tag, widths, colors, radius) {
28
- if (BORDER_SAFE_TAGS.has(tag)) return [];
27
+ function checkBorders(tag, widths, colors, radius, opts = {}) {
28
+ // Badge-shaped <span>s (own visible background) are a real stripe target
29
+ // for the top/bottom variant — the inline-tag exemption exists to quiet
30
+ // text-level borders, not chips. They skip the left/right arms below.
31
+ const spanBadge = tag === 'span' && !!opts.badgeLike;
32
+ if (BORDER_SAFE_TAGS.has(tag) && !spanBadge) return [];
33
+ // A live status/alert region wears a colored single-edge border as a
34
+ // severity accent (toast, snackbar, callout), not as the side-tab tell.
35
+ if (opts.statusContext) return [];
29
36
  const findings = [];
30
37
  const sides = ['Top', 'Right', 'Bottom', 'Left'];
31
38
 
@@ -41,10 +48,20 @@ function checkBorders(tag, widths, colors, radius) {
41
48
  const isSide = side === 'Left' || side === 'Right';
42
49
 
43
50
  if (isSide) {
51
+ if (spanBadge) continue;
44
52
  if (radius > 0) findings.push({ id: 'side-tab', snippet: `border-${sn}: ${w}px + border-radius: ${radius}px` });
45
53
  else if (w >= 3) findings.push({ id: 'side-tab', snippet: `border-${sn}: ${w}px` });
46
54
  } else {
47
55
  if (radius > 0 && w >= 2) findings.push({ id: 'border-accent-on-rounded', snippet: `border-${sn}: ${w}px + border-radius: ${radius}px` });
56
+ // Horizontal variant of the side-tab stripe: a thick chromatic accent
57
+ // riding the top or bottom edge of a card/badge/container. Same
58
+ // dominant-edge + chroma gates as left/right, 3-12px band. Selected-
59
+ // tab underlines are exempt via opts.tabContext (adapters look for
60
+ // tablist/nav/tab ancestors and aria-selected); links, buttons,
61
+ // table cells, and <hr> never reach here (BORDER_SAFE_TAGS).
62
+ else if (!opts.tabContext && w >= 3 && w <= 12) {
63
+ findings.push({ id: 'side-tab', snippet: `border-${sn}: ${w}px` });
64
+ }
48
65
  }
49
66
  }
50
67
 
@@ -66,16 +83,26 @@ function isEmojiOnlyText(text) {
66
83
  function checkColors(opts) {
67
84
  const { tag, textColor, bgColor, effectiveBg, effectiveBgStops, fontSize, fontWeight, hasDirectText, isEmojiOnly, bgClip, bgImage, classList } = opts;
68
85
  if (SAFE_TAGS.has(tag)) {
69
- // Exception for <a> and <button> elements styled as buttons. SAFE_TAGS
70
- // exists to suppress contrast noise on inline links and unstyled controls,
71
- // where the element has no own background and the contrast against the
72
- // ancestor surface is already the intended visual. When the element has
73
- // its own opaque background and direct text, it is a styled button — and
74
- // contrast on its own surface is a real, frequent bug worth flagging.
75
- const isStyledButton = (tag === 'a' || tag === 'button')
76
- && hasDirectText
77
- && bgColor && bgColor.a > 0.5;
78
- if (!isStyledButton) return [];
86
+ // Exception for elements styled as controls or chips. SAFE_TAGS exists to
87
+ // suppress contrast noise on inline links and unstyled spans, where the
88
+ // element has no own background and the contrast against the ancestor
89
+ // surface is already the intended visual. When the element paints its own
90
+ // opaque background under direct text, it is a styled button, chip, or
91
+ // badge regardless of tag, and contrast on its own surface is a real,
92
+ // frequent bug worth flagging. (The shipped miss: a <span> severity chip
93
+ // whose white text lost a specificity fight and rendered muted-on-red at
94
+ // 1.2:1; the old a/button-only exception never looked at it.) The 9px
95
+ // font floor keeps sub-text decorations out.
96
+ const isStyledControl = hasDirectText
97
+ && ((bgColor && bgColor.a > 0.5)
98
+ // A gradient painted on the element itself is an own surface the
99
+ // same way a solid background is. Without this branch a nav CTA
100
+ // built as `<a>` with `background: linear-gradient(…)` and a text
101
+ // color that fails against every stop sails through on the
102
+ // SAFE_TAGS suppression (the shipped escape).
103
+ || (bgImage && /gradient/i.test(bgImage)))
104
+ && fontSize >= 9;
105
+ if (!isStyledControl) return [];
79
106
  }
80
107
  const findings = [];
81
108
 
@@ -112,7 +139,11 @@ function checkColors(opts) {
112
139
  // like `text-paper/60` on `bg-ink` sections are the FP pattern.
113
140
  const isAlphaFallbackFP = !DETECTOR_IS_BROWSER && !effectiveBg && (textColor.a != null && textColor.a < 1);
114
141
  if (!isAlphaFallbackFP) {
115
- findings.push({ id: 'low-contrast', snippet: `${ratio.toFixed(1)}:1 (need ${threshold}:1) — text ${colorToHex(textColor)} on ${colorToHex(bgs[worstIdx])}` });
142
+ // Near-threshold ratios (e.g. 4.497) would round to the threshold
143
+ // itself at one decimal and read as "4.5 needs 4.5" — show two
144
+ // decimals there so the finding stays legible.
145
+ const ratioLabel = ratio.toFixed(1) === threshold.toFixed(1) ? ratio.toFixed(2) : ratio.toFixed(1);
146
+ findings.push({ id: 'low-contrast', snippet: `${ratioLabel}:1 (need ${threshold}:1) — text ${colorToHex(textColor)} on ${colorToHex(bgs[worstIdx])}` });
116
147
  }
117
148
  }
118
149
  }
@@ -158,6 +189,27 @@ function checkColors(opts) {
158
189
  return findings;
159
190
  }
160
191
 
192
+ // WCAG contrast for the :hover state of an element whose hover rules change
193
+ // its text color and/or background. The classic miss: a nav CTA whose
194
+ // author-intended hover pair passes AA, but a broader selector (e.g.
195
+ // `.nav-links a:hover`) wins the specificity fight and swaps in a color
196
+ // that fails. Only fires on elements that present as styled controls —
197
+ // direct text plus an opaque-ish own background in either state — so plain
198
+ // inline links keep the same suppression they get in checkColors.
199
+ function checkHoverContrast(opts) {
200
+ const { tag, textColor, bg, ownBgAlpha, fontSize, fontWeight, hasDirectText, isEmojiOnly } = opts;
201
+ if (!hasDirectText || isEmojiOnly || !textColor || !bg) return [];
202
+ if (SAFE_TAGS.has(tag) && !(ownBgAlpha != null && ownBgAlpha > 0.5)) return [];
203
+ const ratio = contrastRatio(textColor, bg);
204
+ const isLargeText = fontSize >= WCAG_LARGE_TEXT_PX || (fontSize >= WCAG_LARGE_BOLD_TEXT_PX && fontWeight >= 700);
205
+ const threshold = isLargeText ? 3.0 : 4.5;
206
+ if (ratio >= threshold) return [];
207
+ return [{
208
+ id: 'low-contrast',
209
+ snippet: `:hover state ${ratio.toFixed(1)}:1 (need ${threshold}:1) — text ${colorToHex(textColor)} on ${colorToHex(bg)}`,
210
+ }];
211
+ }
212
+
161
213
  function isCardLikeFromProps(hasShadow, hasBorder, hasRadius, hasBg) {
162
214
  if (!hasShadow && !hasBorder) return false;
163
215
  return hasRadius || hasBg;
@@ -303,26 +355,57 @@ function isAccentColor(cssColor) {
303
355
  return false;
304
356
  }
305
357
 
358
+ function resolveHeroHeadingSizePx(value) {
359
+ const input = String(value || '').trim().toLowerCase();
360
+ if (!input) return 0;
361
+
362
+ const simpleLengthPx = (token) => {
363
+ const match = /^(-?\d*\.?\d+)\s*(px|rem|em|%)?$/.exec(String(token || '').trim());
364
+ if (!match) return null;
365
+ const amount = Number(match[1]);
366
+ if (!Number.isFinite(amount)) return null;
367
+ if (match[2] === 'rem' || match[2] === 'em') return amount * 16;
368
+ if (match[2] === '%') return amount * 0.16;
369
+ return amount;
370
+ };
371
+
372
+ const direct = simpleLengthPx(input);
373
+ if (direct !== null) return direct;
374
+
375
+ // Static CSS engines cannot resolve viewport units, but clamp's min/max
376
+ // bounds still tell us whether the heading can ever reach hero scale.
377
+ const clamp = /^clamp\((.*)\)$/.exec(input);
378
+ if (clamp) {
379
+ const parts = clamp[1].split(',');
380
+ if (parts.length === 3) {
381
+ const bounds = [simpleLengthPx(parts[0]), simpleLengthPx(parts[2])]
382
+ .filter((candidate) => candidate !== null);
383
+ if (bounds.length > 0) return Math.max(...bounds);
384
+ }
385
+ }
386
+
387
+ return 0;
388
+ }
389
+
306
390
  // Sibling-relationship rule. Anchor on a hero-scale h1, look at the
307
391
  // previousElementSibling, and gate on EITHER the classic tracked-
308
392
  // uppercase eyebrow OR the modern accent-colored bold eyebrow.
309
393
  function checkHeroEyebrow(opts) {
310
394
  const {
311
395
  headingTag, headingText, headingFontSize,
396
+ headingInApplicationContext,
312
397
  siblingTag, siblingText, siblingTextTransform,
313
398
  siblingFontSize, siblingLetterSpacing,
314
399
  siblingFontWeight, siblingColor,
400
+ siblingHasAccentDashPseudo,
315
401
  } = opts;
316
402
  if (headingTag !== 'h1') return [];
317
- // We previously gated on headingFontSize >= 48 to anchor "hero scale".
318
- // But modern hero h1s use clamp() / vw / var(--text-*), none of which
319
- // jsdom can resolve — the computed value comes back as "2em" or
320
- // "var(--text-9xl)" and parseFloat returns 2 or NaN. The gate fails
321
- // on virtually every Tailwind v4 / framework build. The other gates
322
- // (sibling text 2-60 chars, font-size ≤ 14px, accent-bold OR
323
- // tracked-caps) are tight enough to avoid false positives on non-
324
- // hero h1s — a tiny tan label directly above any h1 is the
325
- // antipattern regardless of how big the h1 ends up.
403
+ // This is specifically a marketing-hero cliché, not a ban on compact
404
+ // context labels in product UI (for example, a station name inside a tab
405
+ // panel). Browser-computed sizes are reliable; the static adapter also
406
+ // resolves ordinary px/rem/em and clamp() bounds before reaching here.
407
+ if (headingInApplicationContext) return [];
408
+ if (!(headingFontSize >= 48)) return [];
326
409
  if (!siblingTag) return [];
327
410
  // An h2 above an h1 is a different anti-pattern (heading hierarchy / dual
328
411
  // headings) — never an eyebrow.
@@ -343,11 +426,16 @@ function checkHeroEyebrow(opts) {
343
426
  const weight = Number(siblingFontWeight) || 400;
344
427
  const isAccentBold = weight >= 700 && isAccentColor(siblingColor || '');
345
428
 
346
- if (!isClassicTracked && !isAccentBold) return [];
429
+ // Branch C: dash-prefix eyebrow — sentence case, low tracking, regular
430
+ // weight, but announced by a short chromatic ::before/::after bar
431
+ // (the kicker dash). Same label-above-headline pattern, third styling.
432
+ const isDashPrefixed = !!siblingHasAccentDashPseudo;
433
+
434
+ if (!isClassicTracked && !isAccentBold && !isDashPrefixed) return [];
347
435
 
348
436
  const headingTextSnippet = (headingText || '').trim().slice(0, 60);
349
437
  const eyebrowSnippet = text.slice(0, 40);
350
- const style = isClassicTracked ? 'tracked-caps' : 'accent-bold';
438
+ const style = isClassicTracked ? 'tracked-caps' : isAccentBold ? 'accent-bold' : 'dash-prefix';
351
439
  return [{
352
440
  id: 'hero-eyebrow-chip',
353
441
  snippet: `eyebrow chip (${style}) "${eyebrowSnippet}" above ${headingTag} "${headingTextSnippet}"`,
@@ -408,38 +496,872 @@ function checkMotion(opts) {
408
496
  return findings;
409
497
  }
410
498
 
499
+ // Locate the color token in a single shadow layer. Returns
500
+ // { color, start, end } where color is the parsed {r,g,b,a} (null when the
501
+ // token exists but can't be parsed — e.g. an unresolved var() or an exotic
502
+ // color space), or null when no color token is present at all. Handles both
503
+ // serialization orders: computed style puts the color first
504
+ // ("rgb(…) 0px 0px 20px"), authored CSS usually puts it last
505
+ // ("0 0 20px #3b82f6").
506
+ function findShadowColor(layer) {
507
+ const fn = layer.match(/(?:rgba?|hsla?|hwb|oklch|oklab|lch|lab|color)\([^)]*\)/i);
508
+ if (fn) return { color: parseAnyColor(fn[0]), start: fn.index, end: fn.index + fn[0].length };
509
+ const hex = layer.match(/#[0-9a-fA-F]{3,8}\b/);
510
+ if (hex) return { color: parseAnyColor(hex[0]), start: hex.index, end: hex.index + hex[0].length };
511
+ const wordRe = /[a-zA-Z][a-zA-Z]*/g;
512
+ let m;
513
+ while ((m = wordRe.exec(layer)) !== null) {
514
+ const named = CSS_NAMED_COLORS[m[0].toLowerCase()];
515
+ if (named) return { color: { ...named, a: 1 }, start: m.index, end: m.index + m[0].length };
516
+ }
517
+ return null;
518
+ }
519
+
520
+ // Extract the length values of a shadow layer in declaration order, with the
521
+ // color token removed so its components aren't misread as lengths. Handles
522
+ // computed-style px values AND authored unitless zeros ("0 0 20px"); rem/em
523
+ // approximate at 16px. Result order is offset-x, offset-y, blur, [spread].
524
+ function extractShadowLengths(layer, colorStart, colorEnd) {
525
+ const stripped = colorStart != null
526
+ ? layer.slice(0, colorStart) + ' ' + layer.slice(colorEnd)
527
+ : layer;
528
+ const vals = [];
529
+ const re = /(-?\d*\.?\d+)(px|rem|em)?/g;
530
+ let m;
531
+ while ((m = re.exec(stripped)) !== null) {
532
+ let v = parseFloat(m[1]);
533
+ if (m[2] === 'rem' || m[2] === 'em') v *= 16;
534
+ vals.push(v);
535
+ }
536
+ return vals;
537
+ }
538
+
411
539
  function checkGlow(opts) {
412
- const { boxShadow, effectiveBg } = opts;
413
- if (!boxShadow || boxShadow === 'none') return [];
414
- if (!effectiveBg) return [];
540
+ const { boxShadow, textShadow, effectiveBg } = opts;
541
+ const onDarkBg = effectiveBg ? relativeLuminance(effectiveBg) < 0.1 : false;
542
+
543
+ // Scan one shadow list. Two glow tells, in any color format:
544
+ // 1. Zero-offset chromatic halo (0 0 Npx <color>) — slop on ANY
545
+ // background; the light radiates evenly outward, which is never how
546
+ // real elevation shadows behave. Achromatic zero-offset shadows stay
547
+ // legal (soft ambient elevation), as do focus rings (blur 0).
548
+ // 2. Any chromatic shadow with real blur on a dark background — the
549
+ // classic dark-mode glow accent.
550
+ const scan = (value, prop) => {
551
+ if (!value || value === 'none') return null;
552
+ // Split multiple shadows (commas not inside parentheses)
553
+ for (const layer of value.split(/,(?![^(]*\))/)) {
554
+ const colorInfo = findShadowColor(layer);
555
+ // No color token, or one we can't resolve (unresolved var(), exotic
556
+ // color space): don't guess — skip rather than false-positive.
557
+ if (!colorInfo || !colorInfo.color) continue;
558
+ const color = colorInfo.color;
559
+ if (!hasChroma(color, 30)) continue;
560
+ const vals = extractShadowLengths(layer, colorInfo.start, colorInfo.end);
561
+ // Third value is blur (offset-x, offset-y, blur, [spread])
562
+ if (vals.length < 3 || vals[2] <= 4) continue;
563
+ if (vals[0] === 0 && vals[1] === 0) {
564
+ return { id: 'dark-glow', snippet: `Zero-offset ${prop} glow (${colorToHex(color)})` };
565
+ }
566
+ if (onDarkBg) {
567
+ return { id: 'dark-glow', snippet: `Colored ${prop} glow (${colorToHex(color)}) on dark background` };
568
+ }
569
+ }
570
+ return null;
571
+ };
415
572
 
416
- // Only flag on dark backgrounds (luminance < 0.1)
417
- const bgLum = relativeLuminance(effectiveBg);
418
- if (bgLum >= 0.1) return [];
573
+ const found = scan(boxShadow, 'box-shadow') || scan(textShadow, 'text-shadow');
574
+ return found ? [found] : [];
575
+ }
419
576
 
420
- // Split multiple shadows (commas not inside parentheses)
421
- const parts = boxShadow.split(/,(?![^(]*\))/);
422
- for (const shadow of parts) {
423
- const colorMatch = shadow.match(/rgba?\([^)]+\)/);
424
- if (!colorMatch) continue;
425
- const color = parseRgb(colorMatch[0]);
426
- if (!color || !hasChroma(color, 30)) continue;
577
+ // Collect CSS custom property declarations from raw stylesheet/HTML text.
578
+ // First declaration wins (:root declarations usually come first); good
579
+ // enough for the single-level var() resolution the text engines need.
580
+ function collectCssCustomProps(content) {
581
+ const map = new Map();
582
+ const re = /(--[\w-]+)\s*:\s*([^;{}]+)/g;
583
+ let m;
584
+ while ((m = re.exec(content)) !== null) {
585
+ if (!map.has(m[1])) map.set(m[1], m[2].trim());
586
+ }
587
+ return map;
588
+ }
427
589
 
428
- // Extract px values — in computed style: "color Xpx Ypx BLURpx [SPREADpx]"
429
- const afterColor = shadow.substring(shadow.indexOf(colorMatch[0]) + colorMatch[0].length);
430
- const beforeColor = shadow.substring(0, shadow.indexOf(colorMatch[0]));
431
- const pxVals = [...beforeColor.matchAll(/([\d.]+)px/g), ...afterColor.matchAll(/([\d.]+)px/g)]
432
- .map(m => parseFloat(m[1]));
590
+ // Text-level glow scan shared by the regex engine and the page-level HTML
591
+ // pattern pass. Resolves single-level var() refs against custom properties
592
+ // collected from the same text, then applies the same two glow tells as
593
+ // checkGlow: zero-offset chromatic halo (any background) and chromatic
594
+ // blurred shadow when the page has a dark background. Returns
595
+ // [{ index, snippet }] — index is the offset of the shadow declaration.
596
+ // Dark-page heuristic for raw CSS/HTML text: dark hex/rgb literals, Tailwind
597
+ // dark bg utilities, or a ROOT-scoped (body/html/:root or <body style>)
598
+ // background that resolves — via var() — to a dark color. The var/modern-
599
+ // color extension is deliberately root-scoped: a light page with one dark
600
+ // accent chip must not turn every tinted drop shadow into a "dark page"
601
+ // signal. Shared by the glow and radial-halo text scanners.
602
+ function cssTextHasDarkRootBg(content, customProps) {
603
+ const darkBgRe = /background(?:-color)?\s*:\s*(?:#(?:0[0-9a-f]|1[0-9a-f]|2[0-3])[0-9a-f]{4}\b|#(?:0|1)[0-9a-f]{2}\b|rgb\(\s*(\d{1,2})\s*,\s*(\d{1,2})\s*,\s*(\d{1,2})\s*\))/i;
604
+ const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
605
+ if (darkBgRe.test(content) || twDarkBg.test(content)) return true;
606
+ const rootScopes = [];
607
+ const blockRe = /(?:^|[}\s,;>])(?:body|html|:root)\s*(?:,[^{]*)?\{([^}]*)\}/gi;
608
+ let sm;
609
+ while ((sm = blockRe.exec(content)) !== null) rootScopes.push(sm[1]);
610
+ const inlineBody = content.match(/<body[^>]*\bstyle\s*=\s*"([^"]*)"/i);
611
+ if (inlineBody) rootScopes.push(inlineBody[1]);
612
+ for (const scope of rootScopes) {
613
+ const bgRe = /background(?:-color)?\s*:\s*([^;{}]+)/gi;
614
+ let bm;
615
+ while ((bm = bgRe.exec(scope)) !== null) {
616
+ const c = parseAnyColor(resolveVarRefs(bm[1].trim(), customProps));
617
+ if (c && (c.a ?? 1) > 0.5 && relativeLuminance(c) < 0.1) return true;
618
+ }
619
+ }
620
+ return false;
621
+ }
433
622
 
434
- // Third value is blur (offset-x, offset-y, blur, [spread])
435
- if (pxVals.length >= 3 && pxVals[2] > 4) {
436
- return [{ id: 'dark-glow', snippet: `Colored glow (${colorToHex(color)}) on dark background` }];
623
+ function scanCssTextForGlow(content) {
624
+ const customProps = collectCssCustomProps(content);
625
+ const hasDarkBg = cssTextHasDarkRootBg(content, customProps);
626
+
627
+ const results = [];
628
+ const shadowRe = /\b(box-shadow|text-shadow)\s*:\s*([^;{}]+)/gi;
629
+ let m;
630
+ while ((m = shadowRe.exec(content)) !== null) {
631
+ const prop = m[1].toLowerCase();
632
+ const value = resolveVarRefs(m[2].trim(), customProps);
633
+ for (const layer of value.split(/,(?![^(]*\))/)) {
634
+ const colorInfo = findShadowColor(layer);
635
+ if (!colorInfo || !colorInfo.color || !hasChroma(colorInfo.color, 30)) continue;
636
+ const vals = extractShadowLengths(layer, colorInfo.start, colorInfo.end);
637
+ if (vals.length < 3 || vals[2] <= 4) continue;
638
+ const zeroOffset = vals[0] === 0 && vals[1] === 0;
639
+ if (!zeroOffset && !hasDarkBg) continue;
640
+ results.push({
641
+ index: m.index,
642
+ snippet: zeroOffset
643
+ ? `Zero-offset ${prop} glow (${colorToHex(colorInfo.color)})`
644
+ : `Colored ${prop} glow (${colorToHex(colorInfo.color)}) on dark page`,
645
+ });
646
+ break; // one finding per declaration
437
647
  }
438
648
  }
649
+ return results;
650
+ }
439
651
 
652
+ // Decorative grid or line-field backgrounds drawn with hairline
653
+ // linear-gradient layers tiled by a fixed pixel cell. Shared by the HTML
654
+ // pattern pass and the regex source engine so standalone CSS, component
655
+ // styles, and inline styles receive the same coverage. Both signals must
656
+ // co-occur in one declaration block; unrelated rules must not add up across
657
+ // the file. Returns [{ index, snippet }], capped at one finding per source to
658
+ // match the page-level HTML check's existing behavior.
659
+ function scanCssTextForGridBackground(content) {
660
+ const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
661
+ const invertedHairlineRe = /transparent\s+calc\(100%\s*-\s*\d{1,3}px\)/gi;
662
+ const sizeDeclPxRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
663
+ const sizeDeclPxPairRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\s+\d{1,3}px/i;
664
+ const shorthandPxAnyRe = /\/\s*\d{1,3}px\b/;
665
+ const shorthandPxPairRe = /\/\s*\d{1,3}px\s+\d{1,3}px/;
666
+ const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
667
+ const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
668
+ let blk;
669
+ while ((blk = blockRe.exec(content)) !== null) {
670
+ const block = blk[1] || blk[2] || blk[3] || '';
671
+ let hairlineCount = 0;
672
+ let bgJoined = '';
673
+ let bm;
674
+ bgDeclRe.lastIndex = 0;
675
+ while ((bm = bgDeclRe.exec(block)) !== null) {
676
+ hairlineCount += (bm[1].match(hairlineRe) || []).length;
677
+ hairlineCount += (bm[1].match(invertedHairlineRe) || []).length;
678
+ bgJoined += `${bm[1]};`;
679
+ }
680
+ if (hairlineCount === 0) continue;
681
+ const hasPxCell = sizeDeclPxRe.test(block) || shorthandPxAnyRe.test(bgJoined);
682
+ const hasPxPairCell = sizeDeclPxPairRe.test(block) || shorthandPxPairRe.test(bgJoined);
683
+ if ((hairlineCount >= 2 && hasPxCell) || hasPxPairCell) {
684
+ return [{
685
+ index: blk.index,
686
+ snippet: hairlineCount >= 2
687
+ ? 'two-axis grid-line gradient background'
688
+ : 'px-tiled hairline line-field background',
689
+ }];
690
+ }
691
+ }
440
692
  return [];
441
693
  }
442
694
 
695
+ // Decorative chromatic halo drawn as a radial-gradient background on a dark
696
+ // page: a saturated center stop dissolving to transparent. The gradient
697
+ // sibling of the dark-glow shadow tell. Mechanical gates, in order:
698
+ // * page has a dark root background (shared heuristic with the glow scan)
699
+ // * declaration has no url() layer (photographic imagery is exempt)
700
+ // * the gradient's first color stop is chromatic (RGB spread >= 24) and
701
+ // visible (alpha >= 0.7 — deliberately translucent light-scene washes
702
+ // composite with content instead of painting a flat halo, and stay legal)
703
+ // * the gradient's last stop is transparent / near-zero alpha
704
+ // * no small pixel-sized stop positions (<= 24px = dot/texture patterns)
705
+ // * not a repeating-* gradient
706
+ // Achromatic vignettes fail the chroma gate; panel sheens that fade to an
707
+ // opaque surface color fail the transparent-end gate.
708
+ function scanCssTextForRadialHalo(content) {
709
+ const customProps = collectCssCustomProps(content);
710
+ if (!cssTextHasDarkRootBg(content, customProps)) return [];
711
+
712
+ const findings = [];
713
+ const seen = new Set();
714
+ const declRe = /background(?:-image)?\s*:\s*([^;{}]+)/gi;
715
+ let m;
716
+ while ((m = declRe.exec(content)) !== null) {
717
+ const value = resolveVarRefs(m[1].trim(), customProps);
718
+ if (/url\s*\(/i.test(value)) continue;
719
+
720
+ const gradRe = /(repeating-)?radial-gradient\(/gi;
721
+ let g;
722
+ while ((g = gradRe.exec(value)) !== null) {
723
+ if (g[1]) continue; // repeating-* = pattern, not halo
724
+ // Balanced-paren capture of the gradient arguments.
725
+ let depth = 0, end = -1;
726
+ const open = value.indexOf('(', g.index);
727
+ for (let i = open; i < value.length; i++) {
728
+ if (value[i] === '(') depth++;
729
+ else if (value[i] === ')') { depth--; if (depth === 0) { end = i; break; } }
730
+ }
731
+ if (end < 0) break;
732
+ const args = splitTopLevelCommas(value.slice(open + 1, end));
733
+ if (args.length < 2) continue;
734
+
735
+ // Optional prelude (shape / size / `at <pos>`) carries no color.
736
+ const colorTokenRe = /(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color-mix)\([^)]*(?:\([^)]*\))?[^)]*\)|#[0-9a-f]{3,8}\b|\btransparent\b/i;
737
+ const stops = args.filter(a => colorTokenRe.test(a));
738
+ if (stops.length < 2) continue;
739
+
740
+ // Dot/texture exemption: px-sized stop positions mean a repeating
741
+ // background-size pattern, not a page-scale halo.
742
+ const pxStop = stops.some(s => {
743
+ const pm = s.match(/(-?[\d.]+)px\b/);
744
+ return pm && Math.abs(parseFloat(pm[1])) <= 24;
745
+ });
746
+ if (pxStop) continue;
747
+
748
+ const first = stops[0].match(colorTokenRe);
749
+ const last = stops[stops.length - 1].match(colorTokenRe);
750
+ if (!first || !last) continue;
751
+
752
+ const lastColor = /^transparent$/i.test(last[0]) ? { r: 0, g: 0, b: 0, a: 0 } : parseAnyColor(last[0]);
753
+ if (!lastColor || (lastColor.a ?? 1) > 0.05) continue;
754
+
755
+ const firstColor = /^transparent$/i.test(first[0]) ? null : parseAnyColor(first[0]);
756
+ if (!firstColor) continue;
757
+ if ((firstColor.a ?? 1) < 0.7) continue;
758
+ const spread = Math.max(firstColor.r, firstColor.g, firstColor.b) - Math.min(firstColor.r, firstColor.g, firstColor.b);
759
+ if (spread < 24) continue;
760
+
761
+ const snippet = `radial-gradient halo (${colorToHex(firstColor)} → transparent) on dark page`;
762
+ if (seen.has(snippet)) continue;
763
+ seen.add(snippet);
764
+ findings.push({ index: m.index, snippet });
765
+ }
766
+ }
767
+ return findings;
768
+ }
769
+
770
+ // ---------------------------------------------------------------------------
771
+ // Text-level CSS rule-block scanners (pseudo-element stripes, pulsing dots)
772
+ // ---------------------------------------------------------------------------
773
+
774
+ // Iterate `selector { declarations }` pairs in raw CSS/HTML text. The block
775
+ // body excludes braces, so nested structures (@media, @keyframes) naturally
776
+ // yield their innermost rules with the innermost selector text. Callers
777
+ // create the regex locally — a shared /g instance is not re-entrant.
778
+ const CSS_RULE_BLOCK_SOURCE = String.raw`([^{};]+)\{([^{}]*)\}`;
779
+
780
+ // Parse a declaration block into a prop → value map (last declaration wins,
781
+ // approximating the cascade inside one block). Values keep their raw text
782
+ // with any !important suffix stripped.
783
+ function parseCssDeclBlock(block) {
784
+ const decls = new Map();
785
+ for (const part of String(block || '').split(';')) {
786
+ const idx = part.indexOf(':');
787
+ if (idx <= 0) continue;
788
+ const prop = part.slice(0, idx).trim().toLowerCase();
789
+ const value = part.slice(idx + 1).replace(/\s*!important\s*$/i, '').trim();
790
+ if (prop && value) decls.set(prop, value);
791
+ }
792
+ return decls;
793
+ }
794
+
795
+ function cssLengthToPx(value) {
796
+ const m = String(value || '').trim().match(/^(-?[\d.]+)(px|rem|em)$/i);
797
+ if (!m) return null;
798
+ const n = parseFloat(m[1]);
799
+ return m[2].toLowerCase() === 'px' ? n : n * 16;
800
+ }
801
+
802
+ function isZeroOffset(value) {
803
+ return value != null && /^-?0(?:px|%|rem|em)?$/.test(String(value).trim());
804
+ }
805
+
806
+ // Side-tab variant: the accent stripe drawn as an absolutely-positioned
807
+ // ::before/::after pseudo-element (narrow colored box hugging a vertical
808
+ // edge) instead of a border-left/right. The element-level border checks
809
+ // never see it — pseudo-elements aren't part of the DOM the cascade walks —
810
+ // so this scans stylesheet text directly, mirroring the border rule's
811
+ // gates: >= 3px thick, chromatic fill, full height against a side edge.
812
+ function scanCssTextForPseudoStripe(content) {
813
+ const customProps = collectCssCustomProps(content);
814
+ const findings = [];
815
+ const seen = new Set();
816
+ const ruleRe = new RegExp(CSS_RULE_BLOCK_SOURCE, 'g');
817
+ let m;
818
+ while ((m = ruleRe.exec(content)) !== null) {
819
+ const selector = m[1].trim();
820
+ if (!/::?(?:before|after)\b/i.test(selector)) continue;
821
+ // Keep the border rule's prose exemptions (blockquote bars etc.).
822
+ if (/\b(?:blockquote|pre|code|nav|hr)\b/i.test(selector)) continue;
823
+ const decls = parseCssDeclBlock(m[2]);
824
+ const position = decls.get('position');
825
+ if (position !== 'absolute' && position !== 'fixed') continue;
826
+
827
+ const widthPx = cssLengthToPx(resolveVarRefs(
828
+ decls.get('width') || decls.get('inline-size') || '', customProps));
829
+ const heightPx = cssLengthToPx(resolveVarRefs(
830
+ decls.get('height') || decls.get('block-size') || '', customProps));
831
+ const verticalCandidate = widthPx != null && widthPx >= 3 && widthPx <= 12;
832
+ // Horizontal variant (top/bottom stripe) carries extra exemptions:
833
+ // link/button underline affordances, selected-state indicators
834
+ // (aria-selected="true", aria-current, active/current/selected class
835
+ // hints), and state-conditional (:hover/:focus/...) affordances are
836
+ // not stripes. Tab-strip membership alone ([role=tab], .tabs, bare
837
+ // [aria-selected]) is NOT exempt — a stripe on every tab in the
838
+ // group is decoration; only the selected item's underline stays.
839
+ const horizontalCandidate = heightPx != null && heightPx >= 3 && heightPx <= 12
840
+ && !/(?:^|[\s>+~,(])(?:a|button|summary|tr|td|th|table|li)(?![\w-])/i.test(selector)
841
+ && !/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)
842
+ && !/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)
843
+ && !/(?:^|[\s._[-])(?:active|current|selected|btn[\w-]*|button[\w-]*|link[\w-]*)(?![\w])/i.test(selector)
844
+ && !/:(?:hover|focus|focus-visible|focus-within|active|checked)\b/i.test(selector);
845
+ if (!verticalCandidate && !horizontalCandidate) continue;
846
+
847
+ // Resolve edge offsets, letting an `inset` shorthand fill the gaps.
848
+ const offsets = {
849
+ top: decls.get('top'), right: decls.get('right'),
850
+ bottom: decls.get('bottom'), left: decls.get('left'),
851
+ };
852
+ const inset = decls.get('inset');
853
+ if (inset) {
854
+ const p = inset.split(/\s+/);
855
+ const [t, r, b, l] =
856
+ p.length === 1 ? [p[0], p[0], p[0], p[0]]
857
+ : p.length === 2 ? [p[0], p[1], p[0], p[1]]
858
+ : p.length === 3 ? [p[0], p[1], p[2], p[1]]
859
+ : p;
860
+ if (offsets.top == null) offsets.top = t;
861
+ if (offsets.right == null) offsets.right = r;
862
+ if (offsets.bottom == null) offsets.bottom = b;
863
+ if (offsets.left == null) offsets.left = l;
864
+ }
865
+ if (offsets.left == null) offsets.left = decls.get('inset-inline-start');
866
+ if (offsets.right == null) offsets.right = decls.get('inset-inline-end');
867
+
868
+ const heightValue = String(resolveVarRefs(
869
+ decls.get('height') || decls.get('block-size') || '', customProps)).trim();
870
+ const widthValue = String(resolveVarRefs(
871
+ decls.get('width') || decls.get('inline-size') || '', customProps)).trim();
872
+
873
+ let edge = null;
874
+ let thicknessPx = null;
875
+ if (verticalCandidate) {
876
+ // Full-height stripes hug both corners; the "floating" variant backs
877
+ // off each end by a small inset (top/bottom a few px) so the bar
878
+ // clears the card's corners. Both read as the same side-tab accent —
879
+ // corner treatment is styling, not a different pattern.
880
+ const topPx = cssLengthToPx(resolveVarRefs(String(offsets.top ?? ''), customProps));
881
+ const bottomPx = cssLengthToPx(resolveVarRefs(String(offsets.bottom ?? ''), customProps));
882
+ const fullHeight = (isZeroOffset(offsets.top) && isZeroOffset(offsets.bottom))
883
+ || /^100(?:\.0*)?%$/.test(heightValue)
884
+ || (topPx != null && bottomPx != null
885
+ && topPx >= 0 && topPx <= 20 && bottomPx >= 0 && bottomPx <= 20);
886
+ if (fullHeight) {
887
+ edge = isZeroOffset(offsets.left) ? 'left'
888
+ : isZeroOffset(offsets.right) ? 'right' : null;
889
+ thicknessPx = widthPx;
890
+ }
891
+ }
892
+ if (!edge && horizontalCandidate) {
893
+ const fullWidth = (isZeroOffset(offsets.left) && isZeroOffset(offsets.right))
894
+ || /^100(?:\.0*)?%$/.test(widthValue);
895
+ if (fullWidth) {
896
+ edge = isZeroOffset(offsets.top) ? 'top'
897
+ : isZeroOffset(offsets.bottom) ? 'bottom' : null;
898
+ thicknessPx = heightPx;
899
+ }
900
+ }
901
+ if (!edge) continue;
902
+
903
+ // Chromatic fill only — a neutral hairline divider is not an accent
904
+ // stripe. Unresolvable colors err toward detection, matching the
905
+ // border rule's unknown-format default.
906
+ const bg = String(resolveVarRefs(
907
+ decls.get('background-color') || decls.get('background') || '', customProps)).trim();
908
+ if (!bg || /^(?:none|transparent|inherit|initial|unset|currentcolor)$/i.test(bg)) continue;
909
+ const colorToken = bg.match(/(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\([^)]*\)|#[0-9a-f]{3,8}\b/i);
910
+ const parsed = parseAnyColor(colorToken ? colorToken[0] : bg);
911
+ if (parsed) {
912
+ if ((parsed.a ?? 1) < 0.1) continue;
913
+ const spread = Math.max(parsed.r, parsed.g, parsed.b) - Math.min(parsed.r, parsed.g, parsed.b);
914
+ if (spread < 30) continue;
915
+ } else if (/^(?:white|black|gray|grey|silver)$/i.test(bg)) {
916
+ continue;
917
+ }
918
+
919
+ if (seen.has(selector)) continue;
920
+ seen.add(selector);
921
+ findings.push({
922
+ id: 'side-tab',
923
+ snippet: `${selector} — absolute ${thicknessPx}px pseudo-element stripe (${edge}: 0)`,
924
+ });
925
+ }
926
+ return findings;
927
+ }
928
+
929
+ // Side-tab stripe drawn as a single-edge inset box-shadow
930
+ // (x or y offset 3-12px, other axis 0, no blur/spread, chromatic color):
931
+ // paints a bar along one edge with no border property involved, so the
932
+ // element-level border checks never see it. Selection-state indicators
933
+ // are exempt — an inset stripe on [aria-current] / .active / [role=tab]
934
+ // marks the selected item; the same stripe unconditionally on every item
935
+ // is decoration and flags.
936
+ function scanCssTextForInsetStripe(content) {
937
+ const customProps = collectCssCustomProps(content);
938
+ const findings = [];
939
+ const seen = new Set();
940
+ const ruleRe = new RegExp(CSS_RULE_BLOCK_SOURCE, 'g');
941
+ let m;
942
+ while ((m = ruleRe.exec(content)) !== null) {
943
+ const selector = m[1].trim();
944
+ // Selection-state contexts: current-item markers and interaction
945
+ // states. Tab-strip membership alone ([role=tab], .tabs, bare
946
+ // [aria-selected]) is NOT exempt — a stripe on every tab in the
947
+ // group is decoration; only the selected item's indicator stays.
948
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
949
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
950
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
951
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
952
+ // Structural tags where a single-edge inset shadow is depth/quoting,
953
+ // not an accent stripe.
954
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
955
+
956
+ const decls = parseCssDeclBlock(m[2]);
957
+ const shadow = decls.get('box-shadow');
958
+ if (!shadow || !/\binset\b/i.test(shadow)) continue;
959
+ // Narrow fixed-width elements (logo marks, icon glyphs) use inset
960
+ // fills as artwork, not edge stripes. Stripe targets — cards, badges,
961
+ // menu items — are wider or leave width to layout.
962
+ const declaredWidth = cssLengthToPx(resolveVarRefs(decls.get('width') || decls.get('inline-size') || '', customProps));
963
+ if (declaredWidth != null && declaredWidth <= 40) continue;
964
+ const value = resolveVarRefs(shadow, customProps);
965
+ for (const layer of value.split(/,(?![^(]*\))/)) {
966
+ if (!/\binset\b/i.test(layer)) continue;
967
+ const colorInfo = findShadowColor(layer);
968
+ // Unresolvable colors (currentColor, external vars): don't guess.
969
+ if (!colorInfo || !colorInfo.color) continue;
970
+ const c = colorInfo.color;
971
+ if ((c.a ?? 1) < 0.1) continue;
972
+ const chroma = Math.max(c.r, c.g, c.b) - Math.min(c.r, c.g, c.b);
973
+ if (chroma < 30) continue;
974
+ const vals = extractShadowLengths(layer, colorInfo.start, colorInfo.end);
975
+ const x = vals[0] || 0, y = vals[1] || 0, blur = vals[2] || 0, sp = vals[3] || 0;
976
+ if (blur !== 0 || sp !== 0) continue;
977
+ const ax = Math.abs(x), ay = Math.abs(y);
978
+ const isStripe = (ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0);
979
+ if (!isStripe) continue;
980
+ if (seen.has(selector)) break;
981
+ seen.add(selector);
982
+ const edge = ay === 0 ? (x > 0 ? 'left' : 'right') : (y > 0 ? 'top' : 'bottom');
983
+ findings.push({
984
+ id: 'side-tab',
985
+ snippet: `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`,
986
+ });
987
+ break;
988
+ }
989
+ }
990
+ return findings;
991
+ }
992
+
993
+ // Collect @keyframes names whose body travels horizontally — the marquee
994
+ // loop. X travel is measured across every translateX/translate/translate3d
995
+ // X component in the body: a centered element animating something else
996
+ // keeps a constant -50% X (zero travel) and never qualifies, while a
997
+ // ticker moves from its resting position to a large offset. Keyframes
998
+ // with a single X sample that also vary scale/opacity read as pulses or
999
+ // breathes, not marquees.
1000
+ function collectMarqueeKeyframes(content) {
1001
+ const names = new Set();
1002
+ const re = /@(?:-webkit-)?keyframes\s+([\w-]+)\s*\{/g;
1003
+ let m;
1004
+ while ((m = re.exec(content)) !== null) {
1005
+ let depth = 1;
1006
+ let i = re.lastIndex;
1007
+ while (i < content.length && depth > 0) {
1008
+ const ch = content.charCodeAt(i);
1009
+ if (ch === 0x7b /* { */) depth++;
1010
+ else if (ch === 0x7d /* } */) depth--;
1011
+ i++;
1012
+ }
1013
+ const body = content.slice(re.lastIndex, Math.max(re.lastIndex, i - 1));
1014
+ re.lastIndex = i;
1015
+
1016
+ // Only percentage travel qualifies: a content marquee translates by a
1017
+ // fraction of its own (unknown) track width, so generated tickers use
1018
+ // -50% / -100%. Pixel-travel loops are bespoke product animations —
1019
+ // sweeping playheads, progress indicators — not marquees.
1020
+ const pct = [];
1021
+ const xRe = /\btranslate(?:X|3d)?\(\s*(-?[\d.]+)%/gi;
1022
+ let xm;
1023
+ while ((xm = xRe.exec(body)) !== null) pct.push(parseFloat(xm[1]));
1024
+ if (pct.length === 0) continue;
1025
+ if (pct.length === 1 && /\bscale\(|\bopacity\s*:/i.test(body)) continue;
1026
+ // Implicit start: a lone declared X animates from the element's
1027
+ // resting position, so its magnitude is the travel.
1028
+ const travelPct = pct.length > 1 ? Math.max(...pct) - Math.min(...pct) : Math.abs(pct[0]);
1029
+ if (travelPct >= 20) names.add(m[1]);
1030
+ }
1031
+ return names;
1032
+ }
1033
+
1034
+ // Auto-scrolling marquee: a <marquee> element, or an infinite animation
1035
+ // bound to a keyframe loop that travels a large horizontal distance.
1036
+ // Rotation/opacity animations never qualify (no X travel); JS-driven
1037
+ // carousels with user controls have no infinite CSS X-loop to match.
1038
+ function scanCssTextForMarquee(content) {
1039
+ const findings = [];
1040
+ if (/<marquee\b/i.test(content)) {
1041
+ findings.push({ id: 'marquee', snippet: '<marquee> element' });
1042
+ }
1043
+ const marqueeKeyframes = collectMarqueeKeyframes(content);
1044
+ if (marqueeKeyframes.size === 0) return findings;
1045
+ const seen = new Set();
1046
+ const ruleRe = new RegExp(CSS_RULE_BLOCK_SOURCE, 'g');
1047
+ let m;
1048
+ while ((m = ruleRe.exec(content)) !== null) {
1049
+ const selector = m[1].trim();
1050
+ const decls = parseCssDeclBlock(m[2]);
1051
+ for (const name of infiniteAnimationNames(decls)) {
1052
+ if (!marqueeKeyframes.has(name)) continue;
1053
+ const key = `${selector} ${name}`;
1054
+ if (seen.has(key)) continue;
1055
+ seen.add(key);
1056
+ findings.push({ id: 'marquee', snippet: `${selector} — infinite horizontal loop animation "${name}"` });
1057
+ }
1058
+ }
1059
+ return findings;
1060
+ }
1061
+
1062
+ // Collect @keyframes names and whether each one reads as a "pulse" —
1063
+ // i.e. it varies opacity, scale, or box-shadow. Rotation-only keyframes
1064
+ // (spinners) are explicitly not pulses.
1065
+ function collectPulseKeyframes(content) {
1066
+ const map = new Map();
1067
+ const re = /@(?:-webkit-)?keyframes\s+([\w-]+)\s*\{/g;
1068
+ let m;
1069
+ while ((m = re.exec(content)) !== null) {
1070
+ let depth = 1;
1071
+ let i = re.lastIndex;
1072
+ while (i < content.length && depth > 0) {
1073
+ const ch = content.charCodeAt(i);
1074
+ if (ch === 0x7b /* { */) depth++;
1075
+ else if (ch === 0x7d /* } */) depth--;
1076
+ i++;
1077
+ }
1078
+ const body = content.slice(re.lastIndex, Math.max(re.lastIndex, i - 1));
1079
+ const pulses = /\bopacity\s*:/i.test(body)
1080
+ || /\bbox-shadow\s*:/i.test(body)
1081
+ || /\btransform\s*:[^;{}]*\bscale/i.test(body);
1082
+ if (!map.has(m[1]) || pulses) map.set(m[1], pulses);
1083
+ re.lastIndex = i;
1084
+ }
1085
+ return map;
1086
+ }
1087
+
1088
+ const ANIMATION_VALUE_KEYWORDS = new Set([
1089
+ 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear',
1090
+ 'infinite', 'alternate', 'alternate-reverse', 'normal', 'reverse',
1091
+ 'none', 'forwards', 'backwards', 'both', 'running', 'paused',
1092
+ 'step-start', 'step-end', 'inherit', 'initial', 'unset',
1093
+ ]);
1094
+
1095
+ // Extract animation names that run with iteration-count: infinite from a
1096
+ // declaration block (shorthand layers or animation-name + iteration-count).
1097
+ function infiniteAnimationNames(decls) {
1098
+ const out = [];
1099
+ const shorthand = decls.get('animation');
1100
+ if (shorthand) {
1101
+ for (const layer of shorthand.split(/,(?![^(]*\))/)) {
1102
+ if (!/\binfinite\b/i.test(layer)) continue;
1103
+ const name = layer.split(/\s+/).find(t =>
1104
+ /^[a-zA-Z_-][\w-]*$/.test(t) && !ANIMATION_VALUE_KEYWORDS.has(t.toLowerCase()));
1105
+ if (name) out.push(name);
1106
+ }
1107
+ }
1108
+ const nameDecl = decls.get('animation-name');
1109
+ if (nameDecl && /\binfinite\b/i.test(decls.get('animation-iteration-count') || '')) {
1110
+ for (const raw of nameDecl.split(',')) {
1111
+ const t = raw.trim();
1112
+ if (t && t.toLowerCase() !== 'none') out.push(t);
1113
+ }
1114
+ }
1115
+ return out;
1116
+ }
1117
+
1118
+ function isRoundDotRadius(radiusValue, w, h) {
1119
+ if (!radiusValue) return false;
1120
+ const first = String(radiusValue).trim().split(/\s+/)[0];
1121
+ const pct = first.match(/^([\d.]+)%$/);
1122
+ if (pct) return parseFloat(pct[1]) >= 40;
1123
+ const px = cssLengthToPx(first);
1124
+ if (px == null) return false;
1125
+ return px >= 999 || px >= 0.4 * Math.min(w, h);
1126
+ }
1127
+
1128
+ // Remove @media blocks whose condition is prefers-reduced-motion: reduce.
1129
+ // Those blocks describe the accessibility fallback, not the default
1130
+ // experience that ships — an `animation: none` reset inside one must not
1131
+ // mask the resting-state animation the page plays for everyone else.
1132
+ function stripReducedMotionBlocks(content) {
1133
+ const re = /@media[^{]*prefers-reduced-motion\s*:\s*reduce[^{]*\{/gi;
1134
+ let out = '';
1135
+ let last = 0;
1136
+ let m;
1137
+ while ((m = re.exec(content)) !== null) {
1138
+ let depth = 1;
1139
+ let i = re.lastIndex;
1140
+ while (i < content.length && depth > 0) {
1141
+ const ch = content.charCodeAt(i);
1142
+ if (ch === 0x7b /* { */) depth++;
1143
+ else if (ch === 0x7d /* } */) depth--;
1144
+ i++;
1145
+ }
1146
+ out += content.slice(last, m.index);
1147
+ last = i;
1148
+ re.lastIndex = i;
1149
+ }
1150
+ return out + content.slice(last);
1151
+ }
1152
+
1153
+ // Source-index ranges of <header> and <nav> landmark elements in an HTML
1154
+ // string. Lets string-level scans decide whether a matched element sits in
1155
+ // the page chrome (the hero/nav region) without needing a DOM.
1156
+ function landmarkSourceRanges(content) {
1157
+ const ranges = [];
1158
+ for (const tag of ['header', 'nav']) {
1159
+ const re = new RegExp(`<${tag}\\b|</${tag}\\s*>`, 'gi');
1160
+ const stack = [];
1161
+ let m;
1162
+ while ((m = re.exec(content)) !== null) {
1163
+ if (m[0].charAt(1) === '/') {
1164
+ const start = stack.pop();
1165
+ if (start != null) ranges.push([start, m.index]);
1166
+ } else {
1167
+ stack.push(m.index);
1168
+ }
1169
+ }
1170
+ }
1171
+ return ranges;
1172
+ }
1173
+
1174
+ function indexInSourceRanges(index, ranges) {
1175
+ return ranges.some(([start, end]) => index >= start && index < end);
1176
+ }
1177
+
1178
+ // Does any element targeted by the final compound of `selector` appear
1179
+ // inside a header/nav landmark range of the HTML source? Resolves the last
1180
+ // .class or #id token of the selector against class/id attributes; a
1181
+ // tag-only compound is never resolvable this way and returns false
1182
+ // (conservative: no promotion without placement evidence).
1183
+ function selectorHitsLandmark(content, selector, ranges) {
1184
+ if (!ranges || ranges.length === 0) return false;
1185
+ const last = selector.split(/[\s>+~]+/).filter(Boolean).pop() || '';
1186
+ const idMatch = last.match(/#([A-Za-z_][\w-]*)/);
1187
+ const classMatch = last.match(/\.([A-Za-z_][\w-]*)/);
1188
+ let attrRe = null;
1189
+ if (idMatch) {
1190
+ const id = idMatch[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1191
+ attrRe = new RegExp(`<[a-zA-Z][^>]*\\bid\\s*=\\s*["']${id}["']`, 'gi');
1192
+ } else if (classMatch) {
1193
+ const cls = classMatch[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1194
+ attrRe = new RegExp(`<[a-zA-Z][^>]*\\bclass\\s*=\\s*["'][^"']*(?<![\\w-])${cls}(?![\\w-])[^"']*["']`, 'gi');
1195
+ }
1196
+ if (!attrRe) return false;
1197
+ let m;
1198
+ while ((m = attrRe.exec(content)) !== null) {
1199
+ if (indexInSourceRanges(m.index, ranges)) return true;
1200
+ }
1201
+ return false;
1202
+ }
1203
+
1204
+ // Small circular indicator bound to an infinite pulse animation — the
1205
+ // decorative "live" dot. Gates: tiny (<= 16px square-ish), round
1206
+ // (border-radius >= 40% or pill values), and an infinite animation whose
1207
+ // keyframes vary opacity/scale/box-shadow (or a pulse/blink/ping name when
1208
+ // the keyframes aren't in the scanned text). Rotation-only animations
1209
+ // (spinners) never flag.
1210
+ //
1211
+ // Declarations for one selector are merged across rule blocks before the
1212
+ // predicate runs: size in the base rule plus the animation added in a
1213
+ // second block (or inside a matching @media block) is the construction
1214
+ // that ships. prefers-reduced-motion: reduce overrides are stripped first
1215
+ // so their animation resets don't mask the default experience. A dot whose
1216
+ // element sits inside a header/nav landmark is the hero liveness cliché
1217
+ // and is promoted to error severity; occurrences elsewhere keep the
1218
+ // registry default severity.
1219
+ function scanCssTextForPulsingDot(content) {
1220
+ const customProps = collectCssCustomProps(content);
1221
+ const keyframes = collectPulseKeyframes(content);
1222
+ const heroRanges = landmarkSourceRanges(content);
1223
+ const findings = [];
1224
+ const seen = new Set();
1225
+
1226
+ // Merge declarations per selector across rule blocks, approximating the
1227
+ // cascade: later declarations for the same property win. Comma lists are
1228
+ // split so `.a, .b { … }` contributes to both selectors. Comments are
1229
+ // stripped first so they neither pollute selector keys nor smuggle a
1230
+ // comma into the selector-list split.
1231
+ const scanText = stripReducedMotionBlocks(content).replace(/\/\*[\s\S]*?\*\//g, ' ');
1232
+ const merged = new Map();
1233
+ const ruleRe = new RegExp(CSS_RULE_BLOCK_SOURCE, 'g');
1234
+ let m;
1235
+ while ((m = ruleRe.exec(scanText)) !== null) {
1236
+ const decls = parseCssDeclBlock(m[2]);
1237
+ if (decls.size === 0) continue;
1238
+ for (const rawSelector of m[1].split(',')) {
1239
+ const selector = rawSelector.trim();
1240
+ if (!selector || selector.startsWith('@')) continue;
1241
+ let acc = merged.get(selector);
1242
+ if (!acc) {
1243
+ acc = new Map();
1244
+ merged.set(selector, acc);
1245
+ }
1246
+ for (const [prop, value] of decls) acc.set(prop, value);
1247
+ }
1248
+ }
1249
+
1250
+ for (const [selector, decls] of merged) {
1251
+ const names = infiniteAnimationNames(decls);
1252
+ if (names.length === 0) continue;
1253
+ const pulseName = names.find(n => {
1254
+ const known = keyframes.get(n);
1255
+ if (known != null) return known;
1256
+ return /pulse|blink|ping/i.test(n);
1257
+ });
1258
+ if (!pulseName) continue;
1259
+
1260
+ const w = cssLengthToPx(resolveVarRefs(
1261
+ decls.get('width') || decls.get('inline-size') || '', customProps));
1262
+ const h = cssLengthToPx(resolveVarRefs(
1263
+ decls.get('height') || decls.get('block-size') || '', customProps));
1264
+ if (w == null || h == null || w < 2 || h < 2 || w > 16 || h > 16) continue;
1265
+
1266
+ const radius = resolveVarRefs(decls.get('border-radius') || '', customProps);
1267
+ if (!isRoundDotRadius(radius, w, h)) continue;
1268
+
1269
+ if (seen.has(selector)) continue;
1270
+ seen.add(selector);
1271
+ const inLandmark = selectorHitsLandmark(content, selector, heroRanges);
1272
+ findings.push({
1273
+ id: 'pulsing-dot',
1274
+ snippet: `${selector} — ${w}x${h}px dot with infinite "${pulseName}" animation${inLandmark ? ' in header/nav' : ''}`,
1275
+ selector,
1276
+ ...(inLandmark ? { severity: 'error' } : {}),
1277
+ });
1278
+ }
1279
+
1280
+ // Tailwind utilities: animate-ping / animate-pulse on a tiny rounded-full
1281
+ // element declared entirely in the class attribute.
1282
+ const classRe = /class\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
1283
+ let cm;
1284
+ while ((cm = classRe.exec(content)) !== null) {
1285
+ const cls = cm[1] || cm[2] || '';
1286
+ const anim = cls.match(/\banimate-(ping|pulse)\b/);
1287
+ if (!anim) continue;
1288
+ if (!/\brounded-full\b/.test(cls)) continue;
1289
+ if (!/\b(?:w|h|size)-(?:1|1\.5|2|2\.5|3|3\.5|4)\b/.test(cls)) continue;
1290
+ const key = `tw:${cls}`;
1291
+ if (seen.has(key)) continue;
1292
+ seen.add(key);
1293
+ const inLandmark = indexInSourceRanges(cm.index, heroRanges);
1294
+ findings.push({
1295
+ id: 'pulsing-dot',
1296
+ snippet: `animate-${anim[1]} on tiny rounded-full element${inLandmark ? ' in header/nav' : ''}`,
1297
+ ...(inLandmark ? { severity: 'error' } : {}),
1298
+ });
1299
+ }
1300
+
1301
+ return findings;
1302
+ }
1303
+
1304
+ // Shape-assembled illustration: a large inline SVG composing a pictorial
1305
+ // scene from many primitive shapes (rect / circle / ellipse / polygon) in
1306
+ // several fill colors — the clip-art hero mascot. Gates keep the legitimate
1307
+ // SVG population out:
1308
+ // • icons and logos: intrinsic size gate (>= 200px on both axes, from
1309
+ // width/height attributes or the viewBox when no explicit size is set)
1310
+ // • charts / labeled diagrams: more than two <text>/<tspan> nodes exempts
1311
+ // the graphic (axis labels, callouts)
1312
+ // • line drawings / technical diagrams: primitive count < 8 or fewer
1313
+ // than 3 distinct fills never qualifies (stroke-only art has no fills)
1314
+ // • tiling background textures: any <pattern> definition exempts
1315
+ function scanHtmlForShapeAssembledIllustration(html) {
1316
+ const findings = [];
1317
+ const svgRe = /<svg\b[^>]*>[\s\S]*?<\/svg>/gi;
1318
+ let m;
1319
+ while ((m = svgRe.exec(html)) !== null) {
1320
+ const block = m[0];
1321
+ const openTag = (block.match(/^<svg\b[^>]*>/i) || [''])[0];
1322
+
1323
+ // Data-bearing or annotated graphics: axis labels and callout text
1324
+ // mark a chart or diagram, not a mascot.
1325
+ const textCount = (block.match(/<(?:text|tspan)\b/gi) || []).length;
1326
+ if (textCount > 2) continue;
1327
+ // Tiling texture definitions are decorative backgrounds, not scenes.
1328
+ if (/<pattern\b/i.test(block)) continue;
1329
+
1330
+ const primitives = (block.match(/<(?:rect|circle|ellipse|polygon)\b/gi) || []).length;
1331
+ if (primitives < 8) continue;
1332
+
1333
+ // Intrinsic size: explicit width/height attributes win; fall back to
1334
+ // the viewBox box. Percentage or missing sizes stay unresolvable on
1335
+ // that axis and the viewBox speaks for them.
1336
+ const attrDim = (name) => {
1337
+ // (?<![-\w]) keeps compound attributes like stroke-width from
1338
+ // masquerading as the svg's own width.
1339
+ const am = openTag.match(new RegExp(`(?<![-\\w])${name}\\s*=\\s*["']\\s*([\\d.]+)(?:px)?\\s*["']`, 'i'));
1340
+ return am ? parseFloat(am[1]) : null;
1341
+ };
1342
+ const vb = openTag.match(/\bviewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)\s*["']/i);
1343
+ const w = attrDim('width') ?? (vb ? parseFloat(vb[1]) : null);
1344
+ const h = attrDim('height') ?? (vb ? parseFloat(vb[2]) : null);
1345
+ if (w == null || h == null || w < 200 || h < 200) continue;
1346
+
1347
+ // Distinct fill paints (attributes and inline styles), excluding
1348
+ // non-paints. Multiple fills are what turn a shape pile into a scene.
1349
+ const fills = new Set();
1350
+ for (const fm of block.matchAll(/\bfill\s*[:=]\s*["']?\s*([^"';>}\s]+)/gi)) {
1351
+ const paint = fm[1].trim().toLowerCase();
1352
+ if (!paint || ['none', 'transparent', 'currentcolor', 'inherit'].includes(paint)) continue;
1353
+ fills.add(paint);
1354
+ }
1355
+ if (fills.size < 3) continue;
1356
+
1357
+ findings.push({
1358
+ id: 'shape-assembled-illustration',
1359
+ snippet: `inline <svg> scene: ${primitives} primitive shapes, ~${Math.round(w)}x${Math.round(h)}px, ${fills.size} fill colors`,
1360
+ });
1361
+ }
1362
+ return findings;
1363
+ }
1364
+
443
1365
  /**
444
1366
  * Regex-on-HTML checks shared between browser and Node page-level detection.
445
1367
  * These don't need DOM access, just the raw HTML string.
@@ -473,6 +1395,16 @@ function checkHtmlPatterns(html) {
473
1395
  findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
474
1396
  }
475
1397
 
1398
+ // --- Borders ---
1399
+
1400
+ // Side-tab accent stripe drawn as an absolutely-positioned pseudo-element
1401
+ // (no border property involved, so the element-level border checks and
1402
+ // the border-left regexes never see it).
1403
+ findings.push(...scanCssTextForPseudoStripe(html));
1404
+
1405
+ // Side-tab accent stripe drawn as a single-edge inset box-shadow.
1406
+ findings.push(...scanCssTextForInsetStripe(html));
1407
+
476
1408
  // --- Layout ---
477
1409
 
478
1410
  // Monotonous spacing
@@ -548,33 +1480,34 @@ function checkHtmlPatterns(html) {
548
1480
  }
549
1481
  }
550
1482
 
551
- // --- Dark glow ---
1483
+ // Pulsing status dots (tiny circular elements on infinite pulse animations)
1484
+ findings.push(...scanCssTextForPulsingDot(html));
552
1485
 
553
- const darkBgRe = /background(?:-color)?\s*:\s*(?:#(?:0[0-9a-f]|1[0-9a-f]|2[0-3])[0-9a-f]{4}\b|#(?:0|1)[0-9a-f]{2}\b|rgb\(\s*(\d{1,2})\s*,\s*(\d{1,2})\s*,\s*(\d{1,2})\s*\))/gi;
554
- const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
555
- if (darkBgRe.test(html) || twDarkBg.test(html)) {
556
- const shadowRe = /box-shadow\s*:\s*([^;{}]+)/gi;
557
- let shm;
558
- while ((shm = shadowRe.exec(html)) !== null) {
559
- const val = shm[1];
560
- const colorMatch = val.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
561
- if (!colorMatch) continue;
562
- const [r, g, b] = [+colorMatch[1], +colorMatch[2], +colorMatch[3]];
563
- if ((Math.max(r, g, b) - Math.min(r, g, b)) < 30) continue;
564
- const pxVals = [...val.matchAll(/(\d+)px|(?<![.\d])\b(0)\b(?![.\d])/g)].map(p => +(p[1] || p[2]));
565
- if (pxVals.length >= 3 && pxVals[2] > 4) {
566
- findings.push({ id: 'dark-glow', snippet: `Colored glow (rgb(${r},${g},${b})) on dark page` });
567
- break;
568
- }
569
- }
1486
+ // Shape-assembled illustrations (large pictorial SVGs built from primitives)
1487
+ findings.push(...scanHtmlForShapeAssembledIllustration(html));
1488
+
1489
+ // Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
1490
+ findings.push(...scanCssTextForMarquee(html));
1491
+
1492
+ // --- Dark glow / chromatic halo shadows ---
1493
+
1494
+ const glowHits = scanCssTextForGlow(html);
1495
+ if (glowHits.length > 0) {
1496
+ findings.push({ id: 'dark-glow', snippet: glowHits[0].snippet });
570
1497
  }
571
1498
 
572
- // --- Provider tells (gated): repeating-gradient stripes (GPT) ---
1499
+ // Radial-gradient background halo (gradient-drawn sibling of dark-glow)
1500
+ const haloHits = scanCssTextForRadialHalo(html);
1501
+ if (haloHits.length > 0) {
1502
+ findings.push({ id: 'radial-halo', snippet: haloHits[0].snippet });
1503
+ }
1504
+
1505
+ // --- Generated-UI tells: repeating-gradient stripes ---
573
1506
  if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(html)) {
574
1507
  findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
575
1508
  }
576
1509
 
577
- // --- Provider tells (gated): two-axis grid-line background (Codex/GPT) ---
1510
+ // --- Generated-UI tells: two-axis grid-line background ---
578
1511
  // The Codex grid tell is two hairline `linear-gradient(... <color> 1px,
579
1512
  // transparent 1px)` layers (one per axis) tiled by a repeating
580
1513
  // `background-size` cell. Both signals must co-occur in the SAME style block
@@ -587,30 +1520,12 @@ function checkHtmlPatterns(html) {
587
1520
  // in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
588
1521
  // nested parens, so match the hairline stop directly rather than parsing
589
1522
  // whole gradient layers.
590
- {
591
- const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
592
- const gridSizeRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
593
- const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
594
- const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
595
- let blk;
596
- while ((blk = blockRe.exec(html)) !== null) {
597
- const block = blk[1] || blk[2] || blk[3] || '';
598
- if (!gridSizeRe.test(block)) continue;
599
- let hairlineCount = 0;
600
- let bm;
601
- bgDeclRe.lastIndex = 0;
602
- while ((bm = bgDeclRe.exec(block)) !== null) {
603
- const stops = bm[1].match(hairlineRe);
604
- if (stops) hairlineCount += stops.length;
605
- }
606
- if (hairlineCount >= 2) {
607
- findings.push({ id: 'codex-grid-background', snippet: 'two-axis grid-line gradient background' });
608
- break;
609
- }
610
- }
1523
+ const gridHits = scanCssTextForGridBackground(html);
1524
+ if (gridHits.length > 0) {
1525
+ findings.push({ id: 'codex-grid-background', snippet: gridHits[0].snippet });
611
1526
  }
612
1527
 
613
- // --- Provider tells (gated): "X theater" framing copy (GPT) ---
1528
+ // --- Generated-copy tells: "X theater" framing copy ---
614
1529
  // Lives here (regex-on-HTML) rather than in the text-content analyzers so it
615
1530
  // runs in the bundled browser path too, not just the CLI/static path.
616
1531
  {
@@ -622,7 +1537,7 @@ function checkHtmlPatterns(html) {
622
1537
  if (tm) findings.push({ id: 'theater-slop-phrase', snippet: `"${tm[0].trim()}"` });
623
1538
  }
624
1539
 
625
- // --- Provider tells (gated): image hover transform (Gemini) ---
1540
+ // --- Generated-UI tells: image hover transform ---
626
1541
  // A CSS `img...:hover { transform: ... }` rule, or a Tailwind hover:scale /
627
1542
  // hover:rotate / hover:translate utility on an <img>. Each distinct
628
1543
  // mechanism is its own finding.
@@ -651,7 +1566,11 @@ function checkHtmlPatterns(html) {
651
1566
  // `background: #abc`. Real browsers always decompose, so the fallback is
652
1567
  // a no-op there.
653
1568
  function readOwnBackgroundColor(el, computedStyle) {
654
- const bg = parseRgb(computedStyle.backgroundColor);
1569
+ // Real browsers keep wide-gamut/computed color functions (oklch(), oklab(),
1570
+ // color-mix() results) in getComputedStyle output, which plain parseRgb
1571
+ // misses — a flat oklch button background would silently skip every
1572
+ // contrast check without the parseAnyColor fallback.
1573
+ const bg = parseRgb(computedStyle.backgroundColor) || parseAnyColor(computedStyle.backgroundColor);
655
1574
  if (DETECTOR_IS_BROWSER || (bg && bg.a >= 0.1)) return bg;
656
1575
  const rawStyle = el.getAttribute?.('style') || '';
657
1576
  const bgMatch = rawStyle.match(/background(?:-color)?\s*:\s*([^;]+)/i);
@@ -673,6 +1592,18 @@ function readOwnBackgroundColor(el, computedStyle) {
673
1592
 
674
1593
  function resolveBackground(el, win, customPropMap) {
675
1594
  let current = el;
1595
+ // Translucent layers (0.1 < a < 1) found on the way down to an opaque
1596
+ // base. A browser composites these over the base; the old behavior
1597
+ // either returned them as-if-opaque (browser mode) or skipped them
1598
+ // entirely (static mode), both of which misstate the effective surface
1599
+ // for contrast checks (e.g. `background: color-mix(in oklab, var(--hot)
1600
+ // 16%, transparent)` chips on dark pages).
1601
+ const overlays = [];
1602
+ const flatten = (base) => {
1603
+ let acc = base;
1604
+ for (let i = overlays.length - 1; i >= 0; i--) acc = compositeColorOver(overlays[i], acc);
1605
+ return acc;
1606
+ };
676
1607
  while (current && current.nodeType === 1) {
677
1608
  const style = DETECTOR_IS_BROWSER ? getComputedStyle(current) : win.getComputedStyle(current);
678
1609
  const bgImage = style.backgroundImage || '';
@@ -685,7 +1616,9 @@ function resolveBackground(el, win, customPropMap) {
685
1616
  // decorative. The old behavior bailed on any gradient ancestor, which
686
1617
  // caused massive false-positive contrast findings on grain-textured
687
1618
  // body backgrounds.
688
- let bg = parseRgb(style.backgroundColor);
1619
+ // Real browsers serialize wide-gamut computed values as oklab()/oklch()
1620
+ // (e.g. any color-mix() result), which plain parseRgb misses.
1621
+ let bg = parseRgb(style.backgroundColor) || parseAnyColor(style.backgroundColor);
689
1622
  if (!DETECTOR_IS_BROWSER && (!bg || bg.a < 0.1)) {
690
1623
  // jsdom returns literal "var(--X)" / "oklch(...)" strings. Resolve
691
1624
  // through customPropMap so Tailwind v4 color tokens become RGB.
@@ -705,7 +1638,8 @@ function resolveBackground(el, win, customPropMap) {
705
1638
  }
706
1639
 
707
1640
  if (bg && bg.a > 0.1) {
708
- if (DETECTOR_IS_BROWSER || bg.a >= 0.5) return bg;
1641
+ if (bg.a >= 0.99) return flatten(bg);
1642
+ overlays.push(bg);
709
1643
  }
710
1644
  // No solid bg-color at this level. If THIS level has a gradient/url
711
1645
  // with no underlying solid color we can read:
@@ -721,13 +1655,13 @@ function resolveBackground(el, win, customPropMap) {
721
1655
  // bgs worth checking against).
722
1656
  if (hasGradientOrUrl) {
723
1657
  if (current.tagName === 'BODY' || current.tagName === 'HTML') {
724
- return { r: 255, g: 255, b: 255, a: 1 };
1658
+ return flatten({ r: 255, g: 255, b: 255, a: 1 });
725
1659
  }
726
1660
  return null;
727
1661
  }
728
1662
  current = current.parentElement;
729
1663
  }
730
- return { r: 255, g: 255, b: 255 };
1664
+ return flatten({ r: 255, g: 255, b: 255, a: 1 });
731
1665
  }
732
1666
 
733
1667
  // Walk parents looking for a gradient background and return its color stops.
@@ -789,6 +1723,43 @@ function resolveBorderRadiusPx(el, style, widthPx, win) {
789
1723
 
790
1724
  // Browser adapters — call getComputedStyle/getBoundingClientRect on live DOM
791
1725
 
1726
+ // Selected-state context for accent stripes. Only an actual selection
1727
+ // marker exempts the stripe as the standard active-item indicator:
1728
+ // aria-selected="true", aria-current (any non-false value), or an
1729
+ // active/current/selected class hint. Tab-strip MEMBERSHIP alone
1730
+ // ([role=tablist]/[role=tab]/.tabs ancestry, aria-selected="false")
1731
+ // deliberately does not — a chromatic stripe repeated on every tab in
1732
+ // the group, or on every menu item, is decoration, not state; the
1733
+ // selected item's own underline stays legal.
1734
+ function isTabContextElement(el) {
1735
+ if (!el) return false;
1736
+ try {
1737
+ if (el.closest?.('[aria-selected="true"], [aria-current]:not([aria-current="false"])')) return true;
1738
+ } catch { /* selector engine differences — fall through to class scan */ }
1739
+ let cur = el, depth = 0;
1740
+ while (cur && cur.nodeType === 1 && depth < 6) {
1741
+ const cls = String(cur.getAttribute?.('class') || cur.className || '');
1742
+ if (/(?:^|[\s_-])(?:active|current|selected)(?:$|[\s_-])/i.test(cls)) return true;
1743
+ cur = cur.parentElement;
1744
+ depth++;
1745
+ }
1746
+ return false;
1747
+ }
1748
+
1749
+ // Status-surface context for accent borders. On a live status/alert region
1750
+ // (role=status|alert|alertdialog|log, or aria-live=polite|assertive) a colored
1751
+ // single-edge border is the established severity-accent convention — a toast,
1752
+ // snackbar, or callout bar — not the decorative side-tab tell. The element
1753
+ // itself or a wrapping live region qualifies. This never fires from the
1754
+ // CSS-only / regex scanners, which have no role information.
1755
+ function isStatusContextElement(el) {
1756
+ if (!el) return false;
1757
+ try {
1758
+ if (el.closest?.('[role="status"], [role="alert"], [role="alertdialog"], [role="log"], [aria-live="polite"], [aria-live="assertive"]')) return true;
1759
+ } catch { /* selector engine differences — fall through */ }
1760
+ return false;
1761
+ }
1762
+
792
1763
  function checkElementBordersDOM(el) {
793
1764
  const tag = el.tagName.toLowerCase();
794
1765
  if (BORDER_SAFE_TAGS.has(tag)) return [];
@@ -801,7 +1772,105 @@ function checkElementBordersDOM(el) {
801
1772
  widths[s] = parseFloat(style[`border${s}Width`]) || 0;
802
1773
  colors[s] = style[`border${s}Color`] || '';
803
1774
  }
804
- return checkBorders(tag, widths, colors, parseFloat(style.borderRadius) || 0);
1775
+ const ownBg = parseRgb(style.backgroundColor) || parseAnyColor(style.backgroundColor);
1776
+ return checkBorders(tag, widths, colors, parseFloat(style.borderRadius) || 0, {
1777
+ tabContext: isTabContextElement(el),
1778
+ statusContext: isStatusContextElement(el),
1779
+ badgeLike: !!(ownBg && (ownBg.a ?? 1) > 0.1),
1780
+ });
1781
+ }
1782
+
1783
+ // Browser-side twin of scanCssTextForPseudoStripe. The text scanner reads
1784
+ // stylesheet source, so a stripe whose color only exists at runtime (an
1785
+ // inline per-card custom property, a JS-assigned var) or whose geometry
1786
+ // resolves in layout never matches it. In a real browser the pseudo-element's
1787
+ // computed style carries the actual used color and px geometry — check those
1788
+ // directly. Gates mirror the text scanner: 3-12px thick, chromatic fill,
1789
+ // spanning (nearly) the full edge; corner rounding on the host card is
1790
+ // irrelevant. Exemptions stay narrow: structural/prose tags, real selection
1791
+ // markers (isTabContextElement), and button/link affordances for the
1792
+ // horizontal variant.
1793
+ function checkElementPseudoStripeDOM(el) {
1794
+ const tag = el.tagName.toLowerCase();
1795
+ if (BORDER_SAFE_TAGS.has(tag) || tag === 'summary') return [];
1796
+ if (el.closest?.('nav, blockquote, pre')) return [];
1797
+ if (!isRenderedForBrowserRule(el)) return [];
1798
+ const rect = el.getBoundingClientRect();
1799
+ if (rect.width < 40 || rect.height < 20) return [];
1800
+ if (isTabContextElement(el)) return [];
1801
+
1802
+ const findings = [];
1803
+ for (const which of ['::before', '::after']) {
1804
+ let ps;
1805
+ try { ps = getComputedStyle(el, which); } catch { continue; }
1806
+ if (!ps || ps.content === 'none' || ps.content === '') continue;
1807
+ if (ps.position !== 'absolute' && ps.position !== 'fixed') continue;
1808
+ if ((parseFloat(ps.opacity) || 0) <= 0.01 || ps.display === 'none') continue;
1809
+ const w = parseFloat(ps.width) || 0;
1810
+ const h = parseFloat(ps.height) || 0;
1811
+ if (!(w > 0 && h > 0)) continue;
1812
+
1813
+ // Used values: for absolutely-positioned boxes the browser resolves
1814
+ // both edge offsets after layout, so left/right (and top/bottom) are
1815
+ // real distances, never "auto".
1816
+ const left = parseFloat(ps.left);
1817
+ const right = parseFloat(ps.right);
1818
+ const top = parseFloat(ps.top);
1819
+ const bottom = parseFloat(ps.bottom);
1820
+ const hugs = (v) => Number.isFinite(v) && v >= -2 && v <= 2;
1821
+
1822
+ let edge = null;
1823
+ let thickness = null;
1824
+ // Vertical stripe: narrow box spanning (nearly) the full height of the
1825
+ // host, hugging its left or right edge. "Nearly" tolerates the floating
1826
+ // variant that backs off each end by a small inset.
1827
+ if (w >= 3 && w <= 12 && h >= rect.height - 44 && h >= rect.height * 0.5) {
1828
+ edge = hugs(left) ? 'left' : hugs(right) ? 'right' : null;
1829
+ thickness = w;
1830
+ }
1831
+ // Horizontal stripe riding the top or bottom edge. Button/link-styled
1832
+ // hosts keep their underline affordances.
1833
+ if (!edge && h >= 3 && h <= 12 && w >= rect.width - 44 && w >= rect.width * 0.5) {
1834
+ const cls = String(el.getAttribute?.('class') || el.className || '');
1835
+ if (!/(?:^|[\s_-])(?:btn|button|link)(?:$|[\s\w_-])/i.test(cls)) {
1836
+ edge = hugs(top) ? 'top' : hugs(bottom) ? 'bottom' : null;
1837
+ thickness = h;
1838
+ }
1839
+ }
1840
+ if (!edge) continue;
1841
+
1842
+ const bg = parseRgb(ps.backgroundColor) || parseAnyColor(ps.backgroundColor);
1843
+ if (!bg || (bg.a ?? 1) < 0.1) continue;
1844
+ if (Math.max(bg.r, bg.g, bg.b) - Math.min(bg.r, bg.g, bg.b) < 30) continue;
1845
+
1846
+ findings.push({
1847
+ id: 'side-tab',
1848
+ snippet: `${classSelector(el)}${which} — absolute ${thickness}px pseudo-element stripe (${edge})`,
1849
+ });
1850
+ }
1851
+ return findings;
1852
+ }
1853
+
1854
+ // Full-cover surface pseudo (browser): a ::before/::after positioned
1855
+ // absolute/fixed whose box covers (nearly) the whole host and carries an
1856
+ // opaque background. That pseudo is the element's visible surface even
1857
+ // though the element's own background-color reads transparent — the nav-CTA
1858
+ // construction that otherwise escapes every own-background contrast gate.
1859
+ function readPseudoSurfaceDOM(el, rect) {
1860
+ for (const which of ['::before', '::after']) {
1861
+ let ps;
1862
+ try { ps = getComputedStyle(el, which); } catch { continue; }
1863
+ if (!ps || ps.content === 'none' || ps.content === '') continue;
1864
+ if (ps.position !== 'absolute' && ps.position !== 'fixed') continue;
1865
+ if (ps.display === 'none' || (parseFloat(ps.opacity) || 1) < 0.9) continue;
1866
+ const w = parseFloat(ps.width) || 0;
1867
+ const h = parseFloat(ps.height) || 0;
1868
+ if (w < rect.width - 4 || h < rect.height - 4) continue;
1869
+ const bg = parseRgb(ps.backgroundColor) || parseAnyColor(ps.backgroundColor);
1870
+ if (!bg || (bg.a ?? 1) < 0.9) continue;
1871
+ return bg;
1872
+ }
1873
+ return null;
805
1874
  }
806
1875
 
807
1876
  function checkElementColorsDOM(el) {
@@ -814,11 +1883,24 @@ function checkElementColorsDOM(el) {
814
1883
  const style = getComputedStyle(el);
815
1884
  const directText = [...el.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
816
1885
  const hasDirectText = directText.trim().length > 0;
817
- const effectiveBg = resolveBackground(el);
1886
+ let effectiveBg = resolveBackground(el);
1887
+ let ownBg = readOwnBackgroundColor(el, style);
1888
+ if (!ownBg || (ownBg.a ?? 1) <= 0.5) {
1889
+ const pseudoSurface = readPseudoSurfaceDOM(el, rect);
1890
+ if (pseudoSurface) {
1891
+ ownBg = pseudoSurface;
1892
+ effectiveBg = pseudoSurface;
1893
+ }
1894
+ }
818
1895
  return checkColors({
819
1896
  tag,
820
- textColor: parseRgb(style.color),
821
- bgColor: readOwnBackgroundColor(el, style),
1897
+ // Chrome serializes computed colors specified in modern spaces as
1898
+ // oklch()/oklab() strings; without the parseAnyColor fallback the text
1899
+ // color comes back null and the low-contrast / gray-on-color checks
1900
+ // silently never run (the shipped miss: a nav CTA whose text color was
1901
+ // an oklch token near its own oklch background).
1902
+ textColor: parseRgb(style.color) || parseAnyColor(style.color),
1903
+ bgColor: ownBg,
822
1904
  effectiveBg,
823
1905
  effectiveBgStops: effectiveBg ? null : resolveGradientStops(el),
824
1906
  fontSize: parseFloat(style.fontSize) || 16,
@@ -879,6 +1961,21 @@ function checkElementItalicSerifDOM(el) {
879
1961
  });
880
1962
  }
881
1963
 
1964
+ function domAccentDashPseudo(el) {
1965
+ for (const which of ['::before', '::after']) {
1966
+ let ps;
1967
+ try { ps = getComputedStyle(el, which); } catch { continue; }
1968
+ if (!ps || ps.content === 'none' || ps.content === '') continue;
1969
+ const w = parseFloat(ps.width) || 0;
1970
+ const h = parseFloat(ps.height) || 0;
1971
+ if (!(w >= 8 && w <= 80 && h >= 1 && h <= 6)) continue;
1972
+ const bg = parseRgb(ps.backgroundColor) || parseAnyColor(ps.backgroundColor);
1973
+ if (!bg || (bg.a ?? 1) < 0.1) continue;
1974
+ if (Math.max(bg.r, bg.g, bg.b) - Math.min(bg.r, bg.g, bg.b) >= 30) return true;
1975
+ }
1976
+ return false;
1977
+ }
1978
+
882
1979
  function checkElementHeroEyebrowDOM(el) {
883
1980
  const tag = el.tagName.toLowerCase();
884
1981
  if (tag !== 'h1') return [];
@@ -890,6 +1987,7 @@ function checkElementHeroEyebrowDOM(el) {
890
1987
  headingTag: tag,
891
1988
  headingText: el.textContent || '',
892
1989
  headingFontSize: parseFloat(headStyle.fontSize) || 0,
1990
+ headingInApplicationContext: !!el.closest('[role="tabpanel"], [role="dialog"], [role="application"], dialog'),
893
1991
  siblingTag: sibling.tagName.toLowerCase(),
894
1992
  siblingText: sibling.textContent || '',
895
1993
  siblingTextTransform: sibStyle.textTransform || '',
@@ -897,6 +1995,7 @@ function checkElementHeroEyebrowDOM(el) {
897
1995
  siblingLetterSpacing: parseFloat(sibStyle.letterSpacing) || 0,
898
1996
  siblingFontWeight: sibStyle.fontWeight || '',
899
1997
  siblingColor: sibStyle.color || '',
1998
+ siblingHasAccentDashPseudo: domAccentDashPseudo(sibling),
900
1999
  });
901
2000
  }
902
2001
 
@@ -961,8 +2060,10 @@ function resolveVarRefs(raw, customPropMap, depth = 0) {
961
2060
  // detector's contrast / color checks.
962
2061
  function oklchToRgb(L, C, H) {
963
2062
  const hRad = (H * Math.PI) / 180;
964
- const a = C * Math.cos(hRad);
965
- const b = C * Math.sin(hRad);
2063
+ return oklabToRgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
2064
+ }
2065
+
2066
+ function oklabToRgb(L, a, b) {
966
2067
  const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
967
2068
  const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
968
2069
  const s_ = L - 0.0894841775 * a - 1.2914855480 * b;
@@ -982,13 +2083,178 @@ function oklchToRgb(L, C, H) {
982
2083
  };
983
2084
  }
984
2085
 
985
- // Extended color parser: rgb/rgba/hex/oklch. Returns null on no match.
986
- // Use this when the input might be any CSS color form; use plain parseRgb
987
- // when you only expect computed rgb() values from real browsers.
2086
+ function hslToRgb(h, s, l) {
2087
+ h = ((h % 360) + 360) % 360;
2088
+ const c = (1 - Math.abs(2 * l - 1)) * s;
2089
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
2090
+ const m0 = l - c / 2;
2091
+ const [r, g, b] =
2092
+ h < 60 ? [c, x, 0] :
2093
+ h < 120 ? [x, c, 0] :
2094
+ h < 180 ? [0, c, x] :
2095
+ h < 240 ? [0, x, c] :
2096
+ h < 300 ? [x, 0, c] : [c, 0, x];
2097
+ return {
2098
+ r: Math.round((r + m0) * 255),
2099
+ g: Math.round((g + m0) * 255),
2100
+ b: Math.round((b + m0) * 255),
2101
+ a: 1,
2102
+ };
2103
+ }
2104
+
2105
+ function hwbToRgb(h, w, bl) {
2106
+ if (w + bl >= 1) {
2107
+ const g = Math.round((w / (w + bl)) * 255);
2108
+ return { r: g, g, b: g, a: 1 };
2109
+ }
2110
+ const base = hslToRgb(h, 1, 0.5);
2111
+ const mix = (c) => Math.round(((c / 255) * (1 - w - bl) + w) * 255);
2112
+ return { r: mix(base.r), g: mix(base.g), b: mix(base.b), a: 1 };
2113
+ }
2114
+
2115
+ // Common CSS named colors — the handful that actually show up in generated
2116
+ // UIs, not the full 148-name spec list. Includes the achromatic names so a
2117
+ // named gray parses (and correctly reads as no-chroma) instead of being
2118
+ // treated as an unknown color.
2119
+ const CSS_NAMED_COLORS = {
2120
+ black: { r: 0, g: 0, b: 0 },
2121
+ white: { r: 255, g: 255, b: 255 },
2122
+ gray: { r: 128, g: 128, b: 128 },
2123
+ grey: { r: 128, g: 128, b: 128 },
2124
+ silver: { r: 192, g: 192, b: 192 },
2125
+ dimgray: { r: 105, g: 105, b: 105 },
2126
+ darkgray: { r: 169, g: 169, b: 169 },
2127
+ lightgray: { r: 211, g: 211, b: 211 },
2128
+ gainsboro: { r: 220, g: 220, b: 220 },
2129
+ whitesmoke: { r: 245, g: 245, b: 245 },
2130
+ red: { r: 255, g: 0, b: 0 },
2131
+ crimson: { r: 220, g: 20, b: 60 },
2132
+ tomato: { r: 255, g: 99, b: 71 },
2133
+ coral: { r: 255, g: 127, b: 80 },
2134
+ salmon: { r: 250, g: 128, b: 114 },
2135
+ orange: { r: 255, g: 165, b: 0 },
2136
+ gold: { r: 255, g: 215, b: 0 },
2137
+ yellow: { r: 255, g: 255, b: 0 },
2138
+ olive: { r: 128, g: 128, b: 0 },
2139
+ lime: { r: 0, g: 255, b: 0 },
2140
+ green: { r: 0, g: 128, b: 0 },
2141
+ teal: { r: 0, g: 128, b: 128 },
2142
+ turquoise: { r: 64, g: 224, b: 208 },
2143
+ cyan: { r: 0, g: 255, b: 255 },
2144
+ aqua: { r: 0, g: 255, b: 255 },
2145
+ skyblue: { r: 135, g: 206, b: 235 },
2146
+ dodgerblue: { r: 30, g: 144, b: 255 },
2147
+ blue: { r: 0, g: 0, b: 255 },
2148
+ navy: { r: 0, g: 0, b: 128 },
2149
+ indigo: { r: 75, g: 0, b: 130 },
2150
+ rebeccapurple: { r: 102, g: 51, b: 153 },
2151
+ purple: { r: 128, g: 0, b: 128 },
2152
+ violet: { r: 238, g: 130, b: 238 },
2153
+ orchid: { r: 218, g: 112, b: 214 },
2154
+ magenta: { r: 255, g: 0, b: 255 },
2155
+ fuchsia: { r: 255, g: 0, b: 255 },
2156
+ hotpink: { r: 255, g: 105, b: 180 },
2157
+ pink: { r: 255, g: 192, b: 203 },
2158
+ maroon: { r: 128, g: 0, b: 0 },
2159
+ };
2160
+
2161
+ // Split a string on top-level commas (ignoring commas nested in parens).
2162
+ function splitTopLevelCommas(str) {
2163
+ const parts = [];
2164
+ let depth = 0, start = 0;
2165
+ for (let i = 0; i < str.length; i++) {
2166
+ const ch = str[i];
2167
+ if (ch === '(') depth++;
2168
+ else if (ch === ')') depth = Math.max(0, depth - 1);
2169
+ else if (ch === ',' && depth === 0) {
2170
+ parts.push(str.slice(start, i).trim());
2171
+ start = i + 1;
2172
+ }
2173
+ }
2174
+ const tail = str.slice(start).trim();
2175
+ if (tail) parts.push(tail);
2176
+ return parts;
2177
+ }
2178
+
2179
+ // Evaluate a CSS color-mix() expression to {r,g,b,a}. Returns null when
2180
+ // the expression can't be resolved (unresolved var(), unknown colors).
2181
+ //
2182
+ // Mixing is done with premultiplied alpha in sRGB regardless of the
2183
+ // declared interpolation space. That is exact for the dominant generated-UI
2184
+ // pattern — `color-mix(in oklab, <color> N%, transparent)` — where the
2185
+ // result is simply <color> at alpha N% in ANY rectangular space, and a
2186
+ // close-enough approximation for opaque-opaque mixes (the detector only
2187
+ // consumes these values for contrast/chroma thresholds, not for display).
2188
+ function parseColorMix(str) {
2189
+ const m = String(str).trim().match(/^color-mix\(/i);
2190
+ if (!m) return null;
2191
+ // Balanced-paren capture of the arguments.
2192
+ let depth = 0, end = -1;
2193
+ const open = str.indexOf('(');
2194
+ for (let i = open; i < str.length; i++) {
2195
+ if (str[i] === '(') depth++;
2196
+ else if (str[i] === ')') { depth--; if (depth === 0) { end = i; break; } }
2197
+ }
2198
+ if (end < 0) return null;
2199
+ const args = splitTopLevelCommas(str.slice(open + 1, end));
2200
+ if (args.length !== 3 || !/^in\s/i.test(args[0])) return null;
2201
+
2202
+ const parseComponent = (component) => {
2203
+ // Percentage may lead or trail the color per spec.
2204
+ let pct = null;
2205
+ let colorStr = component;
2206
+ const trail = component.match(/\s+([\d.]+)%$/);
2207
+ const lead = component.match(/^([\d.]+)%\s+/);
2208
+ if (trail) { pct = parseFloat(trail[1]); colorStr = component.slice(0, trail.index).trim(); }
2209
+ else if (lead) { pct = parseFloat(lead[1]); colorStr = component.slice(lead[0].length).trim(); }
2210
+ let color;
2211
+ if (/^transparent$/i.test(colorStr)) color = { r: 0, g: 0, b: 0, a: 0 };
2212
+ else color = parseAnyColor(colorStr);
2213
+ if (!color) return null;
2214
+ return { color, pct };
2215
+ };
2216
+
2217
+ const c1 = parseComponent(args[1]);
2218
+ const c2 = parseComponent(args[2]);
2219
+ if (!c1 || !c2) return null;
2220
+ let p1 = c1.pct, p2 = c2.pct;
2221
+ if (p1 == null && p2 == null) { p1 = 50; p2 = 50; }
2222
+ else if (p1 == null) p1 = 100 - p2;
2223
+ else if (p2 == null) p2 = 100 - p1;
2224
+ const sum = p1 + p2;
2225
+ if (sum <= 0) return null;
2226
+ // Per spec: weights normalize to sum; when sum < 100 the result alpha is
2227
+ // additionally scaled by sum/100.
2228
+ const w1 = p1 / sum, w2 = p2 / sum;
2229
+ const alphaScale = sum < 100 ? sum / 100 : 1;
2230
+ const a1 = c1.color.a ?? 1, a2 = c2.color.a ?? 1;
2231
+ const a = (a1 * w1 + a2 * w2) * alphaScale;
2232
+ if (a <= 0) return { r: 0, g: 0, b: 0, a: 0 };
2233
+ const mix = (ch) => Math.round((c1.color[ch] * a1 * w1 + c2.color[ch] * a2 * w2) / (a1 * w1 + a2 * w2));
2234
+ return { r: mix('r'), g: mix('g'), b: mix('b'), a: Math.min(1, a) };
2235
+ }
2236
+
2237
+ // Composite a translucent color over an opaque(ish) base (simple
2238
+ // source-over in sRGB). Returns an opaque {r,g,b,a:1}.
2239
+ function compositeColorOver(top, base) {
2240
+ const a = top.a ?? 1;
2241
+ return {
2242
+ r: Math.round(top.r * a + base.r * (1 - a)),
2243
+ g: Math.round(top.g * a + base.g * (1 - a)),
2244
+ b: Math.round(top.b * a + base.b * (1 - a)),
2245
+ a: 1,
2246
+ };
2247
+ }
2248
+
2249
+ // Extended color parser: rgb/rgba/hex/oklch/oklab/hsl/hwb/color-mix/common
2250
+ // named colors. Returns null on no match. Use this when the input might be
2251
+ // any CSS color form; use plain parseRgb when you only expect computed rgb()
2252
+ // values from real browsers.
988
2253
  function parseAnyColor(s) {
989
2254
  if (!s || typeof s !== 'string') return null;
990
2255
  const str = s.trim();
991
2256
  if (str === 'transparent' || str === 'currentcolor' || str === 'inherit') return null;
2257
+ if (/^color-mix\(/i.test(str)) return parseColorMix(str);
992
2258
  let m;
993
2259
  m = str.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)(?:\s*[,/]\s*([\d.]+))?\s*\)/);
994
2260
  if (m) return { r: Math.round(+m[1]), g: Math.round(+m[2]), b: Math.round(+m[3]), a: m[4] !== undefined ? +m[4] : 1 };
@@ -1026,6 +2292,41 @@ function parseAnyColor(s) {
1026
2292
  }
1027
2293
  return rgb;
1028
2294
  }
2295
+ // OKLAB — a/b are signed axes; percentages map 100% → 0.4.
2296
+ m = str.match(/oklab\(\s*([\d.]+)(%?)\s+(-?[\d.]+)(%?)\s+(-?[\d.]+)(%?)(?:\s*\/\s*([\d.]+)(%)?)?\s*\)/i);
2297
+ if (m) {
2298
+ const L = m[2] === '%' ? parseFloat(m[1]) / 100 : parseFloat(m[1]);
2299
+ const a = m[4] === '%' ? parseFloat(m[3]) * 0.004 : parseFloat(m[3]);
2300
+ const b = m[6] === '%' ? parseFloat(m[5]) * 0.004 : parseFloat(m[5]);
2301
+ const rgb = oklabToRgb(L, a, b);
2302
+ if (m[7] !== undefined) {
2303
+ const alpha = parseFloat(m[7]);
2304
+ rgb.a = m[8] === '%' ? alpha / 100 : alpha;
2305
+ }
2306
+ return rgb;
2307
+ }
2308
+ // HSL/HSLA — comma or space syntax, optional deg on hue.
2309
+ m = str.match(/hsla?\(\s*(-?[\d.]+)(?:deg)?\s*[,\s]\s*([\d.]+)%\s*[,\s]\s*([\d.]+)%(?:\s*[,/]\s*([\d.]+)(%)?)?\s*\)/i);
2310
+ if (m) {
2311
+ const rgb = hslToRgb(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
2312
+ if (m[4] !== undefined) {
2313
+ const alpha = parseFloat(m[4]);
2314
+ rgb.a = m[5] === '%' ? alpha / 100 : alpha;
2315
+ }
2316
+ return rgb;
2317
+ }
2318
+ // HWB — hue whiteness% blackness%.
2319
+ m = str.match(/hwb\(\s*(-?[\d.]+)(?:deg)?\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*([\d.]+)(%)?)?\s*\)/i);
2320
+ if (m) {
2321
+ const rgb = hwbToRgb(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
2322
+ if (m[4] !== undefined) {
2323
+ const alpha = parseFloat(m[4]);
2324
+ rgb.a = m[5] === '%' ? alpha / 100 : alpha;
2325
+ }
2326
+ return rgb;
2327
+ }
2328
+ const named = CSS_NAMED_COLORS[str.toLowerCase()];
2329
+ if (named) return { ...named, a: 1 };
1029
2330
  return null;
1030
2331
  }
1031
2332
 
@@ -1100,60 +2401,197 @@ function isRepeatedKickerCandidate(opts) {
1100
2401
  if (!kickerText || kickerText.length < 2 || kickerText.length > 34) return false;
1101
2402
  if (/^step\s*\d+/i.test(kickerText) || /^\d{1,2}$/.test(kickerText)) return false;
1102
2403
 
1103
- const isUppercased = kickerTextTransform === 'uppercase'
1104
- || (/[A-Z]/.test(kickerText) && !/[a-z]/.test(kickerText));
1105
- if (!isUppercased) return false;
1106
- if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
1107
- const minTrackedSpacing = Math.max(1, kickerFontSize * 0.08);
1108
- if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
1109
- return true;
2404
+ const isUppercased = kickerTextTransform === 'uppercase'
2405
+ || (/[A-Z]/.test(kickerText) && !/[a-z]/.test(kickerText));
2406
+ if (!isUppercased) return false;
2407
+ if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
2408
+ const minTrackedSpacing = Math.max(1, kickerFontSize * 0.08);
2409
+ if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
2410
+ return true;
2411
+ }
2412
+
2413
+ function collectRepeatedSectionKickerCandidates(doc, getStyle, resolveLetterSpacing) {
2414
+ const candidates = [];
2415
+ for (const heading of doc.querySelectorAll('h2, h3, h4')) {
2416
+ if (heading.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
2417
+ const kicker = heading.previousElementSibling;
2418
+ if (!kicker || kicker.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
2419
+ if (isRepeatedKickerCardContext(heading, kicker)) continue;
2420
+
2421
+ const headingStyle = getStyle(heading);
2422
+ const kickerStyle = getStyle(kicker);
2423
+ const headingText = (heading.textContent || '').replace(/\s+/g, ' ').trim();
2424
+ const kickerText = cleanInlineText(kicker) || (kicker.textContent || '').replace(/\s+/g, ' ').trim();
2425
+ const headingFontSize = resolveLetterSpacing(headingStyle.fontSize || '', 16) || parseFloat(headingStyle.fontSize) || 0;
2426
+ const kickerFontSize = resolveLetterSpacing(kickerStyle.fontSize || '', 16) || parseFloat(kickerStyle.fontSize) || 0;
2427
+ const kickerLetterSpacing = resolveLetterSpacing(kickerStyle.letterSpacing || '', kickerFontSize);
2428
+
2429
+ if (!isRepeatedKickerCandidate({
2430
+ headingTag: heading.tagName.toLowerCase(),
2431
+ headingText,
2432
+ headingFontSize,
2433
+ kickerTag: kicker.tagName.toLowerCase(),
2434
+ kickerText,
2435
+ kickerTextTransform: kickerStyle.textTransform || '',
2436
+ kickerFontSize,
2437
+ kickerLetterSpacing,
2438
+ })) {
2439
+ continue;
2440
+ }
2441
+
2442
+ candidates.push({
2443
+ headingTag: heading.tagName.toLowerCase(),
2444
+ headingText: headingText.replace(/^"|"$/g, '').slice(0, 60),
2445
+ kickerText: kickerText.slice(0, 40),
2446
+ });
2447
+ }
2448
+ return candidates;
2449
+ }
2450
+
2451
+ function checkRepeatedSectionKickersDOM() {
2452
+ const candidates = collectRepeatedSectionKickerCandidates(
2453
+ document,
2454
+ (el) => getComputedStyle(el),
2455
+ (value, fontSize) => resolveLengthPx(value, fontSize) || 0,
2456
+ );
2457
+ return checkRepeatedSectionKickers({ candidates });
2458
+ }
2459
+
2460
+ // ── Numbered section labels ─────────────────────────────────────────────────
2461
+ // Sibling of the repeated-kicker rule: instead of a tracked uppercase word,
2462
+ // the section scaffold is a tiny numeric index riding beside each section
2463
+ // heading — bare and zero-padded, or an index joined to a short micro-label
2464
+ // by a separator glyph. The kicker rule deliberately excludes bare 1-2 digit
2465
+ // labels; this rule owns that shape.
2466
+
2467
+ const NUMBERED_LABEL_TAGS = new Set(['span', 'p', 'div', 'small', 'em', 'strong', 'b']);
2468
+
2469
+ // Returns { index, text } when the trimmed text reads as a section index
2470
+ // label, else null. Two accepted shapes: a zero-padded/two-digit bare index,
2471
+ // or a 1-2 digit index followed by a non-word separator and a short label.
2472
+ function parseNumberedLabelText(rawText) {
2473
+ const text = (rawText || '').replace(/\s+/g, ' ').trim();
2474
+ if (!text || text.length > 40) return null;
2475
+ let m = /^(\d{2})$/.exec(text);
2476
+ if (!m) m = /^(\d{1,2})\s*[^\w\s]\s*\S/.exec(text);
2477
+ if (!m) return null;
2478
+ const index = parseInt(m[1], 10);
2479
+ if (!Number.isFinite(index) || index > 40) return null;
2480
+ return { index, text };
2481
+ }
2482
+
2483
+ function isNumberedSectionLabelCandidate(opts) {
2484
+ const {
2485
+ headingTag, headingText, headingFontSize,
2486
+ labelTag, labelIndex, labelText,
2487
+ labelFontSize, labelLetterSpacing, labelFontWeight,
2488
+ labelFontFamily, labelTextTransform, labelColor,
2489
+ } = opts;
2490
+ if (!['h2', 'h3', 'h4'].includes(headingTag)) return false;
2491
+ if (!headingText || headingText.length < 3) return false;
2492
+ if (!labelTag || !NUMBERED_LABEL_TAGS.has(labelTag)) return false;
2493
+ if (labelIndex == null || !labelText) return false;
2494
+ // Tiny rendered size is the tell — a display-scale section number is a
2495
+ // different (deliberate) device and stays legal.
2496
+ if (!(labelFontSize > 0 && labelFontSize <= 13)) return false;
2497
+ // The heading must be visibly larger where we can resolve its size.
2498
+ // clamp()/var() sizes come back unparseable (0) in the static engine —
2499
+ // the remaining gates carry the check there.
2500
+ if (headingFontSize > 0 && headingFontSize < labelFontSize * 1.3) return false;
2501
+ // Deliberate micro-label styling separates the scaffold from incidental
2502
+ // small text: mono face, bold weight, tracking, uppercase, or accent color.
2503
+ const weight = Number(labelFontWeight) || 400;
2504
+ return /mono/i.test(labelFontFamily || '')
2505
+ || weight >= 600
2506
+ || (labelLetterSpacing || 0) >= 0.5
2507
+ || (labelTextTransform || '') === 'uppercase'
2508
+ || isAccentColor(labelColor || '');
1110
2509
  }
1111
2510
 
1112
- function collectRepeatedSectionKickerCandidates(doc, getStyle, resolveLetterSpacing) {
2511
+ function collectNumberedSectionLabelCandidates(doc, getStyle, resolveLetterSpacing) {
1113
2512
  const candidates = [];
2513
+ const seenLabels = new Set();
1114
2514
  for (const heading of doc.querySelectorAll('h2, h3, h4')) {
1115
2515
  if (heading.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
1116
- const kicker = heading.previousElementSibling;
1117
- if (!kicker || kicker.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
1118
- if (isRepeatedKickerCardContext(heading, kicker)) continue;
2516
+ // The index sits either directly before the heading, or before the
2517
+ // wrapper the heading leads (label | <div><h2>…</h2>…</div>).
2518
+ let label = heading.previousElementSibling;
2519
+ if (!label) {
2520
+ const parent = heading.parentElement;
2521
+ const firstChild = parent?.children?.[0];
2522
+ if (firstChild === heading) label = parent.previousElementSibling;
2523
+ }
2524
+ if (!label || seenLabels.has(label)) continue;
2525
+ if (label.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
2526
+ if (HEADING_TAGS.has(label.tagName.toLowerCase())) continue;
2527
+ if (isRepeatedKickerCardContext(heading, label)) continue;
2528
+
2529
+ const labelText = cleanInlineText(label) || (label.textContent || '').replace(/\s+/g, ' ').trim();
2530
+ const parsed = parseNumberedLabelText(labelText);
2531
+ if (!parsed) continue;
1119
2532
 
1120
2533
  const headingStyle = getStyle(heading);
1121
- const kickerStyle = getStyle(kicker);
2534
+ const labelStyle = getStyle(label);
1122
2535
  const headingText = (heading.textContent || '').replace(/\s+/g, ' ').trim();
1123
- const kickerText = cleanInlineText(kicker) || (kicker.textContent || '').replace(/\s+/g, ' ').trim();
1124
2536
  const headingFontSize = resolveLetterSpacing(headingStyle.fontSize || '', 16) || parseFloat(headingStyle.fontSize) || 0;
1125
- const kickerFontSize = resolveLetterSpacing(kickerStyle.fontSize || '', 16) || parseFloat(kickerStyle.fontSize) || 0;
1126
- const kickerLetterSpacing = resolveLetterSpacing(kickerStyle.letterSpacing || '', kickerFontSize);
2537
+ const labelFontSize = resolveLetterSpacing(labelStyle.fontSize || '', 16) || parseFloat(labelStyle.fontSize) || 0;
1127
2538
 
1128
- if (!isRepeatedKickerCandidate({
2539
+ if (!isNumberedSectionLabelCandidate({
1129
2540
  headingTag: heading.tagName.toLowerCase(),
1130
2541
  headingText,
1131
2542
  headingFontSize,
1132
- kickerTag: kicker.tagName.toLowerCase(),
1133
- kickerText,
1134
- kickerTextTransform: kickerStyle.textTransform || '',
1135
- kickerFontSize,
1136
- kickerLetterSpacing,
2543
+ labelTag: label.tagName.toLowerCase(),
2544
+ labelIndex: parsed.index,
2545
+ labelText: parsed.text,
2546
+ labelFontSize,
2547
+ labelLetterSpacing: resolveLetterSpacing(labelStyle.letterSpacing || '', labelFontSize),
2548
+ labelFontWeight: labelStyle.fontWeight || '',
2549
+ labelFontFamily: labelStyle.fontFamily || '',
2550
+ labelTextTransform: labelStyle.textTransform || '',
2551
+ labelColor: labelStyle.color || '',
1137
2552
  })) {
1138
2553
  continue;
1139
2554
  }
1140
2555
 
2556
+ seenLabels.add(label);
1141
2557
  candidates.push({
2558
+ index: parsed.index,
2559
+ labelText: parsed.text.slice(0, 24),
1142
2560
  headingTag: heading.tagName.toLowerCase(),
1143
2561
  headingText: headingText.replace(/^"|"$/g, '').slice(0, 60),
1144
- kickerText: kickerText.slice(0, 40),
1145
2562
  });
1146
2563
  }
1147
2564
  return candidates;
1148
2565
  }
1149
2566
 
1150
- function checkRepeatedSectionKickersDOM() {
1151
- const candidates = collectRepeatedSectionKickerCandidates(
2567
+ function checkNumberedSectionLabels(opts) {
2568
+ const { candidates, minCount = 2 } = opts;
2569
+ if (!Array.isArray(candidates) || candidates.length < minCount) return [];
2570
+ // A repeated identical number is some other device; the scaffold counts up.
2571
+ const distinctIndices = new Set(candidates.map(c => c.index));
2572
+ if (distinctIndices.size < 2) return [];
2573
+ return candidates.map(candidate => ({
2574
+ id: 'numbered-section-labels',
2575
+ snippet: `tiny numbered label "${candidate.labelText}" beside ${candidate.headingTag} "${candidate.headingText}" (${candidates.length} on page)`,
2576
+ }));
2577
+ }
2578
+
2579
+ function checkNumberedSectionLabelsFromDoc(doc, win) {
2580
+ const candidates = collectNumberedSectionLabelCandidates(
2581
+ doc,
2582
+ (el) => win.getComputedStyle(el),
2583
+ (value, fontSize) => resolveLengthPx(value, fontSize) || 0,
2584
+ );
2585
+ return checkNumberedSectionLabels({ candidates });
2586
+ }
2587
+
2588
+ function checkNumberedSectionLabelsDOM() {
2589
+ const candidates = collectNumberedSectionLabelCandidates(
1152
2590
  document,
1153
2591
  (el) => getComputedStyle(el),
1154
2592
  (value, fontSize) => resolveLengthPx(value, fontSize) || 0,
1155
2593
  );
1156
- return checkRepeatedSectionKickers({ candidates });
2594
+ return checkNumberedSectionLabels({ candidates });
1157
2595
  }
1158
2596
 
1159
2597
  function checkElementMotionDOM(el) {
@@ -1172,7 +2610,14 @@ function checkElementMotionDOM(el) {
1172
2610
  function checkElementGlowDOM(el) {
1173
2611
  const tag = el.tagName.toLowerCase();
1174
2612
  const style = getComputedStyle(el);
1175
- if (!style.boxShadow || style.boxShadow === 'none') return [];
2613
+ const boxShadow = style.boxShadow && style.boxShadow !== 'none' ? style.boxShadow : '';
2614
+ // text-shadow inherits: only check the element that introduces it, so one
2615
+ // declaration doesn't produce a finding on every descendant.
2616
+ let textShadow = style.textShadow && style.textShadow !== 'none' ? style.textShadow : '';
2617
+ if (textShadow && el.parentElement && getComputedStyle(el.parentElement).textShadow === textShadow) {
2618
+ textShadow = '';
2619
+ }
2620
+ if (!boxShadow && !textShadow) return [];
1176
2621
  // Use parent's background — glow radiates outward, so the surrounding context matters
1177
2622
  // If resolveBackground returns null (gradient), try to infer from the gradient colors
1178
2623
  let parentBg = el.parentElement ? resolveBackground(el.parentElement) : resolveBackground(el);
@@ -1195,7 +2640,7 @@ function checkElementGlowDOM(el) {
1195
2640
  cur = cur.parentElement;
1196
2641
  }
1197
2642
  }
1198
- return checkGlow({ tag, boxShadow: style.boxShadow, effectiveBg: parentBg });
2643
+ return checkGlow({ tag, boxShadow, textShadow, effectiveBg: parentBg });
1199
2644
  }
1200
2645
 
1201
2646
  function checkElementAIPaletteDOM(el) {
@@ -1752,7 +3197,7 @@ function checkElementQuality(el, style, tag, window) {
1752
3197
  return checkQuality({ el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect: null, win: window });
1753
3198
  }
1754
3199
 
1755
- function checkElementBorders(tag, style, overrides, resolvedRadius) {
3200
+ function checkElementBorders(tag, style, overrides, resolvedRadius, el = null) {
1756
3201
  const sides = ['Top', 'Right', 'Bottom', 'Left'];
1757
3202
  const widths = {}, colors = {};
1758
3203
  for (const s of sides) {
@@ -1779,7 +3224,12 @@ function checkElementBorders(tag, style, overrides, resolvedRadius) {
1779
3224
  const radius = resolvedRadius != null
1780
3225
  ? resolvedRadius
1781
3226
  : (parseFloat(style.borderRadius) || 0);
1782
- return checkBorders(tag, widths, colors, radius);
3227
+ const ownBg = parseAnyColor(style.backgroundColor);
3228
+ return checkBorders(tag, widths, colors, radius, {
3229
+ tabContext: isTabContextElement(el),
3230
+ statusContext: isStatusContextElement(el),
3231
+ badgeLike: !!(ownBg && (ownBg.a ?? 1) > 0.1),
3232
+ });
1783
3233
  }
1784
3234
 
1785
3235
  function checkElementColors(el, style, tag, window, customPropMap, hasAnchorInheritRule) {
@@ -1820,12 +3270,32 @@ function checkElementColors(el, style, tag, window, customPropMap, hasAnchorInhe
1820
3270
  }
1821
3271
  }
1822
3272
 
3273
+ // Own background: resolve var()/oklch() tokens through the custom-property
3274
+ // map first (mirrors the textColor path above). Without this a chip whose
3275
+ // background is `var(--sev)` reads as no-own-bg in the static engine and
3276
+ // the styled-control contrast exception never engages.
3277
+ let ownBg = (customPropMap ? parseColorResolved(style.backgroundColor, customPropMap) : null)
3278
+ || readOwnBackgroundColor(el, style);
3279
+
3280
+ // Full-cover surface pseudo (static): the cascade pass marks elements
3281
+ // whose ::before/::after paints an opaque covering surface. When the
3282
+ // element itself has no usable own background, that pseudo is the real
3283
+ // surface for contrast purposes.
3284
+ let finalEffectiveBg = effectiveBg;
3285
+ if ((!ownBg || (ownBg.a ?? 1) <= 0.5) && typeof window.getPseudoSurface === 'function') {
3286
+ const pseudoSurface = window.getPseudoSurface(el);
3287
+ if (pseudoSurface) {
3288
+ ownBg = pseudoSurface;
3289
+ finalEffectiveBg = pseudoSurface;
3290
+ }
3291
+ }
3292
+
1823
3293
  return checkColors({
1824
3294
  tag,
1825
3295
  textColor,
1826
- bgColor: readOwnBackgroundColor(el, style),
1827
- effectiveBg,
1828
- effectiveBgStops: effectiveBg ? null : resolveGradientStops(el, window),
3296
+ bgColor: ownBg,
3297
+ effectiveBg: finalEffectiveBg,
3298
+ effectiveBgStops: finalEffectiveBg ? null : resolveGradientStops(el, window),
1829
3299
  fontSize: parseFloat(style.fontSize) || 16,
1830
3300
  fontWeight: parseInt(style.fontWeight) || 400,
1831
3301
  hasDirectText,
@@ -1836,6 +3306,50 @@ function checkElementColors(el, style, tag, window, customPropMap, hasAnchorInhe
1836
3306
  });
1837
3307
  }
1838
3308
 
3309
+ // Static-engine adapter for hover-state contrast. Relies on the static
3310
+ // cascade's hover pass (css-cascade.mjs) exposing a per-element hover style
3311
+ // via window.getHoverStyle — present only when a :hover rule changed the
3312
+ // element's color or background-color relative to its resting state.
3313
+ function checkElementHoverContrast(el, style, tag, window) {
3314
+ if (typeof window.getHoverStyle !== 'function') return [];
3315
+ const hover = window.getHoverStyle(el);
3316
+ if (!hover) return [];
3317
+
3318
+ const directText = [...el.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
3319
+ if (directText.trim().length === 0) return [];
3320
+
3321
+ const textColor = parseAnyColor(hover.color);
3322
+ if (!textColor || (textColor.a != null && textColor.a < 1)) return [];
3323
+
3324
+ const restingOwnBg = parseAnyColor(style.backgroundColor);
3325
+ const hoverOwnBg = parseAnyColor(hover.backgroundColor);
3326
+ const ownBg = hoverOwnBg || restingOwnBg;
3327
+
3328
+ // Effective hover background: the element's own hover bg composited over
3329
+ // whatever sits underneath. Bail when the surface can't be resolved to a
3330
+ // solid color — gradient ancestors are handled (as at rest) by the
3331
+ // resting-state check, not duplicated here.
3332
+ let bg = null;
3333
+ if (ownBg && ownBg.a >= 0.99) {
3334
+ bg = ownBg;
3335
+ } else {
3336
+ const under = resolveBackground(el.parentElement || el, window, null);
3337
+ if (!under) return [];
3338
+ bg = ownBg && ownBg.a > 0.1 ? compositeColorOver(ownBg, under) : under;
3339
+ }
3340
+
3341
+ return checkHoverContrast({
3342
+ tag,
3343
+ textColor,
3344
+ bg,
3345
+ ownBgAlpha: ownBg ? ownBg.a ?? 1 : null,
3346
+ fontSize: parseFloat(style.fontSize) || 16,
3347
+ fontWeight: parseInt(style.fontWeight) || 400,
3348
+ hasDirectText: true,
3349
+ isEmojiOnly: isEmojiOnlyText(directText),
3350
+ });
3351
+ }
3352
+
1839
3353
  function checkElementIconTile(el, tag, window) {
1840
3354
  if (!HEADING_TAGS.has(tag)) return [];
1841
3355
  const sibling = el.previousElementSibling;
@@ -1904,7 +3418,8 @@ function checkElementHeroEyebrow(el, style, tag, window, customPropMap) {
1904
3418
  return checkHeroEyebrow({
1905
3419
  headingTag: tag,
1906
3420
  headingText: el.textContent || '',
1907
- headingFontSize: parseFloat(headingFontSizeRaw) || 0,
3421
+ headingFontSize: resolveHeroHeadingSizePx(headingFontSizeRaw),
3422
+ headingInApplicationContext: !!el.closest?.('[role="tabpanel"], [role="dialog"], [role="application"], dialog'),
1908
3423
  siblingTag: sibling.tagName.toLowerCase(),
1909
3424
  siblingText: sibling.textContent || '',
1910
3425
  siblingTextTransform: sibStyle.textTransform || '',
@@ -1912,6 +3427,11 @@ function checkElementHeroEyebrow(el, style, tag, window, customPropMap) {
1912
3427
  siblingLetterSpacing: resolveLengthPx(letterSpacingRaw, siblingFontSize) || 0,
1913
3428
  siblingFontWeight: fontWeightRaw || '',
1914
3429
  siblingColor: colorRaw || '',
3430
+ // Static cascade marks elements matched by a ::before/::after rule
3431
+ // whose geometry is a short chromatic dash (css-cascade.mjs).
3432
+ siblingHasAccentDashPseudo: typeof window.hasAccentDashPseudo === 'function'
3433
+ ? window.hasAccentDashPseudo(sibling)
3434
+ : false,
1915
3435
  });
1916
3436
  }
1917
3437
 
@@ -1935,8 +3455,10 @@ function checkElementMotion(tag, style) {
1935
3455
  }
1936
3456
 
1937
3457
  function checkElementGlow(tag, style, effectiveBg) {
1938
- if (!style.boxShadow || style.boxShadow === 'none') return [];
1939
- return checkGlow({ tag, boxShadow: style.boxShadow, effectiveBg });
3458
+ const boxShadow = style.boxShadow && style.boxShadow !== 'none' ? style.boxShadow : '';
3459
+ const textShadow = style.textShadow && style.textShadow !== 'none' ? style.textShadow : '';
3460
+ if (!boxShadow && !textShadow) return [];
3461
+ return checkGlow({ tag, boxShadow, textShadow, effectiveBg });
1940
3462
  }
1941
3463
 
1942
3464
  // ─── Section 6: Page-Level Checks ───────────────────────────────────────────
@@ -2046,6 +3568,157 @@ function checkLayout() {
2046
3568
  return findings;
2047
3569
  }
2048
3570
 
3571
+ // Heading rhythm (browser-only): a heading binds to the content it
3572
+ // introduces, so its rendered space above must exceed its space below.
3573
+ // Margins alone can't be trusted (collapsing, flex rows, section padding),
3574
+ // so this measures actual getBoundingClientRect gaps between the heading
3575
+ // and the nearest content genuinely above / below it. Fires only when two
3576
+ // or more headings violate the principle — a single occurrence is noise.
3577
+ function checkHeadingRhythmDOM() {
3578
+ const MIN_VIOLATIONS = 2;
3579
+ const CARD_EXEMPT_HEIGHT = 200;
3580
+ const MAX_BELOW_PX = 160; // beyond this the heading isn't binding to nearby content at all
3581
+ const MIN_DEFICIT_PX = 12;
3582
+
3583
+ function isVisibleFlow(el) {
3584
+ const style = getComputedStyle(el);
3585
+ if (style.display === 'none' || style.visibility === 'hidden') return false;
3586
+ if (parseFloat(style.opacity || '1') <= 0.05) return false;
3587
+ if (style.position === 'absolute' || style.position === 'fixed' || style.position === 'sticky') return false;
3588
+ const rect = el.getBoundingClientRect();
3589
+ return rect.width >= 1 && rect.height >= 1;
3590
+ }
3591
+
3592
+ // Edges only count when they share the heading's column — grid layouts
3593
+ // put content beside a heading, and a far-away element in another column
3594
+ // says nothing about the heading's vertical rhythm.
3595
+ function overlapsX(sr, rect) {
3596
+ return Math.min(sr.right, rect.right) - Math.max(sr.left, rect.left) >= 8;
3597
+ }
3598
+
3599
+ // Does this container draw its own top boundary (background, top border,
3600
+ // shadow)? Crossing out of such a container means the container edge is
3601
+ // the separator above the heading, not raw whitespace — exempt.
3602
+ function hasOwnTopBoundary(el) {
3603
+ const style = getComputedStyle(el);
3604
+ const bg = parseAnyColor(style.backgroundColor || '');
3605
+ if (bg && (bg.a ?? 1) > 0.05) return true;
3606
+ if ((parseFloat(style.borderTopWidth) || 0) > 0) return true;
3607
+ if (style.boxShadow && style.boxShadow !== 'none') return true;
3608
+ return false;
3609
+ }
3610
+
3611
+ // Eyebrows, kickers, and index labels sitting directly on top of a
3612
+ // heading belong to the heading's own cluster — space above is measured
3613
+ // from the top of the cluster, not from the label to the heading.
3614
+ function clusterTop(h, rect) {
3615
+ const headingFontSize = parseFloat(getComputedStyle(h).fontSize) || 16;
3616
+ let topEl = h;
3617
+ let top = rect.top;
3618
+ for (let i = 0; i < 3; i++) {
3619
+ const sib = topEl.previousElementSibling;
3620
+ if (!sib || !isVisibleFlow(sib)) break;
3621
+ const sr = sib.getBoundingClientRect();
3622
+ if (!overlapsX(sr, rect)) break;
3623
+ const gap = top - sr.bottom;
3624
+ if (gap < 0 || gap >= 28 || sr.height > 60) break;
3625
+ const text = (sib.textContent || '').trim();
3626
+ const sibFontSize = parseFloat(getComputedStyle(sib).fontSize) || 16;
3627
+ const labelLike = sibFontSize < headingFontSize * 0.75 || text.length <= 40;
3628
+ if (!labelLike || text.length > 80) break;
3629
+ topEl = sib;
3630
+ top = sr.top;
3631
+ }
3632
+ return { topEl, top };
3633
+ }
3634
+
3635
+ // Nearest content edge strictly above the heading cluster. Walks
3636
+ // previous siblings, then out through ancestors. Skips elements that
3637
+ // vertically overlap (flex-row companions, sticky rails) or sit in
3638
+ // another column. Returns null when nothing qualifies — first content
3639
+ // on the page, or the top of a visually bounded container.
3640
+ function edgeAbove(startEl, top, rect) {
3641
+ let node = startEl;
3642
+ while (node && node !== document.body) {
3643
+ let sib = node.previousElementSibling;
3644
+ while (sib) {
3645
+ if (isVisibleFlow(sib)) {
3646
+ const sr = sib.getBoundingClientRect();
3647
+ if (sr.bottom <= top + 2 && overlapsX(sr, rect)) return sr.bottom;
3648
+ }
3649
+ sib = sib.previousElementSibling;
3650
+ }
3651
+ const parent = node.parentElement;
3652
+ if (!parent || parent === document.body) return null;
3653
+ // Leaving a container upward: if it draws its own top edge, that
3654
+ // edge separates the heading from whatever sits above.
3655
+ if (hasOwnTopBoundary(parent)) return null;
3656
+ node = parent;
3657
+ }
3658
+ return null;
3659
+ }
3660
+
3661
+ // Nearest content edge strictly below the heading — the block the
3662
+ // heading introduces. Crosses wrappers freely (headings often share a
3663
+ // row wrapper with an eyebrow or index label).
3664
+ function edgeBelow(h, rect) {
3665
+ let node = h;
3666
+ while (node && node !== document.body) {
3667
+ let sib = node.nextElementSibling;
3668
+ while (sib) {
3669
+ if (isVisibleFlow(sib)) {
3670
+ const sr = sib.getBoundingClientRect();
3671
+ if (sr.top >= rect.bottom - 2 && overlapsX(sr, rect)) return sr.top;
3672
+ }
3673
+ sib = sib.nextElementSibling;
3674
+ }
3675
+ node = node.parentElement;
3676
+ }
3677
+ return null;
3678
+ }
3679
+
3680
+ function insideSmallCard(h) {
3681
+ let cur = h.parentElement;
3682
+ while (cur && cur !== document.body) {
3683
+ if (isCardLikeDOM(cur)) {
3684
+ const cr = cur.getBoundingClientRect();
3685
+ if (cr.height < CARD_EXEMPT_HEIGHT) return true;
3686
+ }
3687
+ cur = cur.parentElement;
3688
+ }
3689
+ return false;
3690
+ }
3691
+
3692
+ const candidates = [];
3693
+ for (const h of document.querySelectorAll('h2, h3, h4')) {
3694
+ if (!isVisibleFlow(h)) continue;
3695
+ const text = (h.textContent || '').trim().replace(/\s+/g, ' ');
3696
+ if (text.length < 3) continue;
3697
+ const rect = h.getBoundingClientRect();
3698
+ const belowTop = edgeBelow(h, rect);
3699
+ if (belowTop == null) continue; // heading introduces nothing measurable
3700
+ const { topEl, top } = clusterTop(h, rect);
3701
+ const aboveBottom = edgeAbove(topEl, top, rect);
3702
+ if (aboveBottom == null) continue; // first content, or bounded container
3703
+ if (insideSmallCard(h)) continue;
3704
+ const above = Math.max(0, top - aboveBottom);
3705
+ const below = Math.max(0, belowTop - rect.bottom);
3706
+ if (below < 6 || below > MAX_BELOW_PX) continue;
3707
+ // Violation: the space above clearly fails to exceed the space below.
3708
+ // Near-equal gaps are ambiguous rather than inverted, so they pass.
3709
+ if (above < below * 0.75 && below - above >= MIN_DEFICIT_PX) {
3710
+ candidates.push({ el: h, tag: h.tagName.toLowerCase(), text: text.slice(0, 60), above, below });
3711
+ }
3712
+ }
3713
+
3714
+ if (candidates.length < MIN_VIOLATIONS) return [];
3715
+ return candidates.map(c => ({
3716
+ type: 'heading-rhythm',
3717
+ detail: `${c.tag} "${c.text}" has ${Math.round(c.above)}px above vs ${Math.round(c.below)}px below — it reads as bound to the block above (${candidates.length} headings on page)`,
3718
+ el: c.el,
3719
+ }));
3720
+ }
3721
+
2049
3722
  // Node page-level checks — take document/window as parameters
2050
3723
 
2051
3724
  function checkPageTypography(doc, win) {
@@ -2188,6 +3861,135 @@ function checkPageLayout(doc, win) {
2188
3861
  return findings;
2189
3862
  }
2190
3863
 
3864
+ // ── Repeated text inside one container ──────────────────────────────────────
3865
+ // The same literal string rendered 3+ times in structurally different spots
3866
+ // inside one bordered/elevated container — typically a status word wired
3867
+ // into every slot of a card template. Legitimate repetition is structural:
3868
+ // table columns, calendar grids, nav/menu lists, and templated sibling rows
3869
+ // all repeat text in *parallel* positions, so occurrences whose element
3870
+ // paths inside the container are identical (or live in dedicated repetition
3871
+ // structures) never count. Only 3+ occurrences at 3+ distinct structural
3872
+ // positions flag.
3873
+
3874
+ const REPEATED_TEXT_SKIP_SELECTOR = [
3875
+ 'table',
3876
+ 'select',
3877
+ 'datalist',
3878
+ 'nav',
3879
+ 'menu',
3880
+ '[role="navigation"]',
3881
+ '[role="menu"]',
3882
+ '[role="menubar"]',
3883
+ '[role="listbox"]',
3884
+ '[role="grid"]',
3885
+ '[role="tablist"]',
3886
+ '[role="radiogroup"]',
3887
+ '[aria-hidden="true"]',
3888
+ ].join(',');
3889
+
3890
+ const REPEATED_TEXT_CONTAINER_TAGS = new Set([
3891
+ 'div', 'section', 'article', 'aside', 'main', 'figure', 'form', 'fieldset', 'details', 'li',
3892
+ ]);
3893
+
3894
+ // A container worth attributing text to: visibly bounded (border on most
3895
+ // sides or an elevation shadow) and surface-like (radius or own background).
3896
+ function isRepeatedTextContainer(style) {
3897
+ if (!style) return false;
3898
+ const hasShadow = !!(style.boxShadow && style.boxShadow !== 'none' && style.boxShadow !== '');
3899
+ const borderSides = ['Top', 'Right', 'Bottom', 'Left']
3900
+ .filter(side => (parseFloat(style[`border${side}Width`]) || 0) >= 1).length;
3901
+ const hasBorder = borderSides >= 3;
3902
+ const hasRadius = (parseFloat(style.borderRadius) || 0) > 0;
3903
+ const bg = parseRgb(style.backgroundColor) || parseAnyColor(style.backgroundColor);
3904
+ const hasBg = !!(bg && (bg.a ?? 1) > 0.1);
3905
+ return isCardLikeFromProps(hasShadow, hasBorder, hasRadius, hasBg);
3906
+ }
3907
+
3908
+ function collectRepeatedContainerTextFindings(doc, getStyle, opts = {}) {
3909
+ const isVisible = opts.isVisible || (() => true);
3910
+ const findings = [];
3911
+
3912
+ const containers = [];
3913
+ const containerSet = new Set();
3914
+ for (const el of doc.querySelectorAll('*')) {
3915
+ if (!REPEATED_TEXT_CONTAINER_TAGS.has(el.tagName.toLowerCase())) continue;
3916
+ if (el.closest?.(REPEATED_TEXT_SKIP_SELECTOR)) continue;
3917
+ if (!isRepeatedTextContainer(getStyle(el))) continue;
3918
+ containers.push(el);
3919
+ containerSet.add(el);
3920
+ }
3921
+
3922
+ for (const container of containers) {
3923
+ if (!isVisible(container)) continue;
3924
+ const descendants = container.querySelectorAll('*');
3925
+ // Page-scale wrappers that merely happen to carry a background are not
3926
+ // the "one card" this rule reasons about.
3927
+ if (descendants.length > 250) continue;
3928
+
3929
+ const groups = new Map();
3930
+ for (const d of descendants) {
3931
+ // Attribute text to the innermost container only.
3932
+ let anc = d.parentElement;
3933
+ let ownedByInner = false;
3934
+ while (anc && anc !== container) {
3935
+ if (containerSet.has(anc)) { ownedByInner = true; break; }
3936
+ anc = anc.parentElement;
3937
+ }
3938
+ if (ownedByInner) continue;
3939
+ if (d.closest?.(REPEATED_TEXT_SKIP_SELECTOR)) continue;
3940
+ // Icon-font glyph names read as text but render as symbols.
3941
+ if (/icon|material-symbols|(?:^|\s)fa[srlbd]?(?:\s|-|$)/i.test(String(d.getAttribute?.('class') || ''))) continue;
3942
+ if (!isVisible(d)) continue;
3943
+
3944
+ const direct = [...d.childNodes]
3945
+ .filter(n => n.nodeType === 3)
3946
+ .map(n => n.textContent)
3947
+ .join(' ')
3948
+ .replace(/\s+/g, ' ')
3949
+ .trim();
3950
+ if (direct.length < 4 || direct.length > 48) continue;
3951
+ if (!/[a-zA-Z]/.test(direct)) continue;
3952
+
3953
+ // Structural signature: the element path from the occurrence up to
3954
+ // the container. Parallel/templated repetition shares one signature.
3955
+ const sig = [];
3956
+ for (let cur = d; cur && cur !== container; cur = cur.parentElement) {
3957
+ const cls = String(cur.getAttribute?.('class') || '')
3958
+ .trim().split(/\s+/).filter(Boolean).sort().join('.');
3959
+ sig.push(cur.tagName.toLowerCase() + (cls ? `.${cls}` : ''));
3960
+ }
3961
+ if (!groups.has(direct)) groups.set(direct, []);
3962
+ groups.get(direct).push(sig.join('>'));
3963
+ }
3964
+
3965
+ for (const [text, sigs] of groups) {
3966
+ if (sigs.length < 3) continue;
3967
+ if (new Set(sigs).size < 3) continue;
3968
+ findings.push({
3969
+ id: 'repeated-container-text',
3970
+ snippet: `"${text.slice(0, 40)}" rendered ${sigs.length}× in distinct spots inside ${classSelector(container)}`,
3971
+ });
3972
+ }
3973
+ }
3974
+ return findings;
3975
+ }
3976
+
3977
+ function checkRepeatedContainerTextFromDoc(doc, win) {
3978
+ return collectRepeatedContainerTextFindings(
3979
+ doc,
3980
+ (el) => win.getComputedStyle(el),
3981
+ { isVisible: (el) => String(win.getComputedStyle(el).display || '') !== 'none' },
3982
+ );
3983
+ }
3984
+
3985
+ function checkRepeatedContainerTextDOM() {
3986
+ return collectRepeatedContainerTextFindings(
3987
+ document,
3988
+ (el) => getComputedStyle(el),
3989
+ { isVisible: isRenderedForBrowserRule },
3990
+ );
3991
+ }
3992
+
2191
3993
  // ─── Cream / beige palette (the default "tasteful" AI surface) ────────────────
2192
3994
  // A warm, lightly-tinted off-white page background — light, with R≥G≥B and a
2193
3995
  // small warm tint (not white, not a strong color). The current reflex surface.
@@ -2301,7 +4103,7 @@ function checkElementOversizedH1DOM(el) {
2301
4103
  return checkOversizedH1({ tag, fontSize, headingText, rect, viewportWidth, viewportHeight });
2302
4104
  }
2303
4105
 
2304
- // ─── GPT tell: hairline border + wide diffuse shadow (gated --gpt) ────────────
4106
+ // ─── Generated-UI tell: hairline border + wide diffuse shadow ────────────────
2305
4107
  const CSS_COLOR_TOKEN_RE = /(?:rgba?|hsla?|oklch|oklab|lab|lch|color)\([^)]*\)|#[0-9a-fA-F]{3,8}\b|\b(?:black|white|transparent|currentcolor)\b/gi;
2306
4108
 
2307
4109
  function shadowLayerAlpha(layer) {
@@ -2626,13 +4428,653 @@ function checkElementTextOverflowDOM(el) {
2626
4428
  if (el.clientWidth > 0 && delta >= 16) {
2627
4429
  return [{ id: 'text-overflow', snippet: `${classSelector(el)} overflows its box by ${Math.round(delta)}px` }];
2628
4430
  }
4431
+
4432
+ // Inline text owners have no client geometry (clientWidth/scrollWidth are
4433
+ // both 0), so the scrollWidth path above never sees them. Their overflow
4434
+ // registers only on a block ancestor, and that ancestor has no direct text
4435
+ // so the ownership gate skips it. (The shipped miss: a nowrap inline
4436
+ // <span> spilling 45px past its fixed-width grid cell.) Measure the inline
4437
+ // box against the padding box of its nearest block container instead.
4438
+ if (el.clientWidth === 0 && rect && rect.width > 0) {
4439
+ let container = el.parentElement;
4440
+ while (container && container.clientWidth === 0) container = container.parentElement;
4441
+ if (!container) return [];
4442
+ // Transforms make rect comparisons lie; skip anything on that path.
4443
+ for (let p = el; p && p !== container.parentElement; p = p.parentElement) {
4444
+ const t = getComputedStyle(p).transform;
4445
+ if (t && t !== 'none') return [];
4446
+ }
4447
+ const cRect = container.getBoundingClientRect();
4448
+ const contentRight = cRect.left + container.clientLeft + container.clientWidth;
4449
+ const spill = rect.right - contentRight;
4450
+ if (spill >= 16) {
4451
+ return [{ id: 'text-overflow', snippet: `${classSelector(el)} overflows its container by ${Math.round(spill)}px` }];
4452
+ }
4453
+ }
2629
4454
  return [];
2630
4455
  }
2631
4456
 
4457
+ // ---------------------------------------------------------------------------
4458
+ // Blinking cursor (browser-only)
4459
+ // ---------------------------------------------------------------------------
4460
+
4461
+ // Block / underscore glyphs commonly used as a fake text cursor.
4462
+ const CURSOR_GLYPH_RE = /^[_|▀-▟■▮❙❚|]$/;
4463
+
4464
+ // How far down the page still counts as the first-viewport / hero region.
4465
+ // Hero compositions regularly run past a literal viewport height, so the
4466
+ // gate is a landing-region budget, not an exact fold line.
4467
+ const CURSOR_FIRST_VIEWPORT_PX = 1200;
4468
+
4469
+ // Do the named @keyframes only toggle visibility (opacity dropping to ~0 or
4470
+ // visibility:hidden), i.e. a blink rather than a fade/move/spin? Walks the
4471
+ // live CSSOM; cross-origin sheets are skipped.
4472
+ function keyframesToggleVisibilityDOM(name) {
4473
+ if (!name) return false;
4474
+ for (const sheet of document.styleSheets) {
4475
+ let rules;
4476
+ try { rules = sheet.cssRules || sheet.rules; } catch { continue; }
4477
+ if (!rules) continue;
4478
+ const stack = [...rules];
4479
+ while (stack.length) {
4480
+ const rule = stack.shift();
4481
+ if (rule.cssRules && rule.type !== 7) { stack.push(...rule.cssRules); continue; }
4482
+ if (rule.type !== 7 || rule.name !== name) continue; // 7 = KEYFRAMES_RULE
4483
+ let togglesOut = false;
4484
+ for (const frame of rule.cssRules || []) {
4485
+ const fs = frame.style;
4486
+ if (!fs) continue;
4487
+ for (let i = 0; i < fs.length; i++) {
4488
+ const prop = fs[i];
4489
+ if (prop === 'opacity') {
4490
+ if ((parseFloat(fs.getPropertyValue('opacity')) || 0) <= 0.15) togglesOut = true;
4491
+ } else if (prop === 'visibility') {
4492
+ if (/hidden/i.test(fs.getPropertyValue('visibility'))) togglesOut = true;
4493
+ } else if (prop !== 'animation-timing-function') {
4494
+ return false; // keyframes animate something else — not a blink
4495
+ }
4496
+ }
4497
+ }
4498
+ return togglesOut;
4499
+ }
4500
+ }
4501
+ return false;
4502
+ }
4503
+
4504
+ // Decorative blinking cursor: a small block / underscore element bound to an
4505
+ // infinite blink animation, sitting in the first-viewport region of a page.
4506
+ // Real editable surfaces (inputs, textareas, contenteditable, role=textbox)
4507
+ // draw their own caret and are exempt. Round pulsing dots stay with the
4508
+ // pulsing-dot rule.
4509
+ function checkElementBlinkingCursorDOM(el) {
4510
+ const tag = el.tagName.toLowerCase();
4511
+ if (['input', 'textarea', 'select', 'img', 'svg', 'script', 'style'].includes(tag)) return [];
4512
+ const style = getComputedStyle(el);
4513
+
4514
+ const iterations = (style.animationIterationCount || '').split(',').map(s => s.trim());
4515
+ if (!iterations.includes('infinite')) return [];
4516
+ const names = (style.animationName || '').split(',').map(s => s.trim()).filter(n => n && n !== 'none');
4517
+ if (names.length === 0) return [];
4518
+ const blinkName = names.find(n => /blink|caret|cursor/i.test(n))
4519
+ || names.find(n => keyframesToggleVisibilityDOM(n));
4520
+ if (!blinkName) return [];
4521
+
4522
+ // Real caret contexts are exempt.
4523
+ if (el.isContentEditable || el.closest('[contenteditable=""], [contenteditable="true"], [role="textbox"]')) return [];
4524
+
4525
+ const rect = el.getBoundingClientRect();
4526
+ if (rect.width <= 0 || rect.height <= 0) return [];
4527
+
4528
+ // First-viewport gate: the hero cliché, not a footer terminal.
4529
+ const pageTop = rect.top + (window.scrollY || 0);
4530
+ if (pageTop > CURSOR_FIRST_VIEWPORT_PX) return [];
4531
+
4532
+ // Cursor shape: a lone block/underscore glyph, or an empty solid
4533
+ // rectangle sized like a text caret (block or underscore form).
4534
+ const text = (el.textContent || '').trim();
4535
+ const glyphCursor = text.length === 1 && CURSOR_GLYPH_RE.test(text);
4536
+ let blockCursor = false;
4537
+ if (!glyphCursor) {
4538
+ if (text.length > 0 || el.childElementCount > 0) return [];
4539
+ const bg = parseAnyColor(style.backgroundColor || '');
4540
+ const filled = bg && (bg.a ?? 1) > 0.2;
4541
+ const hasBorderFill = ['Left', 'Right', 'Bottom'].some(
4542
+ side => (parseFloat(style[`border${side}Width`]) || 0) >= 1,
4543
+ );
4544
+ if (!filled && !hasBorderFill) return [];
4545
+ const vertical = rect.width >= 1 && rect.width <= 24 && rect.height >= 6 && rect.height <= 48 && rect.height >= rect.width;
4546
+ const underscore = rect.height >= 1 && rect.height <= 6 && rect.width >= 4 && rect.width <= 24;
4547
+ if (!vertical && !underscore) return [];
4548
+ // Round dots are the pulsing-dot rule's territory.
4549
+ const radiusPx = parseFloat(style.borderRadius) || 0;
4550
+ if (radiusPx >= 0.4 * Math.min(rect.width, rect.height)) return [];
4551
+ blockCursor = true;
4552
+ }
4553
+ if (!glyphCursor && !blockCursor) return [];
4554
+
4555
+ // Hero-region promotion: a fake caret blinking in the first ~900px or
4556
+ // inside the page chrome is the shipped hero cliché, not an incidental
4557
+ // flourish. Promote those from the registry's advisory to warning;
4558
+ // lower first-viewport occurrences keep the default severity.
4559
+ const inHeroRegion = pageTop <= 900
4560
+ || !!(el.closest && el.closest('header, nav, [role="banner"], [role="navigation"]'));
4561
+ return [{
4562
+ id: 'blinking-cursor',
4563
+ snippet: `${classSelector(el)} — ${Math.round(rect.width)}x${Math.round(rect.height)}px blinking cursor (animation "${blinkName}") in the first viewport`,
4564
+ ...(inHeroRegion ? { severity: 'warning' } : {}),
4565
+ }];
4566
+ }
4567
+
4568
+ // ---------------------------------------------------------------------------
4569
+ // Content invisible at rest (browser-only, driven by the URL engine)
4570
+ // ---------------------------------------------------------------------------
4571
+
4572
+ // Tags whose text never renders, or whose hidden state is legitimate UI
4573
+ // (templates, dialogs, native select options). Text inside them stays out of
4574
+ // both the numerator and the denominator.
4575
+ const HIDDEN_TEXT_EXCLUDE_TAGS = new Set([
4576
+ 'script', 'style', 'noscript', 'template', 'title', 'head', 'meta', 'link',
4577
+ 'option', 'optgroup', 'select', 'datalist', 'dialog',
4578
+ ]);
4579
+
4580
+ // Measure how many text characters currently render invisible (computed
4581
+ // opacity ~0 or visibility hidden anywhere on the ancestor chain) versus
4582
+ // visible. display:none / [hidden] / aria-hidden subtrees are legitimately
4583
+ // hidden UI (menus, tab panels, templates): they are excluded from the
4584
+ // denominator entirely rather than counted as invisible.
4585
+ function measureHiddenTextDOM() {
4586
+ const cache = new Map();
4587
+ function stateOf(el) {
4588
+ if (!el || el.nodeType !== 1 || el === document.documentElement) return 'visible';
4589
+ const cached = cache.get(el);
4590
+ if (cached) return cached;
4591
+ let state;
4592
+ const tag = el.tagName.toLowerCase();
4593
+ if (HIDDEN_TEXT_EXCLUDE_TAGS.has(tag)) {
4594
+ state = 'excluded';
4595
+ } else {
4596
+ const parentState = stateOf(el.parentElement);
4597
+ if (parentState === 'excluded') {
4598
+ state = 'excluded';
4599
+ } else {
4600
+ const style = getComputedStyle(el);
4601
+ if (style.display === 'none' || el.hidden || el.getAttribute('aria-hidden') === 'true'
4602
+ || String(style.contentVisibility || '').toLowerCase() === 'hidden') {
4603
+ state = 'excluded';
4604
+ } else if (parentState === 'invisible'
4605
+ || (parseFloat(style.opacity) || 0) <= 0.02
4606
+ || /^(hidden|collapse)$/.test(style.visibility)) {
4607
+ state = 'invisible';
4608
+ } else {
4609
+ state = 'visible';
4610
+ }
4611
+ }
4612
+ }
4613
+ cache.set(el, state);
4614
+ return state;
4615
+ }
4616
+
4617
+ let totalChars = 0;
4618
+ let hiddenChars = 0;
4619
+ const hiddenSamples = [];
4620
+ for (const el of document.querySelectorAll('body *')) {
4621
+ let len = 0;
4622
+ for (const node of el.childNodes) {
4623
+ if (node.nodeType === 3) len += node.textContent.replace(/\s+/g, ' ').trim().length;
4624
+ }
4625
+ if (!len) continue;
4626
+ const state = stateOf(el);
4627
+ if (state === 'excluded') continue;
4628
+ totalChars += len;
4629
+ if (state === 'invisible') {
4630
+ hiddenChars += len;
4631
+ if (hiddenSamples.length < 3) {
4632
+ const text = String(el.textContent || '').replace(/\s+/g, ' ').trim().slice(0, 40);
4633
+ if (text) hiddenSamples.push(text);
4634
+ }
4635
+ }
4636
+ }
4637
+ return { totalChars, hiddenChars, hiddenSamples };
4638
+ }
4639
+
4640
+ // Pure threshold check over a measureHiddenTextDOM() result. The URL engine
4641
+ // calls it AFTER a reveal sweep (scroll through the document so every
4642
+ // IntersectionObserver / scroll reveal had its chance to fire, then back to
4643
+ // the top): a healthy reveal-on-scroll page drops to ~0 invisible text after
4644
+ // the sweep, while a page whose reveal script died keeps most of its text at
4645
+ // opacity 0 forever. Fires only when the invisible share stays above 30%
4646
+ // with a real amount of text behind it.
4647
+ function checkContentHiddenAtRest({ totalChars = 0, hiddenChars = 0, hiddenSamples = [] } = {}) {
4648
+ if (totalChars < 200 || hiddenChars < 150) return [];
4649
+ const share = hiddenChars / totalChars;
4650
+ if (share <= 0.3) return [];
4651
+ const sample = hiddenSamples.length ? ` (e.g. "${hiddenSamples[0]}")` : '';
4652
+ return [{
4653
+ id: 'content-hidden-at-rest',
4654
+ snippet: `${Math.round(share * 100)}% of page text (${hiddenChars} of ${totalChars} chars) stays at opacity 0 / visibility hidden after reveal handlers ran${sample}`,
4655
+ }];
4656
+ }
4657
+
4658
+ // ---------------------------------------------------------------------------
4659
+ // Edge-flush cards in horizontal scrollers (browser-only)
4660
+ // ---------------------------------------------------------------------------
4661
+
4662
+ // A visually-defined card (own opaque background, or borders on 2+ sides)
4663
+ // inside a horizontal scroller, sitting flush against one edge of the
4664
+ // scroller's clip box at rest while keeping a clear gutter on the other
4665
+ // side. The canonical bug: the first snap panel is sized wider than the
4666
+ // scroller, so its cards end exactly at the clip edge with their rounded
4667
+ // corners cut, while every sibling panel keeps its inset. Cards that extend
4668
+ // far past the edge are deliberate peeks and stay exempt.
4669
+ function checkEdgeFlushCardsDOM() {
4670
+ const findings = [];
4671
+ const vh = window.innerHeight || 800;
4672
+ const isScroller = (s) => /(auto|scroll)/.test(s.overflowX || '') || /(auto|scroll)/.test(s.overflow || '');
4673
+
4674
+ for (const scroller of document.querySelectorAll('*')) {
4675
+ const style = getComputedStyle(scroller);
4676
+ if (!isScroller(style)) continue;
4677
+ if (scroller.scrollWidth <= scroller.clientWidth + 8) continue;
4678
+ // At rest only: a user-scrolled or snapped-forward scroller legitimately
4679
+ // shows cut cards at both edges.
4680
+ if (scroller.scrollLeft > 4) continue;
4681
+ const scRect = scroller.getBoundingClientRect();
4682
+ if (scRect.width < 120 || scRect.height < 60) continue;
4683
+ // Landing-region gate: the defect matters where the page opens.
4684
+ if (scRect.top + (window.scrollY || 0) > 2 * vh) continue;
4685
+ const contentLeft = scRect.left + scroller.clientLeft;
4686
+ const contentRight = contentLeft + scroller.clientWidth;
4687
+
4688
+ const flush = [];
4689
+ for (const card of scroller.querySelectorAll('*')) {
4690
+ if (!isRenderedForBrowserRule(card)) continue;
4691
+ // Attribute cards to their nearest scroller only (nested scrollers).
4692
+ let owner = card.parentElement;
4693
+ while (owner && owner !== scroller && !isScroller(getComputedStyle(owner))) owner = owner.parentElement;
4694
+ if (owner !== scroller) continue;
4695
+ const cs = getComputedStyle(card);
4696
+ const rect = card.getBoundingClientRect();
4697
+ if (rect.width < 80 || rect.height < 40) continue;
4698
+ const bg = parseAnyColor(cs.backgroundColor || '');
4699
+ const hasBg = !!(bg && (bg.a ?? 1) > 0.5);
4700
+ const borderSides = ['Top', 'Right', 'Bottom', 'Left']
4701
+ .filter(side => (parseFloat(cs[`border${side}Width`]) || 0) > 0).length;
4702
+ if (!hasBg && borderSides < 2) continue;
4703
+ const leftGutter = rect.left - contentLeft;
4704
+ const rightGap = contentRight - rect.right;
4705
+ // Flush right with a left gutter, or the mirror. The -24 floor keeps
4706
+ // deliberately peeking next-cards (cut mid-card) exempt.
4707
+ const flushRight = leftGutter >= 6 && rightGap < 8 && rightGap > -24;
4708
+ const flushLeft = rightGap >= 6 && leftGutter < 8 && leftGutter > -24;
4709
+ if (!flushRight && !flushLeft) continue;
4710
+ flush.push({ card, edge: flushRight ? 'right' : 'left', gap: Math.round(flushRight ? rightGap : leftGutter) });
4711
+ }
4712
+ if (flush.length === 0) continue;
4713
+ const worst = flush.reduce((a, b) => (b.gap < a.gap ? b : a));
4714
+ findings.push({
4715
+ el: scroller,
4716
+ type: 'edge-flush-cards',
4717
+ detail: `${flush.length} card${flush.length === 1 ? '' : 's'} flush against the ${worst.edge} edge of ${classSelector(scroller)} at rest (${worst.gap}px gap, e.g. ${classSelector(worst.card)})`,
4718
+ });
4719
+ }
4720
+ return findings;
4721
+ }
4722
+
4723
+ // ---------------------------------------------------------------------------
4724
+ // Text occlusion / element overlap (browser-only)
4725
+ // ---------------------------------------------------------------------------
4726
+
4727
+ // An opaque decorated box: a near-solid background fill or two-plus visible
4728
+ // borders make it hide whatever sits behind it. Gradient / image fills are
4729
+ // deliberately excluded — a scrim gradient over hero imagery is a contrast
4730
+ // layer, not an occluder, and belongs to the pixel low-contrast rule.
4731
+ function isOpaqueDecoratedBox(cs) {
4732
+ if (!cs) return false;
4733
+ const bg = parseAnyColor(cs.backgroundColor || '');
4734
+ if (bg && (bg.a ?? 1) > 0.6) return true;
4735
+ const borderSides = ['Top', 'Right', 'Bottom', 'Left'].filter((side) => {
4736
+ if ((parseFloat(cs[`border${side}Width`]) || 0) <= 0) return false;
4737
+ const bc = parseAnyColor(cs[`border${side}Color`] || '');
4738
+ return bc && (bc.a ?? 1) > 0.3;
4739
+ }).length;
4740
+ return borderSides >= 2;
4741
+ }
4742
+
4743
+ // Is this element lifted out of normal flow into a layer that can cover
4744
+ // siblings? Two normal-flow blocks stacked vertically cannot truly hide each
4745
+ // other's ink — an overlap between their rects is line-box bleed from tight
4746
+ // leading (a display headline reaching up over the line before it), not
4747
+ // occlusion. Only out-of-flow positioning (absolute / fixed / sticky) moves an
4748
+ // element off its own row onto the pixels of another; an in-place transform or
4749
+ // relative nudge on a display headline does not.
4750
+ function isLayeredElement(el) {
4751
+ for (let cur = el; cur && cur.nodeType === 1 && cur !== document.body; cur = cur.parentElement) {
4752
+ const pos = String(getComputedStyle(cur).position || 'static');
4753
+ if (pos === 'absolute' || pos === 'fixed' || pos === 'sticky') return true;
4754
+ }
4755
+ return false;
4756
+ }
4757
+
4758
+ function elementDirectText(el) {
4759
+ let t = '';
4760
+ for (const node of el.childNodes || []) {
4761
+ if (node.nodeType === 3) t += node.textContent;
4762
+ }
4763
+ return t.trim();
4764
+ }
4765
+
4766
+ // Rendered gate that, unlike isRenderedForBrowserRule, does NOT exempt
4767
+ // aria-hidden subtrees: a decorative aria-hidden box still paints on screen
4768
+ // and can still visually cover real text.
4769
+ function isPaintedForOcclusion(el) {
4770
+ for (let cur = el; cur && cur.nodeType === 1; cur = cur.parentElement) {
4771
+ const style = getComputedStyle(cur);
4772
+ const visibility = String(style.visibility || '').toLowerCase();
4773
+ if (style.display === 'none' || visibility === 'hidden' || visibility === 'collapse') return false;
4774
+ if ((parseFloat(style.opacity) || 0) <= 0.05) return false;
4775
+ if (String(style.contentVisibility || '').toLowerCase() === 'hidden') return false;
4776
+ }
4777
+ return true;
4778
+ }
4779
+
4780
+ // Detects text that is actually painted UNDER an opaque box or another text
4781
+ // run (the reader can't read it), plus two structural overlap tells the
4782
+ // elementFromPoint probe can't reach: a large headline whose edge tucks behind
4783
+ // an opaque card, and an inline element whose leaked padding-box (a common
4784
+ // class-name-collision bug) covers a sibling.
4785
+ //
4786
+ // The occlusion probe is viewport-bound: elementFromPoint only answers for the
4787
+ // scan's current viewport (scroll 0), so the ground-truth paths cover the
4788
+ // first-viewport composition where collisions matter most. The inline-leak
4789
+ // path is pure geometry and runs anywhere on the page.
4790
+ const OCCLUSION_TEXT_SKIP_TAGS = new Set(['script', 'style', 'noscript', 'template', 'title']);
4791
+
4792
+ function checkTextOcclusionDOM() {
4793
+ const findings = [];
4794
+ const seenVictims = new Set();
4795
+ const vw = window.innerWidth || 1280;
4796
+ const vh = window.innerHeight || 800;
4797
+
4798
+ const isFloated = (cs) => {
4799
+ const f = String(cs.cssFloat || cs.float || 'none').toLowerCase();
4800
+ return f === 'left' || f === 'right';
4801
+ };
4802
+ const isMarqueeish = (el, cs) => {
4803
+ if (el.tagName === 'MARQUEE') return true;
4804
+ const ident = `${el.getAttribute?.('class') || ''} ${el.getAttribute?.('id') || ''}`;
4805
+ if (/\b(marquee|ticker|scroller|carousel|conveyor)\b/i.test(ident)) return true;
4806
+ const anim = String(cs.animationName || '').toLowerCase();
4807
+ return /marquee|ticker|scroll/.test(anim);
4808
+ };
4809
+ // A fixed or sticky overlay (status bar, toolbar, sticky header) floats above
4810
+ // scrolling content by design — whatever sits under it at rest scrolls clear,
4811
+ // so it is not occluding the page.
4812
+ const isPinnedOverlay = (el) => {
4813
+ for (let cur = el; cur && cur.nodeType === 1 && cur !== document.body; cur = cur.parentElement) {
4814
+ const pos = String(getComputedStyle(cur).position || 'static');
4815
+ if (pos === 'fixed' || pos === 'sticky') return true;
4816
+ }
4817
+ return false;
4818
+ };
4819
+
4820
+ // Collect renderable text owners in / near the first viewport for the
4821
+ // elementFromPoint probe. SVG <text> counts too.
4822
+ const textEls = [];
4823
+ for (const el of document.querySelectorAll('body *')) {
4824
+ const tag = el.tagName.toLowerCase();
4825
+ if (OCCLUSION_TEXT_SKIP_TAGS.has(tag)) continue;
4826
+ const inSvg = !!el.closest('svg');
4827
+ if (inSvg && tag !== 'text') continue;
4828
+ const text = inSvg ? (el.textContent || '').trim() : elementDirectText(el);
4829
+ if (text.length < 2) continue;
4830
+ if (!isPaintedForOcclusion(el)) continue;
4831
+ let rect; try { rect = el.getBoundingClientRect(); } catch { continue; }
4832
+ if (rect.width < 6 || rect.height < 6) continue;
4833
+ // Viewport-bound probe: keep text whose box overlaps the live viewport.
4834
+ if (rect.bottom <= 0 || rect.top >= vh) continue;
4835
+ textEls.push({ el, rect, text, inSvg });
4836
+ }
4837
+
4838
+ for (const victim of textEls) {
4839
+ const { el, rect, text } = victim;
4840
+ if (seenVictims.has(el)) continue;
4841
+ const style = getComputedStyle(el);
4842
+ if (isScreenReaderOnlyTextStyle(style, { width: rect.width, height: rect.height, clientWidth: el.clientWidth, clientHeight: el.clientHeight })) continue;
4843
+
4844
+ const cols = Math.max(6, Math.min(30, Math.round(rect.width / 12)));
4845
+ const rows = Math.max(1, Math.min(4, Math.round(rect.height / 14)));
4846
+ let total = 0;
4847
+ let occluded = 0;
4848
+ let occluderEl = null;
4849
+ let occluderKind = '';
4850
+ for (let i = 0; i < cols; i++) {
4851
+ const x = rect.left + rect.width * ((i + 0.5) / cols);
4852
+ if (x < 1 || x > vw - 1) continue;
4853
+ for (let j = 0; j < rows; j++) {
4854
+ const y = rect.top + rect.height * ((j + 0.5) / rows);
4855
+ if (y < 1 || y > vh - 1) continue;
4856
+ total++;
4857
+ const top = document.elementFromPoint(x, y);
4858
+ if (!top) continue;
4859
+ // Text visible here: the probe returns the text itself, a descendant,
4860
+ // or one of its ancestors (the text's own container / background).
4861
+ if (top === el || el.contains(top) || top.contains(el)) continue;
4862
+ const topCs = getComputedStyle(top);
4863
+ if (isFloated(topCs) || isMarqueeish(top, topCs) || isPinnedOverlay(top)) continue;
4864
+ const topTag = top.tagName.toLowerCase();
4865
+ // Text sitting under a raw image/video is contrast territory (deduped
4866
+ // against the pixel low-contrast rule); leave those alone here.
4867
+ if (['img', 'video', 'canvas', 'picture'].includes(topTag)) continue;
4868
+ const topHasText = elementDirectText(top).length > 0 || !!top.closest('svg');
4869
+ if (isOpaqueDecoratedBox(topCs)) {
4870
+ occluded++;
4871
+ if (!occluderEl) { occluderEl = top; occluderKind = 'box'; }
4872
+ } else if (topHasText) {
4873
+ occluded++;
4874
+ if (!occluderEl) { occluderEl = top; occluderKind = 'text'; }
4875
+ }
4876
+ }
4877
+ }
4878
+ if (total === 0 || !occluderEl) continue;
4879
+ const occFrac = occluded / total;
4880
+ // A solid box's paint fills its rect, so box coverage is real at a lower
4881
+ // bar. Text coverage rides on elementFromPoint returning the occluder's box
4882
+ // (line box / container), which can exceed its actual glyph ink, so the
4883
+ // text bar is higher — partial overlaps below it are crowding, not burial.
4884
+ if (occFrac < (occluderKind === 'text' ? 0.45 : 0.3)) continue;
4885
+
4886
+ // (i) Substantial occlusion: a real slab of the text is behind something.
4887
+ if (occluderKind === 'text') {
4888
+ // Two SVG texts inside the same emblem (concentric arcs, monogram) are one
4889
+ // decorative unit, not a collision.
4890
+ const victimSvg = el.closest('svg');
4891
+ const occSvg = occluderEl.closest('svg');
4892
+ if (victimSvg && occSvg && victimSvg === occSvg) continue;
4893
+ // Both sides in plain flow: the overlap is line-box bleed from tight
4894
+ // leading (a big headline reaching up over its own eyebrow), not one text
4895
+ // run painted over another.
4896
+ if (!isLayeredElement(el) && !isLayeredElement(occluderEl)) continue;
4897
+ }
4898
+ seenVictims.add(el);
4899
+ findings.push({
4900
+ el,
4901
+ type: 'text-occlusion',
4902
+ detail: `${classSelector(el)} "${text.slice(0, 24)}" is ${Math.round(occFrac * 100)}% covered by ${occluderKind === 'text' ? 'overlapping text' : 'an opaque element'} (${classSelector(occluderEl)})`,
4903
+ });
4904
+ }
4905
+
4906
+ // (ii) Headline overhanging an opaque card: a display-scale line whose bulk
4907
+ // sits outside a bounded content card but whose edge clips into it. The text
4908
+ // may still paint on top and stay readable, but the two layers were dropped
4909
+ // on the same pixels — a placement collision, not a composition.
4910
+ const cards = [];
4911
+ for (const el of document.querySelectorAll('body *')) {
4912
+ if (el.closest('svg')) continue;
4913
+ if (!isPaintedForOcclusion(el)) continue;
4914
+ const cs = getComputedStyle(el);
4915
+ const bg = parseAnyColor(cs.backgroundColor || '');
4916
+ const bgImg = cs.backgroundImage || '';
4917
+ if (!bg || (bg.a ?? 1) <= 0.7) continue;
4918
+ if (bgImg && bgImg !== 'none' && /(gradient|url)\(/i.test(bgImg)) continue;
4919
+ const hasBorder = ['Top', 'Right', 'Bottom', 'Left'].some((s) => (parseFloat(cs[`border${s}Width`]) || 0) > 0);
4920
+ const hasShadow = cs.boxShadow && cs.boxShadow !== 'none';
4921
+ if (!hasBorder && !hasShadow) continue;
4922
+ if (isPinnedOverlay(el)) continue;
4923
+ let cr; try { cr = el.getBoundingClientRect(); } catch { continue; }
4924
+ if (cr.width < 100 || cr.width > 0.8 * vw || cr.height < 60) continue;
4925
+ cards.push({ el, rect: cr });
4926
+ }
4927
+ for (const victim of textEls) {
4928
+ const { el, rect, text } = victim;
4929
+ if (seenVictims.has(el)) continue;
4930
+ const style = getComputedStyle(el);
4931
+ if ((parseFloat(style.fontSize) || 16) < 40) continue;
4932
+ let lineHeight = parseFloat(style.lineHeight);
4933
+ if (!Number.isFinite(lineHeight)) lineHeight = (parseFloat(style.fontSize) || 16) * 1.2;
4934
+ const centerX = rect.left + rect.width / 2;
4935
+ for (const card of cards) {
4936
+ if (card.el === el || el.contains(card.el) || card.el.contains(el)) continue;
4937
+ const ix = Math.max(0, Math.min(rect.right, card.rect.right) - Math.max(rect.left, card.rect.left));
4938
+ const iy = Math.max(0, Math.min(rect.bottom, card.rect.bottom) - Math.max(rect.top, card.rect.top));
4939
+ if (ix < 8 || iy < 0.5 * lineHeight) continue;
4940
+ // The headline's bulk must sit outside the card — only its edge clips in.
4941
+ if (centerX >= card.rect.left && centerX <= card.rect.right) continue;
4942
+ if (ix > 0.5 * rect.width) continue;
4943
+ seenVictims.add(el);
4944
+ findings.push({
4945
+ el,
4946
+ type: 'text-occlusion',
4947
+ detail: `${classSelector(el)} "${text.slice(0, 24)}" overhangs ${classSelector(card.el)} by ${Math.round(ix)}px — the headline and the card collide`,
4948
+ });
4949
+ break;
4950
+ }
4951
+ }
4952
+
4953
+ // (iii) Inline padding leak: an inline element with an opaque background and
4954
+ // large vertical padding paints a filled block whose padding-box overflows
4955
+ // its line (inline padding reserves no vertical space), so the fill lands on
4956
+ // the content above and below instead of enclosing its own text. The
4957
+ // canonical bug is a class-name collision that hands a decorative marker a
4958
+ // payoff card's padding. The tell is a rendered height several times the line
4959
+ // height, which distinguishes the leak from a padded inline highlight.
4960
+ for (const el of document.querySelectorAll('body *')) {
4961
+ if (el.closest('svg')) continue;
4962
+ if (!isPaintedForOcclusion(el)) continue;
4963
+ const cs = getComputedStyle(el);
4964
+ if (cs.display !== 'inline') continue;
4965
+ const bg = parseAnyColor(cs.backgroundColor || '');
4966
+ if (!bg || (bg.a ?? 1) <= 0.6) continue;
4967
+ const padTop = parseFloat(cs.paddingTop) || 0;
4968
+ const padBottom = parseFloat(cs.paddingBottom) || 0;
4969
+ if (padTop + padBottom < 24) continue;
4970
+ let rect; try { rect = el.getBoundingClientRect(); } catch { continue; }
4971
+ if (rect.width < 12 || rect.height < 24) continue;
4972
+ const fontSize = parseFloat(cs.fontSize) || 16;
4973
+ let lineHeight = parseFloat(cs.lineHeight);
4974
+ if (!Number.isFinite(lineHeight)) lineHeight = fontSize * 1.4;
4975
+ // The padding box has to overflow the line by a clear margin — a padded
4976
+ // inline highlight sits at roughly one line height, the leak at several.
4977
+ if (rect.height < 2.2 * lineHeight) continue;
4978
+ if (seenVictims.has(el)) continue;
4979
+ // Name a neighbour the fill lands on, if one is nearby (paint state aside,
4980
+ // reveal-on-scroll siblings still occupy the space it covers).
4981
+ let overlaps = null;
4982
+ for (const other of el.parentElement ? el.parentElement.children : []) {
4983
+ if (other === el || el.contains(other) || other.contains(el)) continue;
4984
+ if (getComputedStyle(other).display === 'none') continue;
4985
+ const oRect = other.getBoundingClientRect();
4986
+ const ix = Math.max(0, Math.min(rect.right, oRect.right) - Math.max(rect.left, oRect.left));
4987
+ const iy = Math.max(0, Math.min(rect.bottom, oRect.bottom) - Math.max(rect.top, oRect.top));
4988
+ if (ix > 4 && iy > 4 && (other.textContent || '').trim().length > 0) { overlaps = other; break; }
4989
+ }
4990
+ seenVictims.add(el);
4991
+ findings.push({
4992
+ el,
4993
+ type: 'text-occlusion',
4994
+ detail: `${classSelector(el)} is an inline element whose opaque fill leaks ${Math.round(rect.height)}px past its line${overlaps ? ` onto ${classSelector(overlaps)}` : ''}`,
4995
+ });
4996
+ }
4997
+
4998
+ return findings;
4999
+ }
5000
+
5001
+ // ---------------------------------------------------------------------------
5002
+ // First-viewport column overflow — the stretched-hero signature (browser-only)
5003
+ // ---------------------------------------------------------------------------
5004
+
5005
+ // A multi-column composition that opens the page (grid/flex with two or more
5006
+ // side-by-side columns, each a real share of the width) where one column's
5007
+ // content runs far past the fold while its sibling fits inside a single
5008
+ // viewport. The row stretches to the tall column, so the short one floats in a
5009
+ // screen-and-a-half of dead space and the fold falls deep inside a single
5010
+ // section. Single-column pages and full-page heroes (no sibling column) are
5011
+ // exempt because there is no fitting sibling to contrast against.
5012
+ function checkFirstViewportColumnOverflowDOM() {
5013
+ const findings = [];
5014
+ const vw = window.innerWidth || 1280;
5015
+ const vh = window.innerHeight || 800;
5016
+ const isMultiCol = (s) => /(^|inline-)(grid|flex)$/.test(String(s.display || ''));
5017
+
5018
+ for (const el of document.querySelectorAll('body *')) {
5019
+ const style = getComputedStyle(el);
5020
+ if (!isMultiCol(style)) continue;
5021
+ let rect; try { rect = el.getBoundingClientRect(); } catch { continue; }
5022
+ if (rect.width < 0.5 * vw) continue;
5023
+ const pageTop = rect.top + (window.scrollY || 0);
5024
+ const pageBottom = pageTop + rect.height;
5025
+ // The fold must fall inside this container: it opens within the first
5026
+ // viewport and runs past it.
5027
+ if (pageTop >= vh * 0.9 || pageBottom <= vh) continue;
5028
+
5029
+ // Direct children that read as side-by-side columns: a real width share,
5030
+ // not full-bleed (stacked single column), sharing the container's top row.
5031
+ const cols = [];
5032
+ for (const child of el.children) {
5033
+ const cs = getComputedStyle(child);
5034
+ if (cs.display === 'none') continue;
5035
+ if (String(cs.position || '') === 'absolute' || String(cs.position || '') === 'fixed') continue;
5036
+ let cr; try { cr = child.getBoundingClientRect(); } catch { continue; }
5037
+ const wShare = cr.width / rect.width;
5038
+ if (wShare < 0.25 || wShare > 0.9) continue;
5039
+ if (cr.height < 40) continue;
5040
+ // Content extent: how far the child's own content actually reaches,
5041
+ // independent of a stretched row height.
5042
+ let contentBottom = cr.top;
5043
+ for (const d of child.querySelectorAll('*')) {
5044
+ const ds = getComputedStyle(d);
5045
+ if (ds.position === 'absolute' || ds.position === 'fixed') continue;
5046
+ if (ds.display === 'none' || ds.visibility === 'hidden') continue;
5047
+ let dr; try { dr = d.getBoundingClientRect(); } catch { continue; }
5048
+ if (dr.width > 0 && dr.height > 0) contentBottom = Math.max(contentBottom, dr.bottom);
5049
+ }
5050
+ cols.push({ child, top: cr.top, contentH: contentBottom - cr.top });
5051
+ }
5052
+ if (cols.length < 2) continue;
5053
+ // Side-by-side: the two candidate columns must share the top row.
5054
+ cols.sort((a, b) => b.contentH - a.contentH);
5055
+ const tall = cols[0];
5056
+ const shortest = cols[cols.length - 1];
5057
+ if (Math.abs(tall.top - shortest.top) > 0.25 * vh) continue;
5058
+ if (tall.contentH <= vh * 1.4) continue;
5059
+ if (shortest.contentH > vh) continue;
5060
+
5061
+ findings.push({
5062
+ el,
5063
+ type: 'first-viewport-column-overflow',
5064
+ detail: `${classSelector(el)} opens the page with one column running ${Math.round(tall.contentH / vh * 100)}% of the viewport tall while a sibling fits in ${Math.round(shortest.contentH / vh * 100)}% — the fold falls deep inside the section`,
5065
+ });
5066
+ }
5067
+ return findings;
5068
+ }
5069
+
2632
5070
  export {
2633
5071
  checkBorders,
2634
5072
  isEmojiOnlyText,
2635
5073
  checkColors,
5074
+ checkHoverContrast,
5075
+ checkElementHoverContrast,
5076
+ parseColorMix,
5077
+ compositeColorOver,
2636
5078
  isCardLikeFromProps,
2637
5079
  checkIconTile,
2638
5080
  resolveSerif,
@@ -2642,6 +5084,17 @@ export {
2642
5084
  checkRepeatedSectionKickers,
2643
5085
  checkMotion,
2644
5086
  checkGlow,
5087
+ scanCssTextForGlow,
5088
+ scanCssTextForGridBackground,
5089
+ scanCssTextForRadialHalo,
5090
+ scanCssTextForPseudoStripe,
5091
+ scanCssTextForInsetStripe,
5092
+ scanCssTextForMarquee,
5093
+ collectMarqueeKeyframes,
5094
+ collectCssCustomProps,
5095
+ cssLengthToPx,
5096
+ scanCssTextForPulsingDot,
5097
+ scanHtmlForShapeAssembledIllustration,
2645
5098
  checkHtmlPatterns,
2646
5099
  readOwnBackgroundColor,
2647
5100
  resolveBackground,
@@ -2662,6 +5115,17 @@ export {
2662
5115
  isRepeatedKickerCandidate,
2663
5116
  collectRepeatedSectionKickerCandidates,
2664
5117
  checkRepeatedSectionKickersDOM,
5118
+ parseNumberedLabelText,
5119
+ isNumberedSectionLabelCandidate,
5120
+ collectNumberedSectionLabelCandidates,
5121
+ checkNumberedSectionLabels,
5122
+ checkNumberedSectionLabelsFromDoc,
5123
+ checkNumberedSectionLabelsDOM,
5124
+ isRepeatedTextContainer,
5125
+ collectRepeatedContainerTextFindings,
5126
+ checkRepeatedContainerTextFromDoc,
5127
+ checkRepeatedContainerTextDOM,
5128
+ checkElementPseudoStripeDOM,
2665
5129
  checkElementMotionDOM,
2666
5130
  checkElementGlowDOM,
2667
5131
  checkElementAIPaletteDOM,
@@ -2700,4 +5164,13 @@ export {
2700
5164
  checkElementClippedOverflowDOM,
2701
5165
  isScreenReaderOnlyTextStyle,
2702
5166
  checkElementTextOverflowDOM,
5167
+ checkHeadingRhythmDOM,
5168
+ checkElementBlinkingCursorDOM,
5169
+ measureHiddenTextDOM,
5170
+ checkContentHiddenAtRest,
5171
+ checkEdgeFlushCardsDOM,
5172
+ isOpaqueDecoratedBox,
5173
+ isLayeredElement,
5174
+ checkTextOcclusionDOM,
5175
+ checkFirstViewportColumnOverflowDOM,
2703
5176
  };