# QoL and Rules

> Quality-of-life, responsive, accessibility, maintainability, loading, and interaction rules for every future web project. Visual skin catalogs are project-specific; usability contracts are shared.

## 1. Core principle

A project is not finished when it looks good at one desktop width. It is finished when its content, controls, theme system, loading states, and failure states remain understandable and operable on phones, tablets, notebooks, desktops, ultrawide monitors, and TVs.

Design for the content and interaction first, then let the layout adapt. Do not make a “desktop version” and a separate “mobile version” that drift apart. Use one semantic document with responsive CSS and progressive enhancement.

## 2. Supported device classes

Validate at minimum at these representative conditions:

| Class | Representative viewport | Requirements |
| --- | --- | --- |
| Small phone | 320 × 568 | no horizontal page scroll; readable controls; one-column fallback |
| Modern phone | 390 × 844 | touch targets, safe-area spacing, dynamic content |
| Tablet portrait | 768 × 1024 | navigation and cards reflow without cramped columns |
| Tablet landscape / notebook | 1024 × 768 | two-column content where useful; no clipped controls |
| Desktop | 1440 × 900 | comfortable max-width, sensible density, no excessive empty space |
| Wide desktop | 1920 × 1080 | constrain reading width; avoid stretching text lines indefinitely |
| TV / living-room display | 2560 × 1440 or 3840 × 2160 | readable at distance, large focus states, no hover-only behavior |

Also test browser zoom at 200%, text-only zoom where available, landscape rotation, touch simulation, keyboard-only navigation, and reduced-motion preferences.

Do not treat these widths as the only breakpoints. Use content-driven breakpoints and flexible values such as `clamp()`, `min()`, `max()`, `minmax()`, CSS grid, and flexbox. The active portfolio already uses useful patterns such as `repeat(auto-fill, minmax(...))`, `clamp()`, aspect ratios, and horizontal scrolling for dense tab lists; carry those ideas forward while simplifying conflicting media rules.

## 3. Responsive layout contract

### 3.1 Global layout

Every page must have:

```html
<meta name="viewport" content="width=device-width, initial-scale=1">
```

Use a centered content container with a maximum width and fluid side padding:

```css
.container {
  width: min(100% - 2rem, var(--content-max, 82rem));
  margin-inline: auto;
}

@media (min-width: 60rem) {
  .container { width: min(100% - 4rem, var(--content-max, 82rem)); }
}
```

Prefer logical properties such as `margin-inline`, `padding-block`, and `inset-inline-end`. Keep `min-width: 0` on flexible grid and flex children so long text and remote content cannot force overflow.

The page itself must not horizontally scroll. If a particular data structure cannot reflow, contain its overflow inside a labeled region such as `.table-responsive` or a horizontally scrollable tab strip. Never solve overflow with `body { overflow-x: hidden; }` alone because it hides broken content and makes it unreachable.

### 3.2 Grid and cards

Use content-aware grids:

```css
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}
```

Cards must stretch to a consistent row height only when doing so improves scanning. Do not force equal heights that hide text. Use `aspect-ratio` for image frames, `object-fit` for media, and explicit `alt` text.

For game, product, repository, and artist cards:

- make the entire information hierarchy readable without hover;

- use hover only as enhancement;

- provide a click/touch details action when details are initially collapsed;

- keep the details action keyboard accessible;

- do not place a panel outside the viewport on the last card in a row;

- allow long names to wrap or truncate with a visible full-name path;

- ensure card controls remain at least 44 × 44 CSS pixels when practical.

### 3.3 Navigation

Desktop navigation may be horizontal. At constrained widths, use a real menu button and a controlled menu panel. The button must expose its state with `aria-expanded` and reference the controlled region with `aria-controls`.

Do not create a navigation that is visually hidden but still keyboard-focusable. When a menu is closed, either remove it from the focus order or use a correctly managed disclosure pattern. Close it on Escape and when a navigation link is selected. Keep the theme control reachable even when the main navigation collapses.

Dense tabs may become a contained horizontal scroll strip, as used by some of the portfolio skins. Preserve visible active state, allow keyboard focus, and do not make the user guess that the strip scrolls. If there is enough space, use a two-column or vertical tab layout; at smaller widths, switch to a scrollable strip or a native select.

