/* ==========================================================================
   DoorDash replica — base design system
   Brand: #EB1700 red · #191919 ink · Inter/TT-Norms-like system stack
   ========================================================================== */

:root {
  /* Brand */
  --red: #EB1700;
  --red-hover: #C91300;
  --red-active: #AD1000;
  --red-soft: #FDECEA;
  --flame: #FF3008;
  --star: #008C64;
  --dashpass: #007233;
  --dashpass-teal: #00897B;
  --dashpass-soft: #E8F5F0;

  /* Ink & lines */
  --ink: #191919;
  --ink-2: #5c5c5c;
  --ink-3: #8f8f8f;
  --line: #EAEAEA;
  --line-2: #DDDDDD;
  --bg: #FFFFFF;
  --bg-2: #F7F7F7;
  --bg-3: #F1F1F1;

  /* Money / status */
  --green: #007233;
  --amber: #B25E00;
  --amber-soft: #FFF4E5;

  /* Layout */
  --container: 1248px;
  --gutter: 24px;
  --header-h: 64px;

  /* Shape & depth */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-2: 0 4px 10px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .06);
  --shadow-3: 0 10px 28px rgba(0, 0, 0, .14), 0 4px 8px rgba(0, 0, 0, .06);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .18);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --font: Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(235, 23, 0, .18); }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 300;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px;
  transition: top .15s var(--ease);
}
.skip-link:focus { top: 8px; text-decoration: none; }

/* ---- Layout helpers ------------------------------------------------------- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.page { min-height: 60vh; }
.stack-sm > * + * { margin-top: 8px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; line-height: 1;
  border-radius: 10px; padding: 0 18px; height: 44px;
  transition: background .15s var(--ease), box-shadow .15s var(--ease),
              transform .08s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-primary:active { background: var(--red-active); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; }
.btn-outline { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-outline:hover { box-shadow: inset 0 0 0 1px var(--ink-3); background: var(--bg-2); }
.btn-ghost { color: var(--ink); padding: 0 12px; }
.btn-ghost:hover { background: var(--bg-3); border-radius: 8px; text-decoration: none; }
.btn-sm { height: 36px; font-size: 13px; padding: 0 14px; border-radius: 8px; }
.btn-lg { height: 52px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] {
  background: var(--bg-3); color: var(--ink-3); box-shadow: none; cursor: not-allowed; transform: none;
}
.btn-primary[disabled] { background: var(--bg-3); }

/* ---- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 600; }
.field .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 10px; background: #fff;
  transition: border-color .12s, box-shadow .12s;
  font-size: 15px;
}
.textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.field.invalid .input, .field.invalid .select, .field.invalid .textarea {
  border-color: var(--red); box-shadow: 0 0 0 1px var(--red);
}
.field-error { font-size: 12px; color: var(--red); font-weight: 500; min-height: 0; display: none; }
.field.invalid .field-error { display: block; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c5c5c' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}

/* ---- Header -------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff; height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.site-header.scrolled { box-shadow: var(--shadow-1); border-bottom-color: var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; height: 100%; }

.logo-link { display: inline-flex; align-items: center; height: 40px; flex: none; }
.logo-link:hover { text-decoration: none; }
.logo-mark { height: 26px; width: auto; }

.address-control {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px;
  font-weight: 600; font-size: 14px; color: var(--ink);
  padding: 8px 10px; border-radius: 8px; flex: none;
}
.address-control:hover { background: var(--bg-2); text-decoration: none; }
.address-control .pin { color: var(--red); display: inline-flex; }
.address-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.address-caret { color: var(--ink-3); }
.eta-inline { font-size: 12px; color: var(--ink-3); font-weight: 500; display: block; text-align: left; }

.mode-toggle {
  display: inline-flex; background: var(--bg-3); border-radius: 999px; padding: 3px;
  flex: none; margin-left: 4px;
}
.mode-toggle button {
  border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); transition: all .15s var(--ease);
}
.mode-toggle button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }

.header-search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.header-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none; display: inline-flex;
}
.header-search .input { height: 40px; border-radius: 999px; padding-left: 38px; background: var(--bg-2); border-color: transparent; }
.header-search .input:focus { background: #fff; border-color: var(--ink); }
.search-suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-3);
  overflow: hidden; z-index: 120;
}
.suggest-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; font-size: 14px;
}
.suggest-item:hover, .suggest-item.active { background: var(--bg-2); text-decoration: none; }
.suggest-item .s-ico { flex: none; color: var(--ink-3); display: inline-flex; width: 18px; }
.suggest-item .s-thumb { flex: none; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; }
.suggest-item .s-meta { min-width: 0; flex: 1; }
.suggest-item .s-sub { font-size: 12px; color: var(--ink-3); }
.suggest-section { padding: 10px 14px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.cart-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 10px; color: var(--ink); }
.cart-button:hover { background: var(--bg-2); }
.cart-badge {
  position: absolute; top: 2px; right: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transform: scale(0); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.cart-badge.on { transform: scale(1); }
.cart-badge.pop { animation: badge-pop .4s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes badge-pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

.orders-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 8px; flex: none; }
.orders-link:hover { background: var(--bg-2); text-decoration: none; }
.signin-btn { flex: none; }

/* ---- Footer --------------------------------------------------------------- */
.site-footer { background: #fff; border-top: 1px solid var(--line); margin-top: 64px; padding: 40px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer-col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 14px; }
.footer-col a, .footer-col li { display: block; padding: 5px 0; font-size: 14px; color: var(--ink-2); }
.footer-col a:hover { color: var(--ink); text-decoration: none; }
.footer-legal { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--ink-3); font-size: 13px; }
.footer-social { display: inline-flex; gap: 8px; }
.footer-social a { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-2); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.footer-social a:hover { background: var(--bg-3); color: var(--ink); }

