/**
 * ReachAbel – Cart Drawer Stylesheet
 * assets/css/cart-drawer.css
 *
 * Scoped to .ra-cart-drawer, .ra-cart-overlay, and .ra-cart-item.
 * Inherits design tokens from the existing ReachAbel token set.
 */

/* ============================================================
   Tokens
   ============================================================ */
:root {
  --ra-gold:          #C8A24A;
  --ra-gold-soft:     #D9B968;
  --ra-gold-dark:     #A07C2E;
  --ra-ink:           #1B1B1B;
  --ra-ink-soft:      #4A4A4A;
  --ra-ink-muted:     #6E6E6E;
  --ra-bg:            #FAF8F4;
  --ra-card:          #FFFFFF;
  --ra-border:        #E2DDD5;
  --ra-nearblack:     #111009;

  --ra-shadow-gold:   0 12px 30px -12px rgba(200,162,74,.5);
  --ra-font-display:  'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --ra-font-sans:     'Jost', ui-sans-serif, system-ui, sans-serif;
  --ra-radius:        0.3rem;
  --ra-ease:          cubic-bezier(0.16, 1, 0.3, 1);

  --ra-drawer-width:  460px;
  --ra-drawer-z: 100001;
--ra-overlay-z: 100000;
}

/* ============================================================
   Overlay
   ============================================================ */
.ra-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 6, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--ra-overlay-z);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms var(--ra-ease);
}
.ra-cart-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   Drawer Shell
   ============================================================ */
.ra-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--ra-drawer-width);
  max-width: 100vw;
  background: var(--ra-card);
  z-index: var(--ra-drawer-z);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 500ms var(--ra-ease);
  will-change: transform;
  overflow: hidden;
  box-shadow: -8px 0 40px rgba(14,11,6,.18);
}
.ra-cart-drawer.is-open {
  transform: translateX(0);
}

/* Body scroll lock */
body.ra-drawer-open {
  overflow: hidden;
}

/* Tablet */
@media (max-width: 768px) {
  .ra-cart-drawer { --ra-drawer-width: 380px; }
}

/* Mobile */
@media (max-width: 540px) {
  .ra-cart-drawer { --ra-drawer-width: 100vw; }
}

/* ============================================================
   Header
   ============================================================ */
.ra-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.375rem 1.5rem;
  border-bottom: 1px solid var(--ra-border);
  flex-shrink: 0;
  background: var(--ra-card);
}
.ra-cart-drawer__header-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.ra-cart-drawer__bag-icon { color: var(--ra-gold-dark); }
.ra-cart-drawer__title {
  font-family: var(--ra-font-display);
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--ra-ink);
  margin: 0;
  letter-spacing: -0.01em;
}
.ra-cart-drawer__close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--ra-border);
  cursor: pointer;
  color: var(--ra-ink-muted);
  transition: background-color 250ms, color 250ms, border-color 250ms;
  flex-shrink: 0;
}
.ra-cart-drawer__close:hover {
  background: var(--ra-bg);
  color: var(--ra-ink);
  border-color: var(--ra-ink);
}
.ra-cart-drawer__close:focus-visible {
  outline: 2px solid var(--ra-gold);
  outline-offset: 2px;
}

/* ============================================================
   Loading State
   ============================================================ */
.ra-cart-drawer__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.8);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}
.ra-cart-drawer__loading.is-loading {
  opacity: 1;
  pointer-events: auto;
}
.ra-cart-drawer__spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--ra-border);
  border-top-color: var(--ra-gold);
  border-radius: 50%;
  animation: ra-spin 700ms linear infinite;
}
@keyframes ra-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ra-cart-drawer__spinner { animation-duration: 1800ms; }
}

/* ============================================================
   Body (items area)
   ============================================================ */
.ra-cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Empty state */
.ra-cart-drawer__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 2rem;
  gap: 0.75rem;
  height: 100%;
  min-height: 300px;
}
.ra-cart-drawer__empty-icon {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--ra-bg);
  color: var(--ra-gold-dark);
  margin-bottom: 0.5rem;
}
.ra-cart-drawer__empty-title {
  font-family: var(--ra-font-display);
  font-size: 1.375rem;
  font-weight: 300;
  color: var(--ra-ink);
  margin: 0;
}
.ra-cart-drawer__empty-desc {
  font-size: 0.875rem;
  color: var(--ra-ink-muted);
  margin: 0;
  line-height: 1.65;
}
.ra-cart-drawer__browse-btn { margin-top: 0.5rem; }

/* Items list */
.ra-cart-drawer__items {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ============================================================
   Cart Item
   ============================================================ */
.ra-cart-item {
  display: grid;
  grid-template-columns: 5rem 1fr 2rem;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ra-border);
  transition: background-color 250ms;
  position: relative;
}
.ra-cart-item:last-child { border-bottom: none; }
.ra-cart-item.is-removing { opacity: 0.4; pointer-events: none; }
.ra-cart-item.is-updating { opacity: 0.6; }

/* Thumbnail */
.ra-cart-item__image-link {
  display: block;
  border-radius: var(--ra-radius);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--ra-bg);
  flex-shrink: 0;
}
.ra-cart-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Details */
.ra-cart-item__details {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}
.ra-cart-item__title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ra-ink);
  text-decoration: none;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ra-cart-item__title:hover { color: var(--ra-gold-dark); }

