|
| 1 | +# Magazine Design Reference |
| 2 | + |
| 3 | +Reference document for `/magazine-edit`. Contains design standards, validation scripts, and patterns learned from session retrospectives. |
| 4 | + |
| 5 | +## WCAG Color Contrast Verification |
| 6 | + |
| 7 | +### Requirements |
| 8 | + |
| 9 | +| Level | Normal text (<18pt) | Large text (≥18pt or ≥14pt bold) | |
| 10 | +|-------|--------------------|---------------------------------| |
| 11 | +| AA (minimum) | 4.5:1 | 3.0:1 | |
| 12 | + |
| 13 | +### Python Verification Script |
| 14 | + |
| 15 | +Run this before finalizing any color pair on dark backgrounds: |
| 16 | + |
| 17 | +```python |
| 18 | +import sys |
| 19 | +def lum(h): |
| 20 | + h=h.lstrip('#'); r,g,b=[int(h[i:i+2],16)/255 for i in(0,2,4)] |
| 21 | + f=lambda c:c/12.92 if c<=0.04045 else((c+.055)/1.055)**2.4 |
| 22 | + return 0.2126*f(r)+0.7152*f(g)+0.0722*f(b) |
| 23 | +def contrast(a,b): |
| 24 | + l1,l2=lum(a),lum(b); mx,mn=max(l1,l2),min(l1,l2) |
| 25 | + return round((mx+.05)/(mn+.05),2) |
| 26 | +# Usage: python3 -c "..." '#ffffff' '#0f0d2e' |
| 27 | +fg,bg=sys.argv[1],sys.argv[2] |
| 28 | +r=contrast(fg,bg) |
| 29 | +print(f'{fg} on {bg}: {r}:1 {"PASS" if r>=4.5 else "FAIL (need 4.5:1)"}') |
| 30 | +``` |
| 31 | + |
| 32 | +### Known Borderline Colors (large text ONLY) |
| 33 | + |
| 34 | +- `#e63946` on `#faf9f6` → 3.96:1 (large text only) |
| 35 | +- `#2ea043` on `#f6f8fa` → 3.17:1 (large text only) |
| 36 | +- `#7c3aed` on `#0d1b2a` → 3.05:1 (large text only) |
| 37 | + |
| 38 | +## Emoji: Use Twemoji Images, Not Native Emoji |
| 39 | + |
| 40 | +Native emoji render differently across platforms. Use Twemoji SVG images instead. |
| 41 | + |
| 42 | +### CDN URL Pattern (pinned to last stable release) |
| 43 | + |
| 44 | +``` |
| 45 | +https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/{CODEPOINT}.svg |
| 46 | +``` |
| 47 | + |
| 48 | +### HTML Usage |
| 49 | + |
| 50 | +```html |
| 51 | +<img src="https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f680.svg" |
| 52 | + alt="rocket" style="width:1.2em;height:1.2em;vertical-align:-0.15em;display:inline-block;"> |
| 53 | +``` |
| 54 | + |
| 55 | +### Codepoint Examples |
| 56 | + |
| 57 | +| Emoji | Codepoint | Filename | |
| 58 | +|-------|-----------|----------| |
| 59 | +| 🚀 | U+1F680 | `1f680.svg` | |
| 60 | +| ⚡ | U+26A1 | `26a1.svg` | |
| 61 | +| 🔥 | U+1F525 | `1f525.svg` | |
| 62 | +| ⭐ | U+2B50 | `2b50.svg` | |
| 63 | + |
| 64 | +Use manual `<img>` tags (not `twemoji.parse()`) for PDF reliability. |
| 65 | + |
| 66 | +## Whitespace Management |
| 67 | + |
| 68 | +### Dense Pages — Bottom Whitespace |
| 69 | + |
| 70 | +| Whitespace | Strategy | |
| 71 | +|------------|----------| |
| 72 | +| < 15mm | Acceptable. Use `<div style="flex:1"></div>` spacer if desired | |
| 73 | +| 15–35mm | Add decorative rule or ornament | |
| 74 | +| > 35mm | Content problem — add more text, increase font size, or merge pages | |
| 75 | + |
| 76 | +### Flex Column Pattern (recommended for all dense pages) |
| 77 | + |
| 78 | +```css |
| 79 | +.page.dense { |
| 80 | + display: flex; |
| 81 | + flex-direction: column; |
| 82 | + padding: 14mm 18mm; |
| 83 | +} |
| 84 | +/* Content grids should NOT stretch cards */ |
| 85 | +.grid-2, .grid-3 { |
| 86 | + align-content: start; /* prevents card stretching */ |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +### Overflow Detection Script |
| 91 | + |
| 92 | +Add to HTML `<script>` during development — shows red overlay on overflowing pages: |
| 93 | + |
| 94 | +```javascript |
| 95 | +if (window.matchMedia('not print').matches) { |
| 96 | + document.querySelectorAll('.page').forEach((p, i) => { |
| 97 | + if (p.scrollHeight > p.clientHeight + 2) { |
| 98 | + p.style.outline = '3px solid red'; |
| 99 | + const l = document.createElement('div'); |
| 100 | + l.style.cssText = 'position:absolute;top:0;left:0;background:red;color:white;font:9px monospace;padding:2px 4px;z-index:9999'; |
| 101 | + l.textContent = `OVERFLOW +${p.scrollHeight - p.clientHeight}px (p${i+1})`; |
| 102 | + p.style.position = 'relative'; p.appendChild(l); |
| 103 | + } |
| 104 | + }); |
| 105 | +} |
| 106 | +``` |
| 107 | + |
| 108 | +## Card Design System |
| 109 | + |
| 110 | +### Tag/Badge Placement: Eyebrow (Above Title) |
| 111 | + |
| 112 | +Tags go ABOVE the title (eyebrow position), not inline or below: |
| 113 | + |
| 114 | +```html |
| 115 | +<div class="card"> |
| 116 | + <div class="card-eyebrow"> |
| 117 | + <span class="tag tag-release">v6</span> |
| 118 | + </div> |
| 119 | + <h3>Astro 6</h3> |
| 120 | + <p>Dev server matches production...</p> |
| 121 | +</div> |
| 122 | +``` |
| 123 | + |
| 124 | +### Section-Scoped Card Styles |
| 125 | + |
| 126 | +| Feature | Dark sections (eco/sec) | Light sections (tools/proj) | |
| 127 | +|---------|------------------------|----------------------------| |
| 128 | +| Card bg | Slightly lighter than page (#1a1d2e vs #0f1119) | White with shadow | |
| 129 | +| Border | Left 3px accent color | Full border thin gray | |
| 130 | +| Code bg | Dark (#252840) | Light (#f0f4f8) | |
| 131 | + |
| 132 | +### Visual Monotony Prevention |
| 133 | + |
| 134 | +1. No 3+ consecutive dense pages without a breather |
| 135 | +2. Each dense page should have at least 1 hero card (spanning full width) |
| 136 | +3. Adjacent pages should use different grid structures (2-col → asymmetric → 3-col) |
| 137 | +4. Alternate accent border direction between pages (left → top) |
| 138 | + |
| 139 | +## CSS Selector Gotchas |
| 140 | + |
| 141 | +### Same-Element vs Descendant Selectors |
| 142 | + |
| 143 | +```css |
| 144 | +/* WRONG: descendant selector — won't match <div class="page s-eco dense"> */ |
| 145 | +.s-eco .dense { padding: 14mm 18mm; } |
| 146 | + |
| 147 | +/* RIGHT: same-element compound selector */ |
| 148 | +.s-eco.dense { padding: 14mm 18mm; } |
| 149 | +``` |
| 150 | + |
| 151 | +Always verify CSS selectors match the actual HTML class structure. |
| 152 | + |
| 153 | +## Verification Workflow |
| 154 | + |
| 155 | +### Pre-Flight Checklist (before declaring "done") |
| 156 | + |
| 157 | +1. **Export PDF** and read every page via `Read` tool — browser preview lies |
| 158 | +2. **WCAG contrast**: run Python script on all text-on-dark-background color pairs |
| 159 | +3. **Overflow**: check no content is clipped at page bottom edges |
| 160 | +4. **Whitespace**: no page has > 35mm unused bottom space |
| 161 | +5. **Selector audit**: grep for `.s-{section} .{class}` patterns — should be `.s-{section}.{class}` for same-element |
| 162 | +6. **Font loading**: verify custom fonts render (not fallback to system fonts) |
| 163 | +7. **Cross-page consistency**: all cards within same section use identical styles |
| 164 | +8. **Names**: all person names verified from Slack/GitHub, never fabricated |
0 commit comments