/*
 * TCHAHIT public layer v120 — responsive finish for every visitor / customer
 * page (home, shops, kitchen, cities, cart and checkout, tracking, errands,
 * account, assistant, legal, help). Loaded next to /tchahit-public-v96.css by
 * <PublicFooter/>, <SiteHeader/> and the customer chrome. Static file: it is
 * not part of the JS/CSS bundles. Values come from the canonical tokens
 * (app/design-tokens.css). Older route sheets use !important heavily, so the
 * rules that must win over them do too, scoped to touch screens or to short
 * landscape phones.
 * Audit: tests/e2e/tools/design-public-v120.spec.ts (11 sizes + landscape).
 */

/* ---- 1. Touch screens: every key stays a 44 px target ---------------------
   Phones in landscape are 568–915 px wide, past the old "max-width: 767px"
   phone rules, so the touch rules key on the pointer, not on the width. */
@media (pointer: coarse) {
  .tc-app-icon { inline-size: 44px !important; block-size: 44px !important; }
  .tc-footer-col ul { gap: 0 !important; }
  .tc-footer-col ul a,
  .tc-footer-legal a { min-height: 44px !important; min-width: 44px; display: inline-flex !important; align-items: center; justify-content: flex-start; }
  .tc-footer-legal a { justify-content: center; }
}
@media (pointer: coarse) {
  /* Assistant: suggestion chips and tools, the report form fields. */
  .assistant-panel :is(.assistant-suggest button, .assistant-tools button, .assistant-more, .assistant-feedback button) { min-height: 44px !important; }
  .assistant-panel :is(.issue-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .issue-form select) { min-height: 44px !important; }
  /* App download page: the legal row under the page. */
  .av-legal a { min-height: 44px !important; min-width: 44px; display: inline-flex !important; align-items: center; justify-content: center; }
}
/* 320–359 px phones keep 44 px language keys too: the room comes from the
   gaps, the page action and the storefront brand (already icon-only). */
@media (pointer: coarse) and (max-width: 359px) {
  html body .language-switch button,
  html body .tc-header .language-switch button,
  html body main.themed-storefront .storefront-top .language-switch button,
  html body .tc-langs a { min-width: 44px !important; padding: 0 4px !important; }
  .tc-header-end, main.themed-storefront .storefront-top { gap: 4px !important; }
  .tc-header-inner { gap: 6px !important; }
  .tc-header-action { padding: 0 8px !important; font-size: 12px !important; }
}
@media (pointer: coarse) and (min-width: 360px) {
  html body .language-switch button,
  html body .tc-header .language-switch button,
  html body .shell .topbar .language-switch button,
  html body main.themed-storefront .storefront-top .language-switch button,
  html body .tc-langs a { min-width: 44px !important; min-height: 44px !important; height: 44px !important; }
  .tc-header .language-switch,
  .tc-langs { height: auto !important; padding: 2px !important; }
}

/* App download page on phones: while the device is being detected, hold the
   height of the phone download key instead of the taller desktop QR block,
   so nothing below jumps (CLS) when the right key appears. */
@media (pointer: coarse) and (max-width: 767px) {
  .av-action[data-device="pending"] { min-block-size: 104px; }
  .av-action[data-device="pending"] > * { display: none !important; }
}

/* Errand page: the spending-cap line arrives with the quote; its own line with
   a reserved height keeps the form below still (CLS). */
.errand-policy-note .errand-cap { display: block; margin-block-start: 4px; min-block-size: 2lh; }
@media (max-width: 480px) { html:not([lang="ar"]) .errand-policy-note .errand-cap { min-block-size: 3lh; } }
@media (max-width: 360px) { html[lang="fr"] .errand-policy-note .errand-cap { min-block-size: 4lh; } }

/* Kitchen cards on small phones: a long country name pushes the category to a
   second line instead of being cut. */
