/* ==========================================================================
   Rachid Menu — frontend styles
   Colors and fonts are CSS variables; config.js overrides them per restaurant.
   Logical properties (inline/block) are used so RTL works without overrides.
   ========================================================================== */

@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('../assets/fonts/source-serif-4-var-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/noto-naskh-arabic-var-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  /* Theme (overridden from config.js) */
  --color-primary: #1f4d3a;
  --color-primary-strong: #143426;
  --color-primary-soft: #e8f1ec;
  --color-accent: #8f6f37;
  --color-price: #9a5a2e;
  --color-bg: #ffffff;
  --color-surface: #f3f5f3;
  --color-text: #1b2420;
  --color-muted: #5a6660;
  --color-muted-soft: #6b7570;
  --color-divider: #e6e9e7;
  --color-unavailable: #9b3426;

  --font-heading: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-arabic: 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;

  /* Active fonts (switched for Arabic below) */
  /* Logo widths in px as unitless numbers (configurable). Mobile scales with the
     viewport and reaches its full width at 433px; tablet/desktop is fixed. */
  --logo-width-mobile: 104;
  --logo-width-desktop: 112;
  /* Space between the logo and the restaurant name (only when a logo is shown). */
  --logo-name-gap: 12px;

  --font-heading-active: var(--font-heading);
  --font-body-active: var(--font-body);

  /* Layout */
  --gutter: 16px;
  --content-width: 720px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --tap: 44px;
  /* The page is the light surface; dish cards, the search field and dialogs use
     the background colour on top of it. */
  --page-bg: var(--color-surface);

  /* Dish cards (v0.8.3): one column on phones and tablets, two from 1024px. */
  --grid-columns: 1;
  --grid-gap: 10px;
  --card-padding: 10px;
  --card-padding-end: 12px;
  --card-gap: 14px;
  --card-radius: 16px;
  --card-shadow: 0 1px 2px rgba(18, 24, 21, 0.05);
  --card-shadow-hover: 0 4px 14px rgba(18, 24, 21, 0.08);
  --card-border-hover: color-mix(in srgb, var(--color-divider), var(--color-text) 12%);
  --card-pressed: rgba(18, 24, 21, 0.04);
  --dish-photo: 96px; /* square, fixed size: no layout shift while it loads */
  --dish-photo-radius: 12px;
  --dish-letter-size: 2.25rem;
  --chevron-size: 32px;
  --fs-dish-name: 1.0625rem;
  --fs-dish-name-ar: 1.1875rem;
  --fs-dish-desc: 0.9375rem;
  --fs-dish-desc-ar: 1rem;
  --fs-price: 1rem;
  --fs-price-ar: 1.0625rem;
  /* Tinted labels; app.js replaces these with values that always reach 4.5:1
     (12% of the colour on the card background, text darkened when needed). */
  --price-pill-bg: color-mix(in srgb, var(--color-price) 12%, var(--color-bg));
  --price-pill-text: var(--color-price);
  --unavailable-pill-bg: color-mix(in srgb, var(--color-unavailable) 12%, var(--color-bg));
  --unavailable-pill-text: var(--color-unavailable);
  --accent-on-page: var(--color-accent);

  --photo-ratio: 4 / 3;
  --photo-radius: 14px;
  --carousel-control-bg: rgba(255, 255, 255, 0.92);
  --carousel-control-shadow: 0 1px 6px rgba(18, 24, 21, 0.25);
  --carousel-dots-bg: rgba(18, 24, 21, 0.45);
  --nav-fade-width: 40px;
  /* Gradient direction from the inline-start edge inwards (flipped for RTL below). */
  --start-to-end: to right;
  --focus-ring: 0 0 0 3px var(--color-bg), 0 0 0 5px var(--color-primary);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 280ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

:root[lang='ar'] {
  --font-heading-active: var(--font-arabic);
  --font-body-active: var(--font-arabic);
}

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

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

body {
  margin: 0;
  min-width: 320px;
  background: var(--page-bg);
  color: var(--color-text);
  font-family: var(--font-body-active);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

:root[lang='ar'] body {
  line-height: 1.75;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1, h2, h3, p, ul {
  margin: 0;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--color-primary);
}

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

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  inset-inline-start: var(--gutter);
  top: calc(var(--safe-top) + 8px);
  z-index: 50;
  padding: 10px 16px;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header ---------- */
.site-header {
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.site-header__inner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 16px var(--gutter) 4px;
}

.brand {
  display: flex;
  flex-direction: column;
  /* Logo, name and tagline share the content column's inline-start edge
     (left in LTR, right in RTL), like the search field and section titles. */
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
}

.brand__logo {
  /* With the default 104 this is exactly clamp(76px, 24vw, 104px). */
  width: clamp(
    calc(var(--logo-width-mobile) * 76px / 104),
    calc(var(--logo-width-mobile) * 24vw / 104),
    calc(var(--logo-width-mobile) * 1px)
  );
  max-width: 100%; /* never wider than the brand column: no overlap, no overflow */
  height: auto;
  margin-block-end: var(--logo-name-gap); /* a hidden logo takes no space, so no gap */
}

.brand__text {
  min-width: 0;
}

.brand__name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(1.3rem, 6.6vw, 1.875rem);
  line-height: 1.1;
  letter-spacing: -0.005em;
  color: var(--color-primary-strong);
  overflow-wrap: anywhere;
}

.brand__name.brand__name--arabic {
  font-family: var(--font-arabic);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

.brand__tagline {
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--color-text);
}

:root[lang='ar'] .brand__tagline {
  font-size: 0.875rem;
  letter-spacing: 0;
  color: var(--color-muted);
}

/* ---------- Language switcher ---------- */
.lang-switcher {
  display: flex;
  align-items: center;
  flex: none;
  margin-top: 8px;
}

.lang-switcher__button {
  position: relative;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--color-text);
}

