:root {
  --bg: #060606;
  --text: #f7f5ee;
  --muted: rgba(255, 250, 235, .62);
  --faint: rgba(255, 250, 235, .38);
  --yellow: #ffd60a;
  --amber: #ffa800;
  --red: #ff4d63;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ───────────── Sfondo ───────────── */

.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

/* scie di velocità */
.streaks { position: absolute; inset: -20%; transform: rotate(-18deg); }
.streaks i {
  position: absolute; left: -40%;
  width: 34vmax; height: 1.5px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  opacity: 0;
  animation: streak 7s linear infinite;
}
.streaks i:nth-child(1) { top: 18%; animation-delay: .4s; }
.streaks i:nth-child(2) { top: 34%; animation-delay: 3.1s; animation-duration: 5.5s;
  background: linear-gradient(90deg, transparent, rgba(255, 214, 10, .85), transparent); }
.streaks i:nth-child(3) { top: 49%; animation-delay: 5.2s; animation-duration: 8s; }
.streaks i:nth-child(4) { top: 63%; animation-delay: 1.7s; animation-duration: 6.2s;
  background: linear-gradient(90deg, transparent, rgba(255, 168, 0, .85), transparent); }
.streaks i:nth-child(5) { top: 77%; animation-delay: 4.3s; animation-duration: 9s; }
.streaks i:nth-child(6) { top: 88%; animation-delay: 6.4s; animation-duration: 6.8s; }

@keyframes streak {
  0% { transform: translateX(0); opacity: 0; }
  8% { opacity: .55; }
  30% { opacity: .55; }
  42%, 100% { transform: translateX(240vmax); opacity: 0; }
}

/* ───────────── Schermate ───────────── */

.screen {
  position: fixed; inset: 0; z-index: 1;
  display: grid; place-items: center;
  padding: 24px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: scale(1.06);
  transition: opacity .7s var(--ease), transform .9s var(--ease), visibility 0s linear .7s;
}
.screen.active {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: none;
  transition: opacity .8s var(--ease) .15s, transform 1s var(--ease) .15s, visibility 0s;
}
.screen.leaving { transform: scale(.94); filter: blur(12px); transition: opacity .7s var(--ease), transform .9s var(--ease), filter .7s var(--ease), visibility 0s linear .7s; }
/* dal benvenuto si "attraversa" il nome per entrare nell'hub */
#welcome.leaving { transform: scale(1.35); filter: blur(18px); }

.screen .rise { opacity: 0; }
.screen:is(.active, .leaving) .rise {
  animation: rise 1s var(--ease) both;
  animation-delay: calc(var(--i) * 95ms + 250ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(26px) scale(.97); filter: blur(10px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

/* ───────────── Logo ───────────── */

.logo { position: relative; aspect-ratio: 800 / 223; flex: none; }
.logo img { display: block; width: 100%; height: 100%;  }
.logo .sheen {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .95) 50%, transparent 62%) no-repeat;
  background-size: 260% 100%;
  background-position: 160% 0;
  mask: url(logo.png) center / contain no-repeat;
  -webkit-mask: url(logo.png) center / contain no-repeat;
  mix-blend-mode: plus-lighter;
}
.logo-xl { width: min(78vw, 620px); }
.logo-md { width: min(64vw, 290px); }
.logo-sm { width: 150px; }

.tricolor { display: flex; height: 3px; width: min(60vw, 420px); border-radius: 3px; overflow: hidden; }
.tricolor span { flex: 1; transform: scaleX(0); transform-origin: left; }
.tricolor span:nth-child(1) { background: #159a5c; }
.tricolor span:nth-child(2) { background: #fff; }
.tricolor span:nth-child(3) { background: #d6283f; }
.tricolor.small { width: 96px; height: 2px; }

/* ───────────── Intro ───────────── */

.intro-inner { display: grid; justify-items: center; gap: 30px; }
#intro:is(.active, .leaving) .logo-xl { animation: intro-logo 1.7s var(--ease) both .15s; }
#intro:is(.active, .leaving) .logo-xl .sheen { animation: sheen-once 1.5s var(--ease) both 1s; }
#intro:is(.active, .leaving) .tricolor span { animation: draw .45s var(--ease) forwards; }
#intro:is(.active, .leaving) .tricolor span:nth-child(1) { animation-delay: 1.1s; }
#intro:is(.active, .leaving) .tricolor span:nth-child(2) { animation-delay: 1.4s; }
#intro:is(.active, .leaving) .tricolor span:nth-child(3) { animation-delay: 1.7s; }

@keyframes intro-logo {
  0% { opacity: 0; transform: translateX(-70px) skewX(-14deg) scale(.92); filter: blur(22px); clip-path: inset(0 100% 0 0); }
  55% { opacity: 1; filter: blur(0); clip-path: inset(0 0 0 0); }
  100% { opacity: 1; transform: none; filter: blur(0); clip-path: inset(0 0 0 0); }
}
@keyframes sheen-once { from { background-position: 160% 0; } to { background-position: -60% 0; } }
@keyframes draw { to { transform: scaleX(1); } }

/* ───────────── Superfici ───────────── */

.panel {
  position: relative;
  border-radius: 20px;
  background: #101010;
  border: 1px solid rgba(255, 255, 255, .09);
}

/* ───────────── Tipografia ───────────── */

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 600; letter-spacing: .26em; text-transform: uppercase;
  color: var(--muted);
}
h1 { font-weight: 700; letter-spacing: -.03em; line-height: 1.05; }
.sub { color: var(--muted); line-height: 1.55; }

/* ───────────── Login ───────────── */

.login-card {
  width: min(100%, 440px);
  padding: 46px 38px 34px;
  display: grid; justify-items: center; text-align: center; gap: 14px;
  animation: float 8s ease-in-out infinite;
}
@keyframes float { 50% { translate: 0 -8px; } }
.login-card .logo { margin-bottom: 16px; }
.login-card h1 { font-size: clamp(26px, 5vw, 32px); }
.login-card .sub { font-size: 15px; max-width: 30ch; }
.login-card.shake { animation: shake .55s var(--ease); }
@keyframes shake {
  15% { transform: translateX(-12px) rotate(-1deg); }
  35% { transform: translateX(10px) rotate(1deg); }
  55% { transform: translateX(-7px); }
  75% { transform: translateX(4px); }
}

.btn-google {
  margin-top: 16px; width: 100%; height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  border-radius: 12px;
  font-weight: 600; font-size: 15.5px; color: #0a0a0a;
  background: #fff;
  transition: transform .35s var(--spring), background .3s var(--ease), filter .3s;
}
.btn-google:hover { transform: translateY(-2px); background: var(--yellow); }
.btn-google:active { transform: scale(.97); }
.btn-google:focus-visible, .btn-ghost:focus-visible, .card:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.btn-google .g { width: 22px; height: 22px; flex: none; }
.spinner {
  display: none; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(11, 14, 22, .18); border-top-color: #0b0e16;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-google.loading { pointer-events: none; filter: saturate(.6) brightness(.92); }
.btn-google.loading .g { display: none; }
.btn-google.loading .spinner { display: block; }

.msg {
  width: 100%;
  display: grid; grid-template-rows: 0fr;
  font-size: 13.5px; line-height: 1.45; color: #ffd3d9;
  opacity: 0;
  transition: grid-template-rows .45s var(--ease), opacity .45s var(--ease), padding .45s var(--ease), margin .45s var(--ease);
  border-radius: 12px;
}
.msg > span { overflow: hidden; min-height: 0; }
.msg.show {
  grid-template-rows: 1fr; opacity: 1;
  padding: 12px 16px; margin-top: 6px;
  background: rgba(255, 77, 99, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 77, 99, .35);
}
.hint { margin-top: 8px; font-size: 12.5px; color: var(--faint); }
.hint b { color: var(--muted); font-weight: 600; }

/* ───────────── Benvenuto ───────────── */

.welcome-inner { display: grid; justify-items: center; text-align: center; gap: 18px; }

.avatar {
  width: 104px; height: 104px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  font-weight: 700; font-size: 38px; letter-spacing: -.02em;
  background: #1a1a1a;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; font-size: 14px; }

.avatar-ring { position: relative; padding: 6px; border-radius: 50%; margin-bottom: 10px; opacity: 0; }
.avatar-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; padding: 2px;
  background: conic-gradient(var(--yellow), transparent 70%, var(--yellow));
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  animation: spin 3.5s linear infinite;
}
.avatar-ring::after {
  content: ""; position: absolute; inset: -18px; border-radius: 50%;
  border: 1px solid rgba(255, 214, 10, .6); opacity: 0;
}
.check {
  position: absolute; right: -2px; bottom: 2px;
  width: 34px; height: 34px; padding: 8px; border-radius: 50%;
  background: var(--yellow); box-shadow: 0 0 0 4px var(--bg);
  fill: none; stroke: #0a0a0a; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  transform: scale(0);
}
.check path { stroke-dasharray: 24; stroke-dashoffset: 24; }

.welcome-eyebrow, .welcome-logo, .progress { opacity: 0; }
.welcome-name {
  font-size: clamp(44px, 10vw, 104px); font-weight: 800; letter-spacing: -.045em;
  white-space: pre-wrap;
}
.welcome-name span {
  display: inline-block; opacity: 0;
}
.welcome-logo { margin-top: 14px; }
.progress { width: 180px; height: 2px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; transform: scaleX(0); transform-origin: left;
  background: var(--yellow); }

#welcome:is(.active, .leaving) .avatar-ring { animation: pop .9s var(--spring) both .3s; }
#welcome:is(.active, .leaving) .avatar-ring::after { animation: ripple 1.6s var(--ease) .9s 2; }
#welcome:is(.active, .leaving) .check { animation: pop .6s var(--spring) forwards 1s; }
#welcome:is(.active, .leaving) .check path { animation: stroke .45s var(--ease) forwards 1.25s; }
#welcome:is(.active, .leaving) .welcome-eyebrow { animation: rise .8s var(--ease) both .6s; }
#welcome:is(.active, .leaving) .welcome-name span {
  animation: letter .9s var(--ease) both;
  animation-delay: calc(var(--i) * 55ms + 800ms);
}
#welcome:is(.active, .leaving) .welcome-logo { animation: rise 1s var(--ease) both 1.5s; }
#welcome:is(.active, .leaving) .progress { animation: rise .6s var(--ease) both 1.7s; }
#welcome:is(.active, .leaving) .progress span { animation: draw 1.9s cubic-bezier(.6, 0, .2, 1) forwards 1.8s; }

#welcome.quick .avatar-ring { animation-delay: .05s; animation-duration: .6s; }
#welcome.quick .avatar-ring::after { animation-delay: .35s; animation-duration: 1s; animation-iteration-count: 1; }
#welcome.quick .check { animation-delay: .35s; animation-duration: .45s; }
#welcome.quick .check path { animation-delay: .5s; animation-duration: .3s; }
#welcome.quick .welcome-eyebrow { animation-delay: .15s; animation-duration: .6s; }
#welcome.quick .welcome-name span { animation-duration: .6s; animation-delay: calc(var(--i) * 28ms + 220ms); }
#welcome.quick .welcome-logo { animation-delay: .5s; animation-duration: .7s; }
#welcome.quick .progress { animation-delay: .55s; animation-duration: .4s; }
#welcome.quick .progress span { animation-delay: .6s; animation-duration: .9s; }

@keyframes pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
@keyframes ripple { from { opacity: .7; transform: scale(.8); } to { opacity: 0; transform: scale(1.7); } }
@keyframes stroke { to { stroke-dashoffset: 0; } }
@keyframes letter {
  from { opacity: 0; transform: translateY(.55em) rotate(8deg) scale(.8); filter: blur(14px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

/* ───────────── Hub ───────────── */

#hub { display: block; padding: 0; overflow-y: auto; overflow-x: hidden; }

.nav {
  position: sticky; top: 18px; z-index: 5;
  margin: 18px auto 0; width: min(calc(100% - 32px), 1040px);
  padding: 10px 12px 10px 22px; border-radius: 999px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-name { font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
  transition: background .3s, color .3s, box-shadow .3s, transform .35s var(--spring);
}
.btn-ghost:hover { background: var(--yellow); color: #0a0a0a; box-shadow: none; transform: scale(1.05); }
.btn-ghost:active { transform: scale(.95); }
.btn-ghost[hidden] { display: none; }
.btn-install { color: var(--yellow); box-shadow: inset 0 0 0 1px rgba(255, 214, 10, .45); animation: rise .6s var(--ease) both; }
.btn-ghost svg, .card svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-ghost svg { width: 17px; height: 17px; }

.hub-body {
  width: min(calc(100% - 32px), 1040px); margin: 0 auto;
  min-height: calc(100% - 84px);
  display: flex; flex-direction: column; justify-content: center; gap: clamp(30px, 5vh, 54px);
  padding: clamp(36px, 7vh, 80px) 0 28px;
}

.hero { display: grid; gap: 16px; justify-items: start; }
.hero h1 { font-size: clamp(38px, 7vw, 76px); font-weight: 800; }
.hero h1 em {
  font-style: italic;
  background: linear-gradient(100deg, #ffd60a 0%, #fff3b0 30%, #ffd60a 55%, #ffa800 80%, #ffd60a 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 7s linear infinite;
  padding-right: .08em;
}
@keyframes shimmer { from { background-position: 0 0; } to { background-position: 200% 0; } }
.hero .sub { font-size: clamp(16px, 2vw, 19px); }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

.card {
  min-height: 280px; padding: 30px;
  display: flex; flex-direction: column; gap: 22px;
  transition: border-color .4s var(--ease), background .4s var(--ease);
  cursor: pointer;
}
/* la .rise anima transform: l'hover viene applicato dopo l'ingresso */
.card.ready { opacity: 1; animation: none !important; transition: transform .5s var(--ease), border-color .4s var(--ease), background .4s var(--ease); }
.card:hover { border-color: var(--accent); background: #141414; }
.card.ready:hover { transform: translateY(-6px); }
.card.ready:active { transform: translateY(-2px) scale(.99); }

.card-icon {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent);
  transition: transform .6s var(--spring);
}
.card-icon svg { width: 28px; height: 28px; color: #0a0a0a; }
.card:hover .card-icon { transform: scale(1.08) rotate(-6deg); }

.card-text { margin-top: auto; }
.card-text h2 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 700; letter-spacing: -.03em; margin-bottom: 8px; }
.card-text p { color: var(--muted); font-size: 16px; line-height: 1.5; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.url { font-size: 13px; color: var(--faint); letter-spacing: .02em; transition: color .3s; }
.card:hover .url { color: var(--text); }
.go {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
  transition: background .4s var(--ease), color .4s var(--ease), transform .5s var(--spring);
}
.go svg { width: 20px; height: 20px; }
.card:hover .go { background: var(--accent); color: #0a0a0a; box-shadow: none; transform: scale(1.12); }
.card:hover .go svg { animation: arrow .6s var(--ease); }
@keyframes arrow { 45% { transform: translateX(34px); opacity: 0; } 46% { transform: translateX(-34px); opacity: 0; } 100% { transform: none; opacity: 1; } }

footer { display: grid; justify-items: center; gap: 12px; margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--faint); letter-spacing: .04em; }
#hub:is(.active, .leaving) footer .tricolor span { animation: draw .5s var(--ease) forwards; }
#hub:is(.active, .leaving) footer .tricolor span:nth-child(1) { animation-delay: 1.2s; }
#hub:is(.active, .leaving) footer .tricolor span:nth-child(2) { animation-delay: 1.45s; }
#hub:is(.active, .leaving) footer .tricolor span:nth-child(3) { animation-delay: 1.7s; }

/* ───────────── Portale ───────────── */

#portal {
  --x: 50%; --y: 50%; --d: 300vmax;
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; overflow: hidden;
  visibility: hidden; pointer-events: none;
}
#portal::before {
  content: ""; position: absolute;
  left: calc(var(--x) - var(--d) / 2); top: calc(var(--y) - var(--d) / 2);
  width: var(--d); height: var(--d); border-radius: 50%;
  background: #080808;
  transform: scale(0);
  will-change: transform;
}
#portal.on { visibility: visible; pointer-events: auto; }
#portal.on::before { transform: scale(1); transition: transform .85s cubic-bezier(.65, 0, .2, 1); }
.portal-inner { position: relative; z-index: 1; display: grid; justify-items: center; gap: 20px; opacity: 0; transform: scale(.9); transition: opacity .5s var(--ease) .35s, transform .7s var(--spring) .35s; }
#portal.on .portal-inner { opacity: 1; transform: none; }
.portal-inner p { color: var(--muted); font-size: 16px; }
.portal-inner b { color: var(--text); }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: dots 1s var(--ease) infinite; }
.dots i:nth-child(1) { background: var(--yellow); }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { background: var(--amber); animation-delay: .3s; }
@keyframes dots { 0%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-9px); opacity: 1; } }

/* ───────────── Responsive ───────────── */

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; gap: 18px; }
  .card { min-height: 230px; padding: 24px; }
  .hub-body { justify-content: flex-start; }
  .nav { padding-left: 16px; }
  .logo-sm { width: 118px; }
  .nav-name { display: none; }
  .btn-install span { display: none; }
  .btn-install { padding: 0 11px; }
  .login-card { padding: 38px 24px 28px; }
}
@media (max-width: 380px) {
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 0 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .streaks i, .logo .sheen, .login-card, .hero h1 em { animation: none !important; }
  .streaks { display: none; }
}
