/* ============================================================
   Kartsy — Custom styles (variables, animations, components)
   Tailwind CDN handles utility styling; this file holds the
   brand palette, animations and effects Tailwind can't express.
   ============================================================ */

:root {
  --primary: #111827;
  --secondary: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --background: #ffffff;
  --surface: #f9fafb;
  --border: #e5e7eb;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
}

html {
  scroll-behavior: smooth;
}

/* The hidden attribute must always win, even against Tailwind
   display utilities like .grid / .flex on the same element. */
[hidden] {
  display: none !important;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 8px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ---------- Focus states ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes heartPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.anim-fade-in { animation: fadeIn 0.3s ease both; }
.anim-fade-up { animation: fadeUp 0.4s ease both; }
.anim-scale-in { animation: scaleIn 0.2s ease both; }
.heart-pop { animation: heartPop 0.35s ease; }

/* ---------- Skeleton loaders ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #eceef1;
  border-radius: 8px;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
  background-size: 400px 100%;
  animation: shimmer 1.3s infinite linear;
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 2.5rem);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-width: 260px;
  max-width: 360px;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.35);
  animation: toastIn 0.28s cubic-bezier(0.21, 1.02, 0.73, 1) both;
}
.toast.toast-leaving { animation: toastOut 0.22s ease forwards; }
.toast .toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: #4ade80; }
.toast-error .toast-icon { color: #f87171; }
.toast-warning .toast-icon { color: #fbbf24; }
.toast-info .toast-icon { color: #93c5fd; }

/* ---------- Drawers & overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.overlay.open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(20rem, 85vw);
  background: #fff;
  z-index: 70;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.drawer-left { left: 0; transform: translateX(-100%); }
.drawer-right { right: 0; transform: translateX(100%); }
.drawer.open { transform: translateX(0); }

.drawer-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  background: #fff;
  z-index: 70;
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.drawer-bottom.open { transform: translateY(0); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease both;
}
.modal-panel { animation: scaleIn 0.2s ease both; }

/* ---------- Product cards ---------- */
.product-card .card-img {
  transition: transform 0.4s ease;
}
.product-card:hover .card-img {
  transform: scale(1.04);
}
.product-card .card-actions {
  opacity: 1;
}
@media (hover: hover) {
  .product-card .quick-add {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
  }
  .product-card:hover .quick-add,
  .product-card:focus-within .quick-add {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Product gallery zoom ---------- */
.zoom-container { overflow: hidden; cursor: zoom-in; }
.zoom-container img { transition: transform 0.25s ease; transform-origin: center; }
@media (hover: hover) {
  .zoom-container:hover img { transform: scale(1.7); }
}

/* ---------- Ratings ---------- */
.stars {
  position: relative;
  display: inline-block;
  font-size: 0.85rem;
  line-height: 1;
  letter-spacing: 1px;
  color: #d1d5db;
}
.stars::before { content: '★★★★★'; }
.stars .stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #f59e0b;
}
.stars .stars-fill::before { content: '★★★★★'; }

/* ---------- Order timeline ---------- */
.timeline-step { position: relative; padding-left: 2.25rem; padding-bottom: 1.75rem; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before {
  content: '';
  position: absolute;
  left: 0.72rem;
  top: 1.6rem;
  bottom: 0.15rem;
  width: 2px;
  background: var(--border);
}
.timeline-step:last-child::before { display: none; }
.timeline-step.done::before { background: var(--success); }
.timeline-dot {
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  background: #fff;
  color: #fff;
  font-size: 0.7rem;
}
.timeline-step.done .timeline-dot { background: var(--success); border-color: var(--success); }
.timeline-step.current .timeline-dot { border-color: var(--accent); background: var(--accent); }
.timeline-step.current .timeline-dot::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.3);
}

/* ---------- Accordion ---------- */
.accordion-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.accordion-content > div { overflow: hidden; }
.accordion-item.open .accordion-content { grid-template-rows: 1fr; }
.accordion-item .accordion-chevron { transition: transform 0.25s ease; }
.accordion-item.open .accordion-chevron { transform: rotate(180deg); }

/* ---------- Misc ---------- */
.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.input-error { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 0.78rem; margin-top: 0.3rem; }

body.no-scroll { overflow: hidden; }

.prose-static h2 { font-size: 1.15rem; font-weight: 700; margin: 1.75rem 0 0.6rem; }
.prose-static h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.4rem; }
.prose-static p { color: #4b5563; line-height: 1.7; margin-bottom: 0.9rem; }
.prose-static ul { list-style: disc; padding-left: 1.4rem; color: #4b5563; line-height: 1.7; margin-bottom: 0.9rem; }
