/* main.css — reset, layout shell, typography, screen transitions. */

:root {
  --bg-top: #070c18;
  --bg-bottom: #0b1226;
  --accent: #22d3ee;
  --accent-rgb: 34, 211, 238;
  --text: #e8f1ff;
  --text-dim: rgba(200, 220, 255, 0.55);
  --panel: #101a33;
  --panel-edge: #1f3a63;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --tap: 48px;
  --font: 'Inter', 'SF Pro Display', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Several components set `display: flex`, which would otherwise beat the UA
   rule for [hidden]. Everything in the UI hides via the hidden attribute, so
   this has to win. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  /* Explicit 100% tracks, not implicit auto ones: an auto track sizes to its
     content's minimum, which lets a wide HUD stretch the shell past the
     viewport on small embedded frames. */
  grid-template-columns: 100%;
  grid-template-rows: 100%;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

/* ---- screens ---------------------------------------------------------- */

.screen {
  grid-area: 1 / 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  animation: screen-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.screen.is-active {
  display: flex;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- loading ---------------------------------------------------------- */

.screen--loading {
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.loading__mark svg {
  width: 150px;
  height: 100px;
  overflow: visible;
}

.loading__beam {
  stroke: #ff3355;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px #ff3355);
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  animation: beam-in 1.1s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.loading__prism {
  fill: rgba(34, 211, 238, 0.08);
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.6));
}

@keyframes beam-in {
  to {
    stroke-dashoffset: 0;
  }
}

.loading__title {
  margin: 0.4rem 0 0;
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  letter-spacing: 0.22em;
  font-weight: 200;
}

.loading__title span {
  color: var(--accent);
  font-weight: 600;
}

.loading__tagline {
  margin: 0;
  color: var(--text-dim);
  letter-spacing: 0.3em;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.loading__bar {
  width: min(260px, 60vw);
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin-top: 1.2rem;
}

.loading__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, transparent, var(--accent));
  transition: width 0.25s ease;
}

/* ---- shared bar ------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
}

.bar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  letter-spacing: 0.01em;
}

.bar__stat {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 0.9rem 2.4rem;
}

/* ---- accessibility ---------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[data-reduced-motion='true'] * {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

html[data-contrast='high'] {
  --text-dim: rgba(235, 245, 255, 0.85);
}

html[data-theme-mode='light'] {
  color-scheme: light;
}

html[data-theme-mode='light'] body {
  color: #101a2c;
}

.perf {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 6px);
  right: 6px;
  z-index: 60;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(0, 0, 0, 0.6);
  color: #9ef;
  padding: 5px 8px;
  border-radius: 6px;
  pointer-events: none;
  white-space: pre;
}
