/* ============================================================================
   Liquor In Front — theme tokens
   Light is the default (:root); dark overrides under prefers-color-scheme.
   ========================================================================== */
:root {
  color-scheme: light dark;
  --font: ui-rounded, "SF Pro Rounded", "Baloo 2", "Nunito",
          -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* brand pops */
  --accent: #ff2e88;   /* magenta */
  --accent-2: #0fb6a3; /* teal (legible on cream) */
  --gold: #f0a52a;
  --ok: #12a566;
  --danger: #e0446a;

  /* LIGHT surfaces + ink */
  --bg-0: #ffe4bd;
  --bg-1: #fff8ec;
  --bg-solid: #f7e6c6;      /* map backdrop / far field */
  --shroud: 247, 230, 198;  /* rgb of bg-solid for map fade */
  --ink: #2c1d3f;
  --muted: #927f6b;
  --chip-bg: rgba(60, 34, 12, 0.08);
  --chip-border: rgba(60, 34, 12, 0.16);
  --panel: rgba(255, 250, 240, 0.66);
  --grad-a: #5a2f7e;       /* distance number gradient */
  --grad-b: #0fb6a3;
  --word-top: #3a2456;
  --tile-filter: saturate(1.12) contrast(1.03) brightness(1.03);
  --logo-glow: 0 8px 22px rgba(240, 120, 60, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent-2: #22e0c8;
    --gold: #ffd166;
    --ok: #3ce0a0;
    --danger: #ff5470;

    --bg-0: #0b0714;
    --bg-1: #150a26;
    --bg-solid: #05030a;
    --shroud: 5, 3, 10;
    --ink: #f6f0ff;
    --muted: #b9a9d6;
    --chip-bg: rgba(255, 255, 255, 0.08);
    --chip-border: rgba(255, 255, 255, 0.14);
    --panel: rgba(8, 4, 16, 0.5);
    --grad-a: #ffffff;
    --grad-b: #22e0c8;
    --word-top: #ffffff;
    --tile-filter: brightness(1.7) contrast(1.05) saturate(1.35) hue-rotate(-8deg);
    --logo-glow: 0 10px 30px rgba(255, 46, 136, 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% -10%, var(--bg-1) 0%, var(--bg-0) 55%, var(--bg-solid) 100%);
  color: var(--ink);
  font-family: var(--font);
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; outline: none; touch-action: none;
  z-index: 1;
}

/* ---------- Isometric street map ---------- */
#map {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden;
  perspective: 900px;
  perspective-origin: 50% 100%;
  background: var(--bg-solid);
}
.map-tilt {
  position: absolute; left: 50%; top: 100%;
  transform-origin: 0 0;
  transform: rotateX(62deg) scale(1.25);
  will-change: transform;
}
.map-rot, .map-pan { position: absolute; transform-origin: 0 0; will-change: transform; }
.map-tile {
  position: absolute; left: 0; top: 0;
  width: 256px; height: 256px;
  image-rendering: auto;
  filter: var(--tile-filter);
}
.map-pin {
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff, var(--gold) 42%, var(--accent) 100%);
  box-shadow: 0 0 22px 6px rgba(255, 160, 90, 0.6), 0 0 60px 14px rgba(255, 46, 136, 0.35);
  animation: pinPulse 1.4s ease-in-out infinite;
}
.map-pin::after {
  content: "🍾"; position: absolute; inset: 0;
  display: grid; place-items: center; font-size: 15px;
  animation: pinBob 1.4s ease-in-out infinite;
}
/* Fade the far field into the ground colour + pool shadow under the compass */
#mapfade {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(var(--shroud), 0.92) 0%, rgba(var(--shroud), 0.6) 10%, rgba(var(--shroud), 0.08) 26%, rgba(var(--shroud), 0) 40%),
    radial-gradient(120% 70% at 50% 112%, rgba(var(--shroud), 0.82) 0%, rgba(var(--shroud), 0.28) 42%, transparent 72%);
}
.map-attr {
  position: absolute; right: 8px; bottom: 6px; z-index: 2;
  font-size: 9px; letter-spacing: .02em;
  color: color-mix(in srgb, var(--ink) 45%, transparent);
  background: color-mix(in srgb, var(--bg-solid) 55%, transparent);
  padding: 2px 6px; border-radius: 6px; pointer-events: none;
}