### 3.4 Side-by-side layouts and narrow screens

Use a side-by-side or split-pane layout when two related pieces of information benefit from direct comparison, such as settings beside a live preview, a list beside selected-item details, or source beside output. Let content determine the split ratio, set `min-width: 0` on panes, and keep scrolling local to a pane only when that is clearer than page scrolling.

On narrow phones, collapse the split into a readable vertical flow, tabs, or a disclosure; do not squeeze paragraphs and controls into narrow columns merely to preserve a desktop screenshot. A compact two-column layout is appropriate on small screens only for short, independently labeled items such as paired settings or small metrics. Never create page-level horizontal overflow.

## 4. Touch, keyboard, and TV interaction

Assume there is no mouse. Every important action must work through touch and keyboard.

- Use real buttons for actions and real links for navigation.

- Do not attach an action only to `mouseover`, `mouseenter`, or `hover`.

- Ensure touch targets are approximately 44 × 44 CSS pixels or have adequate spacing.

- Avoid controls that require precise dragging unless a non-drag alternative exists.

- Keep focus visible in every skin and palette.

- Provide `:focus-visible` styling with sufficient contrast and an offset from the control.

- Make focus order follow the visual and reading order.

- On TV-sized layouts, enlarge text and focus indicators rather than relying on small hover highlights.

- Do not use `tabindex` values greater than zero.

- Preserve focus after dynamic rendering; return focus to the trigger when a modal or popover closes.

Example baseline:

```css
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--color-focus, var(--color-accent));
  outline-offset: 3px;
}
```

## 5. Accessibility baseline

Use semantic HTML before ARIA. Every page should have one clear `main`, a logical heading hierarchy, labeled navigation/regions, and descriptive link text. Do not use a heading only because it provides a desired font size.

Images require meaningful `alt` text. Decorative images use `alt=""`. Images inserted dynamically must receive equivalent treatment. Video and audio need accessible names and, where applicable, captions, transcripts, or a text summary.

For interactive components:

- tabs need a clear active state and a relationship between tab and panel;

- carousels need previous/next controls, current position, and a pause or reduced-motion path;

- dialogs need a label, Escape handling, focus management, and a visible close button;

- disclosure buttons need expanded/collapsed state;

- loading regions need a useful status without trapping focus;

- error states need a human-readable explanation and a retry or fallback when possible.

The current site has a good foundation in `aria-label`, `aria-expanded`, `aria-current`, `hidden`, lazy loading, and reduced-motion selectors. Preserve those patterns, but audit every dynamically generated control and ensure all generated HTML is escaped or created through DOM APIs. Skeleton placeholders, menus, tooltips, custom selects, and sliders must expose their state and accessible names without adding noisy announcements.

## 6. Theme and palette integration

Every page and component must consume the shared theme/palette tokens defined in `theme-pallete.md`. Do not make a new project look “responsive” while leaving its colors, borders, shadows, hover states, modal surfaces, and loading states outside the theme system.

For every component, verify at least:

- the site's own project-default skin, mode, and palette;

- light and dark mode where the site offers both;

- at least one additional skin in both modes when the site exposes skin switching;

- one expressive or high-saturation palette when the site exposes palette choices;

- loading, empty, error, disabled, hover, focus, active, and selected states.

Avoid visual effects that destroy contrast. A gradient, translucent surface, backdrop blur, animated border, or scanline overlay must not reduce readability or cover a focus ring. Turn off expensive decoration when the user enables reduced motion or an effects toggle.

## 7. Content and component rules

Use stable, reusable component patterns for the recurring ecosystem content:

- header and responsive navigation;

- theme/skin/palette picker;

- cards and card grids;

- tabs and project panels;

- tables and responsive data views;

- carousels and galleries;

- modals and drawers;

- loading, empty, and error states;

- external-link actions;

- social/contact lists;

- media players.

Each component should document its required markup, states, events, and theme tokens. Keep content data separate from rendering logic when a list is dynamic. The portfolio's games, artists, promotional products, repositories, and project panels are good candidates for this separation. Prefer the interaction and visual patterns below when they improve clarity; use them selectively rather than decorating every control.

Do not hide important information inside a hover-only overlay. Do not replace readable text with icons on smaller screens without an accessible label. Do not use emoji as a required functional icon when Font Awesome or a semantic text label is available.

