/* Pastel Pocket City — the interface that floats over the 3D scene. */

:root {
  --gutter: 14px;
  --chip-pad-y: 8px;
  --chip-pad-x: 15px;
  --hud-radius: 999px;
}

body.app {
  display: block;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

#scene.is-dragging {
  cursor: grabbing;
}

.stage {
  position: fixed;
  inset: 0;
  padding: 0;
  flex: none;
}

/* ------------------------------------------------------------------ chrome */

.site-header {
  position: fixed;
  top: var(--gutter);
  left: var(--gutter);
  z-index: 6;
  border: 0;
  background: none;
  padding: 0;
}

.site-header .wrap {
  max-width: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 16px;
  border: 2px solid var(--hud-line);
  border-radius: var(--hud-radius);
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(115, 80, 197, 0.18);
}

.brand:hover {
  transform: translateY(-1px);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.link-btn,
.site-nav a {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-text);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--hud-bg);
  border: 2px solid var(--hud-line);
  border-radius: var(--hud-radius);
  padding: 7px 13px;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.link-btn:hover,
.site-nav a:hover {
  color: var(--ink);
  border-color: var(--accent);
}

/* -------------------------------------------------------------------- chips */

.hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding: var(--gutter);
}

.hud-top {
  position: absolute;
  top: var(--gutter);
  right: var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: var(--chip-pad-y) var(--chip-pad-x);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--hud-bg);
  border: 2px solid var(--hud-line);
  border-radius: var(--hud-radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.chip .icon {
  font-size: 1.05rem;
  color: var(--accent);
}

.chip__phase {
  font-family: var(--font-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-left: 7px;
  border-left: 2px solid var(--hud-line);
}

.chip--btn {
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.chip--btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.chip--btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(115, 80, 197, 0.28);
}

.chip--icon {
  padding: 6px 12px;
  font-size: 1.1rem;
}

.world-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 7px 16px 7px 13px;
  background: var(--hud-bg);
  border: 2px solid var(--hud-line);
  border-radius: var(--hud-radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.world-badge .icon {
  font-size: 1.2rem;
  color: var(--accent);
}

.world-badge__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.world-badge__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.world-badge__sub {
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.hud.is-dusk .world-badge .icon,
.hud.is-dusk .chip .icon {
  color: var(--accent-2);
}

.hud.is-dusk .world-badge__name {
  color: var(--accent-2);
}

/* ------------------------------------------------------------------ bottom */

.hud-bottom {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.hud-bottom__left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(60vw, 34rem);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--hud-radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.12s ease;
}

.mode-pill .icon {
  font-size: 1.15rem;
}

.mode-pill:hover {
  transform: translateY(-2px);
}

.mode-pill.is-near {
  background: var(--accent-2);
  animation: nudge 1.4s ease-in-out infinite;
}

.mode-pill[disabled] {
  opacity: 0.75;
  cursor: default;
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--hud-line);
}

.hint {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--hud-bg);
  border: 2px solid var(--hud-line);
  border-radius: var(--radius);
  padding: 7px 13px;
  backdrop-filter: blur(8px);
}

.hint strong {
  font-weight: 700;
}

/* ------------------------------------------------------------------- label */

.label-card {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(90vw, 30rem);
  padding: 13px 20px;
  background: var(--hud-bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  text-align: center;
  animation: pop 0.28s cubic-bezier(0.2, 1.4, 0.5, 1);
}

.label-card__title {
  margin: 0 0 3px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.label-card__line {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.hud.is-dusk .label-card {
  border-color: var(--accent-2);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--hud-radius);
  box-shadow: var(--shadow);
  animation: nudge 1.6s ease-in-out infinite;
}

.hud.is-dusk .prompt {
  background: var(--accent-2);
}

/* --------------------------------------------------------------- overlays */

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(27, 25, 34, 0.28);
}

.touch .crosshair {
  display: none;
}

.stick {
  position: absolute;
  width: 116px;
  height: 116px;
  margin: -58px 0 0 -58px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.75);
  background: rgba(250, 249, 255, 0.22);
  box-shadow: 0 0 0 2px rgba(27, 25, 34, 0.12) inset;
}

.stick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: var(--hud-bg);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.is-on {
  animation: flash 0.7s ease-out;
}

/* ----------------------------------------------------------------- loader */

.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #d8ecff 0%, #f6f1ff 55%, #ffe6ee 100%);
  transition: opacity 0.5s ease, visibility 0.5s;
}

.loader.is-done {
  opacity: 0;
  visibility: hidden;
}

.loader__card {
  max-width: 34rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid rgba(115, 80, 197, 0.25);
  border-radius: 26px;
  padding: 30px 28px 26px;
  box-shadow: 0 4px 0 rgba(115, 80, 197, 0.2), 0 22px 50px rgba(115, 80, 197, 0.22);
}

.loader__kicker {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.loader__title {
  margin: 0 0 12px;
  font-size: clamp(2rem, 8vw, 3rem);
  color: #2b2440;
}

.loader__line {
  margin: 0 auto 16px;
  color: #55516b;
  font-size: 0.95rem;
}

.loader__bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(115, 80, 197, 0.16);
  overflow: hidden;
  margin-bottom: 18px;
}

.loader__bar span {
  display: block;
  height: 100%;
  width: 6%;
  border-radius: 999px;
  background: linear-gradient(90deg, #a585ff, #ff8fa3);
  transition: width 0.3s ease;
}

.loader__tip {
  margin: 0;
  font-size: 0.86rem;
  color: #55516b;
}

/* ------------------------------------------------------------------- sheet */

.sheet {
  border: 2px solid var(--hud-line);
  border-radius: 24px;
  padding: 26px;
  max-width: min(92vw, 54rem);
  color: var(--ink);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(30, 22, 55, 0.5);
  backdrop-filter: blur(3px);
}

.sheet h2 {
  margin-top: 0;
}

.sheet__cols {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}

.sheet h3 {
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.sheet ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.sheet li {
  margin-bottom: 4px;
}

.sheet__close {
  margin-top: 22px;
  padding: 11px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--hud-radius);
  cursor: pointer;
}

.fallback {
  position: fixed;
  inset: auto 20px 20px;
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius);
}

/* --------------------------------------------------------------- keyframes */

@keyframes pop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes nudge {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-4px);
  }
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ phone */

