/* ============================================================
   Kitchen Madam — custom styles & animations (on top of Tailwind)
   ============================================================ */

:root {
  --brand: #4f46e5;
  --accent: #22d3ee;
}

html { -webkit-text-size-adjust: 100%; }

body { font-feature-settings: "cv02", "cv03", "cv04"; overflow-x: hidden; }

::selection { background: rgba(79, 70, 229, 0.2); }

/* ---------- Site-wide zoom-out page transition ---------- */
@keyframes page-zoom-in {
  from { opacity: 0; transform: scale(.975); filter: blur(1px); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

main,
footer,
.page-transition-surface {
  animation: page-zoom-in .48s cubic-bezier(.16,1,.3,1) both;
  transform-origin: 50% 45%;
  transition: opacity .42s ease, transform .42s cubic-bezier(.4,0,.2,1), filter .42s ease;
}

body.zoom-transition-out main,
body.zoom-transition-out footer,
body.zoom-transition-out .page-transition-surface {
  opacity: 0;
  transform: scale(.9);
  filter: blur(2px);
  pointer-events: none;
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  main, footer, .page-transition-surface { animation: none; transition: opacity .12s linear; }
  body.zoom-transition-out main,
  body.zoom-transition-out footer,
  body.zoom-transition-out .page-transition-surface { opacity: 0; transform: none; filter: none; }
}

/* ---------- Scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1); }
.reveal.revealed { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: .08s; }
.reveal[data-delay="2"] { transition-delay: .16s; }
.reveal[data-delay="3"] { transition-delay: .24s; }
.reveal[data-delay="4"] { transition-delay: .32s; }

/* ---------- Hero ---------- */
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-14px) rotate(-1.5deg); }
}
.animate-floaty { animation: floaty 6s ease-in-out infinite; }

@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(28px, -36px) scale(1.1); }
  66%      { transform: translate(-22px, 24px) scale(.94); }
}
.animate-blob { animation: blob 14s ease-in-out infinite; }

@keyframes shine {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}
.animate-shine {
  background-size: 200% auto;
  animation: shine 6s linear infinite;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.animate-marquee { animation: marquee 30s linear infinite; }

/* ---------- Card hover ---------- */
.card-lift { transition: transform .4s cubic-bezier(.16,1,.3,1), box-shadow .4s cubic-bezier(.16,1,.3,1); }
.card-lift:hover { transform: translateY(-6px); box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .18); }

/* ---------- Cart drawer ---------- */
#cart-drawer { transition: transform .35s cubic-bezier(.16,1,.3,1); }
#cart-overlay { transition: opacity .35s ease; }

/* ---------- Toasts ---------- */
.toast { animation: toast-in .35s cubic-bezier(.16,1,.3,1) both; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.toast.leaving { animation: toast-out .3s ease both; }
@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px) scale(.96); }
}

/* ---------- Skeleton shimmer ---------- */
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton { position: relative; overflow: hidden; background: #eef2f7; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  animation: shimmer 1.4s infinite;
}

/* ---------- Policy and help pages ---------- */
.policy-copy p { margin: 0; }
.policy-copy ul { margin: .75rem 0; padding-left: 1.25rem; list-style: disc; }
.policy-copy li { margin: .4rem 0; padding-left: .25rem; }
.policy-copy strong { color: #111827; font-weight: 700; }
.policy-copy a { color: #4f46e5; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.policy-copy a:hover { color: #3730a3; }

/* ---------- Form focus ring ---------- */
.input { @apply w-full rounded-xl border border-gray-300 bg-white px-4 py-2.5 text-sm text-gray-900 placeholder-gray-400 outline-none transition focus:border-brand-500 focus:ring-4 focus:ring-brand-500/10; }

/* ---------- Scrollbar (cart drawer) ---------- */
.nice-scroll::-webkit-scrollbar { width: 6px; }
.nice-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

/* ---------- Accessibility ---------- */
.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;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 200;
  border-radius: 9999px;
  background: #4f46e5;
  color: #fff;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: top .2s ease;
  box-shadow: 0 8px 24px rgba(79, 70, 229, .35);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 1rem;
  outline: 2px solid #fff;
  outline-offset: 2px;
}
:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .animate-floaty, .animate-blob, .animate-shine, .animate-marquee { animation: none !important; }
}

