/*
 * Boot styles: loaded by app.html before the app bundle.
 * Paints the ground colour and the splash before tokens.css arrives.
 * --boot-ground and --boot-ink copy the `ground` and `ink` tokens;
 * scripts/gen-tokens.mjs --check keeps them in sync.
 */
:root {
  --boot-ground: #f6f5f1;
  --boot-ink: #111311;
}

[data-theme='dark'] {
  --boot-ground: #0e100d;
  --boot-ink: #f3f2ec;
}

html {
  background: var(--boot-ground);
}

/*
 * Onest (variable, weights 100-900), served from /fonts (licence: /fonts/OFL.txt; files from
 * @fontsource-variable/onest 5.3.1). The browser loads a file only when the page uses a
 * character in its unicode-range. app.html preloads the latin file. swap: text shows at once
 * in the system font and changes to Onest when the file arrives.
 */

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-latin-ext.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: Onest;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* The SvelteKit mount point should not add a box of its own. */
.app-root {
  display: contents;
}

/* Rows: space, the orb in the centre, the "taking too long" note under it. */
#vz-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  background: var(--boot-ground);
}

#vz-splash .splash-orb {
  grid-row: 2;
  border-radius: 50%;
  animation: splash-orb-turn 12s linear infinite;
}

@keyframes splash-orb-turn {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* "Taking too long? Reload": hidden (also from screen readers) for the first 10 s. The root
   layout removes the splash once the app runs, so a started app never shows it. */
#vz-splash .splash-stuck {
  grid-row: 3;
  align-self: start;
  margin: 24px 24px 0;
  max-width: 32ch;
  text-align: center;
  font:
    400 15px/1.4 Onest,
    ui-sans-serif,
    system-ui,
    sans-serif;
  color: var(--boot-ink);
  visibility: hidden;
  opacity: 0;
  animation: splash-stuck-show 0.4s ease-out 10s forwards;
}

#vz-splash .splash-stuck a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* One language at a time: theme-init.js has set <html lang> before the first paint. */
html:not([lang='ru']) .splash-stuck [lang='ru'],
html[lang='ru'] .splash-stuck [lang='en'] {
  display: none;
}

@keyframes splash-stuck-show {
  to {
    visibility: visible;
    opacity: 1;
  }
}

/* Without JavaScript this note covers the splash (it comes later in the page). */
.vz-noscript {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  background: var(--boot-ground);
  color: var(--boot-ink);
  font:
    400 17px/1.45 Onest,
    ui-sans-serif,
    system-ui,
    sans-serif;
  text-align: center;
}

.vz-noscript p {
  margin: 0;
  max-width: 36ch;
}

@media (prefers-reduced-motion: reduce) {
  #vz-splash .splash-orb {
    animation: none;
  }

  /* No fade: the note just appears after the same 10 s. */
  #vz-splash .splash-stuck {
    animation-duration: 0s;
  }
}
