/* Webiness — AI Development: componente "Stesso processo, due velocità" */

.ai-speed-animation {
  --ai-ink: #0d1628;
  --ai-line: #d8dfeb;
  --ai-white: #ffffff;
  --ai-brand: #cc0090;
  --ai-brand-light: #ffe8f8;
  --ai-loop: 7.2s;
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dfe5ef;
  border-radius: 20px;
  background:
    radial-gradient(circle at 52% 46%, rgba(204, 0, 144, .10), transparent 27%),
    linear-gradient(rgba(13, 22, 40, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 22, 40, .035) 1px, transparent 1px),
    var(--ai-white);
  background-size: auto, 24px 24px, 24px 24px, auto;
  box-shadow: 0 22px 50px rgba(13, 22, 40, .12);
  color: var(--ai-ink);
  font-family: Nunito, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ai-speed-animation *,
.ai-speed-animation *::before,
.ai-speed-animation *::after { box-sizing: border-box; }

.ai-speed-animation::after {
  position: absolute;
  z-index: -1;
  right: -100px;
  bottom: -145px;
  width: 310px;
  height: 310px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(204, 0, 144, .14), rgba(204, 0, 144, 0) 68%);
  content: "";
}

/* ── barra superiore ── */

.ai-board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 20px;
  border-bottom: 1px solid var(--ai-line);
  background: rgba(255, 255, 255, .82);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.ai-board-name { display: flex; align-items: center; gap: 9px; }

.ai-board-name::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ai-brand);
  box-shadow: 0 0 0 5px var(--ai-brand-light);
  content: "";
}

.ai-active {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #16835c;
}

.ai-active i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25aa78;
  animation: ai-blink 1.7s ease-in-out infinite;
}

/* ── corpo ── */

.ai-board { padding: 24px clamp(18px, 4vw, 28px) 20px; }

.ai-task {
  margin-bottom: 26px;
  padding: 13px 15px;
  border: 1px solid #e6eaf1;
  border-radius: 12px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 8px 20px rgba(13, 22, 40, .05);
}

.ai-task-label {
  display: block;
  margin-bottom: 4px;
  color: #8b96a9;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ai-task strong {
  display: block;
  color: var(--ai-ink);
  font-size: .84rem;
  font-weight: 900;
  line-height: 1.25;
}

/* ── le due corsie ── */

.ai-lane + .ai-lane { margin-top: 20px; }

