/* ============================================================
   ME COFFEE — styles.css
   Palette (strict): green, brown, white, black only.
   Mobile-first: base styles target phones; @media widens up.
   ============================================================ */

:root {
  /* Brand tokens */
  --green:        #04593F;   /* deep espresso-bar green (primary)      */
  --green-dark:   #033D2C;   /* pressed / hover state                  */
  --green-tint:   #E8F1ED;   /* green mixed with white (surfaces)      */
  --brown:        #5C3A21;   /* roasted coffee brown (secondary)       */
  --brown-tint:   #F3EEE9;   /* brown mixed with white (surfaces)      */
  --black:        #141414;   /* body text                              */
  --white:        #FFFFFF;

  --radius: 14px;
  --shadow: 0 4px 18px rgba(20, 20, 20, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
          "Helvetica Neue", Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px; /* room for the floating cart bar on mobile */
}

button { font-family: inherit; cursor: pointer; }

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

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--green);
  color: var(--white);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
}

.brand-mark {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--white);
  object-fit: contain;
  padding: 3px;
}

.brand-text strong {
  display: block;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
}

.brand-text small {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  opacity: 0.85;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.hours {
  text-align: right;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  line-height: 1.5;
  opacity: 0.95;
}
.hours strong { font-size: 0.72rem; }

.map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--white);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 3px 9px;
  transition: background 0.15s;
}
.map-link:hover { background: rgba(255, 255, 255, 0.15); }
.map-link svg { width: 11px; height: 11px; }

/* Search (topmost row of the sticky header) */

.search-wrap { background: var(--green-dark); }

.search-bar {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
}

.search-icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--brown);
  opacity: 0.65;
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 10px 42px 10px 42px;
  font-family: inherit;
  font-size: 1rem; /* keep ≥16px or iOS Safari zooms in on focus */
  color: var(--black);
  background: var(--white);
}
.search-bar input::placeholder { color: rgba(20, 20, 20, 0.45); }
/* our own clear button replaces the native webkit one */
.search-bar input::-webkit-search-cancel-button,
.search-bar input::-webkit-search-decoration { -webkit-appearance: none; }

.search-clear {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--brown-tint);
  color: var(--brown);
  font-size: 1rem;
  line-height: 1;
}
.search-clear:hover { background: var(--brown); color: var(--white); }

.search-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--brown);
}
.search-empty p { font-size: 0.95rem; margin-bottom: 14px; }
.search-empty strong { color: var(--green); }
.search-empty .btn { width: auto; margin: 0 auto; padding: 10px 22px; }

/* Visually hidden, still read by screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Category chips */

.cat-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px 12px;
  max-width: 1100px;
  margin: 0 auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-nav::-webkit-scrollbar { display: none; }

.cat-chip {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: var(--white);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.cat-chip:hover { background: rgba(255, 255, 255, 0.15); }
.cat-chip.active { background: var(--white); color: var(--green); border-color: var(--white); }

/* ---------- Layout ---------- */

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Menu ---------- */

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 48px 0;
  justify-content: center;
  color: var(--brown);
  font-weight: 600;
}

.loading-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.6); opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  .loading-dot { animation: none; }
  html { scroll-behavior: auto; }
}

.menu-section { margin-bottom: 34px; scroll-margin-top: 180px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.section-head h2 {
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  color: var(--green);
  text-transform: uppercase;
}

.section-head .count {
  font-size: 0.72rem;
  color: var(--brown);
  font-weight: 700;
}

.section-note {
  font-size: 0.8rem;
  color: var(--brown);
  margin-bottom: 10px;
}

.item-card {
  background: var(--white);
  border: 1px solid var(--green-tint);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item-card.in-cart {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}

.item-name { font-size: 0.98rem; font-weight: 700; }

.item-desc {
  font-size: 0.8rem;
  color: var(--brown);
  margin-top: 2px;
}

.variant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0 0;
  margin-top: 8px;
  border-top: 1px dashed var(--brown-tint);
}
.variant-row:first-of-type { margin-top: 10px; }

.variant-label { font-size: 0.85rem; }
.variant-label .vname { color: var(--black); }
.variant-label .vprice { color: var(--green); font-weight: 700; margin-left: 8px; }

/* Quantity stepper */

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--green-tint);
  border-radius: 999px;
  padding: 2px;
}

.stepper button {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--green);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}
.stepper button:hover { background: var(--green); color: var(--white); }
.stepper button:disabled { opacity: 0.35; pointer-events: none; }

.stepper .qty {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.stepper .qty.zero { color: rgba(20, 20, 20, 0.35); }

/* ---------- Order summary (the "receipt ticket") ---------- */

.summary {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  transform: translateY(105%);
  transition: transform 0.28s ease;
  max-height: 86vh;
  display: flex;
}
.summary.open { transform: translateY(0); }

.ticket {
  background: var(--white);
  width: 100%;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(20, 20, 20, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* perforated receipt edge */
  border-top: 6px solid var(--green);
}

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
}
.ticket-head h2 {
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  color: var(--brown);
}
.ticket-close {
  border: none;
  background: var(--brown-tint);
  color: var(--brown);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}

/* Pickup / Delivery toggle */

.fulfillment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px 10px;
}

