/*
 * The pre-mount splash, shown from index.html until React mounts and the real
 * KorroLoader takes over. Linked as a stylesheet rather than inlined so it and
 * the three marks can be cached: a cold load spends one extra round trip here,
 * which costs a frame or two of white on a slow connection and nothing at all
 * afterwards.
 *
 * Layout and timings are ported from the Flutter portal's own splash
 * (web/styles.css there) and are matched by
 * src/presentation/components/loading/KorroLoader.tsx, so the handover when
 * React mounts is seamless. Keep the three in step.
 *
 * The marks sit on a 10x100 grid rather than in stacked rows: red spans rows
 * 1-66 and the blue/yellow pair rows 55-100, so the pair overlaps the red
 * instead of sitting below it.
 */

#boot-splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.boot-block {
  position: absolute;
  width: 100px;
  height: 100px;
  top: calc(50% - 50px);
  left: calc(50% - 50px);
}

.boot-rotator {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(100, 1fr);
  width: 100px;
  height: 100px;
  aspect-ratio: 1;
  box-sizing: border-box;
  transform-origin: center;
  animation: bootRotateAndScale 3s infinite ease-in;
}

.boot-rotator img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  /* Each mark is brought in by its own animation below. */
  transform: scale(0);
}

@keyframes bootRotateAndScale {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(0deg) scale(1); }
  54% { transform: rotate(-42.18deg) scale(1.138); }
  71% { transform: rotate(720deg) scale(0); }
  99.99% { transform: rotate(0deg) scale(0); }
  100% { transform: rotate(0deg) scale(1); }
}

@keyframes bootScaleRed {
  10% { transform: scale(1.1); }
  15% { transform: scale(1); }
  99.99% { transform: scale(1); }
  100% { transform: scale(0); }
}

@keyframes bootScaleBlue {
  15% { transform: scale(0); }
  25% { transform: scale(1.1); }
  30% { transform: scale(1); }
  99.99% { transform: scale(1); }
  100% { transform: scale(0); }
}

@keyframes bootScaleYellow {
  30% { transform: scale(0); }
  40% { transform: scale(1.1); }
  45% { transform: scale(1); }
  99.99% { transform: scale(1); }
  100% { transform: scale(0); }
}

.boot-red {
  grid-column: 1 / 10;
  grid-row: 1 / 66;
  animation: bootScaleRed 3s infinite ease-in-out;
}

.boot-blue {
  grid-column: 1 / 7;
  grid-row: 55 / 100;
  animation: bootScaleBlue 3s infinite ease-in-out;
}

.boot-yellow {
  grid-column: 7 / 10;
  grid-row: 55 / 100;
  margin-top: 5px;
  animation: bootScaleYellow 3s infinite ease-in-out;
}
