/* "Come funziona" (public/js/help.js): finestra di benvenuto in stile macOS, senza scorrimento.
   Il contenuto si adatta alla finestra con le container query: se è più piccola, si compatta. */

.help-window .window-body {
  overflow: hidden;
}

.hx {
  container-type: size;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  user-select: none;
}

/* --- intestazione ----------------------------------------------------------------------- */

.hx-hero {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px 18px;
  overflow: hidden;
  isolation: isolate;
}

/* Luci colorate che si muovono piano dietro l'intestazione, come gli sfondi di macOS */
.hx-hero-glow {
  position: absolute;
  inset: -60% -10% -40%;
  z-index: -1;
  background:
    radial-gradient(40% 60% at 15% 40%, rgba(90, 200, 250, 0.35), transparent 70%),
    radial-gradient(35% 55% at 55% 20%, rgba(175, 82, 222, 0.25), transparent 70%),
    radial-gradient(40% 60% at 90% 60%, rgba(255, 149, 0, 0.22), transparent 70%);
  filter: blur(18px);
  animation: hx-drift 14s ease-in-out infinite alternate;
}

.hx-hero::after {
  content: '';
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 0.5px;
  background: var(--border);
}

.hx-hero-icon {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 16px rgba(10, 100, 216, 0.35));
  animation: hx-float 5s ease-in-out infinite;
}

.hx-hero-text {
  flex: 1;
  min-width: 0;
}

.hx-hero-text h2 {
  margin: 0 0 3px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hx-hero-text p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-2);
}

/* Pulsante del tour: pillola blu con riflesso che passa al passaggio del mouse */
.hx-tour {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #3b9bff, #0a64d8);
  color: #fff;
  text-align: left;
  box-shadow: 0 6px 18px rgba(10, 100, 216, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.4), box-shadow 0.2s;
}

.hx-tour::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
}

.hx-tour:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 24px rgba(10, 100, 216, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hx-tour:hover::after {
  left: 130%;
  transition: left 0.8s ease;
}

.hx-tour:active {
  transform: scale(0.98);
}

.hx-tour-play {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.hx-tour-play .svg {
  width: 16px;
  height: 16px;
}

.hx-tour strong {
  display: block;
  font-size: 13px;
}

.hx-tour small {
  display: block;
  font-size: 11px;
  opacity: 0.85;
}

/* --- controllo a schede (segmented control) ------------------------------------------- */

.hx-seg {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-self: center;
  margin: 14px 0 4px;
  padding: 2px;
  border-radius: 9px;
  background: var(--row-alt);
  box-shadow: inset 0 0 0 0.5px var(--border);
}

.hx-seg-pill {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: 7px;
  background: var(--window-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.35s cubic-bezier(0.3, 0.8, 0.3, 1.1), width 0.35s cubic-bezier(0.3, 0.8, 0.3, 1.1);
}

.hx-seg-btn {
  position: relative;
  padding: 5px 16px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: color 0.2s;
}

.hx-seg-btn.on {
  color: var(--text);
  font-weight: 600;
}

/* Le scorciatoie servono solo con la tastiera */
@media (hover: none) {
  .hx-keyboard-only {
    display: none;
  }
}

/* --- area delle schede -------------------------------------------------------------------- */

.hx-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 10px 24px 20px;
}

.hx-panel {
  flex: 1;
  min-height: 0;
  animation: hx-panel-in 0.4s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

/* Gli elementi entrano uno dopo l'altro (--i = posizione) */
.hx-step,
.hx-feature,
.hx-shortcuts li {
  animation: hx-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  animation-delay: calc(var(--i, 0) * 60ms + 80ms);
}

/* Come iniziare: quattro tappe collegate da una linea che si "disegna" */
.hx-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-content: center;
}

.hx-steps-line {
  position: absolute;
  top: calc(50% - 64px);
  left: 12.5%;
  right: 12.5%;
  height: 3px;
  border-radius: 2px;
  background: var(--row-alt);
}

.hx-steps-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0a84ff, #af52de, #ff9500, #30d158);
  transform-origin: left;
  animation: hx-line 1.1s 0.3s cubic-bezier(0.6, 0, 0.3, 1) both;
}

.hx-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hx-step-icon {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: var(--window-bg); /* copre la linea dietro l'icona */
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1.4);
}

.hx-step-icon > .svg {
  display: block;
  width: 100%;
  height: 100%;
}

.hx-step-icon b {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--window-bg);
  border-radius: 50%;
  background: var(--text);
  color: var(--window-bg);
  font-size: 11px;
}

