/* style.css
   Tailwind (via CDN, see each page's <head>) handles almost all layout and
   spacing utility classes. This file only covers what Tailwind's utility
   set can't: the CSS custom properties the brand color plugs into, glass
   surfaces, shimmer loading states, and the Kanban board mechanics.
*/

:root {
  --brand: #e4572e;
  --brand-2: #7c2d12;
  --brand-ink: #ffffff;
  --bg: #f7f7f5;
  --ink: #1c1c1e;
  --muted: #6b6b6e;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-border: rgba(255, 255, 255, 0.6);
}

/* Moody "late kitchen" theme — toggled by the admin's Dark mode setting.
   Kept as a class on <html> so it can flip before first paint (see the
   inline snippet in each page's <head>) with no flash of the wrong theme. */
html.theme-dark {
  --bg: #14100f;
  --ink: #f3ede6;
  --muted: #a89e94;
  --surface: rgba(28, 22, 20, 0.66);
  --surface-border: rgba(255, 255, 255, 0.08);
}
html.theme-dark body {
  background: radial-gradient(ellipse at top, #241a16 0%, var(--bg) 55%);
}
html.theme-dark .skeleton {
  background: rgba(255, 255, 255, 0.06);
}
html.theme-dark input,
html.theme-dark select {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

* {
  -webkit-tap-highlight-color: transparent;
}

/* Deter casual selection and saving of interface markup/assets */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Ensure inputs, forms, and editable fields retain natural cursor & selection */
input,
textarea,
select,
[contenteditable="true"] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  transition: background-color 0.4s ease, color 0.4s ease;
  /* NOTE: no fill-mode here (was `both`). A CSS transform left in place by
     `both`/`forwards` after the animation ends — even the identity
     translateY(0) — is NOT the same as the keyword `none`, and per the CSS
     Transforms spec ANY non-`none` transform on an ancestor becomes the
     containing block for `position: fixed` descendants. With `both` here,
     every fixed element on the page (cart drawer, auth/track/profile
     modals, the mobile bottom bar, toast) was positioned relative to the
     full scrollable height of <body> instead of the viewport — on a long
     menu page that pushed them far down, off-screen, looking "broken" on
     mobile. Dropping the fill-mode means the transform is only applied
     *during* the 0.5s animation and reverts to `none` the moment it ends. */
  animation: page-in 0.5s ease;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Ambience layer: embers, grain, faint food doodles ------------------
   Purely decorative, fixed, non-interactive, and behind everything else —
   the "mysterious warmth" of the brand without ever competing with content. */
.ember-field,
.grain-overlay,
.food-doodles {
  position: fixed;
  inset: 0;
  /* Negative z-index reliably keeps these behind ordinary (non-positioned)
     page content in the root stacking context, no matter what order they're
     inserted in the DOM — see mountAmbience() in api.js, which prepends them. */
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ember-field .ember {
  position: absolute;
  bottom: -10px;
  border-radius: 999px;
  background: radial-gradient(circle, var(--brand) 0%, var(--brand-2) 60%, transparent 75%);
  opacity: 0;
  filter: blur(0.3px);
  animation-name: ember-rise;
  animation-timing-function: ease-in;
  animation-iteration-count: infinite;
}

@keyframes ember-rise {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  8% {
    opacity: 0.55;
  }
  50% {
    transform: translateY(-52vh) translateX(8px);
    opacity: 0.35;
  }
  100% {
    transform: translateY(-100vh) translateX(-6px);
    opacity: 0;
  }
}

.grain-overlay {
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html.theme-dark .grain-overlay {
  opacity: 0.06;
}

/* Faint repeating line-art of food (fork, leaf, flame) — visible enough to
   register as texture, quiet enough to never distract from the menu. */
.food-doodles {
  opacity: 0.05;
  background-repeat: repeat;
  background-size: 220px 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cg fill='none' stroke='%231c1c1e' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M28 20v26M34 20v26M40 20v26M28 20c0 8 6 8 6 14v40M40 20c0 8-6 8-6 14'/%3E%3Cellipse cx='110' cy='60' rx='16' ry='22' transform='rotate(20 110 60)'/%3E%3Cpath d='M110 38v-10' transform='rotate(20 110 60)'/%3E%3Cpath d='M170 150c-14-8-14-24-4-32 2 8 8 10 8 18 6-6 4-16-2-24 14 2 22 16 18 30-3 10-12 14-20 8z'/%3E%3Cpath d='M60 150c10 6 24 2 28-8s-2-20-12-22'/%3E%3C/g%3E%3C/svg%3E");
}
html.theme-dark .food-doodles {
  opacity: 0.07;
  filter: invert(1);
}

/* Category-nav taps use scrollIntoView() on the target section. Without
   this, the sticky header (which can grow tall on mobile once the
   announcement/closed banners are showing) covers the top of whatever just
   "scrolled into view", making the tap look like it did nothing. --header-h
   is kept in sync with the header's real rendered height by customer.js. */
#menu-sections section {
  scroll-margin-top: calc(var(--header-h, 132px) + 10px);
}

.font-display {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
}

/* Glass panel used for header, cards, drawers, modals */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--surface-border);
}

.brand-bg {
  background-color: var(--brand);
  color: var(--brand-ink);
}
.brand-text {
  color: var(--brand);
}
.brand-border {
  border-color: var(--brand);
}
.brand-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
}