.fulfill-btn {
  flex: 1;
  border: 1.5px solid var(--green);
  background: var(--white);
  color: var(--green);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.fulfill-btn:hover { background: var(--green-tint); }
.fulfill-btn.active { background: var(--green); color: var(--white); }

.fulfill-info {
  flex: none;
  width: 30px; height: 30px;
  border: 1.5px solid var(--brown);
  background: var(--white);
  color: var(--brown);
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  transition: background 0.15s;
}
.fulfill-info:hover { background: var(--brown-tint); }

.fulfill-note {
  padding: 0 18px 10px;
  font-size: 0.72rem;
  color: var(--brown);
  line-height: 1.5;
}

.ticket-lines {
  list-style: none;
  overflow-y: auto;
  padding: 0 18px;
  flex: 1;
}

.ticket-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--brown-tint);
  font-size: 0.88rem;
}

.ticket-line .line-qty {
  flex: none;
  font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.ticket-line .line-name { flex: 1; }
.ticket-line .line-name small { display: block; color: var(--brown); font-size: 0.74rem; }

.ticket-line .line-amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.line-remove {
  border: none;
  background: none;
  color: var(--brown);
  font-size: 1rem;
  padding: 4px;
  line-height: 1;
}
.line-remove:hover { color: var(--black); }

.ticket-empty {
  padding: 26px 0;
  text-align: center;
  color: var(--brown);
  font-size: 0.88rem;
}

.ticket-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 18px;
  font-weight: 800;
  letter-spacing: 0.1em;
  border-top: 2px solid var(--black);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.ticket-total span:last-child { color: var(--green); font-size: 1.05rem; }
/* display:flex above would defeat the hidden attribute — same fix as .modal-backdrop */
.ticket-total[hidden] { display: none; }

.ticket-actions { padding: 0 18px calc(16px + env(safe-area-inset-bottom)); }

.btn {
  width: 100%;
  border-radius: 12px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn svg { width: 20px; height: 20px; }

.btn-fb { background: var(--green); color: var(--white); }
.btn-fb:hover { background: var(--green-dark); }

.btn-ghost {
  background: var(--white);
  color: var(--green);
  border: 1.5px solid var(--green);
  padding: 10px;
  font-size: 0.85rem;
}
.btn-ghost:hover { background: var(--green-tint); }

.btn-danger { color: var(--brown); border-color: var(--brown); }
.btn-danger:hover { background: var(--brown-tint); }

.ticket-note {
  font-size: 0.72rem;
  color: var(--brown);
  margin-top: 10px;
  text-align: center;
  line-height: 1.5;
}

/* ---------- Floating cart bar (mobile) ---------- */

.cart-bar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--brown);
  color: var(--white);
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.cart-bar[hidden] { display: none; }
.cart-bar .cart-view { letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.8rem; }
.cart-bar .cart-total { font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--black);
  color: var(--white);
  text-align: center;
  padding: 28px 16px 40px;
  font-size: 0.85rem;
  line-height: 1.9;
}
.site-footer a { color: var(--white); }
.site-footer .fineprint { font-size: 0.7rem; opacity: 0.6; margin-top: 8px; }

/* ---------- Delivery info modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 20, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  border-top: 6px solid var(--green);
  box-shadow: 0 12px 40px rgba(20, 20, 20, 0.35);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h2 {
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  color: var(--green);
  text-transform: uppercase;
}
.modal-close {
  border: none;
  background: var(--brown-tint);
  color: var(--brown);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}

.modal-body p {
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 10px;
}
.modal-body strong { color: var(--green); }

.modal-ok { margin-top: 4px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: var(--black);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

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

/* ============================================================
   Tablet & desktop
   ============================================================ */

@media (min-width: 900px) {
  body { padding-bottom: 0; }

  .brand-text strong { font-size: 1.35rem; }
  .hours { font-size: 0.7rem; }
  .hours strong { font-size: 0.82rem; }

  .layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    align-items: start;
    padding: 24px 16px 60px;
  }

  /* Item cards in a 2-col grid inside each section */
  .section-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .item-card { margin-top: 0; }
  .menu-section .section-note { margin-bottom: 2px; }
  .section-head { margin-bottom: 10px; }

  /* Summary becomes a sticky sidebar.
     NOTE: inset (shorthand for top/right/bottom/left) must be reset
     BEFORE top — the other way around it overrides top with auto,
     and a sticky element with no top offset never sticks. */
  .summary {
    position: sticky;
    inset: auto;
    top: 188px;
    transform: none;
    transition: none;
    max-height: calc(100vh - 206px);
  }
  .ticket {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--green-tint);
    border-top: 6px solid var(--green);
  }
  .ticket-close, .cart-bar { display: none; }
}

@media (min-width: 1100px) {
  .section-items { grid-template-columns: 1fr 1fr 1fr; }
}