/* ---- Overlays: modal / drawer -------------------------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(10, 10, 10, .55);
  opacity: 0; transition: opacity .25s var(--ease);
  -webkit-backdrop-filter: saturate(.9); backdrop-filter: saturate(.9);
}
.backdrop.show { opacity: 1; }

.modal-root {
  position: fixed; z-index: 160; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; pointer-events: none;
}
.modal-card {
  pointer-events: auto;
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  width: min(620px, 100%); max-height: min(86vh, 800px);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(18px) scale(.97); opacity: 0;
  transition: transform .28s var(--ease), opacity .22s var(--ease);
}
.modal-card.show { transform: translateY(0) scale(1); opacity: 1; }
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 36px; height: 36px; border-radius: 999px;
  background: rgba(255, 255, 255, .92); box-shadow: var(--shadow-1);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.modal-close:hover { background: #fff; }

/* Right drawer (cart) */
.drawer-viewport { position: fixed; inset: 0; z-index: 160; pointer-events: none; }
.drawer {
  pointer-events: auto;
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: #fff; box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .32s var(--ease);
}
.drawer.show { transform: translateX(0); }

/* ---- Toasts -------------------------------------------------------------- */
.toast-root {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 220; display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; width: min(480px, calc(100vw - 32px));
}
.toast {
  pointer-events: none; /* never block the UI beneath; action buttons opt back in */
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-3);
  animation: toast-in .3s var(--ease); width: fit-content; max-width: 100%;
}
.toast .cart-remove-toast, .toast button { pointer-events: auto; }
.toast.success .t-ico { color: #6CE9B6; }
.toast .t-ico { display: inline-flex; color: #fff; flex: none; }
.toast.toast-out { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.96); } }

/* ---- Chips / badges ------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #fff;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: all .13s var(--ease); white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .x { display: inline-flex; opacity: .7; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 6px; background: var(--bg-3); color: var(--ink-2);
}
.badge-popular { background: #FEF0C7; color: #B25E00; }
.badge-dashpass { background: var(--dashpass-soft); color: var(--dashpass); }
.badge-offer { background: var(--red-soft); color: var(--red); }
.badge-soldout { background: #EFEFEF; color: var(--ink-3); }
.badge-new { background: #E7F0FE; color: #1D4FD7; }
.badge-closed { background: #3d3d3d; color: #fff; }

/* ---- Popover -------------------------------------------------------------- */
.popover-anchor { position: relative; }
.popover {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 130;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-3);
  min-width: 240px; padding: 6px;
  animation: toast-in .18s var(--ease);
}
.popover.right { left: auto; right: 0; }

/* ---- Animations ----------------------------------------------------------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { 0% { background-position: -460px 0; } 100% { background-position: 460px 0; } }
@keyframes pulse-ring { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.anim-fade-up { animation: fade-up .35s var(--ease) both; }

.skeleton {
  background: linear-gradient(90deg, #F0F0F0 25%, #E7E7E7 40%, #F0F0F0 60%);
  background-size: 460px 100%; animation: shimmer 1.25s infinite linear;
  border-radius: 8px;
}

/* ---- Custom scrollbars for rails ------------------------------------------ */
.rail { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px var(--gutter) 18px; scrollbar-width: none; -ms-overflow-style: none; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; flex: none; }

/* ---- Responsive header ---------------------------------------------------- */
@media (max-width: 1024px) {
  .address-control .address-text { max-width: 130px; }
  .header-search { max-width: 300px; }
}
@media (max-width: 860px) {
  .header-search { display: none; }
  .address-control { max-width: 150px; }
  .eta-inline { display: none; }
  .orders-link span { display: none; }
}
@media (max-width: 640px) {
  :root { --gutter: 14px; --header-h: 56px; }
  .header-inner { gap: 8px; }
  .logo-link { height: 32px; }
  .logo-link .logo-mark { height: 17px; }
  .address-control { flex: 0 1 auto; min-width: 0; padding: 8px 6px; font-size: 12px; gap: 5px; }
  .address-text { min-width: 0; }
  .mode-toggle button { padding: 6px 9px; font-size: 12px; }
  .orders-link, .signin-btn { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}