.layer {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 2;
}
.hidden { display: none !important; }

/* ---------- Splash ---------- */
#splash {
  align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(90% 90% at 50% 28%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
  animation: fadeIn .5s ease both;
  overflow: hidden;
}
/* floating decorative sparkles */
#splash::before, #splash::after {
  content: "✨"; position: absolute; font-size: 26px; opacity: .5;
  animation: drift 7s ease-in-out infinite;
}
#splash::before { top: 16%; left: 16%; }
#splash::after { content: "🍸"; bottom: 18%; right: 16%; font-size: 30px; animation-delay: -3s; }

.splash-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px; }
.logo {
  width: clamp(96px, 30vw, 150px); height: auto;
  filter: drop-shadow(var(--logo-glow));
  animation: dropIn .8s cubic-bezier(.2, 1.5, .4, 1) both, bob 3.2s ease-in-out 1s infinite;
  transform-origin: 50% 80%;
}
.wordmark {
  display: flex; flex-direction: column; line-height: .9; letter-spacing: .01em;
  animation: springIn .7s cubic-bezier(.2, 1.5, .4, 1) .12s both;
}
.wordmark .line1 {
  font-weight: 900; font-size: clamp(40px, 14vw, 88px);
  background: linear-gradient(180deg, var(--word-top), var(--muted));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.wordmark .line2 {
  font-weight: 900; font-size: clamp(40px, 14vw, 88px); color: transparent;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--accent) 45%, transparent));
}
.tagline {
  margin: 0 0 6px; color: var(--muted); font-weight: 700;
  font-size: clamp(14px, 4.5vw, 19px);
  animation: springIn .7s cubic-bezier(.2, 1.5, .4, 1) .2s both;
}

.cta {
  position: relative; border: none; cursor: pointer;
  padding: 20px 42px; border-radius: 999px;
  font-weight: 900; font-size: clamp(18px, 5.5vw, 24px); letter-spacing: .03em;
  color: #2a0016;
  background: linear-gradient(135deg, var(--gold), var(--accent) 92%);
  box-shadow: 0 14px 40px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: springIn .6s cubic-bezier(.2, 1.6, .4, 1) .3s both, wiggle 3.5s ease-in-out 1.4s infinite;
  will-change: transform;
}
.cta:hover { animation-play-state: paused; transform: scale(1.04) rotate(-1deg); }
.cta:active { transform: scale(.93); }
.cta-glow {
  position: absolute; inset: -3px; border-radius: 999px; z-index: -1;
  background: conic-gradient(from 0deg, var(--accent), var(--gold), var(--accent-2), var(--accent));
  filter: blur(15px); opacity: .75;
  animation: spin 6s linear infinite;
}
.fineprint { color: var(--muted); font-size: 12px; max-width: 300px; opacity: .85; }

