# VitFit V2 — Design System ## Overview VitFit has two distinct UI modes that share a token foundation but diverge significantly in layout and scale. | Mode | Audience | Key Concern | |------|----------|-------------| | **Management** | Coach / Owner on iPad | Touch-optimized admin, forms, navigation | | **Display** | Gym members via AirPlay TV | Readability at 10–20 feet, landscape, full-screen | Both modes pull from the same CSS custom properties. Branding overrides only the properties listed under "Brandable Tokens." Display-mode properties are never overridden by org branding. --- ## CSS File Responsibilities | File | Loaded by | Contents | |------|-----------|----------| | `base.css` | All pages | Reset, all CSS custom properties, typography helpers | | `layout.css` | Management pages | Shell: banner, nav drawer, main content area | | `components.css` | Management pages | Cards, buttons, forms, modals, toasts, badges | | `display.css` | Display pages only (replaces layout + components) | Full-screen display layouts, phase colors | `display.css` is a **replacement**, not an addition. Display pages never load `layout.css` or `components.css`. --- ## CSS Custom Properties All properties are declared on `:root` in `base.css`. Org branding applies overrides to `:root` via JavaScript on page load (see `Branding.apply()` in `core.js`). ### Brand Tokens (overridable per org) ```css :root { /* Identity */ --brand-name: "VitFit"; /* used in JS only, not CSS */ --color-primary: #00FF88; /* main accent: buttons, active states, highlights */ --color-secondary: #4488FF; /* secondary accent: links, secondary actions */ /* Display phase colors — gym owner can customize these */ --color-work: #00FF88; /* active work period */ --color-rest: #4488FF; /* rest period */ --color-move: #FF4444; /* transition / move to next station */ --color-warning: #FFAA00; /* last 10 seconds of any phase */ --color-complete: #FFFFFF; /* done state */ --color-idle: #FFFFFF; /* waiting to start */ } ``` ### Surface & Text Tokens (not overridable) ```css :root { /* Management mode surfaces */ --surface-bg: #0f0f0f; /* page background */ --surface-card: #1a1a1a; /* card / panel background */ --surface-raised: #242424; /* elevated element (dropdown, modal) */ --surface-border: #2e2e2e; /* dividers, input borders */ --surface-hover: #2a2a2a; /* hover state on interactive surfaces */ /* Text */ --text-primary: #f0f0f0; /* primary content */ --text-secondary: #a0a0a0; /* labels, meta, timestamps */ --text-muted: #606060; /* placeholder, disabled */ --text-inverse: #0f0f0f; /* text on colored backgrounds */ --text-on-primary: #0f0f0f; /* text on --color-primary backgrounds */ /* Semantic feedback */ --color-success: #00FF88; /* success state — same as work by default */ --color-danger: #FF4444; /* destructive actions, errors */ --color-info: #4488FF; /* informational */ --color-warning-ui: #FFAA00; /* warning banners in management UI */ /* Display mode — dark background, always fixed */ --display-bg: #1a1a1a; --display-text: #ffffff; } ``` ### Spacing Scale Base unit: 4px. All spacing values are multiples. ```css :root { --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px; --space-16: 64px; --space-20: 80px; --space-24: 96px; } ``` ### Border Radius ```css :root { --radius-sm: 6px; /* inputs, small badges */ --radius-md: 10px; /* cards, buttons */ --radius-lg: 16px; /* modals, bottom sheets */ --radius-full: 9999px; /* pills, circular icons */ } ``` ### Typography Scale — Management Mode Font stack: `system-ui, -apple-system, "Segoe UI", sans-serif` ```css :root { --font-family: system-ui, -apple-system, "Segoe UI", sans-serif; --text-xs: 12px; /* badges, timestamps */ --text-sm: 14px; /* secondary info, table cells */ --text-base: 16px; /* body, form fields */ --text-lg: 18px; /* card titles, section headers */ --text-xl: 22px; /* page titles */ --text-2xl: 28px; /* large headings */ --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700; --weight-black: 900; --line-height-tight: 1.2; --line-height-normal: 1.5; --line-height-loose: 1.75; } ``` ### Typography Scale — Display Mode Sized for readability at 15 feet. These are minimums, not exact values. ```css /* In display.css */ :root { --display-font-primary: 96px; /* main timer, main number */ --display-font-secondary: 48px; /* lap count, set count, total time */ --display-font-label: 32px; /* phase label, section headers */ --display-font-body: 28px; /* workout item list, CrossFit items */ } ``` ### Transitions ```css :root { --transition-fast: 100ms ease; --transition-base: 200ms ease; --transition-slow: 400ms ease; --transition-phase: 600ms ease; /* display mode phase color changes */ } ``` ### Z-Index Scale ```css :root { --z-base: 1; --z-sticky: 10; --z-drawer: 100; --z-modal: 200; --z-overlay: 300; /* offline banner, session-expired overlay */ --z-toast: 400; } ``` --- ## Breakpoints The app targets iPad in landscape as the primary viewport. Phone breakpoints are secondary. ```css /* Mobile-first — but iPad landscape is the primary target */ /* xs: < 480px — phone portrait */ /* sm: 480–767px — phone landscape */ /* md: 768–1023px — iPad portrait */ /* lg: 1024px+ — iPad landscape (primary target) */ @media (min-width: 768px) { /* md — iPad portrait */ } @media (min-width: 1024px) { /* lg — iPad landscape, primary layout */ } ``` iPad landscape (1024×768 or 1194×834 depending on model) is the layout that determines form factor. Phone layouts exist for coaches checking the app on their phone but are not the primary experience. --- ## Management Shell Layout ``` ┌──────────────────────────────────────────┐ │ BANNER (56px) [hamburger] [org name/logo]│ ├──────────────────────────────────────────┤ │ │ │ MAIN CONTENT AREA │ │ max-width: 960px, centered, padding 24px│ │ │ │ │ └──────────────────────────────────────────┘ NAV DRAWER (slides in from left, 280px wide) ┌──────────┐ │ [Logo] │ │ [Org] │ │──────────│ │ Dashboard│ │ Videos │ │ Workouts │ │ ... │ │──────────│ │ Profile │ │ Log Out │ └──────────┘ ``` **Banner:** 56px tall, `--surface-card` background, contains hamburger icon (left) and org name or logo (center or right). Sticky top. **Drawer:** 280px wide, slides in with `transform: translateX(-280px)` → `translateX(0)`. Scrim overlay behind drawer (`--z-drawer`). Tap scrim or swipe left to close. **Main content:** `padding: var(--space-6)` on all sides. `max-width: 960px` centered with `margin: 0 auto`. Prevents over-wide layouts on larger iPads. --- ## Component Patterns ### Buttons Three variants: ``` [Primary] — filled, --color-primary bg, --text-on-primary text [Secondary] — filled, --surface-raised bg, --text-primary text [Danger] — filled, --color-danger bg, white text [Ghost] — no background, --color-primary text, transparent border ``` Size: minimum 44px height for touch targets (Apple HIG requirement). ```css .btn { height: 44px; padding: 0 var(--space-5); border-radius: var(--radius-md); font-size: var(--text-base); font-weight: var(--weight-semibold); cursor: pointer; transition: opacity var(--transition-fast); } .btn:active { opacity: 0.75; } .btn-primary { background: var(--color-primary); color: var(--text-on-primary); } .btn-secondary { background: var(--surface-raised); color: var(--text-primary); } .btn-danger { background: var(--color-danger); color: #fff; } .btn-ghost { background: transparent; color: var(--color-primary); } .btn-sm { height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); } .btn-lg { height: 52px; padding: 0 var(--space-6); font-size: var(--text-lg); } ``` ### Cards ```css .card { background: var(--surface-card); border-radius: var(--radius-md); border: 1px solid var(--surface-border); padding: var(--space-5); } .card-header { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--text-primary); margin-bottom: var(--space-4); } .card-meta { font-size: var(--text-sm); color: var(--text-secondary); } ``` ### Form Fields ```css .form-field { margin-bottom: var(--space-5); } .form-label { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); margin-bottom: var(--space-2); } .form-input, .form-select, .form-textarea { width: 100%; height: 44px; /* min touch target */ padding: 0 var(--space-4); background: var(--surface-raised); border: 1px solid var(--surface-border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: var(--text-base); } .form-textarea { height: auto; padding: var(--space-3) var(--space-4); } .form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--color-primary); outline: none; } .form-error { font-size: var(--text-sm); color: var(--color-danger); margin-top: var(--space-2); } ``` ### Badges Small status indicators. Always short (1–2 words). ```css .badge { display: inline-block; padding: 2px var(--space-2); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; } .badge-success { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--color-success); } .badge-danger { background: color-mix(in srgb, var(--color-danger) 15%, transparent); color: var(--color-danger); } .badge-info { background: color-mix(in srgb, var(--color-info) 15%, transparent); color: var(--color-info); } .badge-neutral { background: var(--surface-raised); color: var(--text-secondary); } ``` ### Modal ``` ┌─────────────────────────────────────┐ │ Modal Title [×] │ header, --surface-raised bg ├─────────────────────────────────────┤ │ Body content area │ padding 24px │ │ ├─────────────────────────────────────┤ │ [Cancel] [Confirm] │ footer, right-aligned actions └─────────────────────────────────────┘ ``` - Max width: 480px, centered horizontally - Fixed position, `--z-modal` - Scrim behind modal: `rgba(0,0,0,0.7)`, `--z-modal - 1` - On iPad: appears as a floating card, not a bottom sheet - Trap focus within modal while open (accessibility) ### Toast Notifications Non-blocking feedback. Appear at bottom-center, auto-dismiss after 3 seconds. ``` [ ✓ Workout saved successfully ] success [ ! Category has videos attached ] warning [ ✗ Upload failed: file too large ] error ``` - Position: fixed, bottom-center, `--z-toast` - Width: max 360px - Stack if multiple: newest on top - Dismiss on tap or after 3s ### Progress Bar Used for disk usage and upload progress. ```css .progress-bar { height: 8px; background: var(--surface-border); border-radius: var(--radius-full); overflow: hidden; } .progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--color-primary); transition: width var(--transition-slow); } .progress-fill.warning { background: var(--color-warning-ui); } .progress-fill.danger { background: var(--color-danger); } ``` --- ## Display Mode ### Structure Display pages are full-screen with no nav, no banner, and no scrolling. The entire page is one viewport. ```css /* display.css */ body { background: var(--display-bg); color: var(--display-text); font-family: var(--font-family); width: 100vw; height: 100dvh; /* dvh: respects Safari dynamic toolbar */ overflow: hidden; cursor: none; /* no visible cursor during display */ display: flex; flex-direction: column; } ``` ### Phase Color Application Phase color is applied to text elements, not the background. Background stays `--display-bg` always. ``` Work → primary text color = var(--color-work) [#00FF88 green] Rest → primary text color = var(--color-rest) [#4488FF blue] Move → primary text color = var(--color-move) [#FF4444 red] Idle → primary text color = var(--color-idle) [#FFFFFF white] Warning (last 10s) → override to var(--color-warning) [#FFAA00 amber] ``` Color transitions use `transition: color var(--transition-phase)` — not background-color transitions, which can cause perceived flicker on the TV. ### Timer Display Layout ``` ┌──────────────────────────────────────────────┐ 100dvh │ WORK LAP 1/2 SET 1/3 5ex │ 48px status bar │ │ │ │ │ 00:28 │ 96px+ timer (center) │ │ │ BICEP CURLS │ 32px exercise name │ │ │ Total 14:32 │ 28px total time (bottom-left) │ │ │[←touch] [touch→] │ invisible 80px edge zones └──────────────────────────────────────────────┘ ``` Coach touch zones (invisible, not shown on TV): - Left 80px strip: previous / stop - Right 80px strip: next - These are `position: absolute` overlays with `opacity: 0` ### Workout Display Layout ``` ┌──────────────────────────────────────────────┐ │ UPPER BODY BLAST June 11 │ status bar │ │ │ Slot 1: Bench Press 10 reps │ │ Slot 2: Dumbbell Fly 12 reps │ │ Slot 3: Tricep Pushdown 8 reps │ │ Slot 4: — │ │ │ │ [touch: close] │ └──────────────────────────────────────────────┘ ``` ### CrossFit Display Layout ``` ┌──────────────────────────────────────────────┐ │ HERO WOD — MURPH June 11 │ │ │ │ 1. 1 mile run │ │ 2. 100 pull-ups │ │ 3. 200 push-ups │ │ 4. 300 air squats │ │ 5. 1 mile run │ │ │ │ [touch: close] │ └──────────────────────────────────────────────┘ ``` ### AirPlay Keep-Alive Animation Prevent AirPlay stream freeze with a constant imperceptible animation: ```css @keyframes keepAlive { 0%, 100% { opacity: 0.995; } 50% { opacity: 1.0; } } .keep-alive { position: fixed; inset: 0; pointer-events: none; animation: keepAlive 4s ease-in-out infinite; } ``` `Display.startKeepAlive()` adds this element to the body on every display page load. ### Offline / Reconnecting Banners ``` [ ⟳ Reconnecting... ] — top-center, semi-transparent, does not block content [ ⬡ Offline — running locally ] — corner indicator, very small, timer continues ``` These are `position: fixed; z-index: var(--z-overlay)` with `pointer-events: none`. --- ## Icon Strategy No icon library dependency. Use: - Unicode symbols for simple cases (✓ ✕ ⟳ ←) - Inline SVG (< 5 elements) for icons that need custom sizing/color - `currentColor` on SVG paths so icons inherit text color No icon fonts. No external CDN icon packages. --- ## Dark Mode The app is **always dark**. No light mode. The `prefers-color-scheme` media query is ignored. This is intentional: gym environments have mixed lighting, and the dark + high-contrast display theme works in all conditions. --- ## Branding Application When `Branding.apply()` runs on page load, it sets these properties on `:root`: ```js // Brandable properties only — never overrides surface/text tokens document.documentElement.style.setProperty('--color-primary', brand.primaryColor); document.documentElement.style.setProperty('--color-secondary', brand.secondaryColor); document.documentElement.style.setProperty('--color-work', brand.workColor); document.documentElement.style.setProperty('--color-rest', brand.restColor); document.documentElement.style.setProperty('--color-move', brand.moveColor); document.documentElement.style.setProperty('--color-warning', brand.warningColor); ``` Branding color inputs in the Owner settings panel are validated for minimum contrast ratio (4.5:1 against `--display-bg`) before saving. Colors that fail contrast are rejected with an inline warning. --- ## Accessibility Notes - All touch targets: minimum 44×44px (Apple HIG) - Focus visible: `:focus-visible` outline uses `--color-primary`, 2px offset - Display mode: WCAG AA is the floor, aim for 7:1+ given viewing distance - Reduced motion: `@media (prefers-reduced-motion: reduce)` — collapse all transitions to 0ms except keep-alive animation (functional, not decorative) ```css @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } .keep-alive { animation: none; } /* keep-alive uses opacity jitter — acceptable to suppress */ } ``` Note: if `.keep-alive` is suppressed by reduced motion, add an alternative keep-alive mechanism (e.g., a `Date.now()` update on a hidden `` every 10s — DOM text change keeps AirPlay active without animation).