### 7.1 Skeleton loading and reveal

Render the page shell and meaningful structure immediately; do not leave the site or a major content region blank while data, images, or a component loads. Use a themed skeleton that approximates the final content's dimensions and hierarchy, reserve media aspect ratios, and replace the skeleton when real content is ready. Mark the updating region with `aria-busy="true"` while loading and provide one concise status announcement where useful. Do not expose every decorative skeleton bar as separate content to assistive technology. A shimmer/reveal is optional, not required for meaning; keep it subtle and honor reduced motion. If loading fails, replace the skeleton with a clear error, retry, or fallback rather than leaving an indefinite placeholder.

### 7.2 Theme-aware tooltips

Tooltips should use the site's semantic surface, text, border, shadow, and accent tokens, so their colors and shape fit the active skin and palette. Provide the same information on keyboard focus as on hover; on touch, use a tap-operable disclosure or an inline/help alternative. Associate descriptive tooltip text with its trigger using an appropriate accessible relationship such as `aria-describedby`. Do not put required instructions, labels, or essential content only in a tooltip. Keep it within the viewport, avoid pointer gaps that cause flicker, and dismiss it predictably.

### 7.3 Magnetic and other sliders

Use a slider as the standard control when the user chooses a continuous or stepped value (for example, zoom, speed, volume, or a range filter). Prefer a magnetic/snapping treatment when it makes target values easier to understand; keep a native `<input type="range">` as the accessible source of truth where practical. Provide a programmatic label, meaningful min/max/step, visible current value or scale labels, clear focus and thumb states, and keyboard operation. Support touch and pointer input; never make dragging the only way to set the value. Respect the active skin/palette and reduced motion. The React Bits Comet Dial can inspire a specialized dial-like presentation, but it must preserve these slider semantics.

### 7.4 Dropdown menus and enhanced selects

Use a dropdown menu for a small set of related actions or navigation choices, and a select/listbox for choosing a value. Theme the surface, separators, selected/disabled states, focus ring, and shadow with semantic tokens. Open from a real button with an accessible name and an exposed expanded state; support keyboard navigation, Escape dismissal, appropriate focus return, and touch. Prefer a native `<select>` when it is sufficient; if using a custom select such as React Bits Glide Select, preserve label, value, form submission, disabled state, and keyboard behavior. Do not add ARIA menu roles to ordinary links or options unless implementing the corresponding keyboard interaction model.

### 7.5 Branched menus and nested navigation

Use a branched menu only when the information architecture genuinely has expandable levels. Make parent/expanded state explicit, keep each branch reachable by keyboard and touch, and show clear connectors or hierarchy cues without relying on color alone. Avoid deep nesting; provide a useful mobile presentation and close behavior. React Bits Branched Menu is a visual reference, not a requirement to adopt a new framework.

### 7.6 Spring checks and task controls

Animated checkboxes may reinforce a completed task, but use a native checkbox or equivalent semantic control as the state source. Expose checked/unchecked state, label the task, support keyboard/touch, and make completion understandable without animation or color. Keep spring motion brief and disable it under reduced motion.

External links opened in a new tab should normally include `rel="noopener noreferrer"` when appropriate. Link text should tell the user where it goes; “link” alone is not descriptive enough.

### Windowed overlays and desktop-style tools

When a store, launcher, inspector, media browser, or other substantial overlay behaves like an application window, implement it as a reusable **window component**, not as an unstructured centered modal.

The window pattern must provide:

- a visible title bar and descriptive title;

- close control with an accessible name;

- minimize/collapse behavior when the window contains enough content to justify it;

- maximize and restore behavior;

- pointer/touch dragging through the title bar;

- keyboard access to every title-bar control;

- resize behavior with a visible resize affordance and minimum dimensions;

- Escape-to-close, plus an explicit close button;

- focus moved into the window when it opens and returned to the trigger when it closes;

- a contained scrolling body so resizing never causes the page itself to overflow;

- a mobile fallback where the window becomes a bottom sheet or nearly full-screen panel.

Dragging and resizing are enhancements, not the only way to access content. The window must open in a sensible position, remain inside the viewport, work without a mouse, and remain usable when pointer events, animation, or advanced CSS are unavailable. Do not require a user to drag a window to discover its content.