.lang-switcher__button + .lang-switcher__button {
  margin-inline-start: 9px;
}

/* Thin divider between options */
.lang-switcher__button + .lang-switcher__button::before {
  content: '';
  position: absolute;
  top: 13px;
  bottom: 13px;
  inset-inline-start: -5px;
  width: 1px;
  background: var(--color-divider);
}

.lang-switcher__button[lang='ar'] {
  font-family: var(--font-arabic);
  font-size: 1rem;
  letter-spacing: 0;
}

.lang-switcher__button[aria-pressed='true'] {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

.lang-switcher__button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (hover: hover) {
  .lang-switcher__button:hover:not([aria-pressed='true']) {
    color: var(--color-primary);
    background: var(--color-bg);
  }
}

/* ---------- Main / search ---------- */
.menu {
  max-width: var(--content-width);
  margin: 0 auto;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.menu:focus {
  outline: none;
}

.search {
  position: relative;
  margin: 14px var(--gutter) 0;
}

.search__icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 16px;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
}

.search__input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding-block: 12px;
  padding-inline: 50px 48px;
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  background: var(--color-bg);
  font-size: 1rem; /* ≥16px prevents iOS zoom on focus */
  -webkit-appearance: none;
  appearance: none;
}

.search__input::placeholder {
  color: var(--color-muted);
  opacity: 1;
}

.search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search__input:focus-visible {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
  background: var(--color-bg);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
}

.icon-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.search__clear {
  position: absolute;
  top: 50%;
  inset-inline-end: 4px;
  transform: translateY(-50%);
  color: var(--color-muted);
}

/* ---------- Category navigation (sticky, horizontally scrollable) ----------
   Phones and tablets: one scrollable row; a soft fade covers the edge that
   still has tabs behind it (app.js sets .has-more-start / .has-more-end).
   From 1024px the tabs wrap onto several lines instead (see below). */
:root[dir='rtl'] {
  --start-to-end: to left;
}

.category-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: 10px;
  background: var(--page-bg);
  border-bottom: 1px solid var(--color-divider);
}

.category-nav::before,
.category-nav::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: var(--nav-fade-width);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration) ease;
}

.category-nav::before {
  inset-inline-start: 0;
  background: linear-gradient(var(--start-to-end), var(--page-bg) 15%, transparent);
}

.category-nav::after {
  inset-inline-end: 0;
  background: linear-gradient(var(--start-to-end), transparent, var(--page-bg) 85%);
}

.category-nav.has-more-start::before,
.category-nav.has-more-end::after {
  opacity: 1;
}

.category-nav__track {
  display: flex;
  gap: 4px;
  padding: 8px var(--gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-nav__track::-webkit-scrollbar {
  display: none;
}

.category-nav__button {
  flex: none;
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-family: var(--font-heading-active);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

:root[lang='ar'] .category-nav__button {
  font-size: 1.0625rem;
  font-weight: 600;
}

:root[lang='ar'] .search__input {
  font-size: 1.0625rem;
}

.category-nav__button[aria-pressed='true'] {
  background: var(--color-primary);
  color: #fff;
}

.category-nav__button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (hover: hover) {
  .category-nav__button:hover:not([aria-pressed='true']) {
    background: var(--color-bg);
    color: var(--color-primary);
  }
}

/* ---------- Menu sections ---------- */
.menu__list {
  padding: 0 var(--gutter) 8px;
}

.menu-section {
  padding-top: 26px;
  scroll-margin-top: 72px;
}

.menu-section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--grid-gap);
}

.menu-section__title {
  font-family: var(--font-heading-active);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--color-primary-strong);
}

