:root {
  color-scheme: light;
  --bg: #4a4a4a;
  --surface: #0b0b0d;
  --ink: #eef6fb;
  --muted: #9aa6b0;
  --line: rgba(255,255,255,0.06);
  --blue: #10a8e8;
  --blue-dark: #087eb5;
  --black: #050505;
  --accent: #f2f7fb;
  --shadow: 0 18px 45px rgba(5, 24, 38, 0.13);
  /* Sidebar width intentionally handled via percentage (25%) */
  --header-height: 72px;
  --card-radius: 12px;
  --card-shadow: 0 6px 18px rgba(5, 24, 38, 0.06);
  --card-elev: 0 18px 40px rgba(5, 24, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 10% 10%, rgba(16,168,232,0.06), transparent 20rem), var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  height: var(--header-height);
  border-bottom: 1px solid var(--line);
  background: rgba(6,6,8,0.9);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border: 3px solid var(--black);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(16, 168, 232, 0.26);
}

.eyebrow {
  margin: 0 0 0.18rem;
  color: var(--blue-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.12;
}

.layout {
  display: flex;
  flex-direction: column; /* mobile-first: stacked */
  gap: 0;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* account for fixed header so content starts below it */
.layout {
  padding-top: var(--header-height);
}

/* order-panel uses its own styles below; no global menu-panel rules needed */
.order-panel {
  min-width: 0;
}

.category-sidebar {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: #007fff;
  box-shadow: none;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: var(--header-height);
  z-index: 900;
}

.category-list {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.75rem;
  align-items: center;
}

.category-section {
  margin-bottom: 1.25rem;
}

/* Keep the 'Categories' heading visible inside the sidebar */
.category-sidebar .section-head {
  position: sticky;
  top: 0; /* stick to the top of the sidebar container */
  z-index: 901;
  background: #007fff;
  padding-bottom: 0.5rem;
  width: 100%;
}

/* Mobile: pin the small sidebar heading under the fixed page header so
   it remains visible while horizontally scrolling the category buttons */
@media (max-width: 899px) {
  .category-sidebar .section-head {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 1100;
      padding: 0.45rem 0.75rem;
  }

  /* Reserve space in the sidebar for the fixed heading so the category bar doesn't overlap it */
    .category-sidebar {
      /* only reserve space equal to the pinned heading height */
      padding-top: 48px;
    }

  /* ensure the horizontal category list appears below the pinned heading */
  .category-list {
    padding-top: 0.5rem;
  }
}

.category-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4a4a4a;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, transform 160ms ease;
}

.category-tab span {
  min-width: 1.9rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--blue-dark);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 900;
}

.category-tab.active {
  border-color: var(--blue);
  background: var(--black);
  color: #D3D3D3;
}

