/* Works — one full screen (100svh) with the project names in the middle: two lines, "A Normality · Oakley · Salomon Alpine · Quad" and
   "Fantic Motor · Scott Prospect · Scott", centred in the space under the header, on the plain background (--bg). Each name is a link.
   While the mouse is on a name, a preview of that project, in the shape of its video, fades in under the name's text and follows the cursor with a soft delay
   (works.js); the names near the cursor are pushed away a little and lean with the cursor's speed (transform only).
   Stacking, from the bottom: the names and the dots (1) < the preview box (2) < the copy of the names, cut to the box (3) < the name under the cursor (4). */
.home {
  --hover-text-color: var(--paper);                 /* colour of the name under the cursor, above the video (white, like all the text): change it here if it is hard to read on the videos */
  --work-gap: 0.5em;                               /* space on each side of the dot */
  --pv-w: calc(clamp(200px, 23.9vw, 480px) * 1.19);   /* the preview box: works.js sets its size from the ratio of the video (assets/works-ratios.js); this is only before it runs (the default ratio 1.9) */
  --pv-h: calc(var(--pv-w) / 1.9);
  --pv-r: clamp(12px, 1.3vw, 24px);                /* its rounded corners */
  position: relative; box-sizing: border-box; overflow: hidden; background: var(--bg);
  height: 100vh; height: 100svh;
  padding-top: var(--bar-h);                       /* the block is centred in the space under the header */
  display: flex; align-items: center; justify-content: center;
}
.home-ui { position: relative; width: 100%; padding: 0 var(--space-margin); box-sizing: border-box; }   /* no z-index: names and box share one stacking context */
.work-list { text-align: center; color: var(--text); }
.work-line { display: block; }
.work-name, .work-dot {
  font-family: var(--font-body); font-weight: var(--fw-medium); font-size: var(--fs-names); line-height: var(--lh-names); letter-spacing: var(--ls-names);
  white-space: nowrap; color: var(--text);
}
.work-name { position: relative; z-index: 1; display: inline-block; text-decoration: none; will-change: transform; transform: translate3d(0, 0, 0); }
.work-name.is-active { z-index: 4; color: var(--hover-text-color); }
.work-name:focus-visible { outline: none; text-decoration: underline; text-decoration-thickness: 0.09em; text-underline-offset: 0.15em; }
.work-dot { display: inline-block; margin: 0 var(--work-gap); pointer-events: none; user-select: none; position: relative; z-index: 1; will-change: transform; transform: translate3d(0, 0, 0); }   /* not a link, no hover: same colour, 0.5em on each side; it moves with the names (works.js) */

/* Names and dots in two layers (works.js). A: the real ones, always at opacity 1, UNDER the preview box (z-index 1 against 2): the video hides them where it
   covers them. B: .work-ghost, an identical copy without the selected name, ABOVE the video (z-index 3), at opacity 0.3, cut to the rectangle of the box (clip-path,
   set by works.js every frame), so the text is faint only where the box covers it; it follows the opacity of the box. The selected name is above everything (4). */
.work-ghost {
  position: absolute; left: var(--space-margin); right: var(--space-margin); top: 0; z-index: 3; margin: 0; pointer-events: none; user-select: none;
  opacity: 0; visibility: hidden; clip-path: inset(50%);                                       /* closed: nothing */
}
.work-ghost.is-open { opacity: var(--ghost-o, 0.3); }
.work-ghost[hidden] { display: none; }
.work-ghost .work-name, .work-ghost .work-dot { will-change: auto; }
.work-ghost .work-name.is-sel { visibility: hidden; }                                          /* the selected name is not copied here */

/* The preview box. Two layers that never disturb each other: .pv-box follows the cursor (works.js moves it with the `translate` property, its
   centre is the cursor), .pv-inner inside it appears and disappears (scale and opacity, Web Animations API in works.js: in 520 ms / 260 ms, out
   300 ms / 240 ms after 40 ms), about its centre, which is the cursor. Inside, the previews of all the projects are stacked in the same place;
   the one of the name under the cursor fades in over the others in 180 ms. No border, no shadow. Closed state = the CSS here; open = .is-open. */
.pv-box { position: absolute; top: 0; left: 0; z-index: 2; width: var(--pv-w); height: var(--pv-h); pointer-events: none; }
.pv-box.is-moving { will-change: translate; }
.pv-inner {
  position: absolute; inset: 0; overflow: hidden; border-radius: var(--pv-r); isolation: isolate; background: var(--bg);
  opacity: 0; transform: scale(0.55); transform-origin: 50% 50%;           /* closed: invisible and small */
}
.pv-inner.is-open { opacity: 1; transform: none; }
.pv-box.is-anim .pv-inner { will-change: transform, opacity; }               /* only while it appears or disappears */
.pv-slide { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; opacity: 0; transition: opacity 180ms ease-in-out; }   /* crossfade between two names */
.pv-slide.is-on { opacity: 1; }
.pv-slide video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; background: var(--bg); transform: scale(1.004); transform-origin: 50% 50%; backface-visibility: hidden; }   /* a little bigger than the cut: its edge never falls on the clip */
.pv-box.pv-instant .pv-slide { transition: none; }                           /* first entry: the right preview is already there */

/* The name of the site at the bottom right: plain text (no link, no hover), bold. HIDDEN for now, to be turned on again: delete the display: none line. */
.works-name {
  display: none;                                /* nascosto, da riattivare */
  position: absolute; right: var(--space-margin); bottom: var(--edge-b); z-index: 3; margin: 0;
  font-family: var(--font-body); font-weight: var(--fw-medium); white-space: nowrap;
  font-size: var(--name-fs); line-height: var(--lh-title-project); letter-spacing: var(--ls-title-project); color: var(--text);
  pointer-events: none; user-select: none;
}

/* Phones: the names one under the other, centred, a tap opens the project; no dots, no preview, no movement */
@media (max-width: 720px) {
  .home { height: auto; min-height: 100vh; min-height: 100svh; padding-bottom: var(--space-margin); }
  .work-line { display: contents; }
  .work-name { display: block; width: fit-content; max-width: 100%; margin: 0 auto; white-space: normal; will-change: auto; transform: none; }
  .work-dot { display: none; will-change: auto; transform: none; }
  .pv-box { display: none; }
  .work-ghost { display: none; }
}
/* Reduced motion: the preview only fades (150 ms, no scale), still, in the middle of the name */
@media (prefers-reduced-motion: reduce) {
  .pv-slide { transition: none; }
}
