/* Layout: slim top bar, then one of three pages (index.html, works.html, about.html).
   Home = full-width carousel (automatic, random, fed by WORKS). Works = filter bar + 16:9 grid.
   About = portrait + text + contacts. Every video opens in an on-site player (lightbox). */
:root {
  --bg: #0f1012;
  --bg-2: #18191c;
  --fg: #ecebe8;
  --muted: #8d8f96;
  --line: #27282c;
  --accent: #7ab0ff;
  --on-image: #f4f3f0;
  --scrim: rgba(8, 8, 10, 0.78);
  --lb-bg: #070708;
  --lb-line: rgba(244, 243, 240, 0.24);
  --shade: rgba(0, 0, 0, 0.4);            /* layer nero sotto i testi in hover */
  --glow-a: rgba(122, 176, 255, 0.11);    /* sfondo: alone in alto a sinistra */
  --glow-b: rgba(139, 105, 214, 0.09);    /* sfondo: alone in basso a destra */
  --grain: #ffffff;
  --grain-opacity: 0.055;
  --bar-bg: rgba(15, 16, 18, 0.8);
  --font-display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --gutter: max(16px, 3vw);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f2ef; --bg-2: #e7e7e3; --fg: #141518; --muted: #686a71; --line: #d6d6d1; --accent: #2a58c8;
    --glow-a: rgba(42, 88, 200, 0.09); --glow-b: rgba(150, 105, 210, 0.08);
    --grain: #000000; --grain-opacity: 0.045; --bar-bg: rgba(242, 242, 239, 0.8);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f2ef; --bg-2: #e7e7e3; --fg: #141518; --muted: #686a71; --line: #d6d6d1; --accent: #2a58c8;
  --glow-a: rgba(42, 88, 200, 0.09); --glow-b: rgba(150, 105, 210, 0.08);
  --grain: #000000; --grain-opacity: 0.045; --bar-bg: rgba(242, 242, 239, 0.8);
  color-scheme: light;
}

html, body { height: 100%; }
body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- top bar ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 18px var(--gutter);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand b {
  font-family: var(--font-display); font-weight: 700; font-size: 1.38rem;
  letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
}
.brand #brandRole { font-family: var(--font-mono); font-size: 0.86rem; color: var(--muted); letter-spacing: 0.06em; }
nav { display: flex; gap: 28px; }
nav a {
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  padding: 6px 0; border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
nav a:hover { color: var(--fg); }
nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- placeholder frames (replaced by real thumbnails) ---------- */
.frame {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 15%, hsl(var(--h) 45% 34% / 0.9), transparent 60%),
    linear-gradient(140deg, hsl(var(--h) 30% 18%), hsl(calc(var(--h) + 50) 35% 8%));
}
.frame img, .frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame video { opacity: 0; transition: opacity .3s; }
.frame.playing video { opacity: 1; }
.frame .veil {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  padding: 18px 20px; color: var(--on-image);
  background: linear-gradient(to top, var(--scrim), transparent 62%);
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s;
}
.veil h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; line-height: 1.2; text-wrap: balance; }
.veil p { font-size: 0.85rem; opacity: 0.8; }
.veil .tc { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; opacity: 0.7; text-transform: uppercase; }
a:hover .veil, a:focus-visible .veil { opacity: 1; transform: none; }
/* telefoni e tablet (senza mouse): titoli sempre visibili in basso sulle schede; nel carosello solo su quella al centro */
@media (hover: none) {
  .frame .veil { opacity: 1; transform: none; }
  .slide:not([data-active="true"]) .frame .veil { opacity: 0; }
}

