/* Northbridge Market store assistant — mobile first, kiosk by attribute. */

:root {
  --blue: #1a8fd1;
  --blue-dark: #0e6ea6;
  --blue-soft: #e7f4fb;
  --orange: #f2871f;
  --orange-soft: #fdf0e1;
  --ink: #16222e;
  --ink-soft: #5b6b7a;
  --line: #dfe6ed;
  --bg: #f4f7fa;
  --card: #ffffff;
  --good: #1f9254;
  --warn: #b8770d;
  --bad: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 34, 46, .06), 0 8px 24px rgba(22, 34, 46, .07);
  --fs: 15px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs)/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .5px;
  flex: 0 0 auto;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 11.5px; opacity: .85; }

.here {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 55%;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.here b { font-weight: 600; }

.pin {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(242, 135, 31, .8);
  animation: pulse 2s infinite;
  flex: 0 0 auto;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(242, 135, 31, 0); }
  100% { box-shadow: 0 0 0 0 rgba(242, 135, 31, 0); }
}

/* ------------------------------------------------------------------- stage */

.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.conversation {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel { display: none; }

.thread {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* ---------------------------------------------------------------- messages */

.msg, .card { flex: 0 0 auto; }   /* thread is a flex column: never squash a card */

.msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: center;
  max-width: 92%;
  padding: 2px 8px;
}

.msg.error {
  align-self: center;
  background: #fdeceb;
  color: var(--bad);
  border: 1px solid #f5c6c2;
  font-size: 13px;
}

.msg.pending { opacity: .6; font-style: italic; }

.typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ------------------------------------------------------------------- cards */

.card {
  align-self: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card + .card { margin-top: -2px; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 13px 0;
}

.card-head h3 { margin: 0; font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--ink-soft); }

.card-body { padding: 9px 13px 12px; }

.loc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--blue-soft);
  border: 1px solid #c9e6f6;
  color: var(--blue-dark);
  font-size: 12.5px;
  font-weight: 600;
}

