/* =========================================================
   PRIS Candles - shared UI layer
   Animations + mobile / desktop polish (loaded on every page)
   ========================================================= */
:root { --ease: cubic-bezier(.22, .8, .3, 1); }

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; overflow-x: clip; -webkit-tap-highlight-color: transparent; }
button, a, [onclick], label { touch-action: manipulation; }
img { -webkit-user-drag: none; }

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

/* ---------- Scroll reveal (only active when JS is running) ---------- */
.js [data-reveal] {
  opacity: 0; translate: 0 24px;
  transition: opacity .7s var(--ease), translate .7s var(--ease);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal="left"]  { translate: -28px 0; }
.js [data-reveal="right"] { translate: 28px 0; }
@media (max-width: 1023px) { .js [data-reveal="left"], .js [data-reveal="right"] { translate: 0 24px; } } /* no sideways slide on phones = no horizontal scroll */
.js [data-reveal="zoom"]  { translate: 0 0; scale: .94; transition-property: opacity, scale; }
.js [data-reveal].is-visible { opacity: 1; translate: 0 0; scale: 1; }

/* ---------- Image skeleton + fade-in ---------- */
.img-wrap {
  position: relative; overflow: hidden;
  background: linear-gradient(110deg, rgba(0,0,0,.05) 8%, rgba(0,0,0,.11) 18%, rgba(0,0,0,.05) 33%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.dark .img-wrap {
  background: linear-gradient(110deg, rgba(255,255,255,.04) 8%, rgba(255,255,255,.1) 18%, rgba(255,255,255,.04) 33%);
  background-size: 200% 100%;
}
.img-wrap.is-loaded { animation: none; background: none; }
.js img.fade-img { opacity: 0; transition: opacity .55s ease; }
.js img.fade-img.is-loaded { opacity: 1; }

/* ---------- Hero ---------- */
.hero-float { animation: floaty 6s ease-in-out infinite; }
.flame-glow { position: relative; isolation: isolate; }
.flame-glow::before {
  content: ""; position: absolute; inset: -10%; z-index: -1; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,.38), transparent 65%);
  filter: blur(34px); animation: glow 3.6s ease-in-out infinite; pointer-events: none;
}

@media (max-width: 1023px) { .flame-glow::before { inset: 4%; } } /* keep glow inside the screen on phones */

/* ---------- Cards / buttons ---------- */
.pcard { transition: box-shadow .35s var(--ease), translate .35s var(--ease), border-color .3s; }
@media (hover: hover) { .pcard:hover { translate: 0 -6px; } }
.pcard .pimg { transition: scale .7s var(--ease); }
@media (hover: hover) { .pcard:hover .pimg { scale: 1.07; } }
button:active, a.rounded-full:active { scale: .96; }
.cart-badge-count.pop { animation: pop .45s var(--ease); }

/* Home grid: 4 cards fill 2 columns on phones/tablets, 3 on desktop */
@media (min-width: 1024px) { #home-products-grid > :nth-child(4) { display: none; } }

/* ---------- Header + menus + modals ---------- */
header.sticky { transition: box-shadow .3s, background-color .3s; }
header.sticky.is-scrolled { box-shadow: 0 8px 28px -12px rgba(0,0,0,.28); }
#mobile-menu:not(.hidden) { animation: menuDown .28s var(--ease); }

#product-details-modal:not(.hidden), #auth-modal:not(.hidden), #product-modal:not(.hidden) { animation: fadeIn .22s ease; }
#product-details-modal:not(.hidden) > div,
#auth-modal:not(.hidden) > div,
#product-modal:not(.hidden) > div { animation: popIn .32s var(--ease); }

#cart-drawer { height: 100vh; height: 100dvh; }

/* ---------- Toasts ---------- */
#toast-container { bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 2rem); }
@media (max-width: 639px) {
  #toast-container { left: 50%; right: auto; translate: -50% 0; align-items: center; }
}

/* ---------- Mobile polish ---------- */
@media (max-width: 767px) {
  /* 16px inputs stop iOS Safari zooming the page on focus */
  input, select, textarea { font-size: 16px !important; }
  input[type="file"] { font-size: 13px !important; }
}
@media (max-width: 639px) {
  /* Modals become bottom sheets on phones */
  #product-details-modal, #auth-modal, #product-modal { align-items: flex-end !important; padding: 0 !important; }
  #product-details-modal > div, #auth-modal > div, #product-modal > div {
    border-radius: 28px 28px 0 0 !important; max-width: 100% !important;
    max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }
  #product-details-modal:not(.hidden) > div,
  #auth-modal:not(.hidden) > div,
  #product-modal:not(.hidden) > div { animation: sheetUp .38s var(--ease); }
  #cart-drawer { max-width: 100% !important; }
}

/* ---------- Admin: tables turn into cards on phones ---------- */
@media (max-width: 767px) {
  .resp-table, .resp-table tbody, .resp-table tr, .resp-table td { display: block; width: 100%; }
  .resp-table thead { display: none; }
  .resp-table tr { padding: .8rem .9rem; border-bottom: 1px solid rgba(63,63,70,.6); }
  .resp-table td {
    display: flex !important; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .3rem 0 !important; text-align: right; border: 0;
  }
  .resp-table td::before {
    content: attr(data-label); color: #a1a1aa; font-size: 10px; text-transform: uppercase;
    letter-spacing: .07em; text-align: left; flex-shrink: 0; font-weight: 500;
  }
  .resp-table td[data-label=""]::before { display: none; }
  .resp-table td.cell-title { justify-content: flex-start; }
}

/* ---------- Upload tiles (admin) ---------- */
.up-tile { position: relative; aspect-ratio: 1; border-radius: .9rem; overflow: hidden; background: #09090b; border: 1px solid #3f3f46; animation: popIn .3s var(--ease); }
.up-tile img { width: 100%; height: 100%; object-fit: cover; }
.up-tile .up-bar { position: absolute; left: 0; bottom: 0; height: 4px; background: #f59e0b; transition: width .2s; }
.up-tile .up-over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; font-weight: 700; }
.up-tile .up-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
.up-tile .up-actions button { width: 22px; height: 22px; border-radius: 9999px; background: rgba(0,0,0,.7); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; }
.up-tile .up-main { position: absolute; left: 4px; top: 4px; background: #f59e0b; color: #111; font-size: 9px; font-weight: 800; padding: 2px 7px; border-radius: 9999px; }
.dropzone-active { border-color: #f59e0b !important; background: rgba(245,158,11,.08) !important; }

/* ---------- Keyframes ---------- */
@keyframes shimmer { to { background-position-x: -200%; } }
@keyframes floaty  { 0%,100% { translate: 0 0; } 50% { translate: 0 -10px; } }
@keyframes glow    { 0%,100% { opacity: .55; scale: 1; } 50% { opacity: .95; scale: 1.08; } }
@keyframes pop     { 0% { scale: 1; } 40% { scale: 1.45; } 100% { scale: 1; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn   { from { opacity: 0; scale: .95; translate: 0 12px; } to { opacity: 1; scale: 1; translate: 0 0; } }
@keyframes sheetUp { from { translate: 0 100%; } to { translate: 0 0; } }
@keyframes menuDown{ from { opacity: 0; translate: 0 -8px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Respect reduced-motion settings ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .js [data-reveal] { opacity: 1; translate: 0 0; scale: 1; }
}