/* ---------- home carousel ---------- */
.stage {
  --slide-max: 1430px;                    /* larghezza massima del video al centro (era 1100px: +30%) */
  --slide-w: max(260px, min(82vw, var(--slide-max), calc((100svh - 240px) * 1.7778)));
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding-bottom: 28px; min-width: 0;
}
.carousel { overflow: hidden; position: relative; touch-action: pan-y; }
.rail { display: flex; gap: 20px; will-change: transform; transition: transform .75s cubic-bezier(.65, 0, .25, 1); }
.rail.snap { transition: none; }
.slide {
  flex: 0 0 var(--slide-w); display: block; cursor: pointer;
  opacity: 0.32; transform: scale(0.94); transition: opacity .6s, transform .6s;
}
.slide[data-active="true"] { opacity: 1; transform: none; }
.slide .frame { width: 100%; }
.controls {
  width: var(--slide-w); max-width: calc(100% - 2 * var(--gutter)); margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
}
.controls button, .lb-btn {
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center; color: var(--fg); transition: border-color .2s, color .2s; flex: none;
}
.controls button:hover { border-color: var(--accent); color: var(--accent); }
.controls svg, .lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- works ---------- */
.works { padding: 14px var(--gutter) 56px; display: flex; flex-direction: column; gap: 28px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px 26px; align-items: baseline; }
.filters button {
  font-family: var(--font-display); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); padding: 8px 0; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.filters button:hover { color: var(--fg); }
.filters button[aria-pressed="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.filters .n { margin-left: auto; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.grid a { display: block; min-width: 0; animation: rise .35s both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- about ---------- */
.about {
  padding: 24px var(--gutter) 64px; display: grid; gap: clamp(28px, 5vw, 72px);
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; max-width: 1200px; width: 100%; margin-inline: auto;
  box-sizing: border-box;   /* width:100% + padding: senza questo la pagina usciva dallo schermo su telefono e tablet */
}
@media (max-width: 760px) { .about { grid-template-columns: minmax(0, 1fr); } }
.portrait {
  aspect-ratio: 4 / 5; max-width: 100%; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(110% 80% at 25% 10%, hsl(215 40% 30%), transparent 60%), linear-gradient(160deg, hsl(215 30% 16%), hsl(265 30% 9%));
  color: var(--on-image); font-family: var(--font-display); font-weight: 700; font-size: clamp(3rem, 9vw, 6rem); letter-spacing: 0.06em;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.about h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 4.6vw, 3.2rem); line-height: 1.08; text-wrap: balance; margin-bottom: 18px; }