Use semantic structure similar to:

```html
<div class="window-overlay" aria-hidden="true">
  <section class="window" role="dialog" aria-modal="true" aria-labelledby="window-title" tabindex="-1">
    <header class="window-titlebar">
      <h2 id="window-title">Store</h2>
      <div class="window-controls">
        <button type="button" aria-label="Minimize Store">−</button>
        <button type="button" aria-label="Maximize Store">□</button>
        <button type="button" aria-label="Close Store">×</button>
      </div>
    </header>
    <div class="window-body">…</div>
    <div class="window-resize-handle" aria-hidden="true"></div>
  </section>
</div>
```

Keep the title bar controls out of the drag gesture, use pointer events with a touch-safe `touch-action`, clamp the geometry to the viewport, and remove or disable the resize affordance while maximized. Persist window geometry only if that improves the product; never restore an off-screen position without clamping it first.

## 8. Data fetching and failure behavior

Remote data is optional enhancement. The base page must render useful content before GitHub, media, promotional, or third-party requests complete.

For every fetch or remote widget:

1. show an appropriately themed loading state;

1. handle non-2xx responses and timeouts;

1. handle malformed data without breaking the page;

1. render a concise error state with retry or an alternate link;

1. escape user/remote values before inserting them into HTML;

1. avoid repeated requests when a cached result is valid;

1. do not expose tokens or private data in client-side code.

Use a bounded request strategy for APIs such as GitHub. Respect rate limits, avoid requesting data the page does not display, and do not let a failed external request block navigation or the rest of the page.

## 9. Images, video, and layout stability

All media must be responsive:

```css
img,
video,
svg {
  max-width: 100%;
}

.media-frame {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.media-frame > img,
.media-frame > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
```

Use a deliberate `object-fit` choice. Screenshots often need `contain`; cover art often needs `cover`. Provide width/height attributes or an aspect ratio to prevent layout shift. Use lazy loading below the fold, but do not lazy-load the primary content required for first paint.

Do not autoplay audio. Do not start a background video or continuous particle system on a low-power device without respecting reduced motion and performance. For remote images, provide an error placeholder that uses the active theme instead of a hard-coded unrelated color.

## 10. Motion and performance

Animations should communicate a state change or reinforce the visual identity; they should not run continuously just because empty space exists. Honor `prefers-reduced-motion` globally, not only in selected skins. Use each site's active skin, mode, and palette to theme its animated background. On the main site, One Piece Ocean's waves and clouds/birds should move slowly and naturally; Kaiju War's lightning may pulse more sharply, but must derive its colors from the active palette and remain behind content with readable text and focus states.

Avoid expensive work on scroll and resize. Use passive listeners where appropriate, throttle or debounce layout calculations, and prefer CSS for simple transitions. Clean up event listeners, timers, observers, and media-player instances when a component is destroyed or replaced.

Do not render hundreds of decorative particles on every page without a budget. Keep animated layers `pointer-events: none`, behind content, and removable. Prefer a few compositor-friendly CSS/SVG layers over repeated DOM particles. Disable continuous skin animation under `prefers-reduced-motion`, leaving a non-animated visual treatment where useful. Test with CPU throttling and a mobile device profile.

## 11. CSS organization

Keep styles in an intentional order:

1. reset and global tokens;

1. mode and palette tokens;

1. skin tokens and skin overrides;

1. base element styles;

1. reusable layout primitives;

1. components;

1. component states;

1. responsive overrides;

1. reduced-motion and high-contrast adjustments.

Avoid appending unrelated patches indefinitely. The current `style.css` contains multiple generations of skin and responsive rules; when maintaining it, consolidate duplicate selectors and keep the latest intentional rule close to the feature it controls. Do not use `!important` unless a documented third-party conflict requires it.

Prefer one source of truth for each breakpoint and each component state. Keep selectors shallow enough to be overridden by a skin without escalating specificity.

## 12. JavaScript architecture

Initialize features defensively so a missing optional element does not stop the rest of the page. The current site’s pattern of checking elements before attaching listeners is required for reusable pages.

Use:

- one controller per feature;

- data attributes for behavior hooks;

- event delegation for dynamically rendered lists;