:root[lang='ar'] .menu-section__title {
  font-size: 1.75rem;
  line-height: 1.4;
  letter-spacing: 0;
}

.menu-section__count {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-on-page); /* the accent colour, darkened if needed to read on the page */
}

.menu-section__count::before {
  content: '';
  width: 22px;
  height: 1px;
  background: currentColor;
}

:root[lang='ar'] .menu-section__count {
  font-size: 0.875rem;
  letter-spacing: 0;
}

/* ---------- Dish cards ----------
   Each dish is a card on the light page: [photo or letter tile] [text] [chevron],
   mirrored in RTL by the flex direction. The dish name is the card's only button;
   its ::after covers the card, so the whole card is one tap target with one focus
   ring. Sizes come from the --card-* / --dish-* tokens in :root. */
.menu-section__list {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--grid-gap);
  padding: 0;
  list-style: none;
}

.dish {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--card-gap);
  min-width: 0;
  padding: var(--card-padding);
  padding-inline-end: var(--card-padding-end);
  border: 1px solid var(--color-divider);
  border-radius: var(--card-radius);
  background: var(--color-bg);
  box-shadow: var(--card-shadow);
}

.dish__media {
  position: relative;
  flex: 0 0 var(--dish-photo); /* never shrinks: the box is sized before the photo loads */
  width: var(--dish-photo);
  aspect-ratio: 1 / 1;
  border-radius: var(--dish-photo-radius);
  overflow: hidden;
  background: var(--color-surface);
}

.dish__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* No photo: the first letter of the name on the light brand tint, so the names
   stay aligned with the other cards. */
.dish__media--letter {
  display: grid;
  place-items: center;
  background: var(--color-primary-soft);
}

.dish__letter {
  font-family: var(--font-heading-active);
  font-size: var(--dish-letter-size);
  font-weight: 700;
  line-height: 1;
  color: var(--color-primary);
}

.dish__text {
  flex: 1 1 auto;
  min-width: 0;
}

.dish__name {
  font-family: var(--font-body-active);
  font-size: var(--fs-dish-name);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
  overflow-wrap: break-word;
  hyphens: auto;
}

:root[lang='ar'] .dish__name {
  font-size: var(--fs-dish-name-ar);
  line-height: 1.5;
}

.dish__open {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font-weight: inherit;
  text-align: start;
}

/* The name's button covers the whole card. */
.dish__open::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--card-radius);
}

.dish__open:focus-visible {
  outline: none;
}

.dish__open:focus-visible::after {
  box-shadow: var(--focus-ring);
}

.dish__open:active::after {
  background: var(--card-pressed);
}

/* Two lines, then "…". */
.dish__description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 3px;
  font-size: var(--fs-dish-desc);
  line-height: 1.45;
  color: var(--color-muted);
}

:root[lang='ar'] .dish__description {
  margin-top: 2px;
  font-size: var(--fs-dish-desc-ar);
  font-weight: 500;
  line-height: 1.65;
}

.dish__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}

/* Price pill tinted from the restaurant's price colour (values set by app.js). */
.dish__price {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--price-pill-bg);
  color: var(--price-pill-text);
  font-family: var(--font-body-active);
  font-size: var(--fs-price);
  font-weight: 700;
  line-height: 1.4;
  font-variant-numeric: lining-nums tabular-nums;
  unicode-bidi: isolate;
}

:root[lang='ar'] .dish__price {
  font-size: var(--fs-price-ar);
  line-height: 1.5;
}

.price-struck {
  color: var(--color-muted-soft);
  text-decoration-thickness: 1.5px;
}

.dish__price.price-struck {
  padding: 0;
  background: none;
  color: var(--color-muted-soft);
  font-weight: 600;
}

.dish__badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--unavailable-pill-bg);
  color: var(--unavailable-pill-text);
  font-family: var(--font-body-active);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

:root[lang='ar'] .dish__badge {
  font-size: 0.9375rem;
}

