/* ============================================================
   AG54 — Performance & UX Enhancement CSS  v1.0
   Add last in <head> after all other stylesheets
   <link rel="stylesheet" href="/storefront/styles-perf.css">
   ============================================================ */

/* ── 1. SCROLL PROGRESS BAR ─────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent) 0%, #C4654A 100%);
  z-index: 200;
  transition: width 80ms linear;
  transform-origin: left;
}

/* ── 2. PAGE TRANSITION OVERLAY ─────────────────────────────── */
.page-transition {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}
.page-transition.entering { opacity: 1; pointer-events: all; }

/* ── 3. BACK TO TOP BUTTON ──────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: calc(var(--space-8) + 28px); /* above ticker */
  right: var(--space-6);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 250ms var(--ease-out),
    transform 250ms var(--ease-out),
    background 150ms,
    border-color 150ms;
  z-index: 90;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--color-surface-2);
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.back-to-top:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}
/* On map page, ticker exists so offset more */
.has-ticker .back-to-top { bottom: calc(var(--space-8) + 52px); }

/* ── 4. IMAGE SKELETON LOADER ───────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.img-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface)   25%,
    var(--color-surface-2) 50%,
    var(--color-surface)   75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

/* Applied via JS to images before load */
img.loading {
  opacity: 0;
  transition: opacity 300ms ease;
}
img.loaded {
  opacity: 1;
}

/* ── 5. LINK HOVER UNDERLINE ANIMATION ──────────────────────── */
.site-footer__links a {
  position: relative;
}
.site-footer__links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width 220ms var(--ease-out);
}
.site-footer__links a:hover::after { width: 100%; }

/* ── 6. PRODUCT CARD — micro-interaction improvements ──────── */
/* Faster overlay on hover */
.product-card__overlay {
  transition: opacity 200ms var(--ease-out) !important;
}

/* Card focus state */
.product-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* ── 7. HERO — text animation on load ───────────────────────── */
@keyframes hero-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero__eyebrow  { animation: hero-fade-up 500ms 100ms both; }
.hero__title    { animation: hero-fade-up 600ms 250ms both; }
.hero__subtitle { animation: hero-fade-up 500ms 400ms both; }
.hero__actions  { animation: hero-fade-up 500ms 550ms both; }

/* ── 8. SECTION REVEAL — smoother ──────────────────────────── */
.js-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 550ms var(--ease-out),
    transform 550ms var(--ease-out);
}
.js-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
/* Stagger siblings */
.js-reveal:nth-child(2) { transition-delay: 80ms; }
.js-reveal:nth-child(3) { transition-delay: 160ms; }
.js-reveal:nth-child(4) { transition-delay: 240ms; }

/* ── 9. FOCUS IMPROVEMENTS ──────────────────────────────────── */
/* Ensure skip link is actually usable */
.sr-only:focus {
  position: fixed !important;
  top: var(--space-4) !important;
  left: var(--space-4) !important;
  width: auto !important;
  height: auto !important;
  clip: auto !important;
  clip-path: none !important;
  z-index: 9999 !important;
  padding: var(--space-3) var(--space-6) !important;
  background: var(--color-accent) !important;
  color: var(--color-text-inverse) !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

/* ── 10. REDUCED MOTION ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .scroll-progress,
  .back-to-top,
  .hero__eyebrow, .hero__title, .hero__subtitle, .hero__actions,
  .js-reveal,
  .page-transition,
  img.loading,
  img.loaded,
  .product-card__overlay,
  .gallery__main-img { transition: none !important; animation: none !important; }
  .js-reveal { opacity: 1 !important; transform: none !important; }
  img.loading { opacity: 1 !important; }
}

/* ── 11. PRELOAD hint visual (LCP) ──────────────────────────── */
/* Hero image should never flash in — add aspect-ratio hold */
.hero__bg,
.section-hero__bg {
  background: var(--color-surface);
}

/* ── 12. SMOOTH SCROLL on non-reduced-motion ─────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ── 13. PRINT styles ───────────────────────────────────────── */
@media print {
  .site-header, .mobile-nav, .back-to-top,
  .scroll-progress, .hamburger, .theme-toggle,
  .lang-selector, .site-footer__socials,
  .gallery__arrow, .gallery__thumbs { display: none !important; }
  .gallery__main { position: static !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
}
