/* ============================================================
   AG54 — UX Enhancement CSS
   Add this via <link> AFTER styles.css on every storefront page:
   <link rel="stylesheet" href="/storefront/styles-ux.css">
   ============================================================ */


/* ── 1. ANTI-FOWT — apply saved theme before paint ────────────────────────
   Add this INLINE in <head> before any stylesheet:

   <script>
     (function(){
       var t = localStorage.getItem('ag54-theme') || 'dark';
       document.documentElement.setAttribute('data-theme', t);
     })();
   </script>

   This prevents the flash of wrong theme on page load.
   ─────────────────────────────────────────────────────────────────────── */


/* ── 2. NAV — persistent active underline ──────────────────────────────── */
.nav-link.active::after {
  width: 100%;
}
.nav-link.active {
  color: var(--color-text);
}

/* Header gradient so nav links stay readable on light hero images */
.site-header:not(.scrolled) {
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 10, 0.55) 0%,
    rgba(10, 10, 10, 0.0) 100%
  );
}
[data-theme="light"] .site-header:not(.scrolled) {
  background: linear-gradient(
    to bottom,
    rgba(245, 240, 232, 0.7) 0%,
    rgba(245, 240, 232, 0.0) 100%
  );
}


/* ── 3. MOBILE NAV — close button ──────────────────────────────────────── */
.mobile-nav__close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-interactive), background var(--transition-interactive);
  z-index: 102;
}
.mobile-nav__close:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .mobile-nav__close:hover {
  background: rgba(0, 0, 0, 0.06);
}


/* ── 4. PRODUCT CARDS — always visible on touch ─────────────────────────── */

/* Touch devices: always show overlay */
@media (hover: none) {
  .product-card__overlay {
    opacity: 1;
    background: linear-gradient(to top, rgba(10,10,10,0.85) 0%, rgba(10,10,10,0.0) 60%);
  }
}

/* Image loading shimmer */
@keyframes ag54-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.img-loading .product-card__image,
.img-loading .editorial-card__image {
  background: linear-gradient(
    90deg,
    var(--color-surface)       25%,
    var(--color-surface-2)     50%,
    var(--color-surface)       75%
  );
  background-size: 200% 100%;
  animation: ag54-shimmer 1.4s ease-in-out infinite;
}

/* Product card as link */
a.product-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
a.product-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

/* Size pills on product cards */
.product-card__sizes {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}
.product-card__size {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 241, 232, 0.3);
  color: rgba(245, 241, 232, 0.7);
  cursor: pointer;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.product-card__size:hover,
.product-card__size.selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
}


/* ── 5. FOCUS RINGS — keyboard accessibility ────────────────────────────── */
.filter-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}
.btn:focus-visible,
.nav-link:focus-visible,
.social-link:focus-visible,
.theme-toggle:focus-visible,
.hamburger:focus-visible,
.mobile-nav__close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}


/* ── 6. PRE-ORDER MODAL ─────────────────────────────────────────────────── */
#ag54-preorder-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) {
  #ag54-preorder-modal {
    align-items: center;
  }
}
.po-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.po-panel {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-10) var(--space-8) var(--space-8);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: po-slide-up 250ms var(--ease-out);
}
@media (min-width: 640px) {
  .po-panel {
    border-radius: var(--radius-xl);
    max-height: none;
    animation: po-fade-in 200ms var(--ease-out);
  }
}
@keyframes po-slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes po-fade-in {
  from { transform: scale(0.97); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.po-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  font-size: 22px;
  color: var(--color-text-muted);
  background: none; border: none; cursor: pointer;
  transition: color var(--transition-interactive), background var(--transition-interactive);
}
.po-close:hover { color: var(--color-text); background: var(--color-surface-2); }
.po-eyebrow {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.po-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.po-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}
.po-field { margin-bottom: var(--space-4); }
.po-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.po-input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive);
  font-family: var(--font-body);
}
.po-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
}
.po-err {
  display: block;
  font-size: var(--text-xs);
  color: #E05C5C;
  margin-top: var(--space-1);
  min-height: 16px;
}
.po-submit {
  display: block;
  width: 100%;
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-interactive), transform var(--transition-interactive);
}
.po-submit:hover { background: var(--color-accent-hover); transform: translateY(-1px); }
.po-submit:active { transform: translateY(0); }
.po-legal {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-3);
  line-height: 1.5;
}
.po-success {
  text-align: center;
  padding: var(--space-8) 0;
}
.po-tick {
  width: 56px; height: 56px;
  border-radius: var(--radius-full);
  background: rgba(61, 191, 122, 0.12);
  border: 2px solid #3DBF7A;
  color: #3DBF7A;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-4);
}
.po-success h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}
.po-success p { color: var(--color-text-muted); font-size: var(--text-sm); }
.po-success a { color: var(--color-accent); text-decoration: none; }


/* ── 7. OG IMAGE — preorder button variant ──────────────────────────────── */
.btn-preorder {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border: none;
  cursor: pointer;
}
.btn-preorder:hover { background: var(--color-accent-hover); }


/* ── 8. CONTACT FORM — validation errors ────────────────────────────────── */
.form-error {
  display: block;
  font-size: var(--text-xs);
  color: #E05C5C;
  margin-top: var(--space-1);
}
.input.invalid {
  border-color: #E05C5C;
}
.input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(224, 92, 92, 0.15);
}


/* ── 9. NEWSLETTER SECTION — enhanced ──────────────────────────────────── */
.newsletter-section {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  margin: var(--space-16) auto 0;
  max-width: 640px;
}
.newsletter-section .section__eyebrow { margin-bottom: var(--space-3); }
.newsletter-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-3);
}
.newsletter-section p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}
.newsletter-success {
  color: #3DBF7A;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-top: var(--space-3);
  display: none;
}


/* ── 10. RESPONSIVE PRODUCT CARD improvements ───────────────────────────── */
@media (max-width: 480px) {
  .product-card__name { font-size: var(--text-base); }
  .product-card__overlay { padding: var(--space-4); }
}
