/* === HUDSON STREET DELI — Mobile Ordering Prototype === */

:root {
  /* Neutrals */
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --text: #2C2520;
  --text-secondary: #7A7067;
  --text-muted: #A69E94;
  --divider: #E8E2DA;
  --divider-strong: #D4CBC0;

  /* Semantic */
  --info: #3B7DD8;
  --success: #3A8A5C;
  --warning: #C4860B;
  --danger: #C43B3B;
  --pending: #8A8A8A;
  --active: #2B6CB0;

  /* Accent — warm avocado green */
  --accent: #5B8C3E;
  --accent-light: #EAF2E3;

  /* Role colors */
  --role-structural: #C49A3C;
  --role-protein: #8B5E3C;
  --role-richness: #6B8E4E;
  --role-moisture: #5B8DB8;
  --role-acidity: #9AB844;
  --role-crunch: #7AB648;
  --role-heat: #C85A3A;
  --role-umami: #7A5A3E;
  --role-garnish: #6B9E6B;

  /* Typography */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Berkeley Mono', 'IBM Plex Mono', monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 100px;

  /* Touch */
  --touch-min: 44px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: 88px;
  -webkit-font-smoothing: antialiased;
}

/* === DIETARY FILTER BAR === */
#dietary-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--divider);
}

