/**
 * LOOKITSGRAPHIC — Diagram & Mindmap Studio
 * Écran d'accueil animé dans .canvas-panel
 *
 * Deux cycles indépendants, volontairement désynchronisés :
 *   - branches et nœuds  → 7 s
 *   - formes du hub      → 9,8 s (7 formes × 1,4 s)
 */

.mm-welcome {
  --purple: var(--violet);
  --orange: var(--coral);
  --amber: #ffda8a;
  --warm: #d8d2c5;

  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  overflow: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(#11110f2e 1px, transparent 1px);
  background-size: 18px 18px;
  font-family: "Arial Narrow", "Helvetica Neue Condensed", Arial, sans-serif;
  color: var(--ink);
}

.mm-stage {
  position: relative;
  width: min(500px, calc(100% - 32px));
  height: 220px;
  flex: none;
}

.mm-stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mm-stage path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-dasharray: 170;
  stroke-dashoffset: 170;
  animation: mm-draw 7s ease-out infinite;
}

@keyframes mm-draw {
  0%       { stroke-dashoffset: 170; }
  18%, 86% { stroke-dashoffset: 0; }
  96%, 100% { stroke-dashoffset: 170; }
}

.mm-node {
  position: absolute;
  width: 124px;
  border: 2px solid var(--ink);
  background: var(--mm-c);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 4px;
  text-align: center;
  font: 900 12px/1.2 "Courier New", monospace;
  letter-spacing: 0.04em;
  opacity: 0;
  animation: mm-pop 7s ease-out infinite;
}

@keyframes mm-pop {
  0%       { opacity: 0; transform: scale(0.4); }
  12%, 86% { opacity: 1; transform: scale(1); }
  96%, 100% { opacity: 0; transform: scale(0.4); }
}

.mm-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 162px;
  height: 118px;
  margin: -59px 0 0 -81px;
}

/* Une forme + 4 poignées par cycle — contours et handles alignés */
.mm-shape-slot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  animation: mm-shape 9.8s ease-in-out infinite;
}

.mm-shape-inner {
  position: relative;
  flex: none;
}

.mm-shape-slot.s-rounded .mm-shape-inner,
.mm-shape-slot.s-rect .mm-shape-inner,
.mm-shape-slot.s-pill .mm-shape-inner,
.mm-shape-slot.s-note .mm-shape-inner {
  width: 104px;
  height: 78px;
}

.mm-shape-slot.s-diamond .mm-shape-inner {
  width: 76px;
  height: 76px;
  overflow: visible;
}

.mm-shape-slot.s-diamond .mm-shape {
  width: 100%;
  height: 100%;
  transform: rotate(45deg);
  transform-origin: center center;
}

.mm-shape-slot.s-circle .mm-shape-inner {
  width: 88px;
  height: 88px;
}

.mm-shape-slot.s-hexagon .mm-shape-inner {
  width: 104px;
  height: 78px;
}

.mm-shape {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 2px solid var(--ink);
  background: var(--mm-c);
  filter: drop-shadow(4px 4px 0 var(--ink));
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  shape-rendering: geometricPrecision;
}

.mm-shape-slot.s-rounded .mm-shape { border-radius: 12px; }
.mm-shape-slot.s-rect .mm-shape    { border-radius: 0; }
.mm-shape-slot.s-pill .mm-shape    { border-radius: 999px; }
.mm-shape-slot.s-circle .mm-shape  { border-radius: 50%; }
.mm-shape-slot.s-note .mm-shape    { border-radius: 0 18px 0 0; }

.mm-shape-hex {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(4px 4px 0 var(--ink));
}

.mm-shape-hex polygon {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: miter;
}

@keyframes mm-shape {
  0%       { opacity: 0; }
  2%, 13%  { opacity: 1; }
  16%, 100% { opacity: 0; }
}

.mm-hub-label {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  pointer-events: none;
  font: 900 15px/1.1 "Courier New", monospace;
  letter-spacing: 0.06em;
}

/* Poignées calées sur les extrémités de chaque forme */
.mm-shape-inner .mm-handle {
  position: absolute;
  z-index: 5;
  width: 11px;
  height: 11px;
}

.mm-shape-inner .mm-handle::before {
  content: "";
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  animation: mm-handle-pulse 1.9s ease-in-out infinite;
}

.mm-shape-inner .mm-handle.h-left  { left: 0; top: 50%; transform: translate(-50%, -50%); }
.mm-shape-inner .mm-handle.h-right { right: 0; top: 50%; transform: translate(50%, -50%); }
.mm-shape-inner .mm-handle.h-top   { top: 0; left: 50%; transform: translate(-50%, -50%); }
.mm-shape-inner .mm-handle.h-bot   { bottom: 0; left: 50%; transform: translate(-50%, 50%); }

.mm-shape-inner .mm-handle.h-right::before { animation-delay: 0.45s; }
.mm-shape-inner .mm-handle.h-top::before   { animation-delay: 0.9s; }
.mm-shape-inner .mm-handle.h-bot::before   { animation-delay: 1.35s; }

@keyframes mm-handle-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.45); }
}

.mm-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  z-index: 5;
  padding: 0 20px;
}

.mm-foot h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.055em;
}

.mm-foot p {
  margin: 0;
  max-width: 440px;
  text-align: center;
  font: 700 14px/1.5 "Courier New", monospace;
  letter-spacing: 0.02em;
}

.mm-start {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--acid);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  min-height: 48px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.mm-start:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.mm-start:active {
  transform: translate(2px, 2px);
  box-shadow: 3px 3px 0 var(--ink);
}

.mm-start span {
  margin-left: 16px;
  font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .mm-welcome * {
    animation: none !important;
  }

  .mm-stage path {
    stroke-dashoffset: 0;
  }

  .mm-node {
    opacity: 1;
    transform: none;
  }

  .mm-shape-slot {
    opacity: 0;
  }

  .mm-shape-slot.s-rounded {
    opacity: 1;
  }
}
