/* ============================================================
   CART.CSS — Drawer & Checkout Modal Styles
   ============================================================ */

/* Overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
  z-index: 1000;
}

.drawer-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Aside Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  height: 100dvh;
  border-radius: 32px 0 0 32px;
  background: rgba(255, 255, 255, 0.98);
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: none;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease), visibility 0s 0.5s;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.drawer.is-active {
  transform: translateX(0);
  visibility: visible;
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.16);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

@media (max-width: 900px) {
  .drawer {
    border-radius: 0;
    width: 100vw;
  }
}

/* Close button */
.drawer__close-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
  flex-shrink: 0;
}

@media (hover: hover) {
  .drawer__close-btn:hover {
    background-color: var(--surface);
  }
}

/* Drawer Views Container */
.drawer-views-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.drawer-view {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  overflow: hidden;
}

.drawer-view.is-active {
  display: flex;
  opacity: 1;
  transform: translateX(0);
}

/* ---------------- CART VIEW ---------------- */
.drawer-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.drawer-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
  line-height: 1;
}

.drawer-count {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}

/* Cart list */
.cart-list {
  list-style: none;
  padding: 0 24px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.cart-item {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.cart-item__thumb {
  width: 72px;
  height: 92px;
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
  background-color: var(--surface);
}

.cart-item__details {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  gap: 4px;
}

.cart-item__top {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cart-item__name {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.cart-item__size {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--muted);
}

.cart-item__bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.cart-item__price {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-item__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* Qty stepper (40px) */
.cart-qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #FFFFFF;
  overflow: hidden;
}

.cart-qty__btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease);
}

@media (hover: hover) {
  .cart-qty__btn:hover {
    background-color: var(--surface);
  }
}

.cart-qty__val {
  width: 32px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.cart-item__remove {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  min-height: 48px;
  transition: color 0.2s var(--ease);
}

@media (hover: hover) {
  .cart-item__remove:hover {
    color: var(--accent);
  }
}

/* Empty cart state */
.cart-empty {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 20px;
}

.cart-empty__title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ink);
  margin: 0;
}

/* Cart Footer */
.cart-footer {
  padding: 20px 24px calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}

.cart-footer__total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.cart-footer__total-label {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.cart-footer__total-val {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}


/* ---------------- FORM VIEW ---------------- */
.form-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.form-back-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  min-height: 48px;
  transition: transform 0.2s var(--ease);
}

@media (hover: hover) {
  .form-back-btn:hover {
    transform: translateX(-3px);
  }
}

.form-title {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0;
  color: var(--ink);
}

.checkout-form {
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.form-input,
.form-textarea {
  min-height: 56px;
  padding: 0 18px;
  font-family: var(--font-ui);
  font-size: 17px;
  color: var(--ink);
  background-color: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  width: 100%;
}

.form-textarea {
  min-height: 84px;
  padding: 14px 18px;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
  border-color: #111111;
  box-shadow: 0 0 0 1px #111111;
}

.form-input.is-error,
.form-textarea.is-error {
  border-color: var(--accent);
}

.form-error-msg {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--accent);
  display: none;
}

.form-error-msg.is-visible {
  display: block;
}

/* Radio cards for delivery */
.delivery-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
  user-select: none;
}

.radio-card input[type="radio"] {
  accent-color: var(--ink);
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.radio-card__text {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.radio-card.is-selected {
  border-color: #111111;
  background-color: rgba(17, 17, 17, 0.03);
}

/* Delivery conditional fields */
.delivery-fields {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 8px;
}

.delivery-fields.is-visible {
  display: flex;
}

/* Order summary collapsed */
.order-summary-details {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  background: #FFFFFF;
}

.order-summary-details summary {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.order-summary-list {
  list-style: none;
  padding: 12px 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--muted);
}

.order-summary-item {
  display: flex;
  justify-content: space-between;
}

/* Form Submit Button & Spinner */
.form-submit-wrap {
  padding-top: 8px;
}

.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.form-banner-error {
  display: none;
  padding: 14px 16px;
  border-radius: 14px;
  background-color: rgba(140, 47, 57, 0.08);
  border: 1px solid rgba(140, 47, 57, 0.2);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 14px;
  gap: 10px;
  flex-direction: column;
}

.form-banner-error.is-visible {
  display: flex;
}

/* ---------------- SUCCESS VIEW ---------------- */
.success-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px calc(40px + env(safe-area-inset-bottom, 0px));
  gap: 20px;
}

.success-check-circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.success-svg {
  width: 48px;
  height: 48px;
}

.success-svg path {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: checkDraw 0.6s var(--ease) forwards 0.2s;
}

@keyframes checkDraw {
  to { stroke-dashoffset: 0; }
}

.success-title {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}

.success-desc {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 17px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 360px;
  margin: 0;
}

.success-mailto-note {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  padding: 12px 18px;
  border-radius: 14px;
  max-width: 360px;
  display: none;
}

.success-mailto-note.is-visible {
  display: block;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 12px;
}

/* Accessibility reduced motion */
@media (prefers-reduced-motion: reduce) {
  .drawer {
    transition: none !important;
  }
  .drawer-view {
    transition: none !important;
    transform: none !important;
  }
  .success-svg path {
    stroke-dashoffset: 0 !important;
    animation: none !important;
  }
  .btn-spinner {
    animation: none !important;
  }
}
