/* ============================================================
   The Hearth Roastery — Global Styles
   Shared by: home.html, menu.html, detail.html, contact.html
   Loaded after Tailwind CDN so utilities keep precedence.
   ============================================================ */

/* ---------- Base ---------- */
body {
  background-color: #fef9f1; /* token: surface */
  color: #1d1c17;            /* token: on-surface */
}

.dark body {
  background-color: #32302b; /* token: inverse-surface */
  color: #f5f0e8;            /* token: inverse-on-surface */
}

/* ---------- Navigation ---------- */
.nav-link {
  transition: color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
}

.nav-link:hover {
  color: #fbb981; /* token: tertiary-fixed-dim */
  opacity: 1;
}

.nav-link:active {
  transform: scale(0.95);
}

.nav-link.nav-active {
  color: #fbb981;
  border-bottom: 2px solid #fbb981;
  padding-bottom: 4px; /* spacing: xs */
}

/* ---------- Shadows & Hover Lift ---------- */
.soft-shadow {
  box-shadow: 0 4px 12px rgba(62, 39, 35, 0.08);
}

.soft-shadow:hover {
  box-shadow: 0 8px 24px rgba(62, 39, 35, 0.12);
  transform: translateY(-2px);
  transition: all 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(62, 39, 35, 0.12);
}

/* ---------- Keyframes ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Scroll reveal (home) ---------- */
.animate-on-scroll {
  opacity: 0;
}

.animate-on-scroll.is-visible {
  animation: fadeInUp 0.8s ease-out forwards;
}

/* ---------- Menu page ---------- */
.menu-card {
  transition: all 0.3s ease;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(62, 39, 35, 0.12);
}

.filter-btn {
  transition: all 0.2s ease;
}

.filter-btn.active {
  background-color: #3e2723; /* token: primary-container */
  color: #ffffff;            /* token: on-primary */
  border-color: #3e2723;
}

.invisible-initial {
  opacity: 0;
}

.animate-fade-in {
  animation: fadeIn 0.8s ease-out forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out forwards;
}

/* ---------- Detail page ---------- */
.scroll-reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

.scroll-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Contact page ---------- */
.input-focus-ring:focus {
  border-color: #c08552; /* Toasted Accent */
  outline: none;
  box-shadow: none;
}

.reveal-fade {
  opacity: 0;
  transition: opacity 1s ease-out;
}

.reveal-slide-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal-slide-right {
  opacity: 0;
  transform: translateX(40px);
  transition: all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.is-revealed {
  opacity: 1 !important;
  transform: translateX(0) !important;
}

.btn-loading-transition {
  position: relative;
  overflow: hidden;
}

.btn-loading-transition::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: transform 0.5s ease-in-out;
  opacity: 0;
}

.btn-loading-transition:hover::after {
  opacity: 1;
  transform: translateX(50%);
}

/* ============================================================
   Cart experience (drawer, toast, steppers, fly-to-cart)
   ============================================================ */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);   /* soft deceleration */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* slight overshoot */
}

body.cart-locked { overflow: hidden; }

/* ---------- Drawer ---------- */
.cart-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(39, 19, 16, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s var(--ease-out), visibility 0s linear 0.4s;
}
.cart-overlay.is-open {
  opacity: 1; visibility: visible;
  transition: opacity 0.4s var(--ease-out), visibility 0s;
}

.cart-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(100%, 26rem);
  display: flex; flex-direction: column;
  background: #fef9f1;
  box-shadow: -12px 0 40px rgba(62, 39, 35, 0.18);
  border-radius: 1rem 0 0 1rem;
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.5s var(--ease-out), visibility 0s linear 0.5s;
}
.cart-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.5s var(--ease-out), visibility 0s;
}

/* items enter with a light stagger each time the drawer opens */
.cart-drawer.is-open .drawer-item {
  animation: drawerItemIn 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}
@keyframes drawerItemIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- Row collapse (remove) ---------- */
.collapse-row {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows 0.4s var(--ease-out), opacity 0.3s ease;
}
.collapse-row > .collapse-inner { min-height: 0; overflow: hidden; }
.collapse-row.is-removing { grid-template-rows: 0fr; opacity: 0; }