.dish__chevron {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--chevron-size);
  height: var(--chevron-size);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-primary);
}

.dish__chevron svg {
  display: block;
}

:root[dir='rtl'] .dish__chevron svg {
  transform: scaleX(-1);
}

/* "Several photos" mark in the photo's top inline-end corner. */
.dish__photos {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--carousel-dots-bg);
  color: #fff;
}

.dish__photos svg {
  display: block;
}

/* Unavailable: still shown, muted, with its label and struck price. */
.dish--unavailable .dish__name,
.dish--unavailable .dish__description {
  color: var(--color-muted-soft);
}

.dish--unavailable .dish__media img {
  filter: grayscale(1);
  opacity: 0.55;
}

.dish--unavailable .dish__media--letter {
  background: var(--color-surface);
}

.dish--unavailable .dish__letter {
  color: var(--color-muted-soft);
}

@media (hover: hover) {
  .dish:hover {
    border-color: var(--card-border-hover);
    box-shadow: var(--card-shadow-hover);
  }

  .dish:hover .dish__name {
    color: var(--color-primary);
  }
}

/* ---------- Empty state ---------- */
.empty-state {
  margin: 28px var(--gutter);
  padding: 32px 20px;
  border: 1px solid var(--color-divider);
  border-radius: var(--card-radius);
  background: var(--color-bg);
  text-align: center;
}

.empty-state__title {
  font-family: var(--font-heading-active);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-primary-strong);
}

.empty-state__text {
  margin-top: 6px;
  color: var(--color-muted);
}

.empty-state .button {
  margin-top: 18px;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.button--primary {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-heading-active);
  font-size: 1.125rem;
}

.button--secondary {
  border: 1px solid var(--color-primary);
  background: var(--color-bg);
  color: var(--color-primary);
}

.button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (hover: hover) {
  .button--primary:hover {
    background: var(--color-primary-strong);
  }
  .button--secondary:hover {
    background: var(--color-primary-soft);
  }
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--content-width);
  margin: 12px auto 0;
  padding: 20px var(--gutter) calc(24px + var(--safe-bottom));
  padding-left: calc(var(--gutter) + var(--safe-left));
  padding-right: calc(var(--gutter) + var(--safe-right));
  border-top: 1px solid var(--color-divider);
  font-size: 0.8125rem;
  color: var(--color-muted);
  text-align: center;
}

.site-footer p + p {
  margin-top: 4px;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 8px;
}

.noscript {
  margin: 24px var(--gutter);
}

/* ---------- Bottom sheet (native <dialog>) ---------- */
.sheet {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(18, 24, 21, 0);
  color: inherit;
  overflow: hidden;
  transition: background-color var(--duration) ease;
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.sheet::backdrop {
  background: transparent;
}

.sheet.is-open {
  background: rgba(18, 24, 21, 0.55);
}

.sheet__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - var(--safe-top) - 16px);
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -6px 24px rgba(18, 24, 21, 0.12);
  transform: translateY(100%);
  transition: transform var(--duration) var(--ease-out);
  overflow: hidden;
}

.sheet.is-open .sheet__panel {
  transform: translateY(0);
}

/* Bar stays outside the scroll area so the close button is always reachable. */
.sheet__bar {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: none;
  min-height: 56px;
  padding: 8px 10px 4px;
}

.sheet__handle {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 44px;
  height: 5px;
  margin-left: -22px;
  border-radius: 999px;
  background: #d9dedb;
}

.sheet__close {
  color: var(--color-text);
}

@media (hover: hover) {
  .sheet__close:hover {
    background: var(--color-surface);
  }
}

.sheet__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet__media {
  padding: 0 20px;
}

/* Photos: one or a carousel of up to 4, all shown in the 4:3 crop. */
.carousel {
  position: relative;
}

.carousel__track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-radius: var(--photo-radius);
}

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

.carousel__slide {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.sheet__image {
  width: 100%;
  aspect-ratio: var(--photo-ratio);
  max-height: 40vh; /* landscape phones keep the text in view */
  object-fit: cover;
  background: var(--color-surface);
  -webkit-user-drag: none;
  user-select: none;
}

/* Previous/next: 44px round buttons over the photo, mirrored in RTL. */
.carousel__button {
  position: absolute;
  top: 50%;
  margin-top: calc(var(--tap) / -2);
  background: var(--carousel-control-bg);
  color: var(--color-text);
  box-shadow: var(--carousel-control-shadow);
  transition: opacity var(--duration) ease, visibility var(--duration);
}

.carousel__button--prev {
  inset-inline-start: 8px;
}

.carousel__button--next {
  inset-inline-end: 8px;
}

:root[dir='rtl'] .carousel__button svg {
  transform: scaleX(-1);
}

.carousel__button:disabled {
  opacity: 0;
  visibility: hidden;
}

.carousel__dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  display: flex;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--carousel-dots-bg);
  transform: translateX(-50%);
  pointer-events: none;
}

