/*
 * The boot screen: what index.html shows before (and without) the app's JavaScript, so the first
 * paint on a slow connection is designed, not raw markup. Render-blocking and tiny on purpose: no
 * @import, no web fonts (the system face stands in for Geist), no url(). The app keeps this file
 * for its own "not reachable" and "having a problem" screens (main.js), which use the same look.
 * Colours mirror the Workspace tokens (src/styles/tokens.css; styles/__tests__/boot.test.js keeps
 * them in step). Served from /public as /boot.css and precached by the service worker.
 */

:root {
  --boot-canvas: #f2f0eb;
  --boot-text: #18181a;
  --boot-muted: #6d6860;
  --boot-link: #835b3b;
  --boot-accent: #9d7450;
  --boot-track: #e8e4dc;
  --boot-tile: #18181a;
  --boot-glyph: #ddb892;
  --boot-glyph-light: #f8dbb7;
  --boot-glyph-dark: #8e6849;
  --boot-glyph-shadow: #342114;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --boot-canvas: #0f0f0e;
    --boot-text: #ede9e1;
    --boot-muted: #9a948a;
    --boot-link: #ddb892;
    --boot-accent: #ddb892;
    --boot-track: #2a2724;
    --boot-tile: #2a2724;
  }
}

body {
  margin: 0;
  background: var(--boot-canvas);
  color: var(--boot-text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Out of sight until a keyboard reaches it. */
.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 0.875rem;
  border-radius: 9px;
  background: var(--boot-text);
  color: var(--boot-canvas);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

.boot,
.noscript {
  display: grid;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 1.5rem 1rem;
  place-items: center;
  text-align: center;
}

.boot:focus {
  outline: none;
}

.boot__card {
  display: grid;
  max-width: 22rem;
  gap: 0.75rem;
  justify-items: center;
}

.boot__crest {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
}

.boot__tile {
  fill: var(--boot-tile);
}

.boot__head {
  fill: var(--boot-glyph);
}

/* The crest's gradient stops: the bar's sheen, the leaf's light, the bar's shadow on the bowl. */
.boot__light {
  stop-color: var(--boot-glyph-light);
}

.boot__mid {
  stop-color: var(--boot-glyph);
}

.boot__dark {
  stop-color: var(--boot-glyph-dark);
}

.boot__shadow {
  stop-color: var(--boot-glyph-shadow);
}

.boot__name {
  margin: 0.25rem 0 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.boot__title {
  margin: 0.25rem 0 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.boot__text {
  margin: 0;
  color: var(--boot-muted);
}

/* The app's own boot screens (not reachable, having a problem): the way forward. */
.boot__retry {
  margin-top: 0.5rem;
}

/* A quiet loading line: a short brass segment travelling along a hairline track. */
.boot__bar {
  position: relative;
  display: block;
  width: 7.5rem;
  height: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
  border-radius: 2px;
  background: var(--boot-track);
}

.boot__bar::after {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--boot-accent);
  animation: boot-travel 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  content: '';
}

@keyframes boot-travel {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

/* Still loading after a while (a slow connection, a stalled request): say so, kindly, with a way
   to start again. The app replaces the boot screen long before this on a normal connection. */
.boot__slow {
  margin: 0.75rem 0 0;
  color: var(--boot-muted);
  font-size: 0.8125rem;
  visibility: hidden;
  animation: boot-reveal 0s 9s forwards;
}

.boot__slow button,
.noscript a {
  color: var(--boot-link);
  font-weight: 500;
  text-underline-offset: 0.18em;
}

/* Reload is a form's button (it keeps the page's route without script) that reads as a link. */
.boot__slow button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

@keyframes boot-reveal {
  to {
    visibility: visible;
  }
}

.boot :focus-visible,
.skip-link:focus-visible {
  outline: 2px solid var(--boot-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .boot__bar::after {
    left: 30%;
    animation: none;
  }
}

.noscript p {
  max-width: 22rem;
  margin: 0;
}

/* Scripting off: the <noscript> content is real markup, and the loader would wait forever. */
body:has(.noscript) #app {
  display: none;
}