/* Skeleton shimmer for loading states */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Cart drawer: right-side sheet on desktop, bottom sheet on mobile */
.cart-drawer {
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.cart-drawer[data-open='false'] {
  transform: translateY(100%);
}
@media (min-width: 768px) {
  .cart-drawer[data-open='false'] {
    transform: translateX(100%);
  }
}
.cart-drawer[data-open='true'] {
  transform: translateY(0) translateX(0);
}

/* On short viewports (a phone rotated to landscape, or an older small
   phone) the cart drawer's checkout form — now with guest count + notes +
   a charges breakdown — can outgrow the fixed max-height. Let the whole
   drawer scroll as one column there instead of clipping the footer. */
@media (max-height: 640px) {
  .cart-drawer {
    max-height: 100vh !important;
    overflow-y: auto;
  }
  #cart-items {
    flex: none !important;
  }
}

.scrim {
  transition: opacity 0.25s ease;
}

/* Hide scrollbars on the sticky category nav while keeping it scrollable */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --- Admin: sidebar / tab nav --- */
.nav-btn {
  color: var(--muted);
}
.nav-btn.active {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
}
.nav-btn-mobile {
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.nav-btn-mobile.active {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.nav-btn-mobile:active {
  transform: scale(0.94);
}

/* --- Admin: Kanban board --- */
.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
/* On phone, size each column to (almost) the full screen width so swiping
   feels like flipping between single-status screens — "Pending", then
   "Preparing", etc. — rather than showing three cramped slivers at once. */
@media (max-width: 767px) {
  .kanban {
    grid-auto-columns: 87vw;
    scroll-snap-type: x mandatory;
  }
}
.kanban-column {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  max-height: 75vh;
  scroll-snap-align: start;
}
.kanban-column .ticket-list {
  overflow-y: auto;
  flex: 1;
}
.ticket {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ticket:active {
  transform: scale(0.98);
}

/* Order tracker step line */
.step-track {
  display: flex;
  align-items: center;
}
.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.step-dot.active {
  background: var(--brand);
}
.step-line {
  flex: 1;
  height: 3px;
  background: rgba(0, 0, 0, 0.12);
}
.step-line.active {
  background: var(--brand);
}
.step-dot.current {
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent);
  }
  50% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--brand) 0%, transparent);
  }
}

/* Live-tracking progress bar (elapsed time vs. ETA) */
.eta-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.eta-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 1s linear;
}