.carousel__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transition: background-color var(--duration) ease;
}

.carousel__dot.is-active {
  background: #fff;
}

.sheet__body {
  padding: 20px 20px 24px;
}

.sheet__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px 12px;
}

/* The availability chip moves under the title when they don't fit side by side. */
.sheet__title {
  flex: 1 1 11ch;
  min-width: 0;
  font-family: var(--font-heading-active);
  font-weight: 700;
  font-size: clamp(1.625rem, 7.4vw, 2.125rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--color-text);
  overflow-wrap: break-word;
}

:root[lang='ar'] .sheet__title {
  font-size: clamp(1.5rem, 6.4vw, 1.875rem);
  line-height: 1.45;
  letter-spacing: 0;
}

.availability {
  flex: none;
  margin-top: 4px;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.availability--yes {
  background: var(--color-primary-soft);
  color: var(--color-primary-strong);
}

.availability--no {
  background: #f8e9e7;
  color: var(--color-unavailable);
}

.sheet__price {
  margin-top: 6px;
  font-family: var(--font-heading-active);
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-price);
  font-variant-numeric: lining-nums tabular-nums;
  unicode-bidi: isolate;
}

:root[lang='ar'] .sheet__price {
  font-size: 1.5rem;
  line-height: 1.5;
}

.sheet__price .price-struck {
  font-weight: 600;
}

.sheet__subtitle {
  margin-top: 22px;
  font-family: var(--font-heading-active);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

:root[lang='ar'] .sheet__subtitle {
  font-size: 1.3125rem;
}

.sheet__description {
  margin-top: 6px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-muted);
}

:root[lang='ar'] .sheet__description {
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.75;
}

:root[lang='ar'] .availability {
  font-size: 1rem;
}

:root[lang='ar'] .ingredients li {
  font-size: 1.0625rem;
  font-weight: 500;
}

:root[lang='ar'] .button--primary {
  font-size: 1.25rem;
}

.sheet__ingredients {
  margin-top: 20px;
  border-top: 1px solid var(--color-divider);
}

.sheet__ingredients .sheet__subtitle {
  margin-top: 18px;
}

.ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
}

