/* NexMart: language switch, Sinhala typography, and the "Order from your list" panel. */

/* ---------- Sinhala typography ----------
   The Latin fonts have no Sinhala letters, so Sinhala text falls through to the phone's own
   Sinhala font. Tight negative letter-spacing breaks Sinhala letters apart, so it is reset,
   and lines get a little more room for the taller vowel signs. */
html[lang="si"] {
  --f-body: "Figtree", "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", system-ui, sans-serif;
  --f-display: "Bricolage Grotesque", "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", system-ui, sans-serif;
}
html[lang="si"] :is(h1, h2, h3, .hero-title, .card-name, .price .now, .band-photo h2) { letter-spacing: 0; }
html[lang="si"] :is(h1, .hero-title) { line-height: 1.3; }
html[lang="si"] :is(h2, h3, .card-name) { line-height: 1.35; }
html[lang="si"] :is(.price .save, .band-photo h2, .foot-col h3, .brand-tag) { letter-spacing: 0; text-transform: none; }
html[lang="si"] .hero-lite h1 { font-size: clamp(1.5rem, 3.4vw, 2.6rem); }
/* Sinhala labels run longer: let buttons wrap instead of pushing the page sideways */
html[lang="si"] .hero-cta { flex-wrap: wrap; }
html[lang="si"] .hero-cta .btn, html[lang="si"] .band-sub .btn { white-space: normal; text-align: center; line-height: 1.3; }
html[lang="si"] .hero-lite > * { min-width: 0; }
html[lang="si"] .card .add { font-size: .82rem; }

/* "Normal" stays readable; only the old price is struck through */
.price s span { display: inline-block; text-decoration: none; margin-right: .2em; }

