/* ============================================================
   FILE: enhance.css
   Loading screen, animations, hero particles, mobile fixes,
   About and Policy page styles.
   ============================================================ */
:root { --af-green: #14281D; --af-green2: #1d3a2a; --af-gold: #C59B27; --af-cream: #FBF7EE; --af-sand: #E8DFC8; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { overflow-x: hidden; }
img { max-width: 100%; }
.hidden { display: none; }

/* ---------- LOADING SCREEN ---------- */
#pageLoader {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(circle at 50% 40%, #1d3a2a 0%, #14281D 60%, #0c1a12 100%);
  transition: opacity .6s ease, visibility .6s ease;
}
#pageLoader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.af-ring { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.af-ring::before, .af-ring::after { content: ""; position: absolute; border-radius: 50%; }
.af-ring::before { inset: 0; border: 2px solid rgba(197,155,39,.25); border-top-color: var(--af-gold); animation: afSpin 1.1s linear infinite; }
.af-ring::after { inset: 12px; border: 2px dashed rgba(197,155,39,.45); animation: afSpin 3s linear infinite reverse; }
.af-ring img { width: 64px; height: 64px; object-fit: contain; border-radius: 50%; animation: afPulse 1.8s ease-in-out infinite; }
.af-ring .af-fallback { font-size: 34px; animation: afPulse 1.8s ease-in-out infinite; }
.af-name { font-family: "Cormorant Garamond", Georgia, serif; letter-spacing: .35em; color: #f4dc8e; font-size: 20px; text-transform: uppercase; }
.af-stitch { width: 190px; height: 0; border-top: 2px dashed var(--af-gold); position: relative; opacity: .85; animation: afStitch 1s linear infinite; }
.af-stitch::after { content: "🪡"; position: absolute; top: -13px; left: 0; font-size: 20px; animation: afNeedle 2.2s ease-in-out infinite; }
.af-hint { color: rgba(251,247,238,.6); font-size: 12px; letter-spacing: .15em; }
@keyframes afSpin { to { transform: rotate(360deg); } }
@keyframes afPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .8; } }
@keyframes afStitch { to { border-top-style: dashed; background-position: 16px 0; } }
@keyframes afNeedle { 0% { left: 0; } 50% { left: calc(100% - 20px); } 100% { left: 0; } }

/* ---------- SKELETONS (shown while slow internet loads items) ---------- */
@keyframes afShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes afHideSkel { to { opacity: 0; visibility: hidden; } }
#homeSections:empty, #productGrid:empty {
  min-height: 340px; border-radius: 16px;
  background: linear-gradient(100deg, #efe7d2 30%, #faf5e6 50%, #efe7d2 70%);
  background-size: 200% 100%;
  animation: afShimmer 1.4s linear infinite, afHideSkel .5s 14s forwards;
}
article img:not(.af-ok), .cat-tile img:not(.af-ok), #productModal img:not(.af-ok) {
  background: linear-gradient(100deg, #efe7d2 30%, #faf5e6 50%, #efe7d2 70%);
  background-size: 200% 100%; animation: afShimmer 1.4s linear infinite;
}

/* ---------- SCROLL PROGRESS "THREAD" ---------- */
#afProgress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 99998;
  background: linear-gradient(90deg, #8a6a12, #f4dc8e, #C59B27); box-shadow: 0 0 10px rgba(197,155,39,.7); }

/* ---------- REVEAL ON SCROLL ---------- */
.rv { opacity: 0; }
.rv.in { opacity: 1; animation: afReveal .9s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes afReveal { from { opacity: 0; translate: 0 30px; filter: blur(6px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }

/* ---------- BUTTON RIPPLE + SHINE ---------- */
.btn-gold, .btn-ghost, .nav-pill, .category-btn, .view-all { position: relative; overflow: hidden; }
.af-ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.55); transform: scale(0); animation: afRipple .6s ease-out forwards; pointer-events: none; }
@keyframes afRipple { to { transform: scale(4); opacity: 0; } }
.btn-gold::after { content: ""; position: absolute; top: 0; left: -80%; width: 50%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.45), transparent); transform: skewX(-20deg); transition: left .7s ease; pointer-events: none; }
.btn-gold:hover::after { left: 130%; }
header { transition: box-shadow .3s ease; }
header.af-scrolled { box-shadow: 0 12px 30px -16px rgba(0,0,0,.5); }
#cartCount.af-bump { animation: afBump .5s ease; }
@keyframes afBump { 40% { transform: scale(1.5); } }
.cat-tile { transition: transform .45s cubic-bezier(.2,.7,.2,1), box-shadow .45s ease; }
.cat-tile:hover { transform: translateY(-6px); box-shadow: 0 24px 40px -20px rgba(20,40,29,.6); }
.cat-tile img { transition: transform .8s ease; }
.cat-tile:hover img { transform: scale(1.08); }
.gold-divider span { display: inline-block; animation: afTwirl 6s linear infinite; }
@keyframes afTwirl { to { transform: rotate(360deg); } }