.ingredients li {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.sheet__footer {
  flex: none;
  padding: 12px 20px calc(14px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  background: var(--color-bg);
  box-shadow: 0 -1px 0 var(--color-divider);
}

/* ---------- Very small phones (e.g. 320px) ---------- */
@media (max-width: 359px) {
  :root {
    --gutter: 14px;
    --card-gap: 12px;
    --dish-photo: 84px;
    --dish-letter-size: 2rem;
    --fs-dish-name: 1rem;
    --fs-dish-name-ar: 1.125rem;
    --fs-dish-desc: 0.875rem;
  }

  .brand__tagline {
    letter-spacing: 0.14em;
  }

  .lang-switcher__button {
    padding: 0 6px;
    font-size: 0.875rem;
  }

  .lang-switcher__button + .lang-switcher__button {
    margin-inline-start: 5px;
  }

  .lang-switcher__button + .lang-switcher__button::before {
    inset-inline-start: -3px;
  }

  .menu-section__title {
    font-size: 1.75rem;
  }

  .sheet__media,
  .sheet__body {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ---------- Larger screens (tablet 600px+, computer 1024px+) ----------
   Mobile-first: everything below only adds to the phone styles above, so phones
   are unchanged. Values come from the tokens defined in each :root block. */
@media (min-width: 600px) {
  :root {
    /* Layout */
    --gutter: clamp(24px, 3.5vw, 48px);
    --container-tablet: 720px;
    --container-desktop: 1120px;
    --content-width: var(--container-tablet);
    --search-width: 480px;
    --grid-gap: 14px;
    --card-padding: 12px;
    --card-padding-end: 16px;
    --card-gap: 18px;
    --dish-photo: 112px;
    --section-space: clamp(28px, 3vw, 44px);
    --logo-name-gap: 16px;

    /* Dish dialog */
    --dialog-width: 720px;
    --dialog-margin: clamp(16px, 4vh, 48px);
    --dialog-pad: clamp(20px, 2.4vw, 32px);
    --dialog-enter: 24px;
    --dialog-footer-gap: 12px;
    --dialog-shadow: 0 12px 40px rgba(18, 24, 21, 0.22);

    /* Typography (scales smoothly with the viewport) */
    --fs-brand-name: clamp(1.875rem, 1.2rem + 1.6vw, 2.5rem);
    --fs-tagline: clamp(0.8125rem, 0.7rem + 0.3vw, 0.875rem);
    --fs-tagline-ar: clamp(0.9375rem, 0.8rem + 0.3vw, 1.0625rem);
    --fs-category: clamp(1.0625rem, 0.95rem + 0.3vw, 1.1875rem);
    --fs-category-ar: clamp(1.0625rem, 0.95rem + 0.3vw, 1.1875rem);
    --fs-search: clamp(1rem, 0.9rem + 0.25vw, 1.125rem);
    --fs-section-title: clamp(2rem, 1.5rem + 1.2vw, 2.5rem);
    --fs-section-title-ar: clamp(1.75rem, 1.35rem + 1vw, 2.25rem);
    --fs-dish-name: 1.125rem;
    --fs-dish-name-ar: 1.25rem;
    --fs-dish-desc-ar: 1.0625rem;
    --fs-price: 1.0625rem;
    --fs-price-ar: 1.125rem;
  }

  /* Header: same start-aligned brand; name and tagline scale. */
  .brand__logo {
    width: calc(var(--logo-width-desktop) * 1px);
  }

  .brand__name {
    font-size: var(--fs-brand-name);
  }

  .brand__tagline {
    font-size: var(--fs-tagline);
  }

  :root[lang='ar'] .brand__tagline {
    font-size: var(--fs-tagline-ar);
  }

  /* Search: limited width, starting at the content edge. */
  .search {
    max-inline-size: var(--search-width);
  }

  .search__input {
    font-size: var(--fs-search);
  }

  /* Category tabs: all visible when they fit; the track still scrolls when they don't. */
  .category-nav__button {
    font-size: var(--fs-category);
  }

  :root[lang='ar'] .category-nav__button {
    font-size: var(--fs-category-ar);
  }

  /* Sections: more space between them. */
  .menu-section {
    padding-block-start: var(--section-space);
  }

  .menu-section__title {
    font-size: var(--fs-section-title);
  }

  :root[lang='ar'] .menu-section__title {
    font-size: var(--fs-section-title-ar);
  }

  /* Dish detail: a centered dialog instead of a bottom sheet. */
  .sheet[open] {
    justify-content: center;
    padding: var(--dialog-margin);
  }

  .sheet__panel {
    max-width: var(--dialog-width);
    max-height: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--dialog-shadow);
    transform: translateY(var(--dialog-enter));
    opacity: 0;
    transition: transform var(--duration) var(--ease-out), opacity var(--duration) ease;
  }

  .sheet.is-open .sheet__panel {
    transform: none;
    opacity: 1;
  }

  .sheet__handle {
    display: none;
  }

  .sheet__media {
    padding-inline: var(--dialog-pad);
  }

  .sheet__body {
    padding: var(--dialog-pad);
  }

  .sheet__footer {
    padding: var(--dialog-footer-gap) var(--dialog-pad) var(--dialog-pad);
  }
}

@media (min-width: 1024px) {
  :root {
    --content-width: var(--container-desktop);
    --grid-columns: 2;
    --grid-gap: 16px;
  }

  /* Category tabs: every category always visible, wrapping onto more lines. */
  .category-nav__track {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .category-nav::before,
  .category-nav::after {
    display: none;
  }

  /* Two-column dialog: photo on the inline-start side; close button, text and
     back button on the other. The scroll wrapper steps aside (display: contents)
     so the text column scrolls on its own; RTL mirrors via the grid direction. */
  .sheet__panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .sheet__panel:has(.sheet__media[hidden]) {
    grid-template-columns: minmax(0, 1fr); /* dish without a photo: one column */
  }

  .sheet__scroll {
    display: contents;
  }

  .sheet__media {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: start;
    padding: var(--dialog-pad);
    padding-inline-end: 0;
  }

  .sheet__image {
    max-height: none;
  }

  .sheet__bar,
  .sheet__body,
  .sheet__footer {
    grid-column: -2 / -1;
  }

  .sheet__bar {
    grid-row: 1;
  }

  .sheet__body {
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-block-start: 0;
  }

  .sheet__footer {
    grid-row: 3;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