.category-tab.active span {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.right-section {
  width: 100%;
  min-width: 0;
  display: block;
}

.menu-content {
  padding: clamp(1rem, 4vw, 2.5rem);
  min-height: 0;
}

/* Add spacing between meal cards */
.menu-grid {
  display: grid;
  gap: 0.95rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: start;
}

/* 3D card transition on category change */
.menu-grid {
  perspective: 1200px; /* container perspective for 3D effect */
  transform-style: preserve-3d;
}

@keyframes card-out {
  from { transform: rotateY(0) translateZ(0); opacity: 1; }
  to   { transform: rotateY(90deg) translateX(20px) translateZ(-40px); opacity: 0; }
}

@keyframes card-in {
  from { transform: rotateY(-90deg) translateX(-20px) translateZ(-40px); opacity: 0; }
  to   { transform: rotateY(0) translateZ(0); opacity: 1; }
}

/* applied during outgoing animation */
.menu-grid.anim-out .menu-card {
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  will-change: transform, opacity;
  animation: card-out 480ms cubic-bezier(.22,.9,.2,1) forwards;
  animation-delay: var(--stagger, 0ms);
}

/* applied when new cards are inserted */
.menu-grid.anim-in .menu-card {
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  will-change: transform, opacity;
  animation: card-in 480ms cubic-bezier(.22,.9,.2,1) forwards;
  animation-delay: var(--stagger, 0ms);
}

/* Mobile: rotate the whole menu grid as one layer for a lighter 3D transition */
@media (max-width: 899px) {
  .menu-grid {
    transform-origin: 50% 0;
    will-change: transform, opacity;
  }

  @keyframes menu-grid-out-mobile {
    from {
      opacity: 1;
      transform: perspective(900px) rotateY(0) translateX(0) translateZ(0);
    }

    to {
      opacity: 0;
      transform: perspective(900px) rotateY(14deg) translateX(10px) translateZ(-16px);
    }
  }

  @keyframes menu-grid-in-mobile {
    from {
      opacity: 0;
      transform: perspective(900px) rotateY(-14deg) translateX(-10px) translateZ(-16px);
    }

    to {
      opacity: 1;
      transform: perspective(900px) rotateY(0) translateX(0) translateZ(0);
    }
  }

  .menu-grid.anim-out {
    animation: menu-grid-out-mobile 260ms cubic-bezier(.22,.9,.2,1) forwards;
  }

  .menu-grid.anim-in {
    animation: menu-grid-in-mobile 300ms cubic-bezier(.22,.9,.2,1) forwards;
  }

  .menu-grid.anim-out .menu-card,
  .menu-grid.anim-in .menu-card {
    animation: none;
    transform: none;
    will-change: auto;
  }
}

/* Desktop: apply fixed split-screen */
@media (min-width: 900px) {
  .layout {
    flex-direction: row;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
    padding-top: 0;
  }

  .category-sidebar {
    width: 25%;
    min-width: 220px;
    max-width: 420px;
    height: 100%;
    padding: 1rem;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .category-list {
    display: grid;
    gap: 0.5rem;
    padding-bottom: 2rem;
  }

  .category-tab {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 8px;
  }

  .right-section {
    width: 75%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .menu-content {
    overflow-y: auto;
  }
}

.order-panel {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(10,12,14,0.96), rgba(12,14,16,0.98));
  box-shadow: 0 18px 40px rgba(0,0,0,0.6);
  overflow-y: auto;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head.compact {
  align-items: center;
}

.ghost-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.ghost-button {
  padding: 0 0.85rem;
}

/* Clear cart button: make 'Vider' dark blue with white text */
#clearCart {
  background: var(--blue-dark);
  color: #fff;
  border-color: transparent;
}

/* Subtle base shadow for each meal card, with stronger hover elevation */
.menu-card {
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border-radius: var(--card-radius);
  overflow: hidden;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--card-shadow);
  transition: box-shadow 180ms ease, transform 180ms ease;
  border: 1px solid rgba(10, 30, 60, 0.04);
}

.menu-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--card-elev);
}

/* food image cover and rounded top */
.food-photo {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: calc(var(--card-radius) - 4px);
  background: linear-gradient(180deg, var(--accent), #fff);
  margin-bottom: 0.6rem;
}

.food-art {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 0.8rem;
  border-radius: 8px;
  background: var(--black);
  color: #fff;
  font-size: 1.7rem;
  font-weight: 900;
}

.food-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 0.8rem;
  border-radius: 8px;
  object-fit: contain;
  background: var(--accent);
}

.menu-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
  line-height: 1.2;
  color: #4a4a4a;
}

.category-heading {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 900;
  color: #4a4a4a;
}