- explicit cleanup for timers and external widgets;

- normalized persisted state;

- small pure rendering functions for data-driven content;

- a clear `themechange` event when visual state changes.

Avoid global variables unless a shared module contract requires them. Keep unrelated systems—navigation, theme, carousel, API loading, promo modal, and seasonal effects—from depending on accidental execution order.

## 13. Quality gates before delivery

A future project is ready only after these checks pass:

### Layout

- No page-level horizontal overflow at 320px, 390px, 768px, 1024px, 1440px, 1920px, and a TV-sized viewport.

- Text wraps or truncates intentionally; no clipped headings or buttons.

- Tables, tabs, grids, media, and modals have a mobile strategy.

- Content remains readable at 200% zoom.

### Interaction

- All actions work with keyboard and touch.

- Focus is always visible and never trapped unexpectedly.

- Menus, dialogs, tabs, and carousels expose their state.

- No core information depends on hover.

- Back, Escape, outside click, and close actions behave predictably.

### Theme

- The site's own skin catalog and palettes are applied consistently to every surface and state; do not assume every site shares the main-site catalog.

- Skin switching does not break layout or semantics; project-specific skins may have distinct visual identities.

- Saved preferences survive reload and invalid values fall back safely.

- Focus, contrast, reduced motion, skeleton/loading, empty, error, disabled, expanded, and selected states are required.

- Tooltips, menus, dropdowns, and sliders work with keyboard and touch and match the active skin/palette.

- Side-by-side layouts collapse or adapt cleanly at narrow widths.

### Dependencies

- Bootstrap 5, Font Awesome, and jQuery are used only within the policy in `external-libs.md`.

- Conditional libraries are justified, pinned, and have a fallback.

- Remote failures do not blank the page.

### Performance and resilience

- Images and video do not cause layout shift.

- Below-the-fold media is lazy where appropriate.

- API errors, empty data, and loading states are themed and useful.

- No secrets are shipped to the browser.

- Event listeners, timers, and player instances are not leaked.

### Content quality

- Headings are in order.

- Links describe destinations.

- Images have correct alternative text.

- External links are safe and intentional.

- The page remains useful if JavaScript or one third-party service is unavailable.
## 14. Shared floating controls, motion and ecosystem helpers
Every project using the universal layer provides the round floating appearance button at bottom-left, a settings panel containing localization (English US and Brazilian Portuguese), skin, palette, appearance mode and scroll animation speed (30%, 100%, 170%). Include safe-area padding and ensure the settings remain usable at 320px. Keep the scroll-to-top control available but hidden until the user scrolls more than 300px; respect reduced-motion preferences. When it appears, lift the cart/shop control to its established upper position.

Avoid scroll jank: keep scroll listeners passive, coalesce visual work with `requestAnimationFrame`, avoid layout reads/writes in repeated handlers, and animate `transform`/`opacity` rather than layout properties. Avoid large fixed background repaints, excessive blur/backdrop-filter on mobile, and continuously animated decorative effects; provide reduced-motion behavior. Load large images lazily and reserve their aspect ratio to prevent layout jumps.

Reusable notifications must include success, danger, warning and informational types, an accessible live region, close button, timed progress indicator, and entrance/exit animation. Reusable windows must have a title bar, minimize/maximize/close actions, bounded viewport geometry and a scrollable body. Use safe DOM construction for untrusted values, Escape dismissal, focus handling, and touch-sized controls.


### 14.1 Appearance window contract
The floating appearance launcher opens a movable app-style window (not a popover). It includes skin selection; explicit dark/light controls; named, swatch-based accent palettes; custom accent color; localization; animated-border toggle; and a visible range slider from 30% through 170% for scroll animation speed. The window has titlebar controls to minimize, maximize/restore, and close, remains within the viewport, and must not cover or disable the shop/cart control when it is closed. Slider changes take effect immediately, persist, and use the same scale for all scroll-to-top timing; 30% means slower than 100%, while 170% means faster.


### Vertical header behavior
The universal CSS supports a reusable `.ug-vertical-header` body class. On wide screens, keep the nav as a fixed left rail and offset the main content; below 900px, restore a compact top header with a keyboard- and touch-operable collapsed menu. Discord skin enables the vertical layout automatically.
