/* ============================================================
   AllMyPeptides - Enhancement Styles
   Adds: animations, transitions, responsive improvements,
         accessibility enhancements, and polish
   ============================================================ */

/* ---- Page Transition Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes gentlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(37,99,235,0.15); }
  50% { box-shadow: 0 0 40px rgba(37,99,235,0.3); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(59,130,246,0.2); }
  50% { border-color: rgba(59,130,246,0.5); }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes heroGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Staggered entrance animation classes */
.entrance-fade-up {
  opacity: 0;
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.entrance-fade-up:nth-child(1) { animation-delay: 0.05s; }
.entrance-fade-up:nth-child(2) { animation-delay: 0.1s; }
.entrance-fade-up:nth-child(3) { animation-delay: 0.15s; }
.entrance-fade-up:nth-child(4) { animation-delay: 0.2s; }
.entrance-fade-up:nth-child(5) { animation-delay: 0.25s; }
.entrance-fade-up:nth-child(6) { animation-delay: 0.3s; }
.entrance-fade-up:nth-child(7) { animation-delay: 0.35s; }
.entrance-fade-up:nth-child(8) { animation-delay: 0.4s; }

/* Entrance variants */
.entrance-scale {
  opacity: 0;
  animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.entrance-slide-right {
  opacity: 0;
  animation: slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.entrance-slide-left {
  opacity: 0;
  animation: slideInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ---- Enhanced Glass Card ---- */
.glass-card-enhanced {
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  background-color: var(--color-surface, #0C0F1A);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.35s ease,
              box-shadow 0.35s ease;
  position: relative;
  overflow: hidden;
}

.glass-card-enhanced::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(59,130,246,0.03), transparent 60%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  border-radius: inherit;
}

.glass-card-enhanced:hover {
  transform: translateY(-8px);
  border-color: rgba(59,130,246,0.35);
  box-shadow: 0 24px 70px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.15), 0 0 50px rgba(59,130,246,0.12);
}

.glass-card-enhanced:hover::before {
  opacity: 1;
}

/* ---- Enhanced Button Styles ---- */
.btn-enhanced {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-enhanced::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-enhanced:hover::after {
  transform: translateX(100%);
}

.btn-enhanced:active {
  transform: scale(0.97);
}

/* ---- Glowing Border Effect ---- */
.glow-border {
  position: relative;
  animation: borderGlow 3s ease-in-out infinite;
}

.glow-border::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(59,130,246,0.4), rgba(20,184,166,0.3), rgba(59,130,246,0.4));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.glow-border:hover::after {
  opacity: 1;
}

/* ---- Smooth Image Loading ---- */
img {
  opacity: 1;
  transition: opacity 0.3s ease;
}

img[data-loading="true"] {
  opacity: 0;
  background: linear-gradient(90deg, rgba(12,15,26,0.8) 25%, rgba(17,24,39,0.6) 50%, rgba(12,15,26,0.8) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ---- Link Underline Animation ---- */
.link-underline {
  position: relative;
  display: inline-block;
}

.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #2563EB, #14B8A6);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.link-underline:hover::after {
  width: 100%;
}

/* ---- Floating Animation for decorative elements ---- */
.float-animation {
  animation: float 4s ease-in-out infinite;
}

.float-animation-delayed {
  animation: float 4s ease-in-out 1s infinite;
}

/* ---- Improved Focus States ---- */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}

/* ---- Typography Improvements ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Syne', sans-serif;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.2rem, 3vw, 1.8rem); }

p {
  max-width: 70ch;
  line-height: 1.7;
  margin-left: auto;
  margin-right: auto;
}

/* Hero section content — LEFT ALIGNED to match badges row below.
   The hero section uses min-h-[75dvh] as its distinguishing class. */
[class*="min-h-[75dvh]"] h1,
[class*="min-h-[75dvh]"] h2,
[class*="min-h-[75dvh]"] p {
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Buttons in hero: left-aligned */
[class*="min-h-[75dvh]"] a,
[class*="min-h-[75dvh]"] button {
  justify-content: flex-start !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* The left column of the hero grid: all content left-aligned */
[class*="grid-cols-[55%_45%]"] > div:first-child h1,
[class*="grid-cols-[55%_45%]"] > div:first-child p {
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

[class*="grid-cols-[55%_45%]"] > div:first-child a,
[class*="grid-cols-[55%_45%]"] > div:first-child button {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ---- Responsive Container Padding ---- */
.container-enhanced {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
}

/* ---- Mobile Improvements ---- */
@media (max-width: 768px) {
  html { font-size: 15px; }
  
  .glass-card-enhanced:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.4), 0 0 0 1px rgba(59,130,246,0.12);
  }
  
  .entrance-fade-up {
    animation-duration: 0.4s;
  }
  
  /* Touch-friendly tap targets */
  button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  
  h1 { font-size: clamp(1.75rem, 7vw, 2.5rem); }
  h2 { font-size: clamp(1.4rem, 6vw, 2rem); }
}

/* ---- Tablet Optimizations ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .container-enhanced {
    padding: 0 1.5rem;
  }
}

/* ---- Large Screen Optimizations ---- */
@media (min-width: 1536px) {
  .container-enhanced {
    max-width: 1400px;
  }
}

/* ---- Dark Mode Support (already dark, but ensure consistency) ---- */
@media (prefers-color-scheme: dark) {
  ::selection {
    background: rgba(37,99,235,0.4);
    color: #F8FAFC;
  }
}

/* ---- Print Styles ---- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .glass-card-enhanced,
  .glass-card {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
  a { color: #0066cc !important; text-decoration: underline !important; }
  h1, h2, h3 { color: #000 !important; }
}

/* ---- Status Indicators ---- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge-success { background: rgba(16,185,129,0.12); color: #10B981; }
.status-badge-warning { background: rgba(245,158,11,0.12); color: #F59E0B; }
.status-badge-info    { background: rgba(37,99,235,0.12); color: #3B82F6; }

/* ---- Scroll-Triggered Visibility ---- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* ---- Skeleton Loading ---- */
.skeleton {
  background: linear-gradient(90deg, rgba(17,24,39,0.8) 25%, rgba(30,41,59,0.6) 50%, rgba(17,24,39,0.8) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* ---- Tooltip Enhancement ---- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 6px 12px;
  background: #1e293b;
  color: #F8FAFC;
  font-size: 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
}

[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  .entrance-fade-up,
  .entrance-scale,
  .entrance-slide-right,
  .entrance-slide-left,
  .reveal,
  .float-animation,
  .float-animation-delayed,
  .glow-border {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  
  .glass-card-enhanced:hover,
  .btn-enhanced:hover,
  .link-underline:hover::after {
    transform: none !important;
  }
}

/* ---- AMP Rewards Section Text Alignment Fix ---- */
/* Fix text alignment in tier cards and rewards layout */
[class*="tier"] h3,
[class*="tier"] .tier-name,
[class*="tier-card"] h3 {
  text-align: left !important;
}

[class*="tier"] .tier-points,
[class*="tier"] [class*="points"],
[class*="tier-card"] [class*="points"] {
  text-align: left !important;
}

[class*="tier"] ul,
[class*="tier"] li,
[class*="tier-card"] ul,
[class*="tier-card"] li {
  text-align: left !important;
}

/* Fix the "How It Works" rewards section alignment */
[class*="rewards"] [class*="how-it-works"] h3,
[class*="rewards"] [class*="works"] h3 {
  text-align: left !important;
}

[class*="rewards"] [class*="how-it-works"] p,
[class*="rewards"] [class*="works"] p {
  text-align: left !important;
}

/* Ensure consistent card padding in rewards */
[class*="tier-card"],
[class*="tier"] {
  display: flex;
  flex-direction: column;
}

[class*="tier-card"] > *,
[class*="tier"] > * {
  width: 100%;
}

/* Fix any floating element alignment issues */
[class*="tier"] [class*="icon"],
[class*="tier"] [class*="badge"] {
  align-self: flex-start;
}

/* ---- Footer Fixes: Category Titles & Spacing ---- */
/* NOTE: Core footer layout fixes are patched directly in index-B-sPGeca.js.
   CSS below provides the missing Tailwind utility classes and fine-tuning. */

/* Missing Tailwind arbitrary-value classes for footer */
.text-\[11px\] {
  font-size: 11px !important;
}

.text-\[13px\] {
  font-size: 13px !important;
}

.tracking-\[0\.03em\] {
  letter-spacing: 0.03em !important;
}

.tracking-\[0\.08em\] {
  letter-spacing: 0.08em !important;
}

.min-w-\[80px\] {
  min-width: 80px !important;
}

.min-w-\[100px\] {
  min-width: 100px !important;
}

.space-y-0 > :not([hidden]) ~ :not([hidden]) {
  --tw-space-y-reverse: 0 !important;
  margin-top: calc(0px * calc(1 - var(--tw-space-y-reverse))) !important;
  margin-bottom: calc(0px * var(--tw-space-y-reverse)) !important;
}

/* Footer column titles: prevent cutting on desktop, handle mobile gracefully */
footer h3[class*="uppercase"][class*="font-syne"] {
  white-space: nowrap !important;
  overflow: visible !important;
  word-break: keep-all !important;
}

/* Reduce space between footer link items */
footer ul[class*="space-y"] > li > a {
  line-height: 1.35 !important;
  padding-top: 1px !important;
  padding-bottom: 1px !important;
  display: inline-block !important;
}

/* Footer column layout fixes for all breakpoints */
footer [class*="flex-1"][class*="flex-wrap"] > div {
  flex: 1 1 auto !important;
}

/* ===== MOBILE FOOTER FIXES ===== */
@media (max-width: 640px) {
  /* Footer category titles */
  footer h3[class*="uppercase"][class*="font-syne"] {
    font-size: 10px !important;
    letter-spacing: 0.04em !important;
    white-space: nowrap !important;
    margin-bottom: 0.4rem !important;
  }
  
  /* Footer columns: 3 per row with tight gaps */
  footer [class*="flex-1"][class*="flex-wrap"] {
    gap: 0.5rem !important;
    row-gap: 1rem !important;
  }
  
  footer [class*="flex-1"][class*="flex-wrap"] > div {
    min-width: 28% !important;
    flex: 1 1 28% !important;
    max-width: 34% !important;
  }

/* ===== MOBILE CART & BUTTON FIXES ===== */
@media (max-width: 640px) {
  /* Sort: Featured dropdown - box style */
  select[class*="appearance-none"],
  select[class*="sort"] {
    border-radius: 8px !important;
    padding: 8px 32px 8px 12px !important;
    font-size: 12px !important;
    min-height: 36px !important;
  }

  /* How It Works / Earn on Every Order boxes - consistent sizing */
  .grid-cols-1.sm\\:grid-cols-3 > div,
  [class*="grid-cols-1"][class*="sm:grid-cols-3"] > div {
    padding: 12px !important;
  }

  /* COA Quick View icon - ensure centered */
  [class*="rounded-xl"][class*="bg-amp-teal"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Cart saving line - bold green */
  .text-amp-green.font-bold {
    font-size: 14px !important;
  }

  /* Shipment Protection toggle - proper circle */
  button[class*="rounded-full"][class*="w-11"] {
    min-height: 24px !important;
    height: 24px !important;
  }

  /* Refer Friends box buttons */
  a[class*="rounded-lg"][class*="text-center"][class*="text-[11px]"] {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* ===== COA QUICK VIEW: center icon globally ===== */
[class*="rounded-xl"][class*="bg-amp-teal/10"] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ===== SHIPMENT PROTECTION TOGGLE FIX ===== */
button[class*="rounded-full"][class*="transition-colors"] {
  min-height: 24px !important;
  height: 24px !important;
  display: flex !important;
  align-items: center !important;
}

button[class*="rounded-full"][class*="transition-colors"] > div {
  width: 20px !important;
  height: 20px !important;
}

/* ---- Backdrop blur support check ---- */
@supports not (backdrop-filter: blur(10px)) {
  .glass-card-enhanced,
  .glass-card {
    background-color: rgba(12,15,26,0.98) !important;
  }
}

/* ===== CART SCROLLBAR: dark neutral instead of blue ===== */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.scrollbar-thin::-webkit-scrollbar {
  width: 4px;
}
.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.12);
  border-radius: 20px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255,255,255,0.2);
}

/* ===== MOBILE CART BADGE FIX ===== */
@media (max-width: 768px) {
  /* —— Header cart icon —— */
  button[data-cart-button="true"] {
    position: relative !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
  button[data-cart-button="true"] > span:last-child {
    position: absolute !important;
    top: -2px !important;
    right: 1px !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border: 2px solid #0a0a0a;
  }

  /* —— Header search + cart group —— */
  a[aria-label="Search products"],
  button[data-cart-button="true"] {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
  }
  a[aria-label="Search products"] {
    position: relative !important;
    left: 20px !important;
  }

  /* —— Bottom nav cart —— */
  nav[class*="bottom"] span[code-path*="MobileBottomNav.tsx:44:13"] {
    position: absolute !important;
    top: -5px !important;
    right: 2px !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 !important;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    border: 2px solid #0a0a0a;
  }
}
