/*
 * ============================================================================
 *  Azienda:   Exion Networks SA
 *  Developer: Danijel Balcakovic
 *  Email:     balcakovic.danijel@gmail.com
 *  GitHub:    I3assotto
 * ============================================================================
 *  Reset, tipografia di base, layout, sistema di comparsa (reveal), testo a
 *  parole, transizioni fra pagine e preferenze di movimento.
 *  2026-11-08: animazioni piu brevi e leggere, niente grana, solo
 *  trasformazioni 2D (meno livelli di composizione = scroll piu fluido).
 *  2026-11-08 (sera): scroll nativo (niente piu Lenis) e comparse rapide,
 *  perche il sito risponda subito alla rotella e al trackpad.
 */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
  scroll-behavior: smooth;
  scrollbar-color: var(--ex-600) var(--ex-900);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.65;
  color: var(--ex-text);
  background: var(--ex-900);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.03em;
  color: var(--ex-text);
  text-wrap: balance;
  overflow-wrap: break-word;
}
h3, h4 { letter-spacing: -0.02em; line-height: 1.18; }
:lang(de) h1, :lang(de) h2, :lang(de) h3 { hyphens: auto; }
p { text-wrap: pretty; }

a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
ul, ol { list-style: none; padding: 0; }
strong { font-weight: 600; color: var(--ex-text); }
::selection { background: var(--ex-gold); color: var(--ex-900); }

main:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ex-gold);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Un'ancora non deve finire sotto l'header fisso */
[id] { scroll-margin-top: calc(var(--header-h) + 1.5rem); }

/* --- Barra di scorrimento discreta --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ex-900); }
::-webkit-scrollbar-thumb { background: var(--ex-700); border: 2px solid var(--ex-900); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--ex-600); }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide { max-width: calc(var(--container-wide) + var(--gutter) * 2); }

.section { position: relative; padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.55); }
.section--flush-top { padding-top: 0; }

/* --- Etichette --- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--ex-gold);
}
.eyebrow::before {
  content: "";
  flex: none;
  width: 9px; height: 10px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.eyebrow__num { color: var(--ex-text-dim); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.eyebrow__num::after { content: "/"; margin-left: 0.75rem; color: var(--ex-600); }

.text-muted { color: var(--ex-text-muted); }
.gold { color: var(--ex-gold); }

/* Accento: la parte del titolo in oro. Stesso carattere e stesso peso del
   resto del titolo: cambia solo il colore. */
.accent, .gold-accent { color: var(--ex-gold); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 1001;
  padding: 0.7rem 1.1rem; border-radius: var(--radius-pill);
  background: var(--ex-gold); color: var(--ex-900); font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--t-med);
}
.skip-link:focus { transform: none; }

/* ===========================================================================
   SMOOTH SCROLL (Lenis) — regole raccomandate dalla libreria
   =========================================================================== */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

/* ===========================================================================
   COMPARSA AL CONTATTO CON LA VISTA
   Lo stato "nascosto" esiste solo se il browser esegue script: senza JS (o
   con un browser che non conosce la media query) il contenuto e subito
   visibile. Se main.js non arriva entro 2,6 s, un'animazione di riserva
   mostra comunque tutto: la pagina non puo restare vuota.
   =========================================================================== */
.reveal {
  --reveal-y: 14px;
  transition:
    opacity 0.45s var(--ease),
    transform 0.55s var(--ease-out-expo);
  transition-delay: calc(var(--reveal-delay, 0s) * 0.6 + var(--i, 0) * var(--stagger));
}
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .reveal:not(.is-in) { opacity: 0; transform: translate(0, var(--reveal-y)); }
  .reveal--fade:not(.is-in) { transform: none; }
  .reveal--scale:not(.is-in) { transform: scale(0.97); }
  .reveal--left:not(.is-in) { transform: translate(-24px, 0); }
  .reveal--line:not(.is-in) { opacity: 1; transform: scaleX(0); }

  /* Testo a parole: il contenitore resta fermo, salgono le parole */
  .split.reveal:not(.is-in) { opacity: 1; transform: none; }
  .split.reveal:not(.is-in) .w__i { transform: translate(0, 105%); }

  html:not(.js-ready) .reveal:not(.is-in) { animation: ex-failsafe 0.01s 2.6s forwards; }
  html:not(.js-ready) .split.reveal:not(.is-in) .w__i { animation: ex-failsafe 0.01s 2.6s forwards; }
}
@keyframes ex-failsafe { to { opacity: 1; transform: none; } }
.reveal--line { transform-origin: 0 50%; }
.js-late .reveal, .js-late .reveal .w__i { transition: none !important; }

/* Parole: ogni parola in una maschera, l'interno scorre in su */
.w {
  display: inline-block;
  max-width: 100%;
  overflow: clip;
  overflow-clip-margin: 0.04em;
  vertical-align: top;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}
.w__i {
  display: inline-block;
  transition: transform 0.6s var(--ease-out-expo);
  transition-delay: calc(var(--reveal-delay, 0s) * 0.6 + var(--wi, 0) * 16ms);
}

/* Comparsa all'apertura (header pagina, hero): animazione CSS pura, parte
   al primo disegno senza aspettare nessuno script. */
@media (prefers-reduced-motion: no-preference) {
  .intro .w__i { animation: ex-word-up 0.75s var(--ease-out-expo) both; animation-delay: calc(0.08s + var(--wi, 0) * 24ms); }
  .intro-fade { animation: ex-fade-up 0.65s var(--ease-out-expo) both; animation-delay: calc(var(--d, 0.4s) * 0.55); }
}
@keyframes ex-word-up { from { transform: translate(0, 105%); } to { transform: none; } }
@keyframes ex-fade-up { from { opacity: 0; transform: translate(0, 16px); } to { opacity: 1; transform: none; } }
@keyframes ex-fade { from { opacity: 0; } to { opacity: 1; } }

/* ===========================================================================
   TRANSIZIONI FRA PAGINE (View Transitions fra documenti)
   Dove il browser le supporta la navigazione diventa una dissolvenza; dove
   no, si naviga come sempre. Nessuno script.
   =========================================================================== */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: ex-vt-out 0.12s var(--ease) both; }
::view-transition-new(root) { animation: ex-vt-in 0.22s var(--ease-out-expo) both; }
@keyframes ex-vt-out { to { opacity: 0; } }
@keyframes ex-vt-in { from { opacity: 0; } }

/* ===========================================================================
   MOVIMENTO RIDOTTO: niente scorrimenti, niente parallasse, niente cicli
   =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal, .w__i { opacity: 1 !important; transform: none !important; }
}
