/* ==========================================================================
   Cart drawer, mobile sticky cart bar, mobile bottom navigation.
   ========================================================================== */

dialog.drawer {
  border: none;
  padding: 0;
  margin: 0 0 0 auto;
  width: min(100vw, 450px);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.1);
  color: var(--text);
}

dialog.drawer[open] {
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.25s ease;
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.cart-empty {
  text-align: center;
  color: #999;
  padding: 2rem 0;
}

.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.cart-line-name {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.cart-line-price {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.qty-control button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  font-weight: 700;
}

.qty-control button:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.cart-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--light);
}

.cart-note {
  font-size: 0.75rem;
  text-align: center;
  margin-top: 0.8rem;
  color: #999;
}

/* ── Mobile: sticky cart bar + bottom navigation ─────────────────────────── */

.sticky-cart-bar,
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 74px;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    justify-content: space-around;
    align-items: flex-end;
    background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 0 max(0.5rem, env(safe-area-inset-bottom));
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: none;
    border: none;
    color: #666;
    font-size: 0.62rem;
  }

  .bottom-nav-icon {
    font-size: 1.3rem;
  }

  .bottom-nav-cart {
    position: relative;
    width: 54px;
    height: 54px;
    margin-top: -22px;
    border: none;
    border-radius: 50%;
    background: var(--gradient);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    font-size: 1.4rem;
    flex-shrink: 0;
  }

  .bottom-nav-cart .cart-count {
    top: 2px;
    right: 0;
    background: var(--accent);
  }
}

@media (max-width: 640px) {
  .sticky-cart-bar {
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    bottom: calc(74px + max(0.6rem, env(safe-area-inset-bottom)));
    z-index: 940;
    align-items: center;
    gap: 0.6rem;
    border: none;
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
    background: var(--gradient);
    color: var(--white);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    text-align: left;
  }

  .sticky-cart-bar.is-visible {
    display: flex;
  }

  .sticky-cart-text {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 600;
  }

  .sticky-cart-total {
    font-weight: 800;
  }
}
