/* Webiness — Marketing in Outsourcing: componente "Da fornitori sparsi a un ufficio unico" */

.mo-office-animation {
  --mo-ink: #0d1628;
  --mo-muted: #526077;
  --mo-line: #d8dfeb;
  --mo-white: #ffffff;
  --mo-brand: #cc0090;
  --mo-brand-light: #ffe8f8;
  --mo-shadow: 0 22px 50px rgba(13, 22, 40, .12);
  --mo-loop: 8.4s;
  --mo-gap: clamp(14px, 3.2vw, 30px);
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  min-height: 390px;
  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(--mo-white);
  background-size: auto, 24px 24px, 24px 24px, auto;
  box-shadow: var(--mo-shadow);
  color: var(--mo-ink);
  font-family: Nunito, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mo-office-animation *,
.mo-office-animation *::before,
.mo-office-animation *::after { box-sizing: border-box; }

.mo-office-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 ── */

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

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

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

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

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

/* ── griglia principale ── */

.mo-board {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr) minmax(0, .95fr);
  align-items: center;
  min-height: 268px;
  padding: 22px var(--mo-gap) 16px;
  gap: var(--mo-gap);
}

.mo-col { position: relative; min-width: 0; }

.mo-col-label {
  display: block;
  margin-bottom: 10px;
  color: #8b96a9;
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ── colonna 1: fornitori sparsi ── */

.mo-slot {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 8px;
  border: 1px dashed #e2e7f0;
  border-radius: 9px;
}

.mo-slot:nth-of-type(1) { --mo-i: 0; margin-left: 0; }
.mo-slot:nth-of-type(2) { --mo-i: 1; margin-left: 16px; }
.mo-slot:nth-of-type(3) { --mo-i: 2; margin-left: 5px; }
.mo-slot:nth-of-type(4) { --mo-i: 3; margin-left: 21px; }

.mo-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -1px;
  padding: 7px 10px;
  border: 1px dashed #cdd5e2;
  border-radius: 9px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 14px rgba(13, 22, 40, .05);
  color: #6b7789;
  font-size: .67rem;
  font-weight: 800;
  white-space: nowrap;
  animation: mo-chip var(--mo-loop) ease-in-out infinite;
  animation-delay: calc(var(--mo-i) * .5s);
}

.mo-chip::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: #c3ccda;
  content: "";
}

.mo-nocoord {
  display: block;
  margin-top: 12px;
  color: #a2acbb;
  font-size: .6rem;
  font-weight: 800;
  font-style: italic;
  animation: mo-nocoord var(--mo-loop) ease-in-out infinite;
}

/* ── colonna 2: l'ufficio marketing ── */

.mo-office {
  position: relative;
  padding: 16px 15px 14px;
  border: 1px solid #f0c4e2;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffafd, #ffffff 58%);
  box-shadow: 0 14px 32px rgba(13, 22, 40, .09);
  animation: mo-office-glow var(--mo-loop) ease-in-out infinite;
}

.mo-office-head {
  margin-bottom: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid #f3e2ee;
}

.mo-office-tag {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--mo-brand);
  color: #fff;
  font-size: .54rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.mo-office-head strong {
  display: block;
  color: var(--mo-ink);
  font-size: .84rem;
  font-weight: 900;
  line-height: 1.2;
}

.mo-fn {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
  padding: 8px 10px;
  border: 1px solid #e6eaf1;
  border-radius: 9px;
  background: #fff;
  color: #7a8596;
  font-size: .68rem;
  font-weight: 800;
  animation: mo-fn var(--mo-loop) ease-in-out infinite;
  animation-delay: calc(var(--mo-i) * .5s);
}

.mo-fn i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #dbe1ea;
  animation: mo-dot var(--mo-loop) ease-in-out infinite;
  animation-delay: calc(var(--mo-i) * .5s);
}

/* il primo div della card è .mo-office-head, quindi le righe partono da 2 */
.mo-fn:nth-of-type(2) { --mo-i: 0; }
.mo-fn:nth-of-type(3) { --mo-i: 1; }
.mo-fn:nth-of-type(4) { --mo-i: 2; }
.mo-fn:nth-of-type(5) { --mo-i: 3; }

/* ── colonna 3: il risultato ── */

.mo-flow {
  position: absolute;
  top: calc(50% + 11px); /* compensa l'etichetta "Risultato" sopra la card */
  right: 100%;
  width: var(--mo-gap);
  height: 3px;
  margin-top: -1px;
  background-image: repeating-linear-gradient(90deg, var(--mo-brand) 0 6px, transparent 6px 12px);
  background-size: 12px 3px;
  animation:
    mo-flow-in var(--mo-loop) ease-in-out infinite,
    mo-flow-move .62s linear infinite;
}

.mo-outcome {
  padding: 14px 13px 13px;
  border: 1px dashed #dfe5ef;
  border-radius: 12px;
  background: rgba(255, 255, 255, .6);
  animation: mo-outcome var(--mo-loop) ease-in-out infinite;
}

.mo-outcome b {
  display: grid;
  width: 24px;
  height: 24px;
  margin-bottom: 9px;
  place-items: center;
  border-radius: 7px;
  background: #dbe1ea;
  color: #fff;
  font-size: .65rem;
  animation: mo-outcome-check var(--mo-loop) ease-in-out infinite;
}

.mo-outcome strong {
  display: block;
  color: #7a8596;
  animation: mo-outcome-title var(--mo-loop) ease-in-out infinite;
  font-size: .76rem;
  font-weight: 900;
  line-height: 1.25;
}

.mo-outcome small {
  display: block;
  margin-top: 3px;
  color: #7d8799;
  font-size: .6rem;
  font-weight: 700;
}

