@import url("./vars.css");

/* ---------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.45;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}

html[dir="rtl"] body,
html[lang="ar"] body {
  font-family: var(--font-ar);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3 {
  font-family: var(--font-ar);
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------- bits */

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-espresso);
  border-color: var(--brand-espresso);
  color: var(--text-on-dark);
}

.btn-gold {
  background: var(--brand-gold-bright);
  border-color: var(--brand-gold-deep);
  color: var(--on-gold);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.pill {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.demo-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step--1);
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.demo-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-gold);
  flex: none;
}

.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  /* Opaque: the menu scrolls underneath it, and a see-through bar lets the
     cards ghost through behind the category tabs. */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 14px -12px rgba(58, 42, 30, 0.5);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--pad) 6px;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 34px;
  height: 38px;
  flex: none;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.1;
}

html[dir="rtl"] .brand-name {
  font-family: var(--font-ar);
}

.spacer {
  flex: 1 1 auto;
}

.demo-strip {
  display: flex;
  justify-content: center;
  padding: 0 var(--pad) 7px;
}

/* --------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px var(--pad) 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .tabs {
    scroll-behavior: auto;
  }
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--brand-espresso);
  border-color: var(--brand-espresso);
  color: var(--text-on-dark);
}

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

/* One scrolling list, a section per category. --sticky-h is measured in JS
   from the pinned header, so scrolling to a section never hides its heading
   underneath; --dock-h keeps the last row clear of the bottom dock. */
:root {
  --sticky-h: 150px;
  --dock-h: 120px;
}

.menu-sections {
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: calc(var(--dock-h) + 24px);
}

.menu-section {
  scroll-margin-top: var(--sticky-h);
  padding: 0 var(--pad);
}

.section-head {
  font-size: var(--step-2);
  padding: 18px 2px 10px;
  color: var(--brand-espresso);
  position: relative;
}

.section-head::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  border-radius: 2px;
  background: var(--brand-gold);
  margin-top: 6px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gap);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-1);
}

.card-photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--surface-3);
  display: block;
}

.card-photo--ph {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.card-photo--ph img {
  width: 44px;
  height: 50px;
  opacity: 0.55;
}

.card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.card-name {
  font-weight: 600;
  line-height: 1.25;
}

.card-sub {
  font-size: var(--step--1);
  color: var(--text-faint);
}

.card-foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price {
  font-weight: 700;
  color: var(--brand-cocoa);
  white-space: nowrap;
}

.price small {
  font-weight: 600;
  color: var(--text-faint);
  font-size: 0.75em;
  margin-inline-start: 3px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}

.stepper button {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: var(--step-2);
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--brand-espresso);
}

.stepper button.add {
  background: var(--brand-espresso);
  color: var(--text-on-dark);
}

.stepper .qty {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stepper[data-empty="true"] .minus,
.stepper[data-empty="true"] .qty {
  display: none;
}

/* ----------------------------------------------------------- cart bar */

.dock {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 14px -12px rgba(58, 42, 30, 0.5);
  padding-bottom: env(safe-area-inset-bottom);
}

.cartbar {
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--line);
  display: none;
}

.cartbar[data-open="true"] {
  display: block;
}

/* Call waiter / Bring the bill: reachable from anywhere in the menu. */
.service-row {
  display: flex;
  gap: 8px;
  padding: 8px var(--pad) 10px;
}

.btn-service {
  flex: 1;
  min-height: var(--tap);
  padding: 0 10px;
  font-size: var(--step--1);
  background: var(--surface);
  border-color: var(--line-strong);
  font-variant-numeric: tabular-nums;
}

.btn-service[disabled] {
  opacity: 1;
  background: var(--surface-2);
  color: var(--text-faint);
  border-style: dashed;
}

.toast {
  margin: 0;
  padding: 9px var(--pad);
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-soft);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.toast-bad {
  color: var(--danger);
  background: var(--danger-soft);
}

.cartbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.cartbar .summary {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.cartbar .summary .count {
  font-size: var(--step--1);
  color: var(--text-soft);
}

.cartbar .summary .total {
  font-weight: 700;
  font-size: var(--step-1);
}

/* ------------------------------------------------------------- sheets */

dialog.sheet {
  border: 0;
  padding: 0;
  background: transparent;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
}

dialog.sheet::backdrop {
  background: rgba(36, 28, 20, 0.5);
}

.sheet-card {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: var(--pad) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  max-height: 92dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  dialog.sheet {
    margin: auto;
  }
  .sheet-card {
    border-radius: var(--radius-lg);
    border-bottom: 1px solid var(--line);
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-head h2 {
  font-size: var(--step-2);
}

.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.line-price {
  color: var(--text-soft);
  font-size: var(--step--1);
}

.note-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.note-field textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  resize: vertical;
}

.note-count {
  display: block;
  text-align: end;
  font-size: var(--step--1);
  color: var(--text-faint);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: var(--step-1);
  font-weight: 700;
}

/* ------------------------------------------------------------- status */

.status-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--pad) var(--pad) calc(var(--dock-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.order-head {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  text-align: center;
  box-shadow: var(--shadow-1);
}

.order-number {
  direction: ltr;
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 700;
  line-height: 1;
  color: var(--brand-espresso);
  font-variant-numeric: tabular-nums;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
}

.timeline li {
  flex: 1;
  text-align: center;
  font-size: var(--step--1);
  color: var(--text-faint);
  padding-top: 26px;
  position: relative;
  font-weight: 600;
}

.timeline li::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--surface);
}

html[dir="rtl"] .timeline li::before {
  transform: translateX(50%);
}

.timeline li::after {
  content: "";
  position: absolute;
  top: 8px;
  inset-inline-start: calc(50% + 12px);
  width: calc(100% - 24px);
  height: 2px;
  background: var(--line-strong);
}

html[dir="rtl"] .timeline li::after {
  inset-inline-start: auto;
  inset-inline-end: calc(50% + 12px);
}

.timeline li:last-child::after {
  display: none;
}

.timeline li[data-done="true"] {
  color: var(--ok);
}

.timeline li[data-done="true"]::before {
  background: var(--ok);
  border-color: var(--ok);
}

.timeline li[data-current="true"]::before {
  box-shadow: var(--ring);
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--step--1);
}

.notice-danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.notice-ok {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.resume-strip {
  padding: 8px var(--pad) 0;
  max-width: 1200px;
  margin: 0 auto;
}

.resume-strip button {
  width: 100%;
  justify-content: space-between;
  background: var(--info-soft);
  border-color: var(--info);
  color: var(--info);
}

.page-foot {
  padding: 0 var(--pad) 26px;
  text-align: center;
  color: var(--text-faint);
  font-size: var(--step--1);
}

/* Any text a guest typed is shown inside its own bidi island, so a stray
   direction mark can never reorder the words around it. */
.order-note,
.note-field textarea,
.line-name {
  unicode-bidi: isolate;
}
