/*
 * The installed app's launch screen (Android / iOS home-screen app).
 *
 * index.html puts .launch inside #root, so it paints before any script and
 * React replaces it on first render. App.tsx's RouteFallback shows the same
 * screen while the first page's code downloads, so the hand-off is seamless.
 * Only shown when the site runs as an installed app (display-mode:
 * standalone); in a browser tab the page loads as it always has.
 *
 * Plain CSS in /public on purpose: it has to work before the app's bundle,
 * and the manifest's background_color (#14223F) matches the edges, so the
 * phone's own splash fades into this one.
 */
@font-face {
  font-family: 'Inter Launch';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter Launch';
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2');
}

.launch { display: none; }

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .launch {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 24px;
    overflow: hidden;
    color: #fff;
    font-family: 'Inter Launch', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background:
      radial-gradient(120% 70% at 50% 38%, rgba(64, 98, 160, 0.55) 0%, rgba(37, 56, 97, 0) 60%),
      linear-gradient(180deg, #1B2D52 0%, #14223F 55%, #0F1A31 100%);
  }

  /* Faint dot grid, fading out toward the edges. */
  .launch::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(70% 55% at 50% 42%, #000 0%, transparent 100%);
    mask-image: radial-gradient(70% 55% at 50% 42%, #000 0%, transparent 100%);
    pointer-events: none;
  }

  /* The manifold: the logo's three branches, drawn large and faint behind. */
  .launch__lines {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 760px;
    height: 760px;
    transform: translate(-50%, -50%);
    opacity: 0.08;
    pointer-events: none;
  }

  .launch__mark {
    position: relative;
    width: 104px;
    height: 104px;
    border-radius: 28px;
    background: #253861;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 40px rgba(5, 10, 25, 0.45), 0 0 0 8px rgba(255, 255, 255, 0.03);
    display: grid;
    place-items: center;
    margin-bottom: 28px;
  }
  .launch__mark::after {
    /* The gold dot's glow. */
    content: '';
    position: absolute;
    left: 50%;
    top: 26px;
    width: 64px;
    height: 64px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(240, 180, 41, 0.35), rgba(240, 180, 41, 0) 70%);
    pointer-events: none;
  }
  .launch__mark svg { width: 68px; height: 68px; position: relative; z-index: 1; }

  .launch__name {
    position: relative;
    margin: 0;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    color: #fff;
  }
  .launch__iq { color: #B9CBEA; }
  .launch__i { position: relative; }
  .launch__i::before {
    /* The gold tittle on the i, as in the logo lockup. */
    content: '';
    position: absolute;
    left: 50%;
    top: 0.02em;
    width: 0.2em;
    height: 0.2em;
    border-radius: 50%;
    background: #F0B429;
    transform: translateX(-50%);
  }

  .launch__rule {
    position: relative;
    width: 40px;
    height: 2px;
    margin: 18px 0 16px;
    border-radius: 2px;
    background: #F0B429;
  }

  .launch__tagline {
    position: relative;
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(226, 234, 248, 0.78);
    padding-left: 0.32em; /* balances the trailing letter-space */
  }

  /* What we do: three pillars under the tagline, fading in one by one. */
  .launch__pillars {
    position: relative;
    display: flex;
    gap: 8px;
    margin: 30px 0 0;
    padding: 0;
    list-style: none;
  }
  .launch__pillars li {
    width: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 6px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    color: rgba(236, 241, 250, 0.92);
    opacity: 0;
    animation: launch-in 0.5s ease-out forwards;
  }
  .launch__pillars li:nth-child(2) { animation-delay: 0.15s; }
  .launch__pillars li:nth-child(3) { animation-delay: 0.3s; }
  .launch__pillars svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #F0B429;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  @keyframes launch-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }

  /* A rising trend line across the lower part of the screen. */
  .launch__chart {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    height: 22vh;
    pointer-events: none;
  }
  .launch__chart-line {
    fill: none;
    stroke: #F0B429;
    stroke-opacity: 0.6;
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
  }
  /* Drawn left to right as the app opens. */
  .launch__chart { clip-path: inset(0 100% 0 0); animation: launch-draw 1.6s ease-out 0.2s forwards; }
  @keyframes launch-draw { to { clip-path: inset(0 0 0 0); } }

  .launch__progress {
    position: absolute;
    left: 50%;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    width: 120px;
    height: 3px;
    transform: translateX(-50%);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
  }
  .launch__progress::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 40%;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(240, 180, 41, 0), #F0B429);
    animation: launch-slide 1.3s ease-in-out infinite;
  }
  @keyframes launch-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(250%); }
  }
  .launch--settled .launch__pillars li { animation: none; opacity: 1; }
  .launch--settled .launch__chart { animation: none; clip-path: none; }

  @media (prefers-reduced-motion: reduce) {
    .launch__progress::after { animation: none; width: 100%; opacity: 0.5; }
    .launch__pillars li { animation: none; opacity: 1; }
    .launch__chart { animation: none; clip-path: none; }
  }
}