.about p { max-width: 62ch; color: var(--fg); margin-bottom: 14px; }
.about p.dim { color: var(--muted); }
.contact { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); display: grid; gap: 18px; }
.contact h2 { font-family: var(--font-mono); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.mail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.mail span { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; overflow-wrap: anywhere; }
.mail button { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 0.8rem; color: var(--muted); transition: color .2s, border-color .2s; }
.mail button:hover { color: var(--accent); border-color: var(--accent); }
.reps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.reps p { margin: 0; font-size: 0.95rem; }
.reps small { display: block; color: var(--muted); }

/* ---------- footer ---------- */
footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 24px;
  padding: 20px var(--gutter); border-top: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--muted);
}
footer .soc { display: flex; align-items: center; gap: 18px; }
footer .soc a { display: grid; place-items: center; height: 38px; color: var(--muted); transition: color .2s; }
footer .soc a:hover { color: var(--accent); }
footer .soc svg { height: 22px; width: auto; display: block; }
footer .soc .fi { font-size: 26.4px; line-height: 1; display: block; }
footer .soc .fi-brands-imdb { font-size: 36px; }
footer .soc a.soc-imdb:hover { color: #deb522; }
footer .soc a.soc-vimeo:hover { color: #1ab7ea; }
footer .credit { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color .2s; }
footer .credit:hover { color: var(--accent); }

/* ---------- on-site player ---------- */
dialog#lb {
  border: 0; padding: 0; margin: 0; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  background: var(--lb-bg); color: var(--on-image);
}
dialog#lb[open] { display: flex; flex-direction: column; }
dialog#lb::backdrop { background: var(--lb-bg); }
.lb-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: calc(24px + env(safe-area-inset-top, 0px)) var(--gutter) 14px;
}
.lb-top > div { min-width: 0; }   /* un titolo lungo va a capo e non spinge il tasto di chiusura */
.lb-top h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.725rem; line-height: 1.2; text-wrap: balance; margin: 0; }
.lb-top p { font-size: 1.02rem; opacity: 0.7; margin: 4px 0 0; }
/* telefoni: titolo un po' meno grande, per lasciare spazio al video */
@media (max-width: 520px) {
  .lb-top h2 { font-size: 1.4rem; }
  .lb-top p { font-size: 0.95rem; }
}
.lb-main { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 var(--gutter); container-type: size; }
.lb-stage {
  position: relative; background: #000; aspect-ratio: 16 / 9; max-width: 100%;
  width: min(100%, calc((100vh - 200px) * 1.7778));
  width: min(100%, calc((100dvh - 200px) * 1.7778));
  width: min(100cqw, calc(100cqh * 16 / 9));   /* misura esatta dello spazio libero (browser recenti) */
}
.lb-stage:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; }
.lb-stage iframe, .lb-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.lb-stage .frame { position: absolute; inset: 0; aspect-ratio: auto; display: grid; place-items: center; }
.lb-msg { position: relative; max-width: 42ch; padding: 0 24px; text-align: center; font-size: 0.95rem; opacity: 0.85; }
.lb-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px var(--gutter) calc(16px + env(safe-area-inset-bottom, 0px));
}
.lb-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; text-align: center; }
.lb-meta { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.lb-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; font-size: 0.85rem; }
.lb-actions a, .lb-actions button { opacity: 0.8; padding: 4px 0; }
.lb-actions a:hover, .lb-actions button:hover { opacity: 1; color: var(--accent); }
.lb-btn { border-color: var(--lb-line); color: var(--on-image); }
.lb-btn:hover { border-color: var(--accent); color: var(--accent); }
.lb-btn[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* telefoni: il nome grande e il menu non devono uscire dallo schermo */
@media (max-width: 520px) {
  .brand b { font-size: 1.2rem; letter-spacing: 0.1em; }
  nav { gap: 22px; }
  nav a { font-size: 0.9rem; }
}
/* anteprima in movimento (Home e Works).
   Il lettore YouTube e' piu' alto del riquadro di --pv-bleed sopra e sotto: titolo, icone, logo e sottotitoli che
   YouTube disegna ai bordi cadono nelle fasce fuori dal riquadro e vengono tagliati. Il video non viene ritagliato.
   Con --pv-bleed: 0px si torna a come era prima. */
.frame iframe {
  --pv-bleed: 110px;
  position: absolute; left: 0; width: 100%;
  top: calc(-1 * var(--pv-bleed)); height: calc(100% + 2 * var(--pv-bleed));
  border: 0; pointer-events: none;
  opacity: 0; transition: opacity .5s; transform: scale(var(--pv-zoom, 1));
}
.frame iframe.pv-on { opacity: 1; }
/* ---------- sfondo: due aloni di colore fissi + grana leggera, dietro a tutti i contenuti ---------- */
body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
body::before {
  background:
    radial-gradient(ellipse 70vmax 55vmax at 10% -8%, var(--glow-a), transparent 65%),
    radial-gradient(ellipse 60vmax 50vmax at 105% 108%, var(--glow-b), transparent 65%);
}
body::after {
  background: var(--grain); opacity: var(--grain-opacity);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27n%27%20x%3D%270%27%20y%3D%270%27%20width%3D%27100%25%27%20height%3D%27100%25%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.8%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270%200%200%200%200%20%200%200%200%200%200%20%200%200%200%200%200%20%200%200%200%201.4%20-.2%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27100%25%27%20height%3D%27100%25%27%20filter%3D%27url%28%23n%29%27%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27n%27%20x%3D%270%27%20y%3D%270%27%20width%3D%27100%25%27%20height%3D%27100%25%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.8%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270%200%200%200%200%20%200%200%200%200%200%20%200%200%200%200%200%20%200%200%200%201.4%20-.2%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27100%25%27%20height%3D%27100%25%27%20filter%3D%27url%28%23n%29%27%2F%3E%3C%2Fsvg%3E");
  -webkit-mask-size: 180px 180px; mask-size: 180px 180px;
}

/* ---------- hover con il mouse: layer nero 40% sotto i testi ---------- */
@media (hover: hover) {
  /* Works: testi in basso come prima, in più il layer nero */
  .grid .veil { background: linear-gradient(to top, var(--scrim), transparent 62%), var(--shade); }
  /* Home (solo il frame al centro): testi centrati, 30% più grandi (--zoom), layer nero */
  .slide[data-active="true"] .veil {
    --zoom: 1.3;
    align-items: center; justify-content: center; text-align: center;
    gap: calc(2px * var(--zoom)); padding: 24px 8%;
    background: var(--shade);
  }
  .slide[data-active="true"] .veil h3 { font-size: calc(1.15rem * var(--zoom)); }
  .slide[data-active="true"] .veil p { font-size: calc(0.85rem * var(--zoom)); }
  .slide[data-active="true"] .veil .tc { font-size: calc(0.7rem * var(--zoom)); }
}

/* =====================================================================
   Telefoni e tablet (senza mouse)
   ===================================================================== */
@media (hover: none) {
  /* stesso layer scuro dell'hover su desktop, sempre presente sotto i titoli */
  .frame .veil { background: linear-gradient(to top, var(--scrim), transparent 62%), var(--shade); }
}

/* pulsante "Attiva audio": compare solo se il telefono blocca l'avvio con audio e il video parte muto */
.lb-sound {
  position: absolute; left: 10px; bottom: 56px; z-index: 3;
  padding: 8px 14px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  color: var(--on-image); background: rgba(0, 0, 0, 0.62); border: 1px solid var(--lb-line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* player a schermo: telefoni in verticale e in orizzontale */
@media (hover: none) and (max-width: 700px), (hover: none) and (max-height: 500px) {
  .lb-main { padding: 0; }                       /* il video va da bordo a bordo */
}
/* telefono in orizzontale: il video riempie tutto lo schermo; titolo e comandi compaiono per qualche secondo sopra il video */
@media (hover: none) and (max-height: 500px) {
  .lb-main { position: absolute; inset: 0; }
  .lb-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; pointer-events: none; padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: 0; }
  .lb-top > div {
    background: rgba(0, 0, 0, 0.55); padding: 6px 12px; border-radius: 10px; max-width: calc(100% - 64px);
    opacity: 0; transition: opacity .4s;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .lb-top h2 { font-size: 1.15rem; }
  .lb-top p { font-size: 0.85rem; margin-top: 2px; }
  .lb-top .lb-btn { pointer-events: auto; background: rgba(0, 0, 0, 0.5); }
  .lb-bottom {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; pointer-events: none; padding-top: 0;
    opacity: 0; transition: opacity .4s;
  }
  .lb-bottom .lb-btn, .lb-bottom .lb-actions a, .lb-bottom .lb-actions button { background: rgba(0, 0, 0, 0.5); }
  .lb-mid { background: rgba(0, 0, 0, 0.55); padding: 4px 12px; border-radius: 10px; }
  dialog#lb.lb-peek .lb-top > div, dialog#lb.lb-peek .lb-bottom { opacity: 1; }
  dialog#lb.lb-peek .lb-bottom { pointer-events: auto; }
  .lb-sound { bottom: auto; top: 10px; left: auto; right: 64px; }
}

/* ---------- logo RC (usato come maschera: prende il colore del testo, quindi funziona in tema scuro e chiaro) ---------- */
.mark {
  display: block; flex: none; aspect-ratio: 667 / 388; background: currentColor;
  -webkit-mask: url(logo.svg) center / contain no-repeat; mask: url(logo.svg) center / contain no-repeat;
}
.brand .mark { height: 34px; color: var(--fg); transition: color .2s; }
.brand:hover .mark { color: var(--accent); }
.foot-l { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
footer .mark { height: 15px; color: var(--muted); opacity: .8; }
.about-mark { height: 64px; margin-top: 36px; color: var(--muted); opacity: .55; }
@media (max-width: 520px) { .brand { gap: 10px; } .brand .mark { height: 28px; } .about-mark { height: 52px; } }
