CSS Refactoring Analysis
Overview
After reviewing all CSS files in /assets/css, I’ve identified significant duplication that can be consolidated into a shared base file.
Files Analyzed
- homepage.css (454 lines) - Base styles, header, hero, sections
- episode.css (441 lines) - Episode pages
- search.css (271 lines) - Search page
- page.css (293 lines) - Misc resource pages
Total: ~1,459 lines with substantial duplication
Major Duplication Found
1. Purple Gradient Pattern (appears 8+ times)
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
Found in:
homepage.css:.header,.hero,.access-card,.session-group summaryepisode.css:.episode-herosearch.css:.search-heropage.css:.page-hero
Recommendation: Create CSS variable --gradient-primary
2. Hero Section Pattern (3 duplicates)
All three page types have nearly identical hero sections:
episode.css (.episode-hero):
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 3rem 2rem 2rem;
text-align: center;
h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
font-weight: 800;
line-height: 1.2;
}
search.css (.search-hero) - IDENTICAL structure page.css (.page-hero) - IDENTICAL structure
Recommendation: Create shared .hero-section class with variants
3. Content Typography (2 near-duplicates)
The .notes-content (episode.css) and .page-content (page.css) have 95% identical styling:
Both include:
- Identical h1, h2, h3, h4 styling
- Identical paragraph, list, link styling
- Identical code block styling
- Identical blockquote styling
- Identical table styling
- Identical image styling
- Identical hr styling
Lines duplicated: ~150 lines per file = 300 lines total
Recommendation: Create shared .content-area class
4. Card Pattern (3 variations)
Similar card patterns with slight variations:
.episode-card(homepage.css).search-result(search.css).resource-card(page.css)
All share:
- White background
border-radius: 12px- Left border accent (
border-left: 4px solid #667eea) - Hover transform and shadow effects
- Similar padding
Recommendation: Create base .card class with modifiers
5. Section Container Pattern
Repeated across files:
background: white;
padding: 2rem;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
margin: 2rem auto;
Found in:
homepage.css:.sectionepisode.css:.episode-player-section,.episode-notes-sectionsearch.css:.search-sectionpage.css:.page-content-section
Recommendation: Create shared .section-container class
6. Responsive Breakpoints (4 duplicates)
All files use identical breakpoint:
@media (max-width: 768px) { ... }
With similar adjustments:
- Hero h1: 2.5rem → 1.8rem
- Subtitles: reduced
- Padding adjustments
Recommendation: Consolidate responsive utilities
7. Button Styles (multiple variations)
.btn,.btn-primary,.btn-secondary(homepage.css).nav-btn,.nav-btn-prev,.nav-btn-next,.nav-btn-edit(episode.css).search-btn(search.css, homepage.css)
Many shared properties:
padding: 0.75rem 1.5rem(or similar)border-radius: 8pxfont-weight: 600transition: all 0.2s- Hover effects with transform
Recommendation: Create unified button system
8. Color Values (hardcoded throughout)
Repeated color values:
#667eea(primary purple) - 40+ occurrences#764ba2(gradient end) - 8+ occurrences#2c3e50(dark text) - 25+ occurrences#f8f9fa(light background) - 20+ occurrences#e0e0e0(borders) - 15+ occurrences
Recommendation: Use CSS variables
Proposed Refactoring Structure
New File: common.css or base.css
Contains:
- CSS Variables
- Colors (primary, secondary, text, backgrounds, borders)
- Spacing scale
- Border radius values
- Shadow values
- Font sizes
- Reset & Base Styles
- Universal box-sizing
- Body font and colors
- Container max-width
- Header & Footer
- Shared across all pages
- Hero Section Pattern
- Base
.hero-sectionclass - Modifiers for variants
- Base
- Button System
- Base
.btnclass - Color variants (primary, secondary, ghost)
- Size variants
- Base
- Card Pattern
- Base
.cardclass - Hover effects
- Variants
- Base
- Section Container
- White background sections
- Standard padding and shadow
- Content Typography
- Shared
.content-areafor markdown content - All typography, code, table, blockquote styles
- Shared
- Responsive Utilities
- Standard breakpoint mixins/patterns
Updated File Structure
assets/css/
├── common.css (NEW - ~400 lines)
├── homepage.css (REDUCED to ~150 lines)
├── episode.css (REDUCED to ~100 lines)
├── search.css (REDUCED to ~80 lines)
└── page.css (REDUCED to ~50 lines)
Total after refactoring: ~780 lines (46% reduction)
Estimated Savings
- Lines eliminated: ~680 lines (46% reduction)
- Maintenance: Single source for common patterns
- Consistency: Guaranteed visual consistency
- Performance: One shared CSS file cached across pages
Implementation Priority
Phase 1 (High Priority - Most Impact)
- CSS Variables for colors and spacing
- Hero section consolidation
- Content typography (
.content-area) - Button system
Phase 2 (Medium Priority)
- Card pattern consolidation
- Section container pattern
- Header/Footer extraction
Phase 3 (Low Priority - Polish)
- Responsive utilities
- Animation/transition variables
eg.
- Create CSS variables for colors, spacing, shadows, and other design tokens
- Consolidate hero section pattern across episode, search, and page layouts
- Extract shared content typography into .content-area class
- Create unified button system consolidating all button variants
- Consolidate card pattern (.episode-card, .search-result, .resource-card)
- Create shared section container pattern
- Migrate header and footer styles (already done, verify extraction)
- Create responsive utility classes and consolidate breakpoints
- Update animation/transition variables and standardize usage
Migration Notes
- Each page would need to include both
common.cssand its specific CSS - Layout files would add:
<link rel="stylesheet" href="/assets/css/common.css"> - Existing class names can be preserved with aliases during transition
- Can be done incrementally (one section at a time)