/* ---------- Permission priming modal ---------- */
#permit {
  z-index: 5;
  align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--bg-0) 78%, transparent);
  backdrop-filter: blur(12px);
  animation: fadeIn .3s ease both;
}
.permit-card {
  position: relative; width: min(92vw, 420px);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 30px 24px 22px; border-radius: 28px;
  background: var(--bg-1); border: 1px solid var(--chip-border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .4);
  animation: springIn .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
.permit-emoji {
  font-size: 46px; animation: bob 3.2s ease-in-out infinite;
  filter: drop-shadow(0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent));
}
.permit-title { margin: 0; font-size: clamp(20px, 6vw, 26px); font-weight: 900; color: var(--ink); }
.permit-sub { margin: 0 0 2px; color: var(--muted); font-weight: 700; font-size: 14px; }
.permit-list { list-style: none; margin: 4px 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.permit-list li {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 14px; border-radius: 18px;
  background: var(--chip-bg); border: 1px solid var(--chip-border);
}
.permit-ico { flex: none; width: 34px; text-align: center; font-size: 26px; }
.permit-copy { display: flex; flex-direction: column; gap: 2px; }
.permit-copy b { font-size: 15px; font-weight: 900; color: var(--ink); }
.permit-copy small { font-size: 12.5px; font-weight: 700; line-height: 1.3; color: var(--muted); }
.permit-cta { margin-top: 6px; padding: 17px 40px; animation: none; }
.permit-cta:disabled { opacity: .65; cursor: default; }

/* ---------- Blocked / friendly dead-end ---------- */
#blocked {
  z-index: 6;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  background:
    radial-gradient(90% 90% at 50% 28%, color-mix(in srgb, var(--danger) 14%, transparent), transparent 60%),
    var(--bg-0);
  animation: fadeIn .4s ease both;
}
.blocked-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(92vw, 440px); }
.blocked-emoji {
  font-size: clamp(48px, 16vw, 62px); animation: bob 3.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .3));
}
.blocked-title {
  margin: 0; font-size: clamp(24px, 7.5vw, 34px); font-weight: 900; line-height: 1.05;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.blocked-sub {
  margin: 0; max-width: 360px; line-height: 1.4;
  color: var(--muted); font-weight: 700; font-size: clamp(14px, 4vw, 16px);
}
.blocked-cta { margin-top: 6px; padding: 17px 40px; animation: none; }

/* ---------- HUD (absolute zones so nothing overlaps) ---------- */
#hud { pointer-events: none; }
#hud .chip, #hud button { pointer-events: auto; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; letter-spacing: .22em; font-size: clamp(10px, 3vw, 13px); color: var(--muted);
  animation: springIn .6s cubic-bezier(.2, 1.5, .4, 1) both;
}
.brand-mark { height: 28px; width: auto; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .25)); animation: bob 3.2s ease-in-out infinite; }
.headnote {
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  padding: 9px 15px; border-radius: 999px;
  background: var(--danger); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--danger) 45%, transparent);
  animation: pop1 .4s cubic-bezier(.2, 1.7, .4, 1);
}
.headnote.info {
  background: var(--chip-bg); color: var(--ink);
  border: 1px solid var(--chip-border); box-shadow: none;
}
#recenter { font-size: 18px; width: 42px; height: 42px; display: grid; place-items: center; transition: transform .3s ease; }
#recenter:active { transform: rotate(-180deg) scale(.9); }

.hud-readout {
  position: absolute; left: 0; right: 0;
  top: clamp(56px, 12vh, 104px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  animation: springIn .6s cubic-bezier(.2, 1.5, .4, 1) .1s both;
}
.distance {
  font-weight: 900; font-variant-numeric: tabular-nums;
  font-size: clamp(46px, 15vw, 108px); line-height: .86; letter-spacing: -.02em;
  background: linear-gradient(180deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 26px color-mix(in srgb, var(--grad-b) 45%, transparent));
  transition: filter .3s ease;
}
.distance .unit { font-size: .3em; margin-left: .1em; color: var(--muted); -webkit-text-fill-color: var(--muted); }
.store {
  font-size: clamp(14px, 4.4vw, 20px); font-weight: 800; color: var(--ink);
  max-width: min(90vw, 520px); padding: 7px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--chip-border); backdrop-filter: blur(8px);
}
.store-addr {
  margin-top: 2px; min-height: 1em;
  font-size: clamp(11px, 3.2vw, 13px); font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}

/* Inventory trigger docked beneath the address — prominent CTA pill.
   (Overrides the injected .inv-trigger defaults; higher specificity wins.) */