@media (max-width: 720px) {
  :root {
    --gutter: 10px;
  }

  .site-header .wrap {
    gap: 6px;
  }

  .brand {
    font-size: 0.86rem;
    padding: 7px 12px;
  }

  .site-header .nav-toggle {
    background: var(--hud-bg);
    border: 2px solid var(--hud-line);
    border-radius: var(--hud-radius);
    font-family: var(--font-text);
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--ink);
    backdrop-filter: blur(8px);
  }

  .js .nav-toggle ~ .site-nav {
    background: var(--hud-bg);
    border: 2px solid var(--hud-line);
    border-radius: var(--radius);
    padding: 6px;
    margin-top: 6px;
    backdrop-filter: blur(8px);
  }

  .hud-top {
    top: 58px;
  }

  .hud-chips {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .world-badge__sub,
  .chip__phase {
    display: none;
  }

  .chip {
    font-size: 0.86rem;
    padding: 7px 12px;
  }

  .world-badge {
    padding: 6px 13px;
  }

  .world-badge__name {
    font-size: 0.9rem;
  }

  .hud-bottom__left {
    max-width: 100%;
  }

  .hint {
    font-size: 0.76rem;
  }

  .label-card {
    bottom: 104px;
    max-width: 92vw;
  }

  .prompt {
    bottom: 170px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .label-card,
  .prompt,
  .mode-pill.is-near {
    animation: none;
  }

  .flash.is-on {
    animation: none;
  }
}

/* ------------------------------------------------------------------------- *
 * Phones: the HUD has to share a small screen with the city.
 * ------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .label-card {
    bottom: 122px;
    max-width: calc(100vw - 24px);
    padding: 10px 14px;
  }

  .label-card__title {
    font-size: 1.02rem;
  }

  .label-card__line {
    font-size: 0.82rem;
  }

  .hint {
    font-size: 0.74rem;
    padding: 5px 10px;
    max-width: calc(100vw - 24px);
  }

  .mode-pill {
    font-size: 0.82rem;
    padding: 6px 12px;
  }

  .world-badge__sub {
    display: none;
  }

  .chip {
    padding: 6px 11px;
    font-size: 0.86rem;
  }

  .chip--clock .chip__phase {
    display: none;
  }

  .hud-bottom {
    padding-bottom: 8px;
  }
}

@media (max-width: 420px) {
  .brand {
    font-size: 0.92rem;
    padding: 6px 11px;
  }

  .site-header .nav-toggle {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .hud-top {
    gap: 6px;
  }
}
