/* omo11 web shell: the loader overlay and the update toast. Colours and sizes follow the game's
   UI theme (crates/client/src/ui/theme.rs) so the hand-off to the game's own screens is seamless. */

@font-face {
  font-family: "Fira Sans";
  src: url("assets/fonts/FiraSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Fira Sans";
  src: url("assets/fonts/FiraSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --background: #0d1221;
  --background-deep: #070a14;
  --panel: rgba(15, 20, 38, 0.78);
  --panel-border: rgba(255, 219, 140, 0.35);
  --text: #f5f7ff;
  --text-muted: #b3c2e0;
  --accent: #fcd161;
  --accent-soft: rgba(252, 209, 97, 0.28);
  --button: #2e5cb8;
  --button-hover: #3a6fd6;
  --bar-background: rgba(0, 0, 0, 0.45);
  --danger: #f04f66;
  --radius: 10px;
  --gutter: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--background);
  color: var(--text);
  font-family: "Fira Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
}

#omo11-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* --- Loader --------------------------------------------------------------------------------- */

#loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
    max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background:
    radial-gradient(120% 80% at 50% 0%, #1d2a52 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 100%, #2a1838 0%, transparent 70%),
    linear-gradient(180deg, var(--background) 0%, var(--background-deep) 100%);
  transition:
    opacity 600ms ease,
    visibility 0s linear 600ms;
  z-index: 10;
}

#loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Slow drifting light motes: a little life while waiting. */
.mote {
  position: absolute;
  bottom: -20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 4px var(--accent-soft);
  opacity: 0;
  animation: rise 11s linear infinite;
}
.mote:nth-child(1) { left: 12%; animation-delay: 0s; }
.mote:nth-child(2) { left: 28%; animation-delay: 3.5s; width: 4px; height: 4px; }
.mote:nth-child(3) { left: 47%; animation-delay: 6s; }
.mote:nth-child(4) { left: 63%; animation-delay: 1.8s; width: 5px; height: 5px; }
.mote:nth-child(5) { left: 79%; animation-delay: 8s; width: 4px; height: 4px; }
.mote:nth-child(6) { left: 91%; animation-delay: 4.6s; }

@keyframes rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.9; }
  50% { transform: translateY(-50vh) translateX(18px); }
  90% { opacity: 0.6; }
  100% { transform: translateY(-105vh) translateX(-12px); opacity: 0; }
}

.card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 24px 24px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}

.emblem {
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(252, 209, 97, 0.18) 0%, transparent 70%);
  animation: breathe 3.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px var(--accent-soft)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 0 16px var(--accent-soft)); }
}

.title {
  margin: 0 0 18px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.status {
  min-height: 1.4em;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--bar-background);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f5b742, var(--accent) 60%, #fff0b8);
  box-shadow: 0 0 14px var(--accent-soft);
  transition: width 240ms ease-out;
  position: relative;
  overflow: hidden;
}

/* A soft sheen running over the filled part. */
.fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.55) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: sheen 1.8s ease-in-out infinite;
}

@keyframes sheen {
  to { transform: translateX(100%); }
}

/* Unknown duration (checking, starting): a sliding segment instead of a fill. */
.bar.indeterminate .fill {
  width: 35% !important;
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

.bar.failed .fill {
  background: var(--danger);
  box-shadow: none;
}

.details {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 1.3em;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.note {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.note:empty {
  display: none;
}

.button {
  min-height: 44px;
  margin-top: 16px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease;
}

.button:hover {
  background: var(--button-hover);
}

.button:active {
  transform: scale(0.97);
}

.button.small {
  min-height: 44px;
  margin-top: 0;
  padding: 0 16px;
  font-size: 14px;
}

.button.ghost {
  background: transparent;
  color: var(--text-muted);
}

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  font-size: 12px;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

[hidden] {
  display: none !important;
}

/* --- Update toast --------------------------------------------------------------------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  z-index: 20;
  animation: toast-in 300ms ease-out;
}

#toast-text {
  flex: 1 1 auto;
}

.toast-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@media (max-width: 480px) {
  #toast {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 12px;
  }
  .toast-actions {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mote, .emblem, .fill::after, .bar.indeterminate .fill {
    animation: none;
  }
}

/* Invisible text inputs laid over the game's text fields on touch devices, so tapping one opens
   the phone keyboard (crates/client/src/web.rs). 16px text stops iOS from zooming in. */
.omo11-field {
  position: fixed;
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0.01;
  z-index: 5;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
