/**
 * ASEAN–Hong Kong Collective Mark Initiative
 * Component Styles & Micro-Animations
 */

/* Custom Typography Fallbacks */
body {
  background-color: var(--color-cream);
  color: var(--color-charcoal);
  font-family: var(--font-sans);
}

h1, h2, h3, .font-serif {
  font-family: var(--font-serif);
}

/* Custom Smooth Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-cream);
}

::-webkit-scrollbar-thumb {
  background: var(--color-sage);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-forest);
}

/* Authentic Southeast Asian Woven Motif Pattern (Subtle Opacity) */
.woven-pattern {
  background-image: 
    radial-gradient(var(--color-harvest) 0.8px, transparent 0.8px), 
    radial-gradient(var(--color-harvest) 0.8px, var(--color-forest) 0.8px);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
  opacity: 0.08;
}

.woven-pattern-light {
  background-image: 
    radial-gradient(var(--color-sage) 0.8px, transparent 0.8px),
    radial-gradient(var(--color-terracotta) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  opacity: 0.12;
}

/* Modal Backdrop & Transitions */
.modal-backdrop {
  transition: opacity 0.25s ease-in-out;
}

.modal-content {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-in-out;
}

/* Interactive Card Elevation & Tactile Micro-interactions */
.country-card, .product-card {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
  will-change: transform, box-shadow;
}

.country-card:hover, .product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 25px -5px rgba(24, 60, 46, 0.14), 0 8px 10px -6px rgba(24, 60, 46, 0.08);
  border-color: rgba(212, 162, 76, 0.6); /* Warm Harvest Gold border glow */
}

/* Scroll-Driven Reveal Animations (Zero External Dependencies) */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-on-scroll.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 80ms; }
.reveal-delay-2 { transition-delay: 160ms; }
.reveal-delay-3 { transition-delay: 240ms; }
.reveal-delay-4 { transition-delay: 320ms; }

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .country-card:hover, .product-card:hover {
    transform: none !important;
  }
  .animate-float-slow, .animate-float-reverse {
    animation: none !important;
  }
}

/* Line Clamp Utilities */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Ambient Lighting & Depth */
.hero-ambient-bg {
  background-color: var(--color-forest);
  background-image: 
    radial-gradient(circle at 85% 18%, rgba(212, 162, 76, 0.28) 0%, transparent 48%),
    radial-gradient(circle at 15% 85%, rgba(31, 75, 143, 0.22) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(24, 60, 46, 0.7) 0%, var(--color-forest) 100%);
}

.country-card.active {
  border-color: var(--color-harvest) !important;
  box-shadow: 0 0 0 2px var(--color-harvest), 0 20px 25px -5px rgba(212, 162, 76, 0.25) !important;
  transform: translateY(-4px);
}

/* Floating Animation Utility */
@keyframes float-slow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}

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

.animate-float-slow {
  animation: float-slow 5s ease-in-out infinite;
}

.animate-float-reverse {
  animation: float-reverse 6s ease-in-out infinite;
}

/* 3D Book Publication Styling */
.book-cover-3d {
  box-shadow: -8px 0 16px -3px rgba(0, 0, 0, 0.3), 12px 18px 28px -5px rgba(24, 60, 46, 0.22);
  position: relative;
}

.book-cover-3d::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.25) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(0, 0, 0, 0.15) 100%);
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
  z-index: 5;
  pointer-events: none;
}

/* Aspect Ratio Native Utility */
.aspect-\[4\/3\] {
  aspect-ratio: 4 / 3;
}

/* 3D Flipbook Viewer Engine */
.flipbook-stage {
  perspective: 2500px;
  transform-style: preserve-3d;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto; /* Enable smooth scrolling when zoomed in for high readability */
  user-select: none;
  padding: 6px 8px;
}

.flipbook-spread {
  display: flex;
  position: relative;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
  margin: auto;
  cursor: grab;
  touch-action: pan-y; /* Preserves vertical scroll, delegates horizontal drag to page turn */
  user-select: none;
}

.flipbook-spread.is-dragging {
  cursor: grabbing !important;
  transition: none !important; /* Real-time 60fps tracking without lag */
}

.flipbook-spread.is-springing {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease !important;
}

/* Corner Dog-Ear Curl Hint */
.corner-curl-hint {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, transparent 50%, rgba(212, 162, 76, 0.4) 50%, rgba(212, 162, 76, 0.8) 100%);
  border-bottom-left-radius: 12px;
  box-shadow: -2px 2px 6px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  z-index: 28;
  transition: all 0.25s ease;
  pointer-events: auto;
}

.corner-curl-hint:hover {
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, transparent 50%, rgba(212, 162, 76, 0.6) 50%, #D4A24C 100%);
  box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.28);
}

.corner-curl-hint-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  background: linear-gradient(225deg, transparent 50%, rgba(212, 162, 76, 0.4) 50%, rgba(212, 162, 76, 0.8) 100%);
  border-bottom-right-radius: 12px;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  z-index: 28;
  transition: all 0.25s ease;
  pointer-events: auto;
}