.ai-lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.ai-tag {
  padding: 3px 9px;
  border: 1px solid #dce2ec;
  border-radius: 20px;
  background: #f4f6fa;
  color: #6b7789;
  font-size: .6rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.ai-tag--ai {
  border-color: transparent;
  background: var(--ai-brand);
  color: #fff;
}

/* stato: "in corso" e "completato" si alternano */

.ai-state {
  position: relative;
  display: grid;
  font-size: .62rem;
  font-weight: 800;
}

.ai-state > span {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.ai-state-run { color: #98a3b3; }
.ai-state-done { color: var(--ai-brand); opacity: 0; }

.ai-state-run i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c3ccda;
  animation: ai-pulse 1.1s ease-in-out infinite;
}

.ai-lane--before .ai-state-done { color: #6b7789; }

/* ── la barra di avanzamento ── */

.ai-track {
  position: relative;
  display: block;
  height: 11px;
  overflow: hidden;
  border-radius: 7px;
  background: #edf0f5;
  background-image: repeating-linear-gradient(90deg, transparent 0 33px, rgba(255, 255, 255, .95) 33px 35px);
}

.ai-track i {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  border-radius: 7px;
  background: linear-gradient(90deg, #b9c3d2, #94a1b5);
}

.ai-lane--after .ai-track i {
  background: linear-gradient(90deg, #ff5eb8, var(--ai-brand));
  box-shadow: 0 0 10px rgba(204, 0, 144, .35);
}

/* la corsia "oggi" arranca, con due stalli */
.ai-lane--before .ai-track i { animation: ai-fill-slow var(--ai-loop) linear infinite; }
.ai-lane--before .ai-state-run { animation: ai-run-slow var(--ai-loop) linear infinite; }
.ai-lane--before .ai-state-done { animation: ai-done-slow var(--ai-loop) linear infinite; }

/* la corsia "con l'AI" chiude subito */
.ai-lane--after .ai-track i { animation: ai-fill-fast var(--ai-loop) cubic-bezier(.3, .8, .3, 1) infinite; }
.ai-lane--after .ai-state-run { animation: ai-run-fast var(--ai-loop) linear infinite; }
.ai-lane--after .ai-state-done { animation: ai-done-fast var(--ai-loop) linear infinite; }

.ai-note {
  margin: 22px 0 0;
  color: #7d8799;
  font-size: .68rem;
  font-weight: 800;
  font-style: italic;
  text-align: center;
  animation: ai-note var(--ai-loop) ease-in-out infinite;
}

/* ── piede ── */

.ai-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 13px 18px 16px;
  border-top: 1px solid #eaeff6;
  color: #8b96a9;
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.ai-foot span { display: flex; align-items: center; gap: 7px; }

.ai-foot span::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ai-brand);
  opacity: .55;
  content: "";
}

/* ── keyframes ── */

@keyframes ai-blink {
  0%, 32% { background: #25aa78; box-shadow: 0 0 0 1px #25aa78, 0 0 0 5px rgba(37, 170, 120, .16); }
  33%, 100% { background: #bdc8d8; box-shadow: 0 0 0 1px #bdc8d8; }
}

@keyframes ai-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

@keyframes ai-fill-slow {
  0%, 5% { width: 0; }
  24% { width: 19%; }
  32% { width: 21%; }  /* stallo */
  50% { width: 44%; }
  58% { width: 46%; }  /* stallo */
  74% { width: 74%; }
  82%, 95% { width: 100%; }
  96%, 100% { width: 0; }
}

@keyframes ai-fill-fast {
  0%, 5% { width: 0; }
  25%, 95% { width: 100%; }
  96%, 100% { width: 0; }
}

@keyframes ai-run-slow {
  0%, 80% { opacity: 1; }
  84%, 95% { opacity: 0; }
  96%, 100% { opacity: 1; }
}

@keyframes ai-done-slow {
  0%, 80% { opacity: 0; }
  84%, 95% { opacity: 1; }
  96%, 100% { opacity: 0; }
}

@keyframes ai-run-fast {
  0%, 22% { opacity: 1; }
  27%, 95% { opacity: 0; }
  96%, 100% { opacity: 1; }
}

@keyframes ai-done-fast {
  0%, 22% { opacity: 0; }
  27%, 95% { opacity: 1; }
  96%, 100% { opacity: 0; }
}

@keyframes ai-note {
  0%, 30% { opacity: 0; }
  40%, 95% { opacity: 1; }
  96%, 100% { opacity: 0; }
}

/* l'animazione parte solo quando il pannello entra nella viewport */
.ai-speed-animation:not(.is-visible) .ai-track i,
.ai-speed-animation:not(.is-visible) .ai-state-run,
.ai-speed-animation:not(.is-visible) .ai-state-run i,
.ai-speed-animation:not(.is-visible) .ai-state-done,
.ai-speed-animation:not(.is-visible) .ai-note,
.ai-speed-animation:not(.is-visible) .ai-active i { animation-play-state: paused; }

@media (max-width: 560px) {
  .ai-board { padding-top: 20px; }
  .ai-task { margin-bottom: 22px; }
  .ai-lane + .ai-lane { margin-top: 17px; }
  .ai-lane-head { flex-wrap: wrap; gap: 6px; }
  .ai-foot { gap: 6px 14px; font-size: .58rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-speed-animation *,
  .ai-speed-animation *::before,
  .ai-speed-animation *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  /* stato finale leggibile senza movimento: entrambe completate, l'AI molto prima */
  .ai-speed-animation .ai-lane--before .ai-track i { width: 46%; }
  .ai-speed-animation .ai-lane--after .ai-track i { width: 100%; }
  .ai-speed-animation .ai-lane--before .ai-state-run { opacity: 1; }
  .ai-speed-animation .ai-lane--before .ai-state-done { opacity: 0; }
  .ai-speed-animation .ai-lane--after .ai-state-run { opacity: 0; }
  .ai-speed-animation .ai-lane--after .ai-state-done { opacity: 1; }
  .ai-speed-animation .ai-note { opacity: 1; }
}