/* ---------- Quantity stepper ---------- */
.stepper {
  display: inline-flex; align-items: center;
  border: 1px solid #d3c3c0; border-radius: 9999px; background: #fff;
}
.stepper button {
  width: 2rem; height: 2rem; border-radius: 9999px;
  display: grid; place-items: center; color: #3e2723;
  transition: background-color 0.2s ease, transform 0.15s var(--ease-spring);
}
.stepper button:hover { background: #f2ede5; }
.stepper button:active { transform: scale(0.85); }
.stepper .qty { min-width: 1.75rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Number / badge feedback ---------- */
.num-flash { animation: numFlash 0.6s var(--ease-out); }
@keyframes numFlash {
  0%   { color: #c08552; transform: scale(1.12); }
  100% { transform: scale(1); }
}

.cart-badge {
  transform: scale(0); opacity: 0;
  transition: transform 0.35s var(--ease-spring), opacity 0.2s ease;
}
.cart-badge.has-items { transform: scale(1); opacity: 1; }
.cart-badge.bump { animation: badgeBump 0.5s var(--ease-spring); }
@keyframes badgeBump {
  0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); }
}
.cart-shake { animation: cartShake 0.5s ease; }
@keyframes cartShake {
  0%,100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 60% { transform: rotate(10deg); }
}

/* ---------- Quick-add button on cards ---------- */
.quick-add {
  position: absolute; right: 0.75rem; bottom: 0.75rem; z-index: 10;
  width: 2.75rem; height: 2.75rem; border-radius: 9999px;
  display: grid; place-items: center;
  background: #3e2723; color: #fff;
  box-shadow: 0 6px 16px rgba(62, 39, 35, 0.3);
  transition: transform 0.3s var(--ease-spring), background-color 0.3s ease;
}
.quick-add:hover { transform: scale(1.1); background: #c08552; }
.quick-add:active { transform: scale(0.9); }
.quick-add.is-done { background: #4c7a4f; transform: scale(1.15) rotate(360deg); transition-duration: 0.5s; }
@media (hover: hover) {
  .menu-card .quick-add { opacity: 0; transform: translateY(8px) scale(0.9); }
  .menu-card:hover .quick-add, .menu-card:focus-within .quick-add { opacity: 1; transform: none; }
  .menu-card:hover .quick-add:hover { transform: scale(1.1); }
}

/* ---------- Fly dot ---------- */
.fly-dot {
  position: fixed; z-index: 90; pointer-events: none;
  left: 0; top: 0; opacity: 0; border-radius: 9999px; will-change: transform, opacity;
  background: #c08552; box-shadow: 0 0 0 4px rgba(192, 133, 82, 0.25);
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; z-index: 100; left: 50%; bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  width: min(92vw, 24rem); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border-radius: 0.75rem;
  background: #32302b; color: #f5f0e8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.5s var(--ease-spring) both;
}
.toast.is-leaving { animation: toastOut 0.3s ease forwards; }
.toast button { color: #fbb981; font-weight: 600; margin-left: auto; white-space: nowrap; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------- Cart page entrance ---------- */
.cart-row-in { animation: drawerItemIn 0.55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .cart-drawer, .cart-overlay, .collapse-row, .toast, .quick-add, .cart-badge { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .drawer-item, .cart-row-in, .num-flash, .bump, .cart-shake { animation: none !important; }
}

/* success state must win over the hover-reveal rules above */
.quick-add.is-done,
.menu-card:hover .quick-add.is-done {
  opacity: 1;
  background: #4c7a4f;
  transform: scale(1.15) rotate(360deg);
  transition-duration: 0.5s;
}

/* ============================================================
   Store closed bar, order tracker, owner dashboard
   ============================================================ */
.store-closed-bar {
  position: fixed; top: 4rem; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.35rem 1rem; font-size: 0.85rem;
  background: #f4d9c6; color: #5c2f12; border-bottom: 1px solid rgba(92, 47, 18, 0.15);
}

.tracker { display: flex; justify-content: space-between; position: relative; list-style: none; padding: 0; }
.tracker::before {
  content: ''; position: absolute; top: 1.6rem; left: 12.5%; right: 12.5%; height: 4px;
  background: rgba(62, 39, 35, 0.12); border-radius: 4px;
}
.tracker-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; position: relative; z-index: 1; text-align: center; }
.tracker-dot {
  width: 3.2rem; height: 3.2rem; border-radius: 9999px; display: grid; place-items: center;
  background: #f1e9e4; color: rgba(62, 39, 35, 0.4);
  transition: background 0.4s var(--ease-out), color 0.4s var(--ease-out), transform 0.4s var(--ease-spring);
}
.tracker-label { font-size: 0.85rem; color: rgba(62, 39, 35, 0.55); transition: color 0.3s; }
.tracker-step.is-done .tracker-dot { background: #c08552; color: #fff; }
.tracker-step.is-done .tracker-label { color: #3e2723; }
.tracker-step.is-current .tracker-dot { background: #3e2723; color: #fff; transform: scale(1.12); animation: trackerPulse 1.8s ease-out infinite; }
.tracker-step.is-current .tracker-label { color: #3e2723; font-weight: 700; }
@keyframes trackerPulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 133, 82, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(192, 133, 82, 0); }
}
@media (max-width: 480px) { .tracker-dot { width: 2.6rem; height: 2.6rem; } .tracker::before { top: 1.3rem; } .tracker-label { font-size: 0.72rem; } }

.dash-board { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); align-items: start; }
.dash-col { background: rgba(62, 39, 35, 0.04); border-radius: 0.9rem; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.6rem; min-height: 8rem; }
.dash-col-title { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #3e2723; padding: 0.15rem 0.25rem; }
.dash-col-title b { background: #3e2723; color: #fff; border-radius: 9999px; font-size: 0.75rem; padding: 0.05rem 0.55rem; }
.dash-col[data-col="pending"] .dash-col-title b { background: #c08552; }
.dash-card { background: #fff; border-radius: 0.7rem; padding: 0.8rem; box-shadow: 0 2px 8px rgba(62, 39, 35, 0.08); animation: fadeInUp 0.35s var(--ease-out) both; }
.dash-note { font-style: italic; font-size: 0.85rem; color: rgba(62, 39, 35, 0.75); background: #faf3ee; border-radius: 0.4rem; padding: 0.3rem 0.5rem; }
.dash-empty { text-align: center; font-size: 0.85rem; color: rgba(62, 39, 35, 0.4); padding: 0.75rem 0; }
.dash-btn { background: #3e2723; color: #fff; border-radius: 0.5rem; padding: 0.4rem 0.8rem; font-size: 0.85rem; font-weight: 700; transition: transform 0.15s; }
.dash-btn:active { transform: scale(0.95); }
.dash-btn-ghost { background: transparent; color: #3e2723; border: 1px solid rgba(62, 39, 35, 0.25); }
.dash-live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: rgba(62, 39, 35, 0.6); }
.dash-live i { width: 0.55rem; height: 0.55rem; border-radius: 9999px; background: #4caf50; animation: trackerPulse 1.8s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .tracker-step.is-current .tracker-dot, .dash-live i, .dash-card { animation: none !important; }
}