.mo-meter {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #f3e2ee;
  color: #8b96a9;
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.mo-meter span {
  display: block;
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #f0e3ec;
}

.mo-meter i {
  display: block;
  width: 6%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff5eb8, var(--mo-brand));
  animation: mo-meter var(--mo-loop) ease-in-out infinite;
}

/* ── piede ── */

.mo-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 22px;
  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;
}

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

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

/* ── keyframes ── */

@keyframes mo-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; }
}

/* i fornitori compaiono sparsi, poi vengono assorbiti verso l'ufficio */
@keyframes mo-chip {
  0%, 16% { opacity: 1; transform: translateX(0) scale(1); }
  27% { opacity: .9; transform: translateX(9px) scale(.99); }
  38%, 88% { opacity: 0; transform: translateX(34px) scale(.86); }
  97%, 100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes mo-nocoord {
  0%, 24% { opacity: 1; }
  36%, 90% { opacity: 0; }
  100% { opacity: 1; }
}

/* ogni funzione si accende quando il fornitore corrispondente è stato assorbito */
@keyframes mo-fn {
  0%, 34% { border-color: #e6eaf1; background: #fff; color: #7a8596; }
  42%, 86% { border-color: #f1b8dd; background: #fffafd; color: var(--mo-ink); }
  93%, 100% { border-color: #e6eaf1; background: #fff; color: #7a8596; }
}

@keyframes mo-dot {
  0%, 34% { background: #dbe1ea; transform: scale(1); }
  42%, 86% { background: var(--mo-brand); transform: scale(1.15); }
  93%, 100% { background: #dbe1ea; transform: scale(1); }
}

@keyframes mo-office-glow {
  0%, 58% { box-shadow: 0 14px 32px rgba(13, 22, 40, .09); }
  70%, 86% { box-shadow: 0 14px 32px rgba(13, 22, 40, .09), 0 0 0 4px rgba(204, 0, 144, .09); }
  94%, 100% { box-shadow: 0 14px 32px rgba(13, 22, 40, .09); }
}

@keyframes mo-flow-in {
  0%, 60% { opacity: 0; }
  68%, 88% { opacity: 1; }
  93%, 100% { opacity: 0; }
}

@keyframes mo-flow-move {
  to { background-position: -12px 0; }
}

@keyframes mo-outcome {
  0%, 62% {
    border-style: dashed; border-color: #dfe5ef;
    background: rgba(255, 255, 255, .6);
    box-shadow: none;
    transform: none;
  }
  72%, 88% {
    border-style: solid; border-color: #f1b8dd;
    background: #fffafd;
    box-shadow: 0 12px 26px rgba(13, 22, 40, .07);
    transform: translateY(-2px);
  }
  95%, 100% {
    border-style: dashed; border-color: #dfe5ef;
    background: rgba(255, 255, 255, .6);
    box-shadow: none;
    transform: none;
  }
}

@keyframes mo-outcome-check {
  0%, 62% { background: #dbe1ea; transform: scale(1); }
  72%, 88% { background: var(--mo-brand); transform: scale(1.06); }
  95%, 100% { background: #dbe1ea; transform: scale(1); }
}

@keyframes mo-outcome-title {
  0%, 62% { color: #7a8596; }
  72%, 88% { color: var(--mo-ink); }
  95%, 100% { color: #7a8596; }
}

@keyframes mo-meter {
  0%, 66% { width: 6%; }
  88%, 100% { width: 100%; }
}

/* l'animazione parte solo quando il pannello entra nella viewport */
.mo-office-animation:not(.is-visible) .mo-chip,
.mo-office-animation:not(.is-visible) .mo-nocoord,
.mo-office-animation:not(.is-visible) .mo-fn,
.mo-office-animation:not(.is-visible) .mo-fn i,
.mo-office-animation:not(.is-visible) .mo-office,
.mo-office-animation:not(.is-visible) .mo-flow,
.mo-office-animation:not(.is-visible) .mo-outcome,
.mo-office-animation:not(.is-visible) .mo-outcome b,
.mo-office-animation:not(.is-visible) .mo-outcome strong,
.mo-office-animation:not(.is-visible) .mo-meter i,
.mo-office-animation:not(.is-visible) .mo-active i { animation-play-state: paused; }

@media (max-width: 640px) {
  .mo-office-animation { min-height: 0; }
  .mo-board {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding-top: 18px;
    gap: 20px;
  }
  /* i fornitori passano da colonna a griglia compatta */
  .mo-col--suppliers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .mo-col--suppliers .mo-col-label,
  .mo-col--suppliers .mo-nocoord { flex: 1 0 100%; margin: 0; }
  .mo-slot { margin: 0 !important; }
  .mo-chip { font-size: .64rem; }
  .mo-office { padding: 14px 13px 12px; }
  .mo-fn { margin-top: 6px; padding: 7px 9px; }
  .mo-flow { display: none; }
  .mo-foot { gap: 6px 16px; font-size: .58rem; }
}

@keyframes mo-flow-move-v {
  to { background-position: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .mo-office-animation *,
  .mo-office-animation *::before,
  .mo-office-animation *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
  /* stato finale leggibile senza movimento */
  .mo-office-animation .mo-chip { opacity: 1; transform: none; }
  .mo-office-animation .mo-fn { border-color: #f1b8dd; background: #fffafd; color: var(--mo-ink); }
  .mo-office-animation .mo-fn i { background: var(--mo-brand); }
  .mo-office-animation .mo-flow { opacity: 1; }
  .mo-office-animation .mo-outcome { border-style: solid; border-color: #f1b8dd; background: #fffafd; }
  .mo-office-animation .mo-outcome b { background: var(--mo-brand); }
  .mo-office-animation .mo-outcome strong { color: var(--mo-ink); }
  .mo-office-animation .mo-meter i { width: 100%; }
}