/* ---------- Loading bar & overlay ---------- */
#km-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  z-index: 9999;
  background: linear-gradient(90deg, #4f46e5, #22d3ee, #4f46e5);
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
  transition: width .35s ease, opacity .2s ease;
}
#km-loading-bar.is-active {
  opacity: 1;
  width: 70%;
  animation: km-bar-shimmer 1s linear infinite;
}
#km-loading-bar.is-complete {
  width: 100%;
  transition: width .25s ease;
}
@keyframes km-bar-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
#km-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
#km-loading-overlay.is-active {
  opacity: 1;
  pointer-events: all;
}
.km-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(79, 70, 229, 0.2);
  border-top-color: #4f46e5;
  animation: km-spin .7s linear infinite;
}
@keyframes km-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #km-loading-bar.is-active { animation: none; width: 100%; }
  .km-spinner { animation: none; border-top-color: #4f46e5; }
  #km-loading-overlay { display: none; }
}

/* Cookie banner stacking above chat */
#km-cookie-banner { z-index: 110; }

/* ============================================================
   Light / Dark mode
   ============================================================ */
:root {
  color-scheme: light;
  --km-bg: #ffffff;
  --km-bg-soft: #f9fafb;
  --km-surface: #ffffff;
  --km-text: #111827;
  --km-text-muted: #6b7280;
  --km-border: #e5e7eb;
  --km-header: rgba(255, 255, 255, 0.85);
  --km-input-bg: #ffffff;
  --km-shadow: rgba(15, 23, 42, 0.08);
}

html.dark {
  color-scheme: dark;
  --km-bg: #0b1020;
  --km-bg-soft: #111827;
  --km-surface: #151c2c;
  --km-text: #f3f4f6;
  --km-text-muted: #9ca3af;
  --km-border: #1f2a3d;
  --km-header: rgba(11, 16, 32, 0.9);
  --km-input-bg: #0f1624;
  --km-shadow: rgba(0, 0, 0, 0.45);
}

html.dark body {
  background-color: var(--km-bg) !important;
  color: var(--km-text) !important;
}

/* Surfaces */
html.dark .bg-white,
html.dark .bg-white\/80,
html.dark .bg-gray-50,
html.dark .bg-gray-50\/60 {
  background-color: var(--km-surface) !important;
}
html.dark .bg-gray-100 {
  background-color: #1a2336 !important;
}
html.dark main,
html.dark .page-transition-surface {
  background-color: transparent;
}

/* Text */
html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-black {
  color: var(--km-text) !important;
}
html.dark .text-gray-700,
html.dark .text-gray-600 {
  color: #d1d5db !important;
}
html.dark .text-gray-500,
html.dark .text-gray-400 {
  color: var(--km-text-muted) !important;
}

/* Borders */
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .divide-gray-100 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-y > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--km-border) !important;
}
html.dark .ring-gray-200,
html.dark .ring-1 {
  --tw-ring-color: var(--km-border);
}

/* Header / sticky */
html.dark #site-header {
  background-color: var(--km-header) !important;
  border-color: var(--km-border) !important;
}
html.dark #mobile-menu {
  background-color: var(--km-surface) !important;
  border-color: var(--km-border) !important;
}

/* Cards, inputs, tables */
html.dark .input,
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html.dark select,
html.dark textarea {
  background-color: var(--km-input-bg) !important;
  border-color: var(--km-border) !important;
  color: var(--km-text) !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #6b7280 !important;
}
html.dark table thead {
  background-color: #121a2b !important;
  color: var(--km-text-muted) !important;
}
html.dark tr:hover {
  background-color: rgba(255, 255, 255, 0.03) !important;
}

