Design Technologist · AI-Assisted CSS Engineering

Multi-theme scoped component systems, from repeated markup to one variable-driven card.

This showcase documents the complete assignment from raw semantic HTML through prompt engineering, human auditing, and a verified Product Feature Card whose appearance changes by editing only the parent theme class.

01Problem
02CSS Concepts
03Raw HTML
04AI Prompt
05Audit
06Final Result
07Verification
01

Why duplicate component styling fails at scale

Production components need different visual personalities without duplicating the HTML or repeating layout rules.

Before

A card can be copied into light, dark, and specialized environments, but repeated theme-specific component blocks quickly drift. Padding, borders, typography, and interaction rules become harder to audit when every visual variant restates the structure.

Modern approach

Cascade Layers declare where theme variables and component rules belong. Scoped custom properties make the parent wrapper the visual switch, and native nesting keeps each child rule close to the component that owns it.

Duplicated layout Unscoped variables Specificity drift Theme leakage Hardcoded hover colors
02

The CSS systems behind scoped visual transformation

Six coordinated ideas let one Product Feature Card become light, dark, or cyberpunk through parent-owned variables.

03

The repeated semantic card before theme engineering

The HTML already proves that all three cards share the same structure; the browser just has not received the theme system yet.

before.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Week 05 Lab: Multi-Theme Components</title>
</head>
<body>

  <div class="theme-playground">

    <!-- THEME A: LIGHT (Default Elegant) -->
    <div class="theme-container theme--light">
      <article class="themed-card">
        <header class="themed-card__header">
          <span class="themed-card__badge">New Release</span>
          <h3 class="themed-card__title">Minimalist Workspace</h3>
        </header>
        <div class="themed-card__body">
          <p>An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.</p>
        </div>
        <footer class="themed-card__footer">
          <button class="themed-card__btn">Explore Space</button>
        </footer>
      </article>
    </div>

    <!-- THEME B: DARK (Terminal Sleek) -->
    <div class="theme-container theme--dark">
      <article class="themed-card">
        <header class="themed-card__header">
          <span class="themed-card__badge">New Release</span>
          <h3 class="themed-card__title">Minimalist Workspace</h3>
        </header>
        <div class="themed-card__body">
          <p>An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.</p>
        </div>
        <footer class="themed-card__footer">
          <button class="themed-card__btn">Explore Space</button>
        </footer>
      </article>
    </div>

    <!-- THEME C: CYBERPUNK (High-Contrast Neon) -->
    <div class="theme-container theme--cyberpunk">
      <article class="themed-card">
        <header class="themed-card__header">
          <span class="themed-card__badge">New Release</span>
          <h3 class="themed-card__title">Minimalist Workspace</h3>
        </header>
        <div class="themed-card__body">
          <p>An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.</p>
        </div>
        <footer class="themed-card__footer">
          <button class="themed-card__btn">Explore Space</button>
        </footer>
      </article>
    </div>

  </div>

</body>
</html>

Browser defaults only

theme--light

New Release

Minimalist Workspace

An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.

theme--dark

New Release

Minimalist Workspace

The same Product Feature Card still appears in browser-default flow.

theme--cyberpunk

New Release

Minimalist Workspace

The class name is present, but no visual theme has been mapped yet.

04

How the AI prompt became an auditable contract

Each layer describes a testable styling responsibility rather than asking the model to create three unrelated card designs.

Layer 1 — Lock the structure

Preserve the three identical Product Feature Card instances and their parent theme classes.

Layer 2 — Declare the layer order

Require reset, base, themes, and components layers before any rule is written.

Layer 3 — Scope the variables

Place only local custom-property overrides inside the three theme wrapper classes.

Layer 4 — Nest the component

Keep the card, badge, title, body, footer, button, and states nested under the component scope.

Layer 5 — Prevent duplication

Require one structural card system and prohibit repeated padding, layout, and typography inside every theme.

Layer 6 — Demand verification

Make the final audit inspect the single-class swap, cascade layer order, redundancy, focus, zoom, and overflow behavior.

AI prompt
Act as a senior CSS systems engineer. Generate a production-ready stylesheet for the supplied multi-theme Product Feature Card HTML without replacing its structural class system.

Architecture requirements:

1. Establish the cascade layer sequence at the very top of the stylesheet as @layer reset, base, themes, components;.

2. Keep reset behavior in the reset layer and foundational document or playground rules in the base layer so structural responsibilities stay predictable.

3. In the themes layer, declare only scoped custom property overrides for .theme--light, .theme--dark, and .theme--cyberpunk. Do not place layout, spacing, typography, or component declarations in the themes layer.

4. Each theme wrapper must define local variables for --card-bg, --card-text, --card-border, and --card-accent. Add supporting theme variables only when they remain local to the themed component system.

5. In the components layer, style .themed-card and all of its children using native CSS nesting. Keep the header, badge, title, body, footer, button, hover, active, and focus states nested under the parent component scope.

6. All card colors, borders, badge colors, button colors, and button hover states must reference the scoped theme variables rather than hardcoded values inside repeated theme-specific component blocks.