.dietary-filters {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.dietary-filters::-webkit-scrollbar { display: none; }

.dietary-chip {
  flex-shrink: 0;
  height: 32px;
  min-width: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--divider-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dietary-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === SCREENS === */
.screen { display: none; }
.screen.active { display: block; }
.screen.hidden { display: none; }

/* === MENU HEADER === */
.menu-header {
  text-align: center;
  padding: var(--space-8) var(--space-4) var(--space-4);
}
.logo {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: 0.08em;
  color: var(--text);
}
.logo span {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-top: 2px;
}
.tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}

/* === CATEGORY TABS === */
.category-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.cat-tab.active {
  background: var(--text);
  color: var(--surface);
}

/* === MENU CARDS === */
.menu-list {
  padding: 0 var(--space-4) var(--space-10);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.menu-card {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--divider);
  padding: var(--space-4);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.menu-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.menu-card.unavailable {
  opacity: 0.45;
  pointer-events: none;
}

.menu-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.menu-card-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.menu-card-price {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.menu-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.menu-card-ingredients {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}
.menu-card-dietary {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.dietary-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(91,140,62,0.2);
}
.dietary-badge.df { background: #E3F0E8; color: #3A8A5C; border-color: rgba(58,138,92,0.2); }
.dietary-badge.gf { background: #FFF3E0; color: #B8860B; border-color: rgba(184,134,11,0.2); }
.dietary-badge.nf { background: #F0E6F6; color: #7B3FA0; border-color: rgba(123,63,160,0.2); }
.dietary-badge.v { background: #E8F5E9; color: #2E7D32; border-color: rgba(46,125,50,0.2); }
.dietary-badge.vg { background: #E8F5E9; color: #388E3C; border-color: rgba(56,142,60,0.2); }

/* === BOTTOM SHEET === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,37,32,0.4);
  z-index: 90;
  transition: opacity 0.2s;
}
.overlay.hidden { display: none; }

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  z-index: 100;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.bottom-sheet.hidden {
  transform: translateY(100%);
  pointer-events: none;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--divider-strong);
  border-radius: 2px;
  margin: 10px auto 0;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-4) var(--space-4) var(--space-2);
}
.sheet-header h2 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.cust-price {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* === INGREDIENT LIST === */
.cust-section {
  padding: var(--space-2) var(--space-4) var(--space-3);
}
.cust-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ingredient-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row:active { background: rgba(0,0,0,0.02); }

.ingredient-row.removed {
  opacity: 0.35;
  text-decoration: line-through;
}
.ingredient-row.substituted .ing-name {
  color: var(--accent);
}
.ingredient-row.substituted {
  opacity: 1;
  text-decoration: none;
}
.ingredient-row.substituted .ing-remove {
  background: #FEF3CD;
  color: var(--warning);
  font-size: 14px;
}

.ing-remove {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: #FEE2E2;
  color: var(--danger);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}
.ing-remove:active { transform: scale(0.9); }

.ing-name {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.ing-roles {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.role-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #F5F0EB;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}
.role-tag.structural { background: #FEF3CD; color: #92650A; }
.role-tag.protein { background: #F5E6D8; color: #6B3E20; }
.role-tag.richness { background: var(--accent-light); color: #3D6B2E; }
.role-tag.moisture { background: #DBEAFE; color: #1E5BA8; }
.role-tag.acidity { background: #ECFCD4; color: #4D7A0A; }
.role-tag.crunch { background: #DCFCE7; color: #15803D; }
.role-tag.heat { background: #FEE2E2; color: #B91C1C; }
.role-tag.umami { background: #F5E6D8; color: #7A5A3E; }
.role-tag.garnish { background: #DCFCE7; color: #3B7A4A; }
.role-tag.freshness { background: #ECFDF5; color: #166534; }
.role-tag.binding { background: #E0E7FF; color: #4338CA; }

.ing-dietary {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  pointer-events: none;
}

/* === SUBSTITUTION ZONE === */
.substitution-zone {
  background: #F8FAF5;
  border-radius: var(--r-md);
  border: 1px dashed rgba(91,140,62,0.3);
  margin: 0 var(--space-4);
  padding: var(--space-3);
}
.substitution-zone.hidden { display: none; }
.substitution-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.substitution-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sub-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1.5px solid var(--divider);
  cursor: pointer;
  min-height: var(--touch-min);
  transition: all 0.15s;
}
.sub-card:active { transform: scale(0.98); }
.sub-card.auto-suggest { border-color: var(--accent); border-style: solid; }
.sub-card.applied { background: var(--accent-light); border-color: var(--accent); }

.sub-arrow {
  font-size: 20px;
  color: var(--accent);
  font-weight: 300;
  flex-shrink: 0;
}
.sub-original {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: line-through;
  flex-shrink: 0;
}
.sub-replacement {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.sub-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.sub-price {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}
.sub-price.positive { color: var(--warning); }
.sub-price.zero { color: var(--success); }
.sub-roles-mini {
  display: flex;
  gap: 2px;
}
.sub-roles-mini .role-tag { height: 15px; font-size: 8px; padding: 0 4px; }

.sub-see-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 40px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-1);
}

/* === SUBSTITUTION DETAIL SHEET === */
.substitution-detail {
  max-height: 85dvh;
}
.sub-detail-removed {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.unfilled-roles {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  flex-wrap: wrap;
}
.unfilled-roles .role-tag {
  height: 22px;
  font-size: 10px;
  padding: 0 8px;
  background: #FEF3CD;
  color: #92650A;
  border: 1px dashed #D4A20A;
}
.candidate-list {
  padding: var(--space-2) var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.candidate-card {
  background: var(--surface);
  border: 1.5px solid var(--divider);
  border-radius: var(--r-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.15s;
}
.candidate-card:active { transform: scale(0.98); }
.candidate-card.auto { border-color: var(--accent); }
.candidate-name {
  font-size: 16px;
  font-weight: 600;
}
.candidate-reasoning {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}
.candidate-meta {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.candidate-roles {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.candidate-dietary {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.candidate-price {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  margin-left: auto;
}
.candidate-price.positive { color: var(--warning); }
.candidate-price.zero { color: var(--success); }
.candidate-flavor {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

/* === CONFIG CONTROLS === */
.config-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.config-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.config-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 70px;
}
.config-options {
  display: flex;
  gap: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1.5px solid var(--divider-strong);
  flex: 1;
}
.config-opt {
  flex: 1;
  height: 38px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  border-right: 1px solid var(--divider-strong);
}
.config-opt:last-child { border-right: none; }
.config-opt.active {
  background: var(--text);
  color: var(--surface);
}

/* === DIETARY SUMMARY === */
.dietary-summary {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* === ALLERGEN WARNING === */
.allergen-warning {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin: 0 var(--space-4);
  background: #FEF2F2;
  border: 1.5px solid #FECACA;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}
.allergen-warning.hidden { display: none; }
.allergen-icon { font-size: 18px; }

/* === ADD TO ORDER === */
.add-to-order-btn {
  display: block;
  width: calc(100% - 32px);
  margin: var(--space-4) auto var(--space-6);
  height: 54px;
  border: none;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.add-to-order-btn:active { transform: scale(0.97); opacity: 0.9; }

/* === CART FAB === */
.cart-fab {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  height: 56px;
  border: none;
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  cursor: pointer;
  z-index: 80;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: transform 0.15s;
  max-width: 388px;
  margin: 0 auto;
}
.cart-fab:active { transform: scale(0.97); }
.cart-fab.hidden { display: none; }
.cart-fab-count {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-fab-label {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  text-align: left;
}
.cart-fab-total {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}

/* === CART SCREEN === */
.screen-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.screen-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.back-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
}

.cart-items {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cart-item {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  padding: var(--space-4);
}
.cart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.cart-item-name {
  font-size: 16px;
  font-weight: 600;
}
.cart-item-price {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}
.cart-item-config {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.cart-item-subs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.cart-sub-line {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.cart-remove-btn {
  margin-top: var(--space-2);
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  padding: 0;
}

.cart-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--divider);
  padding: var(--space-4);
  z-index: 10;
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-3);
}
.cart-total-row span:last-child {
  font-family: var(--font-mono);
}
.place-order-btn {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.place-order-btn:active { opacity: 0.9; }

/* === TRACKER SCREEN === */
.tracker-content {
  padding: var(--space-8) var(--space-4);
  text-align: center;
}
.tracker-status {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  position: relative;
  padding: 0 var(--space-2);
}
.tracker-status::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 24px;
  right: 24px;
  height: 2px;
  background: var(--divider);
  z-index: 0;
}
.tracker-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  position: relative;
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--divider-strong);
  transition: all 0.3s;
}
.tracker-step.completed .step-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.tracker-step.completed .step-dot::after {
  content: '✓';
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.tracker-step.active .step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91,140,62,0.2);
  animation: pulse 2s ease-in-out infinite;
}
.step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.tracker-step.completed .step-label { color: var(--accent); }
.tracker-step.active .step-label { color: var(--text); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(91,140,62,0.2); }
  50% { box-shadow: 0 0 0 8px rgba(91,140,62,0.1); }
}

.tracker-detail {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-8);
}

.back-to-menu-btn {
  border: 2px solid var(--text);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  height: 50px;
  padding: 0 32px;
  cursor: pointer;
}

/* === UTILITIES === */
.hidden { display: none !important; }

/* Desktop preview frame */
@media (min-width: 500px) {
  body {
    max-width: 420px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
    min-height: 100dvh;
  }
  .cart-footer, .cart-fab {
    max-width: 420px;
    left: 50%;
    transform: translateX(-50%);
  }
  .cart-fab:active { transform: translateX(-50%) scale(0.97); }
  .overlay, .bottom-sheet {
    max-width: 420px;
    left: 50%;
    transform: translateX(-50%);
  }
  .bottom-sheet.hidden { transform: translateX(-50%) translateY(100%); }
}