/* ---------- Language switch in the top bar ---------- */
.lang-btn {
  height: 38px; padding: 0 12px; border-radius: 999px; border: 1.5px solid #E3E7EE; background: #fff;
  color: var(--ink); font: 700 .85rem/1 var(--f-body); white-space: nowrap;
  font-family: "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", var(--f-body);
  &:hover { border-color: var(--nx-green, #7AB800); }
}
@media (max-width: 760px) { .lang-btn { height: 34px; padding: 0 10px; font-size: .8rem; } }

/* ---------- Microphone in the search box ---------- */
.search-mic {
  position: absolute; right: 6px; width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: var(--nx-green-d, #1F7A35); color: #fff;
  svg { position: static; width: 19px; height: 19px; color: #fff; }
  &:hover { background: #17662B; }
}
.search:has(.search-mic:not([hidden])) {
  input { padding-right: 84px; }
  kbd { right: 50px; }
}
@media (max-width: 760px) { .search:has(.search-mic:not([hidden])) input { padding-right: 48px; } }

/* ---------- "Voice order" button: a round button above the call button ----------
   Same size and shape as the call / WhatsApp buttons (.qc); deep navy with a fine light rim,
   so it looks premium and stays quiet over the product photos while scrolling. */
.qc.qc-voice {
  border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 30% 25%, #2A3F74 0%, #13234A 55%, #0A1530 100%);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .22), 0 10px 26px -8px rgb(10 21 48 / .75);
  svg { width: 26px; height: 26px; }
}
/* A gentle pulse ring, like the WhatsApp button's, so it reads as "tap me" */
.qc.qc-voice::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 0 rgb(56 120 255 / .45); animation: voice-pulse 2.8s infinite;
}
@keyframes voice-pulse { 70% { box-shadow: 0 0 0 12px rgb(56 120 255 / 0); } 100% { box-shadow: 0 0 0 0 rgb(56 120 255 / 0); } }
@media (max-width: 560px) { .qc.qc-voice svg { width: 23px; height: 23px; } }
@media (prefers-reduced-motion: reduce) { .qc.qc-voice::after { animation: none; } }

/* ---------- Status row under the flyers (open/closed and the delivery check) ---------- */
.hero-lite { grid-template-columns: 1fr; margin-top: 18px; }
.hero-lite > div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.hero-lite .hero-kicker { margin: 0; }
.hero-lite .hero-check { flex-basis: 100%; margin: 0; min-height: 0; }
.hero-lite .hero-check:empty { display: none; }
@media (max-width: 760px) { .hero-lite { margin-top: 14px; } .hero-lite > div { gap: 8px; } .hero-lite .hero-cta { flex-basis: 100%; } }

/* ---------- Flyers: item-count badge on the first slide ---------- */
.flyer-count {
  position: absolute; z-index: 3; top: clamp(12px, 2vw, 22px); right: clamp(12px, 2vw, 22px);
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: rgb(255 255 255 / .92); color: var(--ink); font-size: .78rem; font-weight: 750;
  box-shadow: 0 6px 16px -8px rgb(0 0 0 / .5); backdrop-filter: blur(4px);
}
.flyer-count::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--nx-green, #7AB800); }
@media (max-width: 760px) { .flyer-count { font-size: .68rem; padding: 4px 9px; } }

/* ---------- The panel ---------- */
.ai-dialog {
  width: min(640px, 100vw); max-width: 100vw; max-height: min(92dvh, 900px); border-radius: var(--r-l);
  display: none; flex-direction: column; overflow: hidden;
  &[open] { display: flex; }
}
/* Phones: the whole screen, sized to the space above the keyboard (aiorder.js sets --ai-h / --ai-top) */
@media (max-width: 640px) {
  .ai-dialog {
    position: fixed; inset: var(--ai-top, 0px) 0 auto 0; margin: 0; width: 100vw; max-width: 100vw;
    height: var(--ai-h, 100dvh); max-height: var(--ai-h, 100dvh); border-radius: 0;
  }
  .ai-dialog .drawer-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; }
}
.ai-body { overflow-y: auto; padding: 14px 20px calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px; align-content: start; }
.ai-intro { margin: 0; font-size: .92rem; }
.ai-body textarea { min-height: 96px; resize: vertical; font-size: 1rem; }
.ai-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-lang { width: auto; min-height: 34px; padding: .3em 2em .3em .8em; border-radius: 999px; font-size: .88rem; }
.ai-mic.on { --bg: var(--chili); --fg: #fff; box-shadow: none; animation: ai-pulse 1.4s infinite; }
@keyframes ai-pulse { 50% { box-shadow: 0 0 0 8px rgb(225 29 72 / .15); } }
.ai-photo { cursor: pointer; }
.ai-status { margin: 0; min-height: 1.3em; font-size: .9rem; font-weight: 600; color: var(--muted); }
.ai-status.bad { color: var(--chili); }
.ai-status.busy::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--nx-green-d, #1F7A35); border-radius: 50%; animation: spin .7s linear infinite;
}

.ai-results { display: grid; gap: 12px; }
.ai-hint { margin: 4px 0 0; font-size: .86rem; color: var(--muted); }
.ai-item { border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: grid; gap: 6px; background: #fff; }
.ai-read { font-size: .85rem; color: var(--muted); b { color: var(--ink); } }
.ai-unsure { font-style: normal; font-weight: 700; color: #B45309; background: #FEF3C7; border-radius: 6px; padding: 1px 6px; font-size: .75rem; }
.ai-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); }
.ai-row:first-of-type { border-top: 0; }
.ai-thumb {
  width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: #F3F5F8; container-type: inline-size;
  img { width: 100%; height: 100%; object-fit: contain; padding: 4px; mix-blend-mode: multiply; }
  .label-art { padding: 6px; .la-name, .la-pack { display: none; } .la-brand { font-size: .6rem; } }
}
.ai-info { min-width: 0; display: grid; gap: 1px; b { font-size: .9rem; line-height: 1.25; } small { color: var(--muted); font-size: .75rem; } }
.ai-info .price { margin-top: 2px; }
.ai-info .price .now { font-size: 1.05rem; }
.ai-info .price .save { font-size: .56rem; padding: 2px 6px; }
.ai-act .add-ai { white-space: nowrap; --bg: var(--nx-green-d, #1F7A35); }
.ai-act .stepper { height: 34px; }
.ai-none { margin: 0; font-size: .88rem; color: var(--muted); }
.ai-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
@media (max-width: 420px) { .ai-row { grid-template-columns: 48px 1fr; } .ai-act { grid-column: 2; } .ai-thumb { width: 48px; height: 48px; } }

/* ---------- New-update count on the delivery icon (notify.js) ---------- */
.top-link { position: relative; }
.order-badge {
  position: absolute; top: 1px; left: 26px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  display: grid; place-items: center; background: var(--chili); color: #fff; font: 800 .7rem/1 var(--f-body);
  border: 2px solid #fff; box-shadow: 0 3px 8px -3px rgb(225 29 72 / .8);
  animation: badge-pop .4s var(--ease-spring);
}

/* ---------- Search: tappable magnifier + suggestions while typing ---------- */
.search-go {
  position: absolute; left: 5px; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 36px; height: 36px; border: 0; padding: 0; border-radius: 50%; background: none;
  display: grid; place-items: center; color: var(--muted); cursor: pointer;
  svg { position: static; width: 20px; height: 20px; color: inherit; pointer-events: none; }
  &:hover, &:focus-visible { background: rgb(12 27 51 / .07); color: var(--ink); }
}
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: #fff; border-radius: 16px; padding: 6px; display: grid; gap: 2px;
  box-shadow: 0 18px 40px -16px rgb(12 27 51 / .45), 0 0 0 1px #E3E7EE;
  max-height: min(70vh, 480px); overflow-y: auto; overscroll-behavior: contain;
}
.sg {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 10px; border-radius: 11px; color: var(--ink); cursor: pointer;
  > svg { position: static; width: 18px; height: 18px; color: var(--muted); flex: none; }
  &:hover, &.on { background: #F1F5FB; }
}
.sg-text { display: grid; min-width: 0; line-height: 1.25;
  b { font-weight: 650; font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  em { font-style: normal; color: var(--sale); font-weight: 700; }
}
.sg-tag { flex: none; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 7px; border-radius: 6px; background: #E8F0DA; color: #3E6E1F; }
html[lang="si"] .sg-tag { text-transform: none; letter-spacing: 0; }
.sg-thumb {
  width: 40px; height: 40px; flex: none; border-radius: 9px; overflow: hidden; background: #F3F5F8; container-type: inline-size;
  img { width: 100%; height: 100%; object-fit: contain; padding: 3px; mix-blend-mode: multiply; }
  .label-art { padding: 4px; .la-name, .la-pack { display: none; } .la-brand { font-size: .5rem; } }
}
.sg-none { margin: 0; padding: 10px 12px; color: var(--muted); font-size: .88rem; }

/* ---------- Product popup: keep a large photo inside the screen ----------
   A grid column sized "1fr" may grow to its content's natural width, so on phones a big photo
   stretched the popup's column past the screen and pushed the Add button over "More …". */
.pd-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 700px) { .pd-main { grid-template-columns: minmax(0, 1fr); } }
.pd-media { min-width: 0; overflow: hidden; }
.pd-media img { min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; }
.pd-info { min-width: 0; }

/* ---------- Voice order: "Show all N items" under each word's best 3 ---------- */
.ai-more-btn {
  justify-self: start; margin-top: 4px; border: 1.5px solid var(--line); background: #fff; color: var(--leaf-2);
  border-radius: 999px; padding: 6px 14px; font: 650 .84rem var(--f-body); cursor: pointer;
  &:hover { background: var(--blue-soft); }
}
.ai-shop-all { justify-self: start; font-size: .82rem; }
.ai-more { display: grid; }
.ai-more[hidden] { display: none; }
