/**
 * Treat Matcher Styles
 * Tinder-style swipe interface for treats
 * Mobile-first, full-screen card experience
 */

/* ========== RESET & BASE ========== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  background: linear-gradient(135deg, #faf7f2 0%, #f5ede0 100%);
  min-height: 100vh;
  overflow: hidden;
}

/* ========== CONTAINER ========== */
.matcher-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ========== HEADER ========== */
.matcher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid #e8e0d5;
  z-index: 100;
  flex-shrink: 0;
  position: relative;
}

.matcher-header h1 {
  font-family: var(--font-display, "Pacifico", cursive);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--charcoal, #2c2c2c);
  margin: 0;
}

.back-btn,
.cart-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--warm-brown, #8b6f47);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}

.back-btn:hover,
.cart-btn:hover {
  background: rgba(139, 111, 71, 0.1);
}

.cart-btn span {
  background: var(--wheat, #e8c547);
  color: var(--charcoal, #2c2c2c);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.8rem;
}

/* ========== INSTRUCTIONS ========== */
.instructions {
  text-align: center;
  padding: 12px 16px;
  background: rgba(232, 197, 71, 0.15);
  border-bottom: 1px solid #e8e0d5;
  flex-shrink: 0;
}

.instructions p {
  margin: 4px 0;
  font-size: 0.9rem;
  color: var(--charcoal, #2c2c2c);
}

.instructions.hidden {
  display: none;
}

/* ========== CARD STACK ========== */
.card-stack {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

/* ========== TREAT CARD ========== */
.treat-card {
  position: absolute;
  width: calc(100% - 32px);
  max-width: 400px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow 0.2s;
}

.treat-card:active {
  cursor: grabbing;
}

.treat-card.swiping {
  transition: none;
}

.treat-card.swipe-right {
  animation: swipeRight 0.4s ease-out forwards;
}

.treat-card.swipe-left {
  animation: swipeLeft 0.4s ease-out forwards;
}

@keyframes swipeRight {
  to {
    transform: translateX(150%) rotate(20deg);
    opacity: 0;
  }
}

@keyframes swipeLeft {
  to {
    transform: translateX(-150%) rotate(-20deg);
    opacity: 0;
  }
}

/* Card stacking effect - cards behind are slightly scaled/offset */
.treat-card:nth-child(2) {
  transform: scale(0.95) translateY(10px);
  z-index: -1;
}

.treat-card:nth-child(3) {
  transform: scale(0.9) translateY(20px);
  z-index: -2;
}

.treat-card:nth-child(n + 4) {
  display: none;
}

/* ========== CARD IMAGE ========== */
.card-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #f5f5f5;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Swipe indicators on image */
.swipe-indicator {
  position: absolute;
  top: 20px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.swipe-indicator.like {
  right: 20px;
  background: rgba(56, 142, 60, 0.95);
  color: white;
  border: 3px solid #388e3c;
}

.swipe-indicator.pass {
  left: 20px;
  background: rgba(211, 47, 47, 0.95);
  color: white;
  border: 3px solid #d32f2f;
}

.treat-card.tilting-right .swipe-indicator.like,
.treat-card.tilting-left .swipe-indicator.pass {
  opacity: 1;
}

/* ========== CARD INFO ========== */
.card-info {
  padding: 16px 20px 20px;
}

.card-name {
  font-family: var(--font-display, "Pacifico", cursive);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--charcoal, #2c2c2c);
  margin: 0 0 8px 0;
}

.card-category {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(232, 197, 71, 0.2);
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--warm-brown, #8b6f47);
  margin-bottom: 12px;
}

.card-description {
  font-size: 0.9rem;
  color: #666;
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.card-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal, #2c2c2c);
}

.card-price .from {
  font-size: 0.8rem;
  font-weight: 400;
  color: #888;
}

/* Dietary badges */
.card-badges {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.gf {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge.sf {
  background: #e3f2fd;
  color: #1565c0;
}

.badge.ship {
  background: #fff3e0;
  color: #bf360c;
}

/* ========== ACTION BUTTONS ========== */
.action-buttons {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 16px;
  flex-shrink: 0;
}

.action-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
  transform: scale(0.9);
}

.pass-btn {
  background: white;
  color: #c62828;
  border: 3px solid #c62828;
}

.pass-btn:hover {
  background: #ffebee;
}

.like-btn {
  background: white;
  color: #2e7d32;
  border: 3px solid #2e7d32;
}

.like-btn:hover {
  background: #e8f5e9;
}

/* ========== FOOTER ========== */
.matcher-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e8e0d5;
  flex-shrink: 0;
}

.cart-total {
  display: flex;
  flex-direction: column;
}

.cart-total span:first-child {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
}

.total-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal, #2c2c2c);
}

.done-btn {
  padding: 12px 24px;
  background: var(--wheat, #e8c547);
  color: var(--charcoal, #2c2c2c);
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.done-btn:hover {
  background: #d4b43f;
  transform: translateY(-2px);
}

/* ========== ADDED OVERLAY ========== */
.added-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(76, 175, 80, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeInOut 0.8s ease-out forwards;
}

.added-overlay.hidden {
  display: none;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

.added-content {
  text-align: center;
  color: white;
}

.added-icon {
  display: block;
  font-size: 4rem;
  margin-bottom: 16px;
}

.added-text {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ========== END SCREEN ========== */
.end-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #faf7f2 0%, #f5ede0 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  z-index: 200;
}

.end-screen.hidden {
  display: none;
}

.end-screen h2 {
  font-family: var(--font-display, "Pacifico", cursive);
  font-size: 2rem;
  color: var(--charcoal, #2c2c2c);
  margin: 0 0 16px 0;
}

.end-screen p {
  font-size: 1.1rem;
  color: #666;
  margin: 0 0 32px 0;
}

.checkout-btn {
  padding: 16px 48px;
  background: var(--wheat, #e8c547);
  color: var(--charcoal, #2c2c2c);
  border: none;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.checkout-btn:hover {
  background: #d4b43f;
  transform: translateY(-2px);
}

.restart-btn {
  padding: 12px 32px;
  background: transparent;
  color: var(--warm-brown, #8b6f47);
  border: 2px solid var(--warm-brown, #8b6f47);
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.restart-btn:hover {
  background: rgba(139, 111, 71, 0.1);
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #888;
}

.empty-state p {
  font-size: 1.1rem;
  margin-bottom: 24px;
}

/* ========== LOADING ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid #e8e0d5;
  border-top-color: var(--wheat, #e8c547);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== SIZE PICKER MODAL ========== */
.size-picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.size-picker-modal.hidden {
  display: none;
}

.size-picker-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.size-picker-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: white;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 32px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.size-picker-content h3 {
  font-family: var(--font-display, "Pacifico", cursive);
  font-size: 1.5rem;
  font-weight: 400;
  text-align: center;
  margin: 0 0 20px 0;
  color: var(--charcoal, #2c2c2c);
}

.size-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.size-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f9f7f4;
  border: 2px solid #e8e0d5;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 56px;
}

.size-option:hover {
  border-color: var(--wheat, #e8c547);
  background: rgba(232, 197, 71, 0.1);
}

.size-option:active {
  transform: scale(0.98);
  background: var(--wheat, #e8c547);
}

.size-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--charcoal, #2c2c2c);
}

.size-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--warm-brown, #8b6f47);
}

.size-picker-note {
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  margin: 16px 0 0 0;
}

/* ========== PROGRESS INDICATOR ========== */
.progress-indicator {
  position: absolute;
  bottom: -6px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.progress-text {
  font-size: 0.7rem;
  color: #888;
  font-weight: 500;
}

.progress-bar {
  width: 60px;
  height: 3px;
  background: #e8e0d5;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--wheat, #e8c547);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ========== CUSTOMIZATION PICKER ========== */
.custom-builder-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #faf7f2;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  overflow-y: auto;
}

.custom-builder-overlay.hidden {
  display: none;
}

.custom-builder-content {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

.custom-builder-content h2 {
  font-family: var(--font-display, "Pacifico", cursive);
  font-size: 1.8rem;
  color: var(--charcoal, #2c2c2c);
  text-align: center;
  margin: 0 0 8px 0;
}

.custom-subtitle {
  text-align: center;
  color: #666;
  margin: 0 0 24px 0;
  font-size: 1rem;
}

.custom-available,
.custom-target {
  margin-bottom: 24px;
}

.custom-available h4,
.custom-target h4 {
  font-size: 0.9rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}

/* Option buttons grid */
.custom-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Clickable option button (for single/multi select) */
.custom-option-btn,
.box-tier-btn,
.box-size-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: white;
  border: 2px solid #e8e0d5;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.custom-option-btn:hover,
.box-tier-btn:hover,
.box-size-btn:hover {
  border-color: var(--wheat, #e8c547);
  background: rgba(232, 197, 71, 0.1);
}

.custom-option-btn.selected {
  border-color: #4caf50;
  background: #e8f5e9;
}

.custom-option-btn .option-name {
  font-weight: 600;
  color: var(--charcoal, #2c2c2c);
  font-size: 1.05rem;
}

.custom-option-btn .default-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  background: rgba(232, 197, 71, 0.3);
  border-radius: 8px;
  color: var(--warm-brown, #8b6f47);
  font-weight: 500;
}

/* Drop target slots grid (kept for future "build your box" feature) */
.custom-slots-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 400px) {
  .custom-slots-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.custom-slot {
  aspect-ratio: 1;
  background: white;
  border: 2px dashed #ccc;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.custom-slot .slot-number {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ccc;
}

.custom-slot.drag-over {
  border-color: var(--wheat, #e8c547);
  background: rgba(232, 197, 71, 0.15);
  transform: scale(1.05);
}

.custom-slot.filled {
  border-style: solid;
  border-color: #4caf50;
  background: #e8f5e9;
  cursor: pointer;
}

.custom-slot.filled:hover {
  background: #ffebee;
  border-color: #f44336;
}

.custom-slot.filled:hover::after {
  content: "✕";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  color: #f44336;
  font-weight: bold;
}

.slot-filled-icon {
  font-size: 1.5rem;
}

.slot-filled-name {
  font-size: 0.65rem;
  color: var(--charcoal, #2c2c2c);
  text-align: center;
  line-height: 1.2;
  padding: 0 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action buttons */
.custom-actions {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, rgba(250, 247, 242, 1) 80%, transparent);
  padding-top: 24px;
}

.custom-cancel-btn {
  flex: 1;
  padding: 14px 20px;
  background: white;
  border: 2px solid #ccc;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.custom-cancel-btn:hover {
  border-color: #999;
  color: #333;
}

.custom-done-btn {
  flex: 2;
  padding: 14px 20px;
  background: #9e9e9e;
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: not-allowed;
  transition: all 0.2s;
}

.custom-done-btn:not(:disabled) {
  background: #2e7d32;
  cursor: pointer;
}

.custom-done-btn:not(:disabled):hover {
  background: #1b5e20;
  transform: translateY(-2px);
}

.custom-done-btn.ready {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

/* ========== BUILD YOUR OWN BOX CARD ========== */
.build-box-card .build-box-image {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.build-box-icon {
  font-size: 5rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.badge.custom {
  background: #e8f5e9;
  color: #2e7d32;
}

/* ========== TIER PICKER ========== */
.tier-btn {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 8px;
  padding: 20px !important;
}

.tier-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tier-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--charcoal, #2c2c2c);
}

.tier-desc {
  font-size: 0.85rem;
  color: #888;
}

.tier-price {
  font-size: 1rem;
  font-weight: 600;
  color: var(--warm-brown, #8b6f47);
  align-self: flex-end;
}

/* ========== BOX BUILDER COOKIES ========== */
.box-cookie {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border: 2px solid #e8e0d5;
  border-radius: 12px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s;
  touch-action: none;
}

.box-cookie:hover {
  border-color: var(--wheat, #e8c547);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.box-cookie.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.box-cookie.touch-dragging {
  background: var(--wheat, #e8c547);
  border-color: var(--warm-brown, #8b6f47);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}
