# hero-section

Full-viewport hero with a looping background video (manual loop with 0.5 s fade so the seam never shows), poster fallback, scrim for contrast, glass nav, display headline and CTA pair. Pauses off-screen, honours reduced motion and Save-Data, has a pause control.

- **Space:** web-development-public (https://github.com/Tech-Realm/space-web-development-public/tree/main/hero-section)
- **Level:** L1 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3, playwright-python, chromium, ffmpeg (optional, to encode your own loop)
- **Routes:** static-local; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use web-development-public/hero-section` or MCP `get_pack web-development-public/hero-section`
- **Files:** CHANGELOG.md, code/_shots/shot-1280-rm.png, code/_shots/shot-1280.png, code/_shots/shot-390-rm.png, code/_shots/shot-390.png, code/hero.js, code/index.html, code/media/hero-loop.mp4, code/media/hero-loop.webm, code/media/hero-poster.jpg, code/style.css, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/fixtures/steps.json, outcome/results.json, pack.yaml, refs/refs.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal
The first screen of a landing page: one clear promise, one primary action, and motion that adds mood without hurting load time, readability or accessibility. Passes on a 390 px phone and on desktop, with and without reduced motion.

## Steps
1. Copy `code/` (index.html hero block, style.css, hero.js, media/).
2. Replace the demo loop: encode your clip to both WebM (VP9) and MP4 (H.264), 6-12 s, no audio, <= 2-4 MB, 1280-1920 px wide:
   `ffmpeg -i in.mp4 -an -vf scale=1600:-2 -c:v libvpx-vp9 -b:v 0 -crf 38 hero-loop.webm` and
   `ffmpeg -i in.mp4 -an -vf scale=1600:-2 -c:v libx264 -crf 26 -preset slow -movflags +faststart hero-loop.mp4`.
   Export a poster from the first frame (`-frames:v 1 hero-poster.jpg`) and preload it.
3. List WebM first, MP4 second (Chromium without proprietary codecs needs WebM; Safari takes MP4).
4. Keep the manual loop in `hero.js`: no `loop` attribute; on `ended` hide, wait 100 ms, rewind, play; the rAF tick keeps opacity 0 for the first and last 0.5 s so the cut is invisible.
5. Keep the scrim gradient; check headline contrast against the brightest frame.
6. Headline 6-10 words, `max-width: 14ch`, fluid `clamp()` size; sub line <= 25 words; CTA pair = primary + ghost.
7. Run the outcome checks; then check LCP (poster or headline should be the LCP element).

## Edge cases
- Autoplay blocked (iOS Low Power, data saver): the poster stays; nothing breaks.
- `prefers-reduced-motion: reduce` or Save-Data: never start the video; entrance animation off.
- Off-screen or background tab: pause (IntersectionObserver + visibilitychange) to save battery.
- `100svh` for mobile browser chrome; avoid `100vh` jumps.
- Long localized headlines: `overflow-wrap: break-word` and the headline-fits-viewport check.

## Don'ts
- Never hotlink NovaMotion or other host media in production; download and re-encode into the project.
- No autoplay with sound; no `crossorigin` games; no video without a pause control when it plays > 5 s.
- Do not put text inside the video; real text stays HTML for SEO and accessibility.
- Do not lazy-load the poster or the hero headline font.



---

Canonical URL: https://logicpacks.io/packs/web-development-public/hero-section

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