.menu-card p {
  margin-bottom: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.price {
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg,#007fff 0%, #10a8e8 100%);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.add-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.add-button,
.primary-button {
  border: 0;
  background: var(--blue);
  color: #fff;
}

.add-button {
  padding: 0 0.9rem;
  box-shadow: 0 8px 18px rgba(16,168,232,0.12);
}

.primary-button,
.secondary-button {
  display: grid;
  place-items: center;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0 1rem;
}

.secondary-button {
  border: 1px solid var(--black);
  background: #fff;
  color: var(--black);
}

.add-button:hover,
.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button:hover {
  border-color: var(--blue-dark);
  color: var(--blue-dark);
}

.primary-button.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.cart-items {
  display: grid;
  gap: 0.55rem;
  min-height: 72px;
  margin-bottom: 0.9rem;
}

.cart-items.empty {
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.cart-items.empty p {
  margin: 0;
}

.continue-shopping-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 48px;
  margin: 0 0 0.9rem;
  padding: 0 1rem;
  border: 1px solid rgba(16, 168, 232, 0.42);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(16, 168, 232, 0.18), rgba(8, 126, 181, 0.26));
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  text-align: center;
}

.continue-shopping-button:hover {
  border-color: var(--blue);
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
}

.cart-row strong {
  display: block;
  margin-bottom: 0.18rem;
}

.cart-row small {
  color: var(--muted);
}

.qty-controls {
  display: grid;
  grid-template-columns: 34px 34px 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-dark);
}

.qty-controls button {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 900;
  color: #fff;
}

.qty-controls span {
  text-align: center;
  font-weight: 900;
  color: #fff;
}

.totals {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: var(--accent);
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.totals dt,
.totals dd {
  margin: 0;
}

.grand-total {
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 1.15rem;
  font-weight: 900;
}

/* make the 'Total' label dark blue for emphasis */
.grand-total dt {
  color: var(--blue-dark);
}

.grand-total dd {
  color: var(--blue-dark);
}

.grand-total dd,
.grand-total #total {
  color: var(--blue-dark) !important;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface);
  color: var(--ink);
  outline-color: var(--blue);
  resize: vertical;
}

.offline-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(340px, calc(100% - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

/* No layout switching: fixed two-column split on all sizes */

/* Desktop: fix the lateral menu to the left of the centered layout
   while leaving space in the grid for the content to avoid overlap. */
/* layout consistent across viewport sizes: left = 25%, right = 75% */

@media (max-width: 620px) {
  .app-header {
    align-items: center;
  }

  .section-head {
    display: grid;
    align-items: start;
  }

  .menu-grid {
    grid-template-columns: 1fr;
  }
}

/* Floating cart button (mobile) */
.floating-cart {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  right: 14px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  background: linear-gradient(135deg,#ff7a00 0%, #ff4b00 100%);
  color: #fff;
  border: none;
  box-shadow: 0 10px 30px rgba(60, 12, 0, 0.18);
}

.floating-cart svg { display: block; }

.cart-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #007fff;
  color: #fff;
  font-weight: 900;
  font-size: 0.78rem;
  box-shadow: 0 6px 12px rgba(0, 127, 255, 0.12);
}

@keyframes cart-attention {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 12px 30px rgba(60, 12, 0, 0.24);
  }

  50% {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 16px 38px rgba(255, 75, 0, 0.36);
  }
}

/* Mobile: make order panel slide up as a drawer when cart opened */
@media (max-width: 899px) {
  .floating-cart {
    top: calc(var(--header-height) + 118px);
    right: 12px;
    min-width: 72px;
    min-height: 54px;
    padding: 0.75rem 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.88);
    animation: cart-attention 1.8s ease-in-out infinite;
  }

  .floating-cart svg {
    width: 26px;
    height: 26px;
  }

  .floating-cart .cart-count {
    min-width: 26px;
    height: 26px;
    font-size: 0.9rem;
  }

  .cart-open .floating-cart {
    animation: none;
    display: none;
  }

  .order-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    transform: translateY(100%);
    transition: transform 260ms cubic-bezier(.22,.9,.2,1);
    max-height: 82vh;
    overflow-y: auto;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    z-index: 1150;
    margin: 0 0 0 0;
    padding: 1rem;
  }

  /* show close button inside the order panel */
  #closeCartMobile { display: inline-block; margin: 0 0 0.6rem 0; }

  .cart-open .order-panel { transform: translateY(0); }

  /* keep the floating cart visible on mobile only */
  .floating-cart { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  .floating-cart {
    animation: none;
  }
}

/* Hide floating cart on large screens */
@media (min-width: 900px) {
  .floating-cart { display: none; }
  #closeCartMobile { display: none; }
}