/* ---- Reveal-on-scroll (menu cards, sections, receipt) ------------------ */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Menu card hover lift + lazy-image fade-in */
.menu-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.menu-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.35);
}
.menu-card img,
.lazy-img {
  opacity: 0;
  transition: opacity 0.45s ease;
}
.menu-card img.loaded,
.lazy-img.loaded {
  opacity: 1;
}

/* Buttons: a little life on press, everywhere */
button {
  transition: transform 0.12s ease, opacity 0.12s ease, background-color 0.2s ease;
}
button:active {
  transform: scale(0.96);
}

/* New-order ticket pop-in on the KDS board */
.ticket.ticket-new {
  animation: ticket-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes ticket-pop {
  0% {
    transform: scale(0.9) translateY(-8px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Toast slide-up */
#toast {
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---- Small reusable toggle switch (admin settings) ---------------------- */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}
.toggle-switch[data-on='true'] {
  background: var(--brand);
}
.toggle-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.toggle-switch[data-on='true'] .knob {
  transform: translateX(18px);
}

/* ---- Image upload dropzone (admin item editor / logo) -------------------- */
.dropzone {
  border: 1.5px dashed var(--surface-border);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  position: relative;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}
.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.image-preview {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 0.75rem;
  background-size: cover;
  background-position: center;
  background-color: rgba(0, 0, 0, 0.06);
  margin-bottom: 0.5rem;
}

/* Veg/non-veg indicator — the small square-with-a-dot mark familiar from
   Swiggy/Zomato. Green = veg, maroon/red = non-veg. Shown only when the
   admin has actually set it (dietTag null = no badge, never assumed). */
.diet-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1.5px solid;
  position: relative;
  flex-shrink: 0;
}
.diet-dot::after {
  content: '';
  position: absolute;
  inset: 2.5px;
  border-radius: 999px;
}
.diet-dot-veg {
  border-color: #0f9d58;
}
.diet-dot-veg::after {
  background: #0f9d58;
}
.diet-dot-nonveg {
  border-color: #b3261e;
}
.diet-dot-nonveg::after {
  background: #b3261e;
}
#i-diet-tag button {
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}
#i-diet-tag button.active {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--ink);
  font-weight: 600;
}
#i-diet-tag button:not(:last-child) {
  border-right: 1px solid var(--surface-border);
}

/* Store logo in header */
.store-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ink) 12%, transparent), 0 1px 3px rgba(0, 0, 0, 0.15);
  background: #fff;
}
@media (min-width: 640px) {
  .store-logo {
    width: 38px;
    height: 38px;
  }
}

@media print {
  /* Print (or "Save as PDF" from the print dialog) only the receipt card,
     not the whole tracking page. visibility:hidden (rather than
     display:none) keeps layout intact so nothing shifts, then the receipt
     itself is pulled out with position:absolute so it doesn't leave a
     giant blank gap where the rest of the now-invisible page used to be.
     This uses the browser's own print engine directly — no canvas capture,
     no virtual window sizing, none of the html2canvas failure modes we hit
     twice before (dead space, then a blank page). */
  body * {
    visibility: hidden;
  }
  #receipt,
  #receipt * {
    visibility: visible;
  }
  #receipt {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    max-width: none;
    background: #fff !important;
    color: #111 !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
  }
  .no-print {
    display: none !important;
  }
}

/* ---- Digital receipt / bill --------------------------------------------
   A few small touches to make the tracking-page receipt read like an actual
   bill: a dashed "tear line" divider between sections, a slightly tighter
   line-height for the item list, and a fixed small logo. */
.receipt-paper #receipt-items {
  font-variant-numeric: tabular-nums;
}
.receipt-divider {
  border-top: 1px dashed var(--surface-border);
  margin: 0.65rem 0;
}
.receipt-logo {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.12);
  background: #fff;
}

/* ---- Custom Broadcast Notifications ---- */
.broadcast-toast {
  animation: broadcast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.broadcast-toast.fade-out {
  transform: translateY(-20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
}
@keyframes broadcast-in {
  from {
    transform: translateY(-30px) scale(0.92);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Survey progress bar fill */
.survey-bar-fill {
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

