/* ===================================
   PHASE 3 - POLISH & ENHANCEMENTS
   Micro-interactions, Typography, Performance, A11y
   =================================== */

/* -----------------------------------
   Typography Enhancements
   ----------------------------------- */
:root {
  /* Enhanced type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  /* Line heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
}

/* Improved readability */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Better heading hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(2rem, 5vw, var(--text-5xl));
}

h2 {
  font-size: clamp(1.5rem, 4vw, var(--text-3xl));
}

h3 {
  font-size: clamp(1.25rem, 3vw, var(--text-2xl));
}

/* Improved paragraph spacing */
p {
  line-height: var(--leading-relaxed);
  margin-bottom: 1em;
}

p:last-child {
  margin-bottom: 0;
}

/* Better link styling */
a {
  transition: all 0.2s ease;
}

a:focus-visible {
  outline: 3px solid var(--honey);
  outline-offset: 3px;
  border-radius: 4px;
}

/* -----------------------------------
   Micro-interactions & Animations
   ----------------------------------- */

/* Button ripple effect */
.btn {
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

/* Scroll reveal animations */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

/* Apply animations with intersection observer */
.animate-on-scroll {
  opacity: 0;
  animation-duration: 0.8s;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.is-visible {
  animation-name: slideInUp;
}

.animate-on-scroll.slide-left.is-visible {
  animation-name: slideInLeft;
}

.animate-on-scroll.slide-right.is-visible {
  animation-name: slideInRight;
}

.animate-on-scroll.scale-in.is-visible {
  animation-name: scaleIn;
}

/* Stagger children animations */
.stagger-children > * {
  opacity: 0;
  animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

/* Number counter animation */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-number {
  animation: countUp 0.8s ease-out;
  will-change: transform, opacity;
}

/* Pulse animation for CTAs */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 217, 61, 0.7);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(255, 217, 61, 0);
  }
}

.btn-primary {
  animation: pulse 2s infinite;
}

.btn-primary:hover {
  animation: none;
}

/* Parallax effect for backgrounds */
.parallax-bg {
  will-change: transform;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card shine effect */
.card-shine {
  position: relative;
  overflow: hidden;
}

.card-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  bottom: -50%;
  left: -50%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%) translateY(-100%) rotate(45deg);
  transition: transform 0.8s;
}

.card-shine:hover::after {
  transform: translateX(100%) translateY(100%) rotate(45deg);
}

/* Loading shimmer */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(
    to right,
    #f0f0f0 0%,
    #f8f8f8 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 1000px 100%;
}

/* -----------------------------------
   Performance Optimizations
   ----------------------------------- */

/* Will-change for animated elements */
.hero-card,
.category-card,
.featured-card,
.testimonial-card,
.gallery-item,
.blog-card {
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .bee,
  .preview-card,
  .visual-card {
    animation: none !important;
  }
}

/* -----------------------------------
   Accessibility Enhancements
   ----------------------------------- */

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bee-black);
  color: var(--white);
  padding: 1rem 2rem;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  transition: top 0.3s;
}

.skip-to-main:focus {
  top: 0;
  outline: 3px solid var(--honey);
  outline-offset: 3px;
}

/* Focus visible styles */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--honey);
  outline-offset: 3px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --honey: #FFB700;
    --bee-black: #000000;
  }

  .btn {
    border: 2px solid currentColor;
  }
}

/* Dark mode support (future) */
@media (prefers-color-scheme: dark) {
  /* Placeholder for dark mode styles */
}

/* Focus trap for modals */
.focus-trap {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

/* -----------------------------------
   Interactive Elements
   ----------------------------------- */

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

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 0.5rem 1rem;
  background: var(--bee-black);
  color: var(--white);
  font-size: 0.875rem;
  white-space: nowrap;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bee-black);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
}

[data-tooltip]:hover::before {
  transform: translateX(-50%) translateY(-12px);
}

/* Badge pulse */
.badge-pulse {
  position: relative;
}

.badge-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  opacity: 0.6;
  animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.2);
    opacity: 0;
  }
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--honey) 0%, var(--soft-orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Glass morphism effect */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Smooth transitions for theme changes */
* {
  transition-property: color, background-color, border-color;
  transition-duration: 0.2s;
  transition-timing-function: ease-in-out;
}

/* Disable transitions during page load */
.preload * {
  transition: none !important;
}

/* -----------------------------------
   Print Styles
   ----------------------------------- */
@media print {
  .navbar,
  .footer,
  .newsletter-modern,
  .floating-bees,
  .honeycomb-bg,
  button {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  a {
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

/* -----------------------------------
   Utility Classes
   ----------------------------------- */

/* Visibility helpers */
.visible { visibility: visible; }
.invisible { visibility: hidden; }
.hidden { display: none; }

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Spacing utilities */
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* Display utilities */
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flex utilities */
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* Cursor utilities */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Select utilities */
.select-none { user-select: none; }

/* Image optimization */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[loading="lazy"] {
  content-visibility: auto;
}

/* Native lazy loading support */
img:not([src]) {
  visibility: hidden;
}