@media (max-width: 420px) {
  .kc-card-kicker { flex-wrap: wrap !important; white-space: normal !important; row-gap: 2px !important; }
  .kc-card-kicker > span[aria-hidden="true"] { display: none; }
  .kc-card-kicker .kc-card-cat { flex: 1 0 100%; }
}
/* Help role tabs: long FR labels wrap inside the key on 320 px phones. */
@media (max-width: 380px) {
  .help-tabs button { white-space: normal !important; overflow-wrap: anywhere; line-height: 1.25 !important; padding-inline: 8px !important; }
}

/* Small phones: a header that already carries a page action (partner sign-up…)
   leaves the app download key to the footer, so nothing spills sideways. */
@media (max-width: 400px) {
  .tc-header-end:has(.tc-header-action) .tc-app-icon { display: none !important; }
}

/* Customer account header on small phones: the sign-out key becomes a 44 px
   icon (its label stays in the DOM for screen readers). */
@media (max-width: 400px) {
  .customer-account > header { gap: 8px !important; }
  html body main.customer-account > header > button { flex: none; min-width: 44px; min-height: 44px; padding: 0 !important; justify-content: center; gap: 0 !important; font-size: 0 !important; }
  html body main.customer-account > header > button svg { width: 20px !important; height: 20px !important; }
}

/* Recipes: the hero keeps the same breathing room under the header as every other page. */
@media screen { .recipes-page .recipes-shell { margin-top: clamp(16px, 3vw, 32px) !important; } }