.hud-readout .inv-trigger {
  position: static; transform: none; left: auto; bottom: auto;
  margin-top: 14px;
  font-size: clamp(14px, 4.2vw, 16px); font-weight: 900; letter-spacing: .02em;
  color: #2a0016;
  padding: 13px 24px; border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--accent) 92%);
  border: none; backdrop-filter: none;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 42%, transparent), inset 0 1px 0 rgba(255,255,255,0.45);
}
.hud-readout .inv-trigger:active { transform: scale(.95); }
.hud-readout .inv-trigger .inv-lens { font-size: 18px; }

/* Playful bouncing-dots loader (shown until we have a distance) */
.loader {
  display: flex; gap: 12px; align-items: flex-end; justify-content: center;
  height: clamp(46px, 15vw, 108px);
}
.loader span {
  width: clamp(12px, 3.6vw, 20px); height: clamp(12px, 3.6vw, 20px);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--gold), var(--accent));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
  animation: loadBounce .9s cubic-bezier(.3, .1, .3, 1) infinite;
}
.loader span:nth-child(2) { animation-delay: .12s; background: linear-gradient(160deg, var(--accent), var(--accent-2)); }
.loader span:nth-child(3) { animation-delay: .24s; background: linear-gradient(160deg, var(--accent-2), var(--gold)); }
@keyframes loadBounce { 0%, 100% { transform: translateY(0) scale(.85); opacity: .55 } 45% { transform: translateY(-26px) scale(1.05); opacity: 1 } }

.arrived {
  position: absolute; left: 0; right: 0; top: 40%;
  text-align: center; font-weight: 900; font-size: clamp(24px, 8vw, 46px);
  color: var(--ok);
  text-shadow: 0 0 30px color-mix(in srgb, var(--ok) 60%, transparent);
  animation: popIn .45s cubic-bezier(.2, 1.7, .4, 1) both, floaty 1.8s ease-in-out infinite;
}

.hud-bottom {
  position: absolute; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex; justify-content: center;
}
.meta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 800; letter-spacing: .03em;
  padding: 9px 15px; border-radius: 999px;
  background: var(--chip-bg); color: var(--ink);
  border: 1px solid var(--chip-border); backdrop-filter: blur(8px);
  transition: transform .2s cubic-bezier(.2, 1.6, .4, 1);
}
.chip:active { transform: scale(.92); }
.chip.ghost { background: transparent; color: var(--muted); }
.chip.live { color: #06110d; background: var(--ok); border-color: transparent; animation: pop1 .4s cubic-bezier(.2,1.7,.4,1); }
.chip.err  { color: #fff; background: var(--danger); border-color: transparent; }

/* states */
.near .distance { filter: drop-shadow(0 6px 30px color-mix(in srgb, var(--gold) 60%, transparent)); }

/* ---------- keyframes ---------- */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes dropIn { 0% { transform: translateY(-60px) scale(.6) rotate(-12deg); opacity: 0 } 100% { transform: translateY(0) scale(1) rotate(0); opacity: 1 } }
@keyframes springIn { 0% { transform: translateY(14px) scale(.9); opacity: 0 } 100% { transform: translateY(0) scale(1); opacity: 1 } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg) } 50% { transform: translateY(-9px) rotate(2deg) } }
@keyframes wiggle { 0%, 92%, 100% { transform: rotate(0) scale(1) } 94% { transform: rotate(-2.5deg) scale(1.03) } 97% { transform: rotate(2.5deg) scale(1.03) } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes drift { 0%, 100% { transform: translateY(0) rotate(-6deg); opacity: .35 } 50% { transform: translateY(-16px) rotate(8deg); opacity: .65 } }
@keyframes popIn { from { transform: scale(.5); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes pop1 { from { transform: scale(.7) } to { transform: scale(1) } }
@keyframes floaty { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
@keyframes pinPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 18px 5px rgba(255,160,90,.5), 0 0 44px 10px rgba(255,46,136,.3) } 50% { transform: scale(1.12); box-shadow: 0 0 26px 8px rgba(255,160,90,.7), 0 0 70px 16px rgba(255,46,136,.4) } }
@keyframes pinBob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-3px) } }

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