.hx-step:hover .hx-step-icon {
  transform: translateY(-4px) rotate(-3deg) scale(1.05);
}

.hx-step strong {
  margin-bottom: 4px;
  font-size: 13.5px;
}

.hx-step p {
  margin: 0;
  max-width: 150px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}

/* Funzioni: riquadri in griglia con icona da "app" */
.hx-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  gap: 12px;
}

.hx-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 14px;
  border-radius: 12px;
  background: var(--row-alt);
  box-shadow: inset 0 0 0 0.5px var(--border);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.hx-feature:hover {
  transform: translateY(-2px);
  background: var(--window-bg);
  box-shadow: inset 0 0 0 0.5px var(--border), 0 8px 20px rgba(0, 0, 0, 0.12);
}

.hx-feature-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.15));
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1.4);
}

.hx-feature:hover .hx-feature-icon {
  transform: scale(1.1) rotate(-4deg);
}

.hx-feature strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 13px;
}

.hx-feature p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-2);
}

/* Scorciatoie: due colonne di tasti in rilievo */
.hx-shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.hx-shortcuts h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}

.hx-shortcuts ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hx-shortcuts li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3.5px 0;
  font-size: 12.5px;
}

.hx-keys {
  display: inline-flex;
  flex-shrink: 0;
  gap: 3px;
}

.hx-shortcuts .hx-keys {
  justify-content: flex-end;
  width: 84px;
}

.hx kbd {
  min-width: 22px;
  padding: 2px 6px;
  border: 0.5px solid var(--btn-border);
  border-radius: 5px;
  background: linear-gradient(180deg, var(--window-bg), var(--btn-bg));
  box-shadow: 0 1px 0 var(--btn-border), 0 1.5px 2px rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

/* --- finestre più piccole: tutto si compatta, niente scorrimento ------------------------ */

@container (max-height: 500px) {
  .hx-hero {
    padding: 14px 20px 12px;
  }

  .hx-hero-icon {
    width: 48px;
    height: 48px;
  }

  .hx-seg {
    margin-top: 10px;
  }

  .hx-stage {
    padding: 6px 20px 14px;
  }

  .hx-feature {
    min-height: 0;
    padding: 9px 12px;
  }

  .hx-feature p {
    display: none;
  }

  .hx-tour {
    padding: 6px 14px 6px 6px;
  }

  .hx-tour small {
    display: none;
  }

  .hx-tour-play {
    width: 24px;
    height: 24px;
  }

  .hx-shortcuts h3 {
    margin-bottom: 3px;
  }

  .hx-shortcuts li {
    padding: 1px 0;
    font-size: 12px;
  }

  .hx kbd {
    padding: 1px 5px;
  }
}

/* Stretta ma alta: il pulsante del tour va sotto, a tutta larghezza */
@container (max-width: 620px) and (min-height: 501px) {
  .hx-hero {
    flex-wrap: wrap;
  }

  .hx-tour {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

/* Stretta e bassa: il pulsante resta accanto al titolo, senza la descrizione */
@container (max-width: 620px) and (max-height: 500px) {
  .hx-hero-text p {
    display: none;
  }
}

@container (max-width: 620px) {
  .hx-features {
    grid-template-columns: 1fr 1fr;
  }

  .hx-shortcuts {
    gap: 14px;
  }

  .hx-shortcuts .hx-keys {
    width: 70px;
  }
}

/* Telefono: tappe a griglia 2×2 e testi più brevi */
@container (max-width: 460px) {
  .hx-hero-text p {
    display: none;
  }

  .hx-steps {
    grid-template-columns: 1fr 1fr;
    row-gap: 18px;
  }

  .hx-steps-line {
    display: none;
  }

  .hx-step-icon {
    width: 52px;
    height: 52px;
  }

  .hx-features {
    gap: 8px;
  }

  .hx-feature {
    flex-direction: column;
    gap: 6px;
    padding: 10px;
  }

  .hx-feature-icon {
    width: 32px;
    height: 32px;
  }

  .hx-stage {
    padding: 6px 14px 14px;
  }
}

/* --- animazioni --------------------------------------------------------------------------- */

@keyframes hx-float {
  50% {
    transform: translateY(-5px) rotate(-2deg);
  }
}

@keyframes hx-drift {
  to {
    transform: translate(4%, 6%) scale(1.08);
  }
}

@keyframes hx-panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes hx-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}

@keyframes hx-line {
  from {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hx-hero-glow,
  .hx-hero-icon,
  .hx-panel,
  .hx-step,
  .hx-feature,
  .hx-shortcuts li,
  .hx-steps-line i {
    animation: none;
  }
}