7. Preserve the exact repeated card markup pattern. The only visual switch should come from changing the parent wrapper class from .theme--light to .theme--dark or .theme--cyberpunk.

8. Do not duplicate structural declarations such as padding, grid, gap, border radius, typography scale, or button sizing inside every theme class.

9. Keep the component responsive with logical properties, safe wrapping, readable contrast, visible keyboard focus, reduced-motion handling, and no horizontal overflow at narrow viewport widths.

10. Add concise comments only where they clarify the layer order, scoped variables, native nesting, or the single-class theme-switching audit.

Return only the complete CSS stylesheet.
05

Auditing the generated scoped theme system

The draft only becomes trustworthy after the layer order, scoped variables, native nesting, and single-class swap are inspected.

audited CSS excerpt
@layer reset, base, themes, components;

@layer themes {
  .theme--light {
    --card-bg: oklch(0.99 0.004 255);
    --card-text: oklch(0.23 0.03 255);
    --card-border: oklch(0.86 0.025 255);
    --card-accent: oklch(0.55 0.16 250);
  }

  .theme--dark {
    --card-bg: oklch(0.18 0.025 255);
    --card-text: oklch(0.95 0.012 255);
    --card-border: oklch(0.35 0.035 255);
    --card-accent: oklch(0.76 0.13 185);
  }

  .theme--cyberpunk {
    --card-bg: oklch(0.16 0.055 300);
    --card-text: oklch(0.96 0.025 315);
    --card-border: oklch(0.78 0.22 330);
    --card-accent: oklch(0.88 0.24 145);
  }
}

@layer components {
  .themed-card {
    background-color: var(--card-bg);
    color: var(--card-text);
    border: 1px solid var(--card-border);

    & .themed-card__badge {
      background: var(--card-accent);
    }

    & .themed-card__btn:hover {
      border-color: var(--card-accent);
      box-shadow: 0 0 0.75rem var(--card-accent);
    }
  }
}
redundancy correction
/* Avoid: duplicated structure inside every theme */
.theme--light .themed-card { padding: 2rem; display: grid; }
.theme--dark .themed-card { padding: 2rem; display: grid; }
.theme--cyberpunk .themed-card { padding: 2rem; display: grid; }

/* Prefer: one structure, swapped variables */
.theme--light { --card-bg: white; --card-text: black; }
.theme--dark { --card-bg: black; --card-text: white; }

.themed-card {
  padding: 2rem;
  display: grid;
  background: var(--card-bg);
  color: var(--card-text);
}
Verified: four-layer sequence

The generated stylesheet begins with @layer reset, base, themes, components;.

Verified: theme layer discipline

The themes layer contains custom-property declarations rather than repeated layout rules.

Verified: local variable contract

Each wrapper owns --card-bg, --card-text, --card-border, and --card-accent.

Verified: nested component scope

Card child selectors and states are grouped under .themed-card with native nesting.

Corrected: no duplicated structure

Padding, grid, radius, and button sizing appear once in the component layer.

Corrected: no hardcoded hover colors

Interactive states resolve through scoped variables so each parent theme controls its own feedback.

Verified: single-class switch

Renaming a parent wrapper class changes the theme while the card markup remains untouched.

Verified: accessible interaction

Keyboard focus, hover, active states, readable contrast, and narrow-viewport wrapping remain inspectable.

06

The final Product Feature Cards after the audit

All three cards keep the same internal structure, while each parent wrapper swaps the local visual system.

New Release

Minimalist Workspace

An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.

New Release

Minimalist Workspace

An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.

New Release

Minimalist Workspace

An elegant, distraction-free environment curated specifically for remote software engineers and designers looking for spatial clarity.

One repeated component

The Light, Dark, and Cyberpunk examples keep the same .themed-card child structure.

One theme contract

The wrapper classes swap variables, and the card consumes those variables through var().

One audit move

Changing .theme--light to .theme--cyberpunk in DevTools should transform the first card instantly.

07

Technical verification before deployment

The final component is accepted only after the variable-swap architecture survives direct inspection.

  1. Confirm the generated assignment CSS begins with @layer reset, base, themes, components;.
  2. Confirm the themes layer contains only custom-property overrides for the theme wrappers.
  3. Confirm .theme--light, .theme--dark, and .theme--cyberpunk each define --card-bg, --card-text, --card-border, and --card-accent.
  4. Confirm the .themed-card component and its children are styled in the components layer.
  5. Search the stylesheet for duplicated structural declarations inside the three theme classes.
  6. Confirm all card backgrounds, text, borders, badge colors, button colors, and hover states reference scoped variables.
  7. Open DevTools, rename the first wrapper from theme--light to theme--cyberpunk, and confirm the card visually changes.
  8. Confirm the repeated card HTML remains identical across the three wrapper contexts.
  9. Navigate with the keyboard and verify visible focus on each Explore Space button.
  10. Resize to narrow widths and confirm the three-card playground stacks without horizontal page overflow.
  11. Zoom to 200% and confirm badge, title, paragraph, and button content remain readable.
  12. Switch available portfolio style families and confirm the showcase shell and local demo remain readable.

AI drafted the scoped theme CSS. Human auditing verified layer boundaries, local variables, native nesting, accessibility, and standards compliance.