.price { font-size: 19px; font-weight: 700; }
.price .was { font-size: 13px; font-weight: 500; color: var(--ink-soft); text-decoration: line-through; margin-left: 7px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.tag.promo { background: var(--orange-soft); color: #9c5405; }
.tag.in { background: #e6f5ec; color: var(--good); }
.tag.low { background: #fdf3e0; color: var(--warn); }
.tag.out { background: #fdeceb; color: var(--bad); }

.steps { margin: 4px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

.route-meta {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.staff-card { border-color: #f6d9b4; background: linear-gradient(180deg, #fffaf3, #fff); }
.staff-card .card-head h3 { color: #9c5405; }

/* --------------------------------------------------------------- store map */

.map-wrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfe;
  padding: 8px;
  /* Hug the map once it stops growing, so a wide screen shows a framed map
     rather than a full-width box with the map marooned in the middle. */
  max-width: calc(58vh * 64 / 44 + 16px);
  margin-inline: auto;
}

/* The point of the map is taking the whole store in at a glance, so it must never
   outgrow the screen. Width is tied to the 64:44 viewBox so capping the height
   shrinks the map instead of letterboxing it inside a full-width box. */
.storemap {
  display: block;
  width: 100%;
  height: auto;
  max-height: 58vh;
  max-width: calc(58vh * 64 / 44);
  margin-inline: auto;
}

.map-wrap .storemap { min-height: 150px; }

.m-floor { fill: #fff; stroke: var(--line); stroke-width: .3; }
.m-aisle { fill: #e9eef3; stroke: #d3dde5; stroke-width: .12; }
.m-aisle.is-target { fill: var(--orange); stroke: #d5730f; }
.m-zone { fill: #eef4f8; stroke: #d3dde5; stroke-width: .12; }
.m-zone.is-target { fill: var(--orange); stroke: #d5730f; }
.m-checkout { fill: #dfe6ed; }

.m-aisle-num, .m-zone-label, .m-entrance {
  fill: var(--ink-soft);
  text-anchor: middle;
  font-family: inherit;
}
.m-aisle-num { font-size: 1.5px; font-weight: 600; }
/* No font-size on .m-zone-label on purpose: each one is sized to its own box by
   a font-size attribute from map.js, and a CSS rule would override it. */

/* The destination is filled orange, so its name has to switch to white to stay
   readable — grey-on-orange was the one label you could never read. */
.m-aisle-num.is-target,
.m-zone-label.is-target { fill: #fff; font-weight: 700; }
/* Lift the name clear of the route line and the marker underneath it. */
.m-zone-label.is-target, .m-aisle-num.is-target {
  paint-order: stroke;
  stroke: #d5730f;
  stroke-width: .28px;
  stroke-linejoin: round;
}
.m-entrance { font-size: 1.7px; letter-spacing: .2px; fill: var(--blue-dark); font-weight: 700; }

.m-path {
  fill: none;
  stroke: var(--blue);
  stroke-width: .6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1.4 1.1;
}

.m-here-dot { fill: var(--blue); }
.m-here-pulse { fill: var(--blue); opacity: .18; animation: mappulse 2s infinite; }
.m-target-dot { fill: var(--orange); }
.m-target-halo { fill: var(--orange); opacity: .2; }

@keyframes mappulse { 0% { opacity: .3; } 60% { opacity: .05; } 100% { opacity: .3; } }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.lg-here::before { background: var(--blue); }
.lg-target::before { background: var(--orange); }

/* ----------------------------------------------------------------- composer */

/* ------------------------------------------------------------- mode choice */

/* The greeting invites the shopper to speak, but a browser will not open a
   microphone until the page has been touched. Asking which lane they want makes
   that first touch useful instead of a dead end. */
.mode-choice {
  display: none;
  gap: 10px;
  flex: 0 0 auto;
  align-self: stretch;
  padding: 2px 0 0;
  /* Full width on a phone, but two buttons the width of a desktop window read
     as a banner rather than a choice. Left-aligned to sit under the greeting. */
  width: 100%;
  max-width: 560px;
}
.mode-choice[data-show="true"] { display: flex; }

/* Both of these set display: flex, which beats the [hidden] default. */
.chips[hidden], .composer[hidden] { display: none; }

.choice {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  box-shadow: 0 1px 2px rgba(22, 34, 46, .05);
  transition: border-color .15s, background .15s, transform .08s;
}
.choice:hover { border-color: var(--blue); background: var(--blue-soft); }
.choice:active { transform: translateY(1px); }
.choice:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.choice svg { width: 30px; height: 30px; fill: var(--blue); }
.choice-title { font-size: 15px; font-weight: 650; }
.choice-sub { font-size: 12.5px; color: var(--ink-soft); }

@media (max-width: 380px) {
  .choice { padding: 14px 8px; }
  .choice-sub { display: none; }
}

.chips {
  display: flex;
  gap: 7px;
  padding: 8px 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--blue); color: var(--blue-dark); }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
  background: var(--bg);
}

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
}
.composer textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

.mic-btn { background: var(--orange); }
.mic-btn[data-on="true"] { background: var(--bad); }

/* --------------------------------------------------------------- voice bar */

.voicebar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #0f2233;
  color: #fff;
  flex: 0 0 auto;
}
.voicebar[data-show="true"] { display: flex; }

.vstate { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }

.eq { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 16px; }
.eq i {
  width: 3px;
  background: var(--orange);
  border-radius: 2px;
  height: 5px;
  animation: eq 900ms infinite ease-in-out;
}
.eq i:nth-child(2) { animation-delay: 120ms; }
.eq i:nth-child(3) { animation-delay: 240ms; }
.eq i:nth-child(4) { animation-delay: 360ms; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 15px; } }

.voicebar[data-state="listening"] .eq i { background: #4bd07f; }
.voicebar[data-state="thinking"] .eq i { animation-duration: 1.6s; background: #8ab4d8; }
.voicebar[data-state="connecting"] .eq i,
.voicebar[data-state="reconnecting"] .eq i { background: #8ab4d8; }

.end-call {
  margin-left: auto;
  padding: 7px 15px;
  border: none;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ----------------------------------------------------------- attract screen */

.attract {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px;
  text-align: center;
  background: linear-gradient(160deg, var(--blue) 0%, #0b5a8a 100%);
  color: #fff;
}
.attract[data-show="true"] { display: flex; }

.attract h1 { margin: 0; font-size: clamp(30px, 5vw, 56px); line-height: 1.1; }
.attract .lead { margin: 0; font-size: clamp(15px, 1.8vw, 22px); opacity: .9; max-width: 32ch; }

.attract-rotator {
  min-height: 2.4em;
  font-size: clamp(18px, 2.6vw, 30px);
  font-weight: 600;
  color: #ffd9ac;
  transition: opacity .35s;
}

.attract-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 34px;
  border: none;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font: inherit;
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.attract-cta svg { width: 26px; height: 26px; fill: currentColor; }

.attract .foot { font-size: 13px; opacity: .75; }

/* ------------------------------------------------------------- kiosk layout */

body[data-mode="kiosk"] { --fs: 18px; }

body[data-mode="kiosk"] .topbar { padding: 16px 26px; }
body[data-mode="kiosk"] .logo { width: 46px; height: 46px; font-size: 18px; }
body[data-mode="kiosk"] .brand-text strong { font-size: 21px; }
body[data-mode="kiosk"] .brand-text span { font-size: 13px; }
body[data-mode="kiosk"] .here { font-size: 15px; padding: 8px 15px; }

body[data-mode="kiosk"] .thread { padding: 22px 26px 6px; gap: 14px; }
body[data-mode="kiosk"] .msg { max-width: 78%; padding: 14px 18px; }
body[data-mode="kiosk"] .chips { padding: 10px 26px 0; }
body[data-mode="kiosk"] .chip { font-size: 16px; padding: 10px 18px; }
body[data-mode="kiosk"] .composer { padding: 14px 26px; }
body[data-mode="kiosk"] .icon-btn { width: 56px; height: 56px; }
body[data-mode="kiosk"] .icon-btn svg { width: 26px; height: 26px; }
body[data-mode="kiosk"] .voicebar { padding: 14px 26px; font-size: 16px; }
body[data-mode="kiosk"] .end-call { font-size: 16px; padding: 10px 22px; }

/* On a kiosk the map and the newest result get their own column. */
@media (min-width: 900px) {
  body[data-mode="kiosk"] .panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 40%;
    max-width: 520px;
    border-left: 1px solid var(--line);
    background: #fff;
    padding: 18px;
    gap: 14px;
    overflow-y: auto;
  }
  body[data-mode="kiosk"] .panel .card { box-shadow: none; }
  body[data-mode="kiosk"] .panel-empty {
    margin: auto;
    text-align: center;
    color: var(--ink-soft);
    font-size: 15px;
    max-width: 26ch;
  }
  body[data-mode="kiosk"] .panel-empty svg { width: 54px; height: 54px; fill: var(--line); display: block; margin: 0 auto 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .thread { scroll-behavior: auto; }
}
