Skip to content

The design language that makes your AI harness better at design.

JavaScript
17.2 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Dark Glow Anti-Patterns — Should Flag vs Should Pass</title>
  <style>
    /* Two-column fixture: left = should flag, right = should pass.
       The dark-glow rule fires when a colored box-shadow appears on a
       child whose ancestor has a dark background. Each column wraps
       its dark-context cases in its own .dark-context section so the
       parent-bg lookup behaves predictably regardless of layout. */
    body { font-family: system-ui, sans-serif; background: #f9fafb; padding: 24px; margin: 0; }
    .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; max-width: 1200px; margin: 0 auto; }
    .col h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 16px; color: #475569; }
    .col h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin: 24px 0 8px; color: #64748b; }
    .note { font-size: 12px; margin: 6px 0 12px; color: #cbd5e1; }
    .dark-context { background: #111827; padding: 16px; border-radius: 12px; }
    .dark-context + .dark-context { margin-top: 12px; }
    /* Card variants: explicit dark vs light pairings, both WCAG AA compliant */
    .card { padding: 14px 16px; border-radius: 10px; margin-bottom: 10px; }
    .card h4 { font-weight: 600; font-size: 13px; margin: 0; }
    .card p { font-size: 12px; margin: 4px 0 0; }
    .card-dark { background: #1f2937; }
    .card-dark h4 { color: #f9fafb; }
    .card-dark p { color: #cbd5e1; }
    .card-light { background: white; }
    .card-light h4 { color: #0f172a; }
    .card-light p { color: #475569; }

    /* ── FLAG: dark background + colored glow ── */
    .glow-blue { box-shadow: 0 0 20px rgba(59, 130, 246, 0.4); }
    .glow-purple { box-shadow: 0 0 25px rgba(139, 92, 246, 0.35); }
    .glow-cyan { box-shadow: 0 0 15px rgba(6, 182, 212, 0.5); }
    .glow-multi { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 0 30px rgba(168, 85, 247, 0.3); }

    /* ── FLAG: modern color formats, var() refs, text-shadow ── */
    :root { --fixture-glow: oklch(0.78 0.14 155); }
    .glow-oklch { box-shadow: 0 0 18px oklch(0.72 0.15 195 / 0.5); }
    .glow-hex { box-shadow: 0 0 16px #3b82f6; }
    .glow-hsl { box-shadow: 0 0 22px hsl(280, 80%, 60%); }
    .glow-var { box-shadow: 0 0 10px var(--fixture-glow); }
    .glow-text h4 { text-shadow: 0 0 12px #22d3ee; }
    /* Zero-offset chromatic halo is slop on light backgrounds too */
    .glow-light-oklch { box-shadow: 0 0 20px oklch(0.65 0.2 300 / 0.45); }
    /* Unreadable surface: url() image ancestor. The zero-offset halo tell
       holds on ANY background, so an unknown surface must not suppress it.
       Both element loops must agree here (the browser adapter once returned
       [] for the whole element on an unresolved surface). */
    .photo-context { background-image: url('/fixtures/antipatterns/missing-photo.png'); padding: 16px; border-radius: 12px; }
    .glow-photo-halo { box-shadow: 0 0 26px rgba(217, 70, 239, 0.5); }
    /* Opaque gradient atop a url() layer: every stop is opaque, so the
       gradient provably covers the image — the surface IS the dark
       gradient, and the dark-background glow tell may score against it
       (browser hunt; the static loop has no gradient hunt). */
    .photo-opaque-grad { background: linear-gradient(#111827, #0b1220), url('/fixtures/antipatterns/missing-photo.png'); padding: 16px; border-radius: 12px; }
    .glow-photo-opaque { box-shadow: 0 6px 22px rgba(249, 115, 22, 0.5); }

    /* ── FLAG: glows that clear the perceptibility floor ── */
    /* 24px of blur at 60% alpha around a 197x40 CTA: 14.4px of light, and a
       halo well inside twice the button's own area. */
    .glow-cta { display: block; width: 197px; height: 40px; box-shadow: 0 0 24px rgba(0, 169, 255, 0.6); }
    /* A stacked elevation ramp on a 96x96 tile. Its first blurred layer is
       under the floor on its own; the layer that carries the light is not, so
       the glow is reported from that layer instead of being passed over. */
    .glow-ramp { display: block; width: 96px; height: 96px; box-shadow: 0 0.7px 0.7px -0.67px rgba(64, 120, 168, 0.37), 0 6.87px 6.87px -2.67px rgba(64, 120, 168, 0.31), 0 13.65px 13.65px -3.33px rgba(64, 120, 168, 0.247); }

    /* ── PASS: same dark/light backgrounds, but neutral or no glow ── */
    .light-colored-shadow { box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15); }
    .dark-normal-shadow { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
    .dark-focus-ring { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); }
    .dark-subtle-shadow { box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2); }
    .dark-elevated-sm { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
    .dark-elevated-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4); }
    .dark-elevated-lg { box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5); }
    .dark-elevated-inset { box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); }
    .dark-elevated-multi { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2); }
    .elevated-sm-light { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
    .elevated-md-light { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
    .elevated-warm-light { box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15); }
    /* Medium-gray card: lighter than dark mode, used to demonstrate "not dark enough" for glow detection. White text for AA contrast. */
    .card-medium { background: #6b7280; }
    .card-medium h4 { color: #ffffff; }
    .card-medium p { color: #ffffff; }
    .medium-gray-shadow { box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3); }
    /* Offset chromatic drop shadow on a light background: a real drop
       shadow, not a halo — must NOT flag under the zero-offset rule.
       (Element path; the page-level text scan caps at one finding.) */
    .light-offset-colored { box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25); }
    /* Achromatic zero-offset shadow: soft ambient elevation, stays legal */
    .light-soft-neutral { box-shadow: 0 0 24px rgba(0, 0, 0, 0.15); }
    /* Offset chromatic shadow under the same unreadable url() surface:
       the dark-background glow tell needs a surface we can read — abstain. */
    .photo-offset-colored { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35); }
    /* Translucent gradient atop a url() layer: the image shows through the
       20% wash, so the real surface is a blend with unknowable pixels (a
       white photo composites to ~#cccccc, not black). Averaging the wash
       stops as if they were the surface scored this "dark" — abstain. */
    .photo-translucent-grad { background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), url('/fixtures/antipatterns/missing-photo.png'); padding: 16px; border-radius: 12px; }
    .photo-translucent-offset { box-shadow: 0 6px 22px rgba(244, 63, 94, 0.45); }
    /* Offset neutral text-shadow on dark card: legibility aid, not a glow */
    .dark-text-offset h4 { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }

    /* ── PASS: chromatic halos too faint to see ── */
    /* A 3x23px typing caret at 38% alpha, caught half faded mid-blink:
       10px of blur times 0.38 times 0.56 is 2.1px of light. */
    .caret-halo { display: block; width: 3px; height: 23px; opacity: 0.56; background: #9b7be8; box-shadow: 0 0 10px 1.5px rgba(155, 123, 232, 0.38); }
    /* 10% alpha over 20px of blur on a 393x42 row: 2px of light. */
    .faint-tint { display: block; width: 393px; height: 42px; box-shadow: 0 4px 20px rgba(149, 100, 255, 0.1); }
    /* A negative spread that swallows its own blur: the light never leaves
       the box, whatever the alpha says. */
    .spread-swallowed { display: block; width: 280px; height: 148px; box-shadow: 0 0 40px -22px rgba(52, 211, 153, 0.4); }
    /* A dropdown parked at opacity 0 until it opens: nothing is on screen. */
    .hidden-menu { display: block; width: 252px; height: 123px; opacity: 0; box-shadow: 0 0 24px rgba(0, 74, 212, 0.2); }

    /* ── PASS (browser): halo out of scale with a tiny element ── */
    /* These clear the strength floor and fail on scale: the lit ring covers
       several times the element's own area, which is an indicator's light
       rather than a treatment on a surface. Only the browser engine can see
       it; a file scan has no layout, so it still reports these two. */
    .status-led { display: block; width: 6px; height: 6px; border-radius: 50%; background: #5cbd68; box-shadow: 0 0 8px rgba(92, 189, 104, 0.5); }
    .pulse-dot { display: block; width: 5px; height: 8px; border-radius: 3px; background: #ffbb65; box-shadow: 0 0 8px rgba(255, 187, 101, 0.7); }
  </style>
</head>
<body>
  <div class="grid">
    <!-- ════════════════════════════════════════════════════════════
         LEFT COLUMN: should flag (dark page + colored glows)
         ═══════════════════════════════════════════════════════════ -->
    <div class="col" data-col="flag">
      <h2>Should flag</h2>

      <h3>CSS colored glows on dark background</h3>
      <div class="dark-context">
        <div class="card card-dark glow-blue">
          <h4>Blue glow</h4>
          <p>box-shadow: 0 0 20px rgba(59, 130, 246, 0.4)</p>
        </div>
        <div class="card card-dark glow-purple">
          <h4>Purple glow</h4>
          <p>box-shadow: 0 0 25px rgba(139, 92, 246, 0.35)</p>
        </div>
        <div class="card card-dark glow-cyan">
          <h4>Cyan glow</h4>
          <p>box-shadow: 0 0 15px rgba(6, 182, 212, 0.5)</p>
        </div>
        <div class="card card-dark glow-multi">
          <h4>Multi-shadow with colored glow</h4>
          <p>Normal shadow + purple glow combined.</p>
        </div>
      </div>

      <h3>Inline-style glow (regex path)</h3>
      <div class="dark-context">
        <div class="card card-dark" style="box-shadow: 0 0 20px rgba(236, 72, 153, 0.5);">
          <h4>Inline pink glow</h4>
          <p>Inline style for regex detection path.</p>
        </div>
      </div>

      <h3>Modern color formats, var() refs, text-shadow</h3>
      <div class="dark-context">
        <div class="card card-dark glow-oklch">
          <h4>OKLCH glow</h4>
          <p>box-shadow: 0 0 18px oklch(0.72 0.15 195 / 0.5)</p>
        </div>
        <div class="card card-dark glow-hex">
          <h4>Hex glow</h4>
          <p>box-shadow: 0 0 16px #3b82f6</p>
        </div>
        <div class="card card-dark glow-hsl">
          <h4>HSL glow</h4>
          <p>box-shadow: 0 0 22px hsl(280, 80%, 60%)</p>
        </div>
        <div class="card card-dark glow-var">
          <h4>Glow via var()</h4>
          <p>box-shadow: 0 0 10px var(--fixture-glow)</p>
        </div>
        <div class="card card-dark glow-text">
          <h4>Glowing text</h4>
          <p>text-shadow: 0 0 12px #22d3ee on the heading.</p>
        </div>
      </div>

      <h3>Zero-offset halo on LIGHT background</h3>
      <div class="card card-light glow-light-oklch">
        <h4>Chromatic halo on light page</h4>
        <p>box-shadow: 0 0 20px oklch(0.65 0.2 300 / 0.45)</p>
      </div>

      <h3>Zero-offset halo on unreadable (image) surface</h3>
      <div class="photo-context">
        <div class="card card-light glow-photo-halo">
          <h4>Halo over photo background</h4>
          <p>box-shadow: 0 0 26px rgba(217, 70, 239, 0.5)</p>
        </div>
      </div>

      <h3>Colored glow under an opaque gradient over an image (browser)</h3>
      <div class="photo-opaque-grad">
        <div class="card card-dark glow-photo-opaque">
          <h4>Opaque dark gradient covers the photo</h4>
          <p>box-shadow: 0 6px 22px rgba(249, 115, 22, 0.5)</p>
        </div>
      </div>

      <h3>Glows above the perceptibility floor</h3>
      <div class="dark-context">
        <div class="glow-cta"></div>
        <p class="note">197x40 CTA, 0 0 24px rgba(0, 169, 255, 0.6).</p>
        <div class="glow-ramp"></div>
        <p class="note">96x96 tile under a six-layer tinted elevation ramp.</p>
      </div>
    </div>

    <!-- ════════════════════════════════════════════════════════════
         RIGHT COLUMN: should pass
         ═══════════════════════════════════════════════════════════ -->
    <div class="col" data-col="pass">
      <h2>Should pass</h2>

      <h3>Light page + colored shadow</h3>
      <div class="card card-light light-colored-shadow">
        <h4>Colored shadow on light background</h4>
        <p>Not dark mode, colored shadow is fine.</p>
      </div>

      <h3>Dark cards with neutral shadows</h3>
      <div class="dark-context">
        <div class="card card-dark dark-normal-shadow">
          <h4>Normal gray shadow on dark card</h4>
          <p>Gray/black shadow is not a glow.</p>
        </div>
        <div class="card card-dark dark-focus-ring">
          <h4>Focus ring (spread, no blur)</h4>
          <p>Functional ring, not decorative glow.</p>
        </div>
        <div class="card card-dark dark-subtle-shadow">
          <h4>Tiny blur (&lt;5px)</h4>
          <p>Too subtle to be "glowing".</p>
        </div>
        <div class="card card-dark dark-elevated-sm">
          <h4>Small dark elevation</h4>
          <p>Subtle shadow on dark card.</p>
        </div>
        <div class="card card-dark dark-elevated-md">
          <h4>Medium dark elevation</h4>
          <p>Standard dark card shadow.</p>
        </div>
        <div class="card card-dark dark-elevated-lg">
          <h4>Large dark elevation</h4>
          <p>Prominent shadow on dark card.</p>
        </div>
        <div class="card card-dark dark-elevated-inset">
          <h4>Inset shadow</h4>
          <p>Inner shadow, not a glow.</p>
        </div>
        <div class="card card-dark dark-elevated-multi">
          <h4>Multi-shadow dark card</h4>
          <p>Layered gray shadows, no color glow.</p>
        </div>
      </div>

      <h3>Medium-gray background (not dark enough)</h3>
      <div class="card card-medium medium-gray-shadow">
        <h4>Not dark enough background</h4>
        <p>Medium gray doesn't qualify as "dark mode".</p>
      </div>

      <h3>Colored drop shadow / neutral halo on light background</h3>
      <div class="card card-light light-offset-colored">
        <h4>Offset colored drop shadow</h4>
        <p>Real drop shadow with a color tint — not a halo.</p>
      </div>
      <div class="card card-light light-soft-neutral">
        <h4>Soft neutral halo</h4>
        <p>Achromatic zero-offset shadow is ambient elevation.</p>
      </div>

      <h3>Offset chromatic shadow on unreadable (image) surface</h3>
      <div class="photo-context">
        <div class="card card-light photo-offset-colored">
          <h4>Offset colored shadow over photo background</h4>
          <p>Surface unknown, offset shadow — abstain, not flag.</p>
        </div>
      </div>

      <h3>Offset chromatic shadow under a translucent gradient over an image</h3>
      <div class="photo-translucent-grad">
        <div class="card card-light photo-translucent-offset">
          <h4>The wash blends with unknowable image pixels</h4>
          <p>Surface unknown — abstain, never score the wash stops as dark.</p>
        </div>
      </div>

      <h3>Neutral text-shadow on dark card</h3>
      <div class="dark-context">
        <div class="card card-dark dark-text-offset">
          <h4>Offset neutral text-shadow</h4>
          <p>Legibility aid, not a glow.</p>
        </div>
      </div>

      <h3>Light elevated cards</h3>
      <div class="card card-light elevated-sm-light">
        <h4>Small elevation (Tailwind shadow-sm)</h4>
        <p>Standard subtle card shadow.</p>
      </div>
      <div class="card card-light elevated-md-light">
        <h4>Medium elevation (Tailwind shadow-md)</h4>
        <p>Standard card shadow.</p>
      </div>
      <div class="card card-light elevated-warm-light">
        <h4>Warm deep shadow</h4>
        <p>Large spread neutral shadow.</p>
      </div>

      <h3>Chromatic halos under the perceptibility floor</h3>
      <div class="dark-context">
        <div class="caret-halo"></div>
        <p class="note">3x23px typing caret, half faded mid-blink.</p>
        <div class="faint-tint"></div>
        <p class="note">393x42 row, 0 4px 20px rgba(149, 100, 255, 0.1).</p>
        <div class="spread-swallowed"></div>
        <p class="note">280x148 panel, 0 0 40px -22px rgba(52, 211, 153, 0.4).</p>
        <div class="hidden-menu"></div>
        <p class="note">252x123 dropdown at opacity 0.</p>
      </div>

      <h3>Halo out of scale with a tiny element (browser only)</h3>
      <div class="dark-context">
        <div class="status-led"></div>
        <p class="note">6x6px status LED with an 8px halo: four times its area.</p>
        <div class="pulse-dot"></div>
        <p class="note">5x8px pulse on a connector: five times its area.</p>
      </div>
    </div>
  </div>
  <script src="/js/detect-antipatterns-browser.js"></script>
</body>
</html>