/* ---------- HERO: moving particles ---------- */
.hero { position: relative; overflow: hidden; }
.af-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.hero .spark { display: none; }

/* extra floating chips (big screens) */
.chip-4 { left: 7%; bottom: 14%; }
.chip-5 { right: 6%; bottom: 20%; }

/* moving fabric strip for phones and tablets */
.fabric-ticker { overflow: hidden; position: relative; z-index: 1; margin-top: 18px; white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.fabric-ticker .track { display: inline-flex; gap: 12px; animation: afTicker 22s linear infinite; }
.fabric-ticker span { padding: 7px 16px; border-radius: 999px; font-size: 12px; color: #f4dc8e;
  background: rgba(197,155,39,.12); border: 1px solid rgba(197,155,39,.45); }
@keyframes afTicker { to { transform: translateX(-50%); } }
@media (min-width: 1280px) { .fabric-ticker { display: none; } }

/* ---------- MOBILE ---------- */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px !important; }
  button, .btn-gold, .btn-ghost { min-height: 44px; }
  .hero-panel { padding: 2rem 1.2rem !important; }
  #productModal { -webkit-overflow-scrolling: touch; padding: 8px; }
  #toast { max-width: 90vw; text-align: center; }
}

/* ---------- ABOUT / POLICY PAGES ---------- */
body.af-page { background: var(--af-cream); color: #1f2a24; font-family: "Plus Jakarta Sans", system-ui, sans-serif; margin: 0; display: flex; flex-direction: column; min-height: 100vh; }
.af-head { background: linear-gradient(135deg, #1d3a2a, #14281D); color: var(--af-cream); position: sticky; top: 0; z-index: 50; }
.af-head .af-wrap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
.af-wrap { max-width: 1000px; margin: 0 auto; }
.af-brand { font-family: "Cormorant Garamond", Georgia, serif; font-size: 24px; letter-spacing: .12em; color: #f4dc8e; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.af-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: contain; }
.af-nav { display: flex; align-items: center; gap: 18px; }
.af-nav a { color: var(--af-cream); text-decoration: none; font-size: 14px; font-weight: 600; }
.af-nav a:hover { color: #f4dc8e; }
.af-banner { background: radial-gradient(circle at 50% 0%, #2a5a3f, #14281D 70%); color: var(--af-cream); text-align: center; padding: 56px 16px 48px; }
.af-banner h1 { font-family: "Cormorant Garamond", Georgia, serif; font-size: clamp(34px, 7vw, 58px); margin: 0 0 8px; font-weight: 600; }
.af-banner h1 em { color: var(--af-gold); }
.af-banner p { margin: 0; opacity: .8; }
.af-main { flex: 1; padding: 36px 16px 56px; }
.af-card { background: #fff; border: 1px solid var(--af-sand); border-radius: 16px; padding: 22px 24px; margin-bottom: 18px; box-shadow: 0 14px 30px -24px rgba(20,40,29,.6); }
.af-card h2 { font-family: "Cormorant Garamond", Georgia, serif; font-size: 26px; margin: 0 0 8px; color: #14281D; }
.af-card h2 span { color: var(--af-gold); }
.af-card p, .af-card li { line-height: 1.7; font-size: 15px; color: #3c4a42; }
.af-card ul { padding-left: 20px; margin: 8px 0 0; }
.af-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.af-stat { text-align: center; padding: 18px; border-radius: 14px; background: linear-gradient(135deg, #1d3a2a, #14281D); color: var(--af-cream); }
.af-stat b { display: block; font-size: 22px; color: #f4dc8e; font-family: "Cormorant Garamond", Georgia, serif; }
.af-foot { background: #14281D; color: rgba(251,247,238,.85); padding: 34px 16px 20px; font-size: 14px; line-height: 1.8; text-align: center; }
.af-foot h3 { font-family: "Cormorant Garamond", Georgia, serif; color: #f4dc8e; letter-spacing: .2em; margin: 0 0 6px; }
.af-foot a { color: #e5c76b; text-decoration: none; }
.footer-extra { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin: 16px 0 6px; padding-top: 14px; border-top: 1px solid rgba(197,155,39,.3); font-size: 14px; }
.footer-extra a { color: #e5c76b; text-decoration: none; font-weight: 600; }
.footer-extra a:hover { color: #fff; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; scroll-behavior: auto !important; }
  .rv { opacity: 1; }
}

/* ============================================================
   ITEM BOX: delivery circle, limited stock, zoom, arrows
   ============================================================ */
.af-item { border: 1px solid var(--af-sand); box-shadow: 0 10px 24px -18px rgba(20,40,29,.5);
  transition: transform .45s cubic-bezier(.2,.7,.2,1), box-shadow .45s ease, border-color .45s ease; }
.af-item:hover { transform: translateY(-6px); border-color: rgba(197,155,39,.7); box-shadow: 0 26px 44px -20px rgba(20,40,29,.55); }
.af-item h3 { font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.15rem; }
.bulk-pill { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: #7a5c0c; background: #fbf1d3; border: 1px solid var(--af-gold); }

/* Round delivery badge */
.del-circle { position: absolute; right: 8px; bottom: 8px; z-index: 2; width: 62px; height: 62px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; text-align: center;
  color: #f4dc8e; background: radial-gradient(circle at 35% 30%, #2a5a3f, #14281D 75%);
  border: 2px solid var(--af-gold); box-shadow: 0 6px 14px -4px rgba(0,0,0,.55), inset 0 0 0 3px rgba(20,40,29,.9);
  animation: afBadge 3s ease-in-out infinite; }
.del-circle b { font-size: 13px; color: #fff; font-weight: 800; }
.del-circle .dc-top { font-size: 6.5px; letter-spacing: .14em; color: #e5c76b; }
.del-circle .dc-bot { font-size: 8px; color: #e5c76b; }
.del-circle.free { background: radial-gradient(circle at 35% 30%, #f4dc8e, #C59B27 75%); color: #14281D; border-color: #fff4cf; }
.del-circle.free b { color: #14281D; font-size: 14px; }
.del-circle.free .dc-top, .del-circle.free .dc-bot { color: #14281D; }
@keyframes afBadge { 0%,100% { box-shadow: 0 6px 14px -4px rgba(0,0,0,.55), 0 0 0 0 rgba(197,155,39,.5); }
  50% { box-shadow: 0 6px 14px -4px rgba(0,0,0,.55), 0 0 0 8px rgba(197,155,39,0); } }
#productModal .del-circle { width: 74px; height: 74px; }
#productModal .del-circle b { font-size: 15px; }
#productModal .del-circle .dc-top { font-size: 7.5px; }

/* Limited stock chip on the card */
.low-chip { position: absolute; left: 8px; bottom: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #14281D;
  background: linear-gradient(135deg, #f4dc8e, #C59B27); box-shadow: 0 6px 14px -6px rgba(0,0,0,.5); }
.low-chip i, .low-dot { width: 8px; height: 8px; border-radius: 50%; background: #b91c1c; display: inline-block; animation: afBlink 1.2s ease-in-out infinite; flex: none; }
@keyframes afBlink { 50% { opacity: .25; transform: scale(.7); } }

/* Limited stock box in the popup */
.low-box { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; color: #5b4306; background: linear-gradient(135deg, #fff7dc, #fbe7a6); border: 1px solid var(--af-gold); }
.low-box .low-dot { margin-top: 6px; }
.stock-line { margin-top: 12px; font-size: 13px; color: #166534; font-weight: 600; }

/* Zoom */
.zoom-wrap { touch-action: pan-y; cursor: zoom-in; }
.zoom-wrap.zoomed { cursor: grab; touch-action: none; }
.zoom-wrap.dragging { cursor: grabbing; }
.zoom-wrap img { transition: transform .25s ease; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.zoom-wrap.dragging img { transition: none; }
.zoom-ctrl { position: absolute; left: 8px; bottom: 8px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
.zoom-ctrl button { width: 38px; height: 38px; min-height: 0; border-radius: 50%; font-size: 20px; font-weight: 700; line-height: 1;
  color: #14281D; background: rgba(251,247,238,.92); border: 1px solid var(--af-gold); box-shadow: 0 4px 10px -4px rgba(0,0,0,.5);
  transition: transform .2s ease, background .2s ease; }
.zoom-ctrl button:hover { transform: scale(1.1); background: #f4dc8e; }
.zoom-hint { margin-top: 8px; font-size: 11px; color: #78716c; text-align: center; }
.nav-count { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8a6a12; font-weight: 700; margin: 0 0 10px; padding-right: 30px; }
.af-swap { animation: afSwap .45s cubic-bezier(.2,.7,.2,1); }
@keyframes afSwap { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* Left / right arrows */
.modal-arrow { position: fixed; z-index: 70; width: 48px; height: 48px; min-height: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #14281D;
  background: linear-gradient(135deg, #f4dc8e, #C59B27); border: 2px solid #fff4cf;
  box-shadow: 0 10px 22px -8px rgba(0,0,0,.6); transition: transform .25s ease, box-shadow .25s ease, opacity .25s ease; }
.modal-arrow:hover:not(:disabled) { transform: scale(1.12); box-shadow: 0 14px 26px -8px rgba(197,155,39,.8); }
.modal-arrow:active:not(:disabled) { transform: scale(.94); }
.modal-arrow:disabled { cursor: not-allowed; color: #a8a29e; background: #e7e5e4; border-color: #d6d3d1; box-shadow: none; opacity: .75; }
@media (min-width: 900px) {
  .modal-arrow { top: 50%; margin-top: -24px; }
  .modal-arrow-prev { left: max(10px, calc(50% - 384px - 64px)); }
  .modal-arrow-next { right: max(10px, calc(50% - 384px - 64px)); }
}
@media (max-width: 899px) {
  .modal-arrow { bottom: 14px; width: 46px; height: 46px; }
  .modal-arrow-prev { left: 16px; }
  .modal-arrow-next { right: 16px; }
  #productModal { padding-bottom: 80px !important; }
}
@media (max-width: 640px) {
  .del-circle { width: 54px; height: 54px; right: 6px; bottom: 6px; }
  .del-circle b { font-size: 11.5px; }
  .del-circle .dc-top { font-size: 5.5px; }
  .low-chip { left: 6px; bottom: 6px; font-size: 10px; padding: 3px 8px; }
  #productModal .del-circle { width: 62px; height: 62px; }
}

/* ============================================================
   ITEM BOX LOADING AND ANIMATIONS
   ============================================================ */

/* Photo area shows a soft shimmer until the picture arrives */
article.af-item > div:first-child {
  background: linear-gradient(100deg, #efe7d2 30%, #faf5e6 50%, #efe7d2 70%);
  background-size: 200% 100%;
  animation: afShimmer 1.4s linear infinite;
}
article.af-item > div:first-child:has(img.af-ok) {
  background: #f5f0e4;
  animation: none;
}
article.af-item img {
  opacity: 0;
  transition: opacity .6s ease, transform .8s ease;
}
/* Keep the whole product photo visible in its existing card frame. */
article.af-item > div:first-child > img {
  object-fit: contain !important;
  transform: none !important;
  background: #f5f0e4;
}
article.af-item:hover > div:first-child > img {
  transform: none !important;
}
article.af-item img.af-ok,
article.af-item img[src]:not([src=""]):is(.af-ok) {
  opacity: 1;
}

/* Text fades in after the photo */
article.af-item .p-3 {
  animation: afFadeUp .7s ease backwards;
  animation-delay: .15s;
}
@keyframes afFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Cards rise in one after another as you scroll */
article.af-item.rv.in {
  animation: afRise .8s cubic-bezier(.2,.7,.2,1) backwards;
}
article.af-item:nth-child(3n+2).rv.in { animation-delay: .08s; }
article.af-item:nth-child(3n+3).rv.in { animation-delay: .16s; }
@keyframes afRise {
  from { opacity: 0; transform: translateY(24px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* Gold shine sweeps across the photo on hover (computers only) */
@media (hover: hover) {
  article.af-item > div:first-child::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255,244,207,.55) 50%, transparent 65%);
    transform: translateX(-120%);
    pointer-events: none;
    z-index: 1;
  }
  article.af-item:hover > div:first-child::after {
    transition: transform .9s ease;
    transform: translateX(120%);
  }
}

/* Lighter effects on phones so scrolling stays smooth */
@media (max-width: 767px) {
  article.af-item.rv.in { animation-duration: .6s; }
  article.af-item > div:first-child { animation-duration: 2s; }
}


/* ============================================================
   BATCH 1: safety fixes, focus outline, 404 page
   ============================================================ */

/* FIX 1: photos always appear within 6 seconds, even if the script fails */
@keyframes afImgShow { to { opacity: 1; } }
@keyframes afImgShowDim { to { opacity: .6; } }
article.af-item img { animation: afImgShow 0s linear 6s forwards; }

/* FIX 2: out-of-stock photos stay faded */
article.af-item img.opacity-60 { animation-name: afImgShowDim; }
article.af-item img.opacity-60.af-ok { opacity: .6; }

/* Keyboard focus outline (helps accessibility) */
:focus-visible { outline: 2px solid #C59B27; outline-offset: 2px; border-radius: 6px; }
a, button { -webkit-tap-highlight-color: rgba(197,155,39,.25); }

/* 404 page */
.af-404 { text-align: center; padding: 70px 16px; }
.af-404 .big { font-family: "Cormorant Garamond", Georgia, serif; font-size: clamp(90px, 22vw, 180px); line-height: 1; color: var(--af-gold); animation: afPulse 2.4s ease-in-out infinite; }
.af-404 a.btn { display: inline-block; margin-top: 18px; padding: 12px 28px; border-radius: 999px; font-weight: 700; text-decoration: none; color: #14281D; background: linear-gradient(135deg, #f4dc8e, #C59B27); }