/* Meta */
.ra-cart-item__meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.ra-cart-item__meta li {
  font-size: 0.75rem;
  color: var(--ra-ink-muted);
  line-height: 1.4;
}
.ra-cart-item__meta--event li { color: var(--ra-gold-dark); }
.ra-cart-item__meta--event li:first-child { font-weight: 500; color: var(--ra-ink-soft); }

/* Bottom row: price + qty */
.ra-cart-item__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}
.ra-cart-item__price {
  font-family: var(--ra-font-display);
  font-size: 1.125rem;
  font-weight: 300;
  color: var(--ra-ink);
}
.ra-cart-item__price .woocommerce-Price-amount { font-size: inherit; }

/* Quantity controls */
.ra-cart-item__qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--ra-border);
  border-radius: var(--ra-radius);
  overflow: hidden;
}
.ra-cart-item__qty-btn {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ra-ink-soft);
  transition: background-color 200ms, color 200ms;
  line-height: 1;
}
.ra-cart-item__qty-btn:hover:not(:disabled) {
  background: var(--ra-bg);
  color: var(--ra-ink);
}
.ra-cart-item__qty-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.ra-cart-item__qty-btn:focus-visible {
  outline: 2px solid var(--ra-gold);
  outline-offset: -2px;
}
.ra-cart-item__qty-num {
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 1.875rem;
  text-align: center;
  color: var(--ra-ink);
  border-left: 1px solid var(--ra-border);
  border-right: 1px solid var(--ra-border);
  line-height: 1.875rem;
}
.ra-cart-item__qty-fixed {
  font-size: 0.75rem;
  color: var(--ra-ink-muted);
}

/* Remove button */
.ra-cart-item__remove {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ra-ink-muted);
  border-radius: 50%;
  align-self: start;
  transition: color 250ms, background-color 250ms;
  flex-shrink: 0;
}
.ra-cart-item__remove:hover {
  color: #B91C1C;
  background: #FEF2F2;
}
.ra-cart-item__remove:focus-visible {
  outline: 2px solid var(--ra-gold);
  outline-offset: 2px;
}

/* ============================================================
   Footer
   ============================================================ */
.ra-cart-drawer__footer {
  flex-shrink: 0;
  padding: 1.375rem 1.5rem 1.75rem;
  border-top: 1px solid var(--ra-border);
  background: var(--ra-card);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.ra-cart-drawer__subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ra-cart-drawer__subtotal-label {
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ra-ink-muted);
  font-family: var(--ra-font-sans);
}
.ra-cart-drawer__subtotal-value {
  font-family: var(--ra-font-display);
  font-size: 1.75rem;
  font-weight: 300;
  color: var(--ra-ink);
  line-height: 1;
}
.ra-cart-drawer__subtotal-value .woocommerce-Price-amount { font-size: inherit; }

.ra-cart-drawer__tax-note {
  font-size: 0.75rem;
  color: var(--ra-ink-muted);
  margin: 0;
  line-height: 1.5;
}

.ra-cart-drawer__checkout-btn {
  width: 100%;
  justify-content: center;
}
.ra-cart-drawer__checkout-btn:hover,
.ra-cart-drawer__checkout-btn:focus-visible {
  background: var(--ra-gold-dark);
  color: #111;
  transform: translateY(-1px);
}

.ra-cart-drawer__continue-btn {
  width: 100%;
  justify-content: center;
  background: transparent;
  border: 1.5px solid var(--ra-border);
  color: var(--ra-ink-soft);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 500;
}
.ra-cart-drawer__continue-btn:hover {
  border-color: var(--ra-ink);
  color: var(--ra-ink);
}

/* ============================================================
   Shared button token re-declarations (standalone safety)
   ============================================================ */
.ra-cart-drawer .ra-btn,
.ra-cart-drawer__footer .ra-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--ra-radius);
  font-family: var(--ra-font-sans);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 500ms var(--ra-ease),
              box-shadow 500ms var(--ra-ease),
              transform 500ms var(--ra-ease),
              color 300ms,
              border-color 300ms;
}
.ra-cart-drawer .ra-btn--gold,
.ra-cart-drawer__footer .ra-btn--gold {
  background: var(--ra-gold);
  color: #111;
  box-shadow: var(--ra-shadow-gold);
  padding: 1rem 2rem;
}
.ra-cart-drawer .ra-btn--outline,
.ra-cart-drawer__footer .ra-btn--outline {
  background: transparent;
  color: var(--ra-ink);
  border: 1.5px solid var(--ra-border);
  padding: 0.75rem 1.5rem;
}
.ra-cart-drawer .ra-btn:focus-visible,
.ra-cart-drawer__footer .ra-btn:focus-visible {
  outline: 2px solid var(--ra-gold);
  outline-offset: 3px;
}

/* ============================================================
   Screen-reader utility
   ============================================================ */
.ra-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Cart count badge (header icon)
   ============================================================ */
.ra-cart-count {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--ra-gold);
  color: #111;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: var(--ra-font-sans);
  line-height: 1.25rem;
  text-align: center;
}
.ra-cart-count--active { display: block; }

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .ra-cart-drawer,
  .ra-cart-overlay { transition-duration: 100ms; }
  .ra-cart-drawer__spinner { animation: none; border-color: var(--ra-gold); }
}