/* Soft status / badge surfaces keep readable in dark */
html.dark .bg-amber-50 { background-color: rgba(245, 158, 11, 0.15) !important; }
html.dark .bg-emerald-50,
html.dark .bg-emerald-50\/60 { background-color: rgba(16, 185, 129, 0.15) !important; }
html.dark .bg-red-50,
html.dark .bg-red-50\/40 { background-color: rgba(239, 68, 68, 0.15) !important; }
html.dark .bg-blue-50 { background-color: rgba(59, 130, 246, 0.15) !important; }
html.dark .bg-violet-50 { background-color: rgba(139, 92, 246, 0.15) !important; }
html.dark .bg-teal-50 { background-color: rgba(20, 184, 166, 0.15) !important; }
html.dark .bg-brand-50,
html.dark .bg-brand-50\/30,
html.dark .bg-brand-50\/60 { background-color: rgba(79, 70, 229, 0.18) !important; }

/* Footer already dark (bg-ink) — slight tweak */
html.dark footer.bg-ink {
  background-color: #070a12 !important;
}

/* Cart drawer */
html.dark #cart-drawer {
  background-color: var(--km-surface) !important;
  color: var(--km-text);
}
html.dark #cart-overlay {
  background-color: rgba(0, 0, 0, 0.6) !important;
}

/* Chatbot window */
html.dark #km-chat-window {
  background-color: var(--km-surface) !important;
  border-color: var(--km-border) !important;
}
html.dark #km-chat-messages {
  background-color: var(--km-bg-soft) !important;
}

/* Cookie banner */
html.dark #km-cookie-banner {
  background-color: rgba(21, 28, 44, 0.97) !important;
  border-color: var(--km-border) !important;
  color: var(--km-text);
}

/* Loading overlay */
html.dark #km-loading-overlay {
  background: rgba(11, 16, 32, 0.45);
}

/* Admin main content area */
html.dark .bg-gray-50.font-sans,
html.dark body.bg-gray-50 {
  background-color: var(--km-bg) !important;
}

/* Theme toggle button */
.km-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  color: #4b5563;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.km-theme-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #111827;
}
html.dark .km-theme-toggle {
  color: #d1d5db;
}
html.dark .km-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.km-theme-toggle .icon-sun { display: none; }
.km-theme-toggle .icon-moon { display: block; }
html.dark .km-theme-toggle .icon-sun { display: block; }
html.dark .km-theme-toggle .icon-moon { display: none; }

/* Admin theme toggle on dark sidebar context */
.km-theme-toggle-admin {
  color: #9ca3af;
}
.km-theme-toggle-admin:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Product 3D viewer */
#km-3d-viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: linear-gradient(160deg, #f8fafc 0%, #eef2ff 50%, #f1f5f9 100%);
  border-radius: 1.5rem;
}
#km-3d-viewer canvas {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: grab;
}
#km-3d-viewer canvas:active { cursor: grabbing; }
.km-3d-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: #6b7280;
  pointer-events: none;
  background: rgba(255,255,255,0.35);
}
.km-media-tab {
  border-radius: 9999px;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  background: transparent;
  border: 1px solid transparent;
  transition: all .15s ease;
}
.km-media-tab:hover { color: #111827; background: #f3f4f6; }
.km-media-tab.is-active {
  color: #fff;
  background: #0b1020;
  border-color: #0b1020;
}
html.dark #km-3d-viewer {
  background: linear-gradient(160deg, #0f1624 0%, #151c2c 50%, #111827 100%);
}
html.dark .km-media-tab.is-active {
  background: #4f46e5;
  border-color: #4f46e5;
}
html.dark .km-media-tab { color: #9ca3af; }
html.dark .km-media-tab:hover { background: #1a2336; color: #f3f4f6; }
.km-3d-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  text-align: center;
  margin-top: 0.5rem;
}