.corner-curl-hint-left:hover {
  width: 58px;
  height: 58px;
  background: linear-gradient(225deg, transparent 50%, rgba(212, 162, 76, 0.6) 50%, #D4A24C 100%);
  box-shadow: 4px 4px 14px rgba(0, 0, 0, 0.28);
}

/* Dynamic Drag Paper Shadow */
.drag-shadow-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0.35) 0%, transparent 60%);
  opacity: 0;
  z-index: 26;
  border-radius: inherit;
  transition: opacity 0.25s ease;
}

.is-dragging .drag-shadow-overlay {
  transition: none;
}

.flipbook-spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, 
    rgba(0, 0, 0, 0.22) 0%, 
    rgba(0, 0, 0, 0.05) 35%, 
    rgba(0, 0, 0, 0.02) 50%, 
    rgba(0, 0, 0, 0.05) 65%, 
    rgba(0, 0, 0, 0.22) 100%
  );
  z-index: 25;
  pointer-events: none;
}

.flipbook-page-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  overflow: hidden;
}

.flipbook-page-slot canvas {
  display: block;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.03);
}

/* Fullscreen Theater Mode */
.modal-theater {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
}

/* 3D Turning Page Effect */
.flipbook-turner {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  z-index: 30;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.flipbook-turner.turn-forward {
  right: 0;
  transform-origin: left center;
}

.flipbook-turner.turn-forward.flipping {
  transform: rotateY(-180deg);
}

.flipbook-turner.turn-backward {
  left: 0;
  transform-origin: right center;
}

.flipbook-turner.turn-backward.flipping {
  transform: rotateY(180deg);
}

.flipbook-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.flipbook-face.back {
  transform: rotateY(180deg);
}

.flipbook-shadow-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to right, rgba(0,0,0,0.2), transparent);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.flipping .flipbook-shadow-overlay {
  opacity: 1;
}

/* 3D Bookshelf Styling */
.bookshelf-shelf {
  position: relative;
  background: linear-gradient(180deg, #bfa068 0%, #8b682e 50%, #5c4418 100%);
  height: 18px;
  border-radius: 4px;
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.4), inset 0 2px 3px rgba(255, 255, 255, 0.35);
  margin-top: -8px;
  z-index: 10;
}

.bookshelf-shelf::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 2px;
  right: 2px;
  height: 6px;
  background: #d4a24c;
  transform: perspective(60px) rotateX(30deg);
  border-radius: 3px 3px 0 0;
  opacity: 0.85;
}

.bookshelf-card {
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
  transform-origin: bottom center;
}

@media (max-width: 639px) {
  .book-cover-3d::before {
    width: 10px;
  }
  .bookshelf-card {
    aspect-ratio: 1 / 1.45;
    min-height: 250px;
    border-radius: 14px;
  }
}

.bookshelf-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.35);
}

/* Floating Side Navigation Buttons (DearFlip Style) */
.flipbook-side-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(24, 60, 46, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #D4A24C;
  border: 1.5px solid rgba(212, 162, 76, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.55), 0 0 16px rgba(212, 162, 76, 0.25);
  cursor: pointer;
  z-index: 45;
  transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flipbook-side-btn:hover:not(:disabled) {
  background: #183C2E;
  border-color: #D4A24C;
  color: #F8F3E8;
  transform: translateY(-50%) scale(1.14);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.65), 0 0 24px rgba(212, 162, 76, 0.5);
}

.flipbook-side-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.94);
}

.flipbook-side-btn:disabled,
.flipbook-side-btn.is-disabled {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
}

.flipbook-side-btn-prev {
  left: 12px;
}

.flipbook-side-btn-next {
  right: 12px;
}

@media (max-width: 640px) {
  .flipbook-side-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }
  .flipbook-side-btn-prev {
    left: 4px;
  }
  .flipbook-side-btn-next {
    right: 4px;
  }
}

/* Sound Effect Pulse Indicator */
@keyframes soundPulseAnim {
  0% { transform: scale(1); filter: drop-shadow(0 0 0px #D4A24C); }
  50% { transform: scale(1.35); filter: drop-shadow(0 0 8px #D4A24C); color: #D4A24C; }
  100% { transform: scale(1); filter: drop-shadow(0 0 0px transparent); }
}

.sound-pulsing {
  animation: soundPulseAnim 0.35s ease-out;
}

/* Realistic 3D Page Turn Keyframes */
@keyframes pageTurnForwardAnim {
  0% {
    transform: perspective(2200px) rotateY(0deg);
  }
  40% {
    transform: perspective(2200px) rotateY(-18deg) skewY(-2deg) scale(0.975);
    box-shadow: 24px 28px 50px -8px rgba(0, 0, 0, 0.55);
  }
  100% {
    transform: perspective(2200px) rotateY(0deg);
  }
}

@keyframes pageTurnBackwardAnim {
  0% {
    transform: perspective(2200px) rotateY(0deg);
  }
  40% {
    transform: perspective(2200px) rotateY(18deg) skewY(2deg) scale(0.975);
    box-shadow: -24px 28px 50px -8px rgba(0, 0, 0, 0.55);
  }
  100% {
    transform: perspective(2200px) rotateY(0deg);
  }
}

.page-flipping-forward {
  animation: pageTurnForwardAnim 0.42s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.page-flipping-backward {
  animation: pageTurnBackwardAnim 0.42s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}