/* Recipe tags: one chip look on the tokens (they were a stand-alone beige). */
.recipe-tags { gap: 8px !important; }
.recipe-tags a { min-height: 36px; display: inline-flex !important; align-items: center; padding: 0 12px !important; border: 1px solid var(--tc-line); border-radius: var(--tc-r-pill) !important; background: var(--tc-surface-2) !important; color: var(--tc-brand-800) !important; font-size: 13px; font-weight: 700; }
.recipe-tags a:hover { border-color: var(--tc-brand-300); background: var(--tc-brand-50) !important; }
.recipe-tags a:focus-visible, .kc-crumbs a:focus-visible { outline: 3px solid var(--tc-focus); outline-offset: 2px; }
.kc-crumbs a { min-width: 44px; justify-content: center; }
@media (pointer: coarse) {
  .recipe-tags a { min-height: 44px; }
  .recipe-collections-line a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* Storefront reviews on phones: one swipeable row instead of a long column. */
@media (max-width: 640px) {
  main.themed-storefront .store-reviews ul { grid-template-columns: none !important; grid-auto-flow: column; grid-auto-columns: 84%; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: 2px; padding-bottom: 8px !important; scrollbar-width: thin; }
  main.themed-storefront .store-reviews li { scroll-snap-align: start; min-width: 0; }
  main.themed-storefront .store-reviews li small { white-space: normal !important; overflow-wrap: anywhere; }
}

/* ---- City pages: a richer hero and compact figures ----------------------- */
.city-figures { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)) !important; }
.city-figures article { position: relative; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px; padding: 14px 18px !important; overflow: hidden; }
.city-figures article::before { content: ""; position: absolute; inset-block: 12px; inset-inline-start: 0; inline-size: 4px; border-radius: 0 4px 4px 0; background: var(--tc-brand-500); }
[dir="rtl"] .city-figures article::before { border-radius: 4px 0 0 4px; }
.city-figures b { line-height: 1.1; }
.city-shops a { position: relative; align-content: start; overflow: hidden; }
.city-shops a::after { content: ""; position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 3px; background: var(--tc-brand-500); transform: scaleX(0); transform-origin: var(--tc-origin, right); transition: transform var(--tc-dur-3) var(--tc-ease-out); }
[dir="ltr"] .city-shops a::after { --tc-origin: left; }
.city-shops a:hover::after, .city-shops a:focus-visible::after { transform: scaleX(1); }
@media (min-width: 900px) {
  .city-hero { min-block-size: 320px; align-content: center; }
  .city-hero::after { content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; inline-size: 46%; pointer-events: none;
    background-image: image-set(url("/hero-food-860.avif") type("image/avif"), url("/hero-food-860.webp") type("image/webp"));
    background-size: cover; background-position: center;
    -webkit-mask-image: linear-gradient(to left, #000 55%, transparent); mask-image: linear-gradient(to left, #000 55%, transparent); }
  [dir="rtl"] .city-hero::after { -webkit-mask-image: linear-gradient(to right, #000 55%, transparent); mask-image: linear-gradient(to right, #000 55%, transparent); }
  .city-hero > * { position: relative; z-index: 1; max-inline-size: 56%; }
}
@media (prefers-reduced-motion: reduce) { .city-shops a::after { transition: none; } }

/* ---- Help guide: the eight steps read as one timeline -------------------- */
.help-panel ol { position: relative; gap: 12px !important; }
.help-panel ol::before { content: ""; position: absolute; inset-block: 24px; inset-inline-start: 32px; inline-size: 2px; border-radius: 2px; background: linear-gradient(var(--tc-brand-200), var(--tc-line)); }
.help-panel li { position: relative; grid-template-columns: 36px minmax(0, 1fr) !important; align-items: center !important; border-color: var(--tc-line) !important; box-shadow: var(--tc-shadow-1); transition: border-color var(--tc-dur-2) var(--tc-ease-out), box-shadow var(--tc-dur-2) var(--tc-ease-out); }
.help-panel li:hover { border-color: var(--tc-brand-200) !important; box-shadow: var(--tc-shadow-2); }
.help-panel li span { position: relative; z-index: 1; inline-size: 36px !important; block-size: 36px !important; border-radius: var(--tc-r-pill) !important; background: var(--tc-action) !important; color: var(--tc-on-action) !important; box-shadow: 0 0 0 4px var(--tc-paper); font-variant-numeric: tabular-nums; }
.help-panel li p { margin: 0 !important; color: var(--tc-text) !important; }
@media (prefers-reduced-motion: reduce) { .help-panel li { transition: none; } }

/* ---- FAQ: hover and open states on the brand ----------------------------- */
.faq-item { transition: border-color var(--tc-dur-2) var(--tc-ease-out), box-shadow var(--tc-dur-2) var(--tc-ease-out); }
.faq-item:hover { border-color: var(--tc-brand-200); }
.faq-item[open] { border-color: var(--tc-brand-300); box-shadow: var(--tc-shadow-1); }
.faq-item[open] summary { color: var(--tc-brand-800); }
.faq-item[open] summary::after { background: var(--tc-action) !important; color: var(--tc-on-action) !important; }
@media (prefers-reduced-motion: reduce) { .faq-item { transition: none; } }

/* ---- Loading skeleton (one look everywhere) ------------------------------ */
.tc-skeleton { display: inline-block; min-block-size: 14px; border-radius: var(--tc-r-pill); background: linear-gradient(90deg, var(--tc-cream-200) 0%, var(--tc-cream-50) 50%, var(--tc-cream-200) 100%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .tc-skeleton { animation: tc120-shimmer 1.4s linear infinite; } }
@keyframes tc120-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.status-skeleton { inline-size: 72px; block-size: 18px; }
.status-components li.is-loading { color: var(--tc-text-2); }

/* ---- Status page: two columns of services on wide screens, a live dot ---- */
@media (min-width: 900px) {
  .status-page .status-components { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; }
  .status-page .status-components li { margin: 0 !important; }
}
.status-page .status-components li.is-operational .status-state svg,
.status-page .status-components li.is-ok .status-state svg { border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
  .status-page .status-banner.is-operational svg, .status-page .status-banner.is-ok svg { animation: tc120-pulse 2.4s var(--tc-ease-in-out) infinite; border-radius: 50%; }
}
@keyframes tc120-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, .35); } 50% { box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); } }

/* ---- Checkout (guest order form) ------------------------------------------
   Full-width rows for the delivery point, payment and address, text on the
   reading side in every language (it was right-aligned in FR/EN). */
.shell .guest-form > :is(.checkout-delivery-point, .checkout-payment-method, .otp-verification-box),
.shell .guest-form > label:has(> input[name="address"]),
.shell .guest-form > label:has(textarea) { grid-column: 1 / -1 !important; }
.shell .guest-form :is(.checkout-delivery-point, .checkout-delivery-point > span, .checkout-payment-method, .checkout-payment-method legend, .checkout-payment-method label, .checkout-payment-method label span) { text-align: start !important; }
.shell .guest-form .checkout-payment-method label span { align-items: flex-start !important; }
.shell .guest-form .checkout-payment-method legend { margin-inline-start: 0 !important; margin-inline-end: auto !important; float: none; }
.shell .guest-form .checkout-delivery-point { border-color: var(--tc-line) !important; background: var(--tc-surface-2) !important; }
.shell .guest-form .checkout-delivery-point > svg { color: var(--tc-brand-600) !important; }
.shell .guest-form .checkout-delivery-point small { color: var(--tc-text-2) !important; }
.shell .checkout-modal .checkout-head h2 { font-weight: var(--tc-fw-heading) !important; line-height: var(--tc-lh-heading) !important; }
/* Phones: the decorative shield gives its width to the title (one line instead of two). */
@media (max-width: 560px) { .shell .checkout-modal .checkout-head > span { display: none !important; } }

/* ---- 2. Short landscape phones (568×320 … 915×412) ------------------------
   The screen is ~350 px tall: bars get compact so the page keeps at least
   half of the height, and the bottom tab bar lays icon + label on one row. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1000px) {
  html:not([data-app]) .tc-webtabs { padding-top: 2px; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tc-webtabs > a { min-height: 44px !important; flex-direction: row !important; gap: 8px !important; padding: 0 6px !important; }
  .tc-webtabs > a[aria-current="page"]::before { top: -3px; }
  .tc-webtabs > a > i { top: 0; }
  html[data-web-tabs]:not([data-app]) body { padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-web-tabs]:not([data-app]) .assistant-launcher { bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-web-tabs]:not([data-app]) .public-map-page { bottom: calc(48px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-web-tabs]:not([data-app]) .public-map-locate { bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-web-tabs]:not([data-app]) .public-map-locate-status { bottom: calc(116px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Home bottom bar: same compact row as the website tabs. */
  .shell nav.mobile-nav > :is(a, button) { min-height: 44px !important; flex-direction: row !important; gap: 8px !important; padding-block: 0 !important; }
  .shell nav.mobile-nav > [aria-current="page"]::before { top: -3px !important; }
  .shell:has(nav.mobile-nav) { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important; }
  .shell:has(nav.mobile-nav) .assistant-launcher { bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Map: one slim bar, chips in one scrolling row. */
  .public-map-bar { padding: 4px 12px !important; gap: 8px !important; }
  .public-map-title small { display: none !important; }
  .public-map-title h1 { font-size: 16px !important; }
  .public-map-filters { padding: 4px 12px !important; }
  .public-map-locate { padding: 10px 16px !important; }

  /* Sign-in: the form starts inside the first screen. */
  .unified-login .signin-stage { padding-block: 16px !important; }
  .unified-login .signin-card { padding-block: 20px !important; }
  .unified-login .signin-head { grid-auto-flow: column; justify-content: center; align-items: center; gap: 12px !important; margin-bottom: 12px !important; }
  .unified-login .signin-logo { inline-size: 48px !important; block-size: 48px !important; margin: 0 !important; }
  .unified-login .signin-head h1 { font-size: 24px !important; margin: 0 !important; }

  /* Sticky public header: one compact row. */
  .tc-header-inner { min-height: 52px !important; }
}

/* ---- 3. Map popup: the shop link keeps AA contrast ------------------------ */
.tch-shop-popup a { min-height: 44px; display: inline-flex !important; align-items: center; justify-content: center; background: var(--tc-action, #c2410c) !important; color: var(--tc-on-action, #fff) !important; border-radius: var(--tc-r-sm, 8px) !important; }
.tch-shop-popup a:hover { background: var(--tc-action-hover, #9a3412) !important; }
.tch-shop-popup em.open { color: var(--tc-success-800, #166534); }
.tch-shop-popup em.closed, .tch-shop-popup small { color: var(--tc-text-2, #5f5650); }

/* ---- 4. Motion: everything that moves respects the reader's setting ------- */
@media (prefers-reduced-motion: reduce) {
  :is(.tc-footer, .tc-header, .tc-webtabs, .kc-card, .tc-empty, .assistant-panel, .store-cart-drawer) *,
  :is(.tc-footer, .tc-header, .tc-webtabs, .kc-card, .tc-empty, .assistant-panel, .store-cart-drawer) { transition-duration: 0ms !important; animation-duration: 0ms !important; animation-iteration-count: 1 !important; }
  .kc-card > a:hover, .kc-card > a:hover .kc-img { transform: none !important; }
}

/* V129 luxury finish: colour, elevation, type finish and micro-motion only (no size changes, no layout shift; no new backdrop blur: it cost ~40 ms of LCP on a 4x-throttled phone); tokens in app/design-tokens.css, notes in docs/design/TCHAHIT_DESIGN_LANGUAGE_AR.md §4-§7. */

:is(.shell, .tc-page, .tc-footer, main) :is(h1, h2, h3) { text-wrap: balance; }
:is(.shell, .tc-page, main) p { text-wrap: pretty; }
html[dir="ltr"] :is(.shell, .tc-page, main) :is(h1, h2) { letter-spacing: var(--tc-tracking-heading); }
html[dir="ltr"] .shell .h96b-title { letter-spacing: var(--tc-tracking-display); }
:is(.shell, main) :is(bdi, time), .tc-webtabs i, .shell nav.mobile-nav i { font-variant-numeric: tabular-nums; }
:is(.shell, .tc-header, .tc-webtabs, main) :is(a, button, [role="button"], summary):focus-visible {
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: var(--tc-ring) !important;
}
.tc-footer :is(a, button, summary):focus-visible { outline: 2px solid transparent !important; box-shadow: 0 0 0 2px var(--tc-night-900), 0 0 0 4px var(--tc-flame-soft) !important; }
.tc-header.tc-header:not(.tc-header-dark) {
  border-bottom-color: transparent !important;
  background: rgba(255, 248, 241, .86) !important;
}
.tc-header.tc-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tc-hairline) 12%, var(--tc-hairline) 88%, transparent);
  pointer-events: none;
}
.tc-header-dark.tc-header::after { background: linear-gradient(90deg, transparent, rgba(255, 87, 40, .4) 50%, transparent); }
.tc-header .tc-brand .logo, .tc-footer-logo .logo { transition: transform var(--tc-dur-3) var(--tc-ease-spring); }
@media (hover: hover) { .tc-header .tc-brand:hover .logo, .tc-footer-logo:hover .logo { transform: rotate(-6deg) scale(1.04); } }
:is(.tc-btn:not(.tc-btn-secondary):not(.tc-btn-ghost), .shell .h96b-go, .partners-cta) {
  box-shadow: var(--tc-shadow-cta);
  transition: background-color var(--tc-dur-2) var(--tc-ease-out), box-shadow var(--tc-dur-3) var(--tc-ease-out), transform var(--tc-dur-2) var(--tc-ease-spring);
}
@media (hover: hover) {
  :is(.tc-btn:not(.tc-btn-secondary):not(.tc-btn-ghost), .shell .h96b-go, .partners-cta):hover:not(:disabled) { box-shadow: var(--tc-shadow-cta-hover); transform: translateY(-1px); }
}
:is(.tc-btn, .shell .h96b-go, .partners-cta):active:not(:disabled) { transform: scale(var(--tc-press-scale)); transition-duration: 80ms; }
.tc-btn-secondary { box-shadow: var(--tc-shadow-1); transition: background-color var(--tc-dur-2) var(--tc-ease-out), box-shadow var(--tc-dur-2) var(--tc-ease-out), transform var(--tc-dur-2) var(--tc-ease-spring); }
.shell .restaurant-grid .restaurant, .kc-card {
  box-shadow: var(--tc-shadow-1);
  transition: box-shadow var(--tc-dur-3) var(--tc-ease-out), transform var(--tc-dur-3) var(--tc-ease-spring);
}
@media (hover: hover) {
  .shell .restaurant-grid .restaurant:hover { box-shadow: var(--tc-shadow-2); transform: translateY(var(--tc-lift)); }
}
:is(.shell, main) :is(article, li, label, h2, h3, p, .tc-btn-secondary) .tc-icon { --tc-icon-duo: var(--tc-brand-500); --tc-icon-duo-opacity: .24; }
:is(.tc-footer, .tc-header-dark, .h96b, .partner-dark) .tc-icon { --tc-icon-duo: var(--tc-flame); --tc-icon-duo-opacity: .32; }
:is(.tc-btn:not(.tc-btn-secondary), .shell .h96b-go, .partners-cta) .tc-icon { --tc-icon-duo: currentColor; --tc-icon-duo-opacity: .3; }
@media (max-width: 900px) {
  html:not([data-app]) .tc-webtabs, .shell nav.mobile-nav {
    border-top-color: var(--tc-hairline) !important;
    background: rgba(255, 255, 255, .97) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 -10px 30px -12px rgba(31, 26, 23, .18) !important;
  }
  .tc-webtabs > a, .shell nav.mobile-nav > :is(a, button) { transition: color var(--tc-dur-2) var(--tc-ease-out), background-color var(--tc-dur-2) var(--tc-ease-out), transform var(--tc-dur-2) var(--tc-ease-spring) !important; }
  .tc-webtabs > a:active, .shell nav.mobile-nav > :is(a, button):active { transform: scale(.94); transition-duration: 80ms !important; }
  .tc-webtabs > a[aria-current="page"], .shell nav.mobile-nav > [aria-current="page"] { background: transparent !important; }
  .tc-webtabs > a[aria-current="page"] .tc-icon, .shell nav.mobile-nav > [aria-current="page"] .tc-icon { --tc-icon-duo: var(--tc-brand-500); --tc-icon-duo-opacity: .5; }
  .tc-webtabs > a[aria-current="page"] small, .shell nav.mobile-nav > [aria-current="page"] small { font-weight: 700 !important; }
  .tc-webtabs > a[aria-current="page"]::before, .shell nav.mobile-nav > [aria-current="page"]::before {
    top: 2px !important;
    inset-inline: calc(50% - 12px) !important;
    height: 3px !important;
    border-radius: var(--tc-r-pill) !important;
    background: var(--tc-action) !important;
  }
  .tc-webtabs > a > i, .shell nav.mobile-nav > button > i { box-shadow: 0 2px 6px -1px rgba(194, 65, 12, .5); }
}
.tc-footer { position: relative; }
.tc-footer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 87, 40, .55) 50%, transparent);
  pointer-events: none;
}
.tc-footer a { transition: color var(--tc-dur-2) var(--tc-ease-out); }
@media (prefers-reduced-motion: reduce) {
  :is(.tc-btn, .shell .h96b-go, .partners-cta, .shell .restaurant-grid .restaurant, .kc-card, .tc-webtabs > a, .shell nav.mobile-nav > *, .logo) { transition: none !important; transform: none !important; }
}
