/* ==========================================================================
   MADHAVTRADE — Premium Agro-Export Design System & Transitions
   Tailored for international commodity trade credibility: editorial,
   purposeful motion, refined typography, and high-trust aesthetics.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Root Variables & Global Polish
   -------------------------------------------------------------------------- */
:root {
  --color-cotton: #F5F0E6;
  --color-cotton-dark: #EDE5D3;
  --color-cream-card: #FBF8F1;
  --color-ink: #221C15;
  --color-ink-soft: #4A4138;
  --color-ink-faint: #6B6055;
  --color-turmeric: #C8801A;
  --color-turmeric-deep: #9C6314;
  --color-turmeric-light: #F4BA5E;
  --color-chilli: #A8341F;
  --color-chilli-deep: #7E2716;
  --color-banana: #5B7649;
  --color-banana-deep: #435838;
  --color-dal-gold: #B59456;
  --font-serif: "Source Serif 4", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth Scrolling & Typography Smoothing */
html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: #F0EAE0;
}
::-webkit-scrollbar-thumb {
  background: #D2C4B0;
  border-radius: 6px;
  border: 2px solid #F0EAE0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-turmeric);
}

/* Text Selection */
::selection {
  background: rgba(200, 128, 26, 0.22);
  color: var(--color-ink);
}

/* --------------------------------------------------------------------------
   Scroll Progress Indicator
   -------------------------------------------------------------------------- */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #C8801A 0%, #E29B2F 50%, #B59456 100%);
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 1px 6px rgba(200, 128, 26, 0.3);
  transition: width 0.08s linear;
}

/* --------------------------------------------------------------------------
   Header Transitions & Navigation Effects
   -------------------------------------------------------------------------- */
header.site-header {
  transition: padding 0.3s var(--ease-in-out), background-color 0.3s var(--ease-in-out), box-shadow 0.3s var(--ease-in-out), border-color 0.3s var(--ease-in-out);
}

header.site-header.scrolled {
  background-color: rgba(245, 240, 230, 0.94);
  box-shadow: 0 8px 24px -6px rgba(34, 28, 21, 0.08), 0 2px 6px -1px rgba(34, 28, 21, 0.04);
  border-bottom-color: rgba(34, 28, 21, 0.12);
}

/* Nav Link Editorial Underline Transition */
.nav-link {
  position: relative;
  transition: color 0.25s var(--ease-in-out);
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--color-turmeric);
  border-radius: 2px;
  transition: width 0.25s var(--ease-out-expo), left 0.25s var(--ease-out-expo);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
  left: 0;
}

.nav-link.active {
  color: var(--color-ink);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Buttons & Interactive Micro-Transitions
   -------------------------------------------------------------------------- */
.btn-primary {
  position: relative;
  overflow: hidden;
  transition: transform 0.28s var(--ease-out-expo), background-color 0.28s var(--ease-out-expo), box-shadow 0.28s var(--ease-out-expo);
  box-shadow: 0 3px 10px rgba(200, 128, 26, 0.25);
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  transform: skewX(-20deg);
  transition: left 0.75s ease;
  pointer-events: none;
}

.btn-primary:hover::after {
  left: 140%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(200, 128, 26, 0.38);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-secondary {
  position: relative;
  overflow: hidden;
  transition: all 0.25s var(--ease-out-expo);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  background-color: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.btn-secondary:active {
  transform: translateY(0) scale(0.97);
}

/* --------------------------------------------------------------------------
   Product Cards — Refined Tactile 3D & Specs Transition
   -------------------------------------------------------------------------- */
.product-card-3d {
  perspective: 1400px;
  -webkit-perspective: 1400px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.product-card-inner {
  transition: transform 0.7s cubic-bezier(0.2, 0.85, 0.3, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  position: relative;
  width: 100%;
  height: 100%;
}

.product-card-3d:hover .product-card-inner,
.product-card-3d.flipped .product-card-inner {
  transform: rotateY(180deg);
}

.product-card-front,
.product-card-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 1.25rem;
  overflow: hidden;
}

.product-card-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

/* Front card zoom on hover */
.product-card-3d:hover .product-card-front img {
  transform: scale(1.05);
}

.product-card-front img {
  transition: transform 0.8s var(--ease-out-expo);
}

/* --------------------------------------------------------------------------
   Interactive Step / Process Connectors
   -------------------------------------------------------------------------- */
.process-step-card {
  transition: transform 0.3s var(--ease-out-expo), box-shadow 0.3s var(--ease-out-expo), border-color 0.3s var(--ease-out-expo);
}

.process-step-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 28px -6px rgba(34, 28, 21, 0.1);
  border-color: rgba(200, 128, 26, 0.4);
}

.process-step-card:hover .step-badge {
  background-color: var(--color-turmeric);
  color: #FFFFFF;
}

.step-badge {
  transition: background-color 0.25s var(--ease-out-expo), color 0.25s var(--ease-out-expo);
}

/* --------------------------------------------------------------------------
   Global Trade Route Map — Vector Animations, Tooltips & Telemetry HUD
   -------------------------------------------------------------------------- */
.shipping-route-line {
  stroke-dasharray: 6 5;
  animation: dashRoute 6s linear infinite;
  transition: stroke 0.3s ease, stroke-width 0.3s ease, opacity 0.3s ease;
}

@keyframes dashRoute {
  from {
    stroke-dashoffset: 44;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.shipping-route-line.dimmed-route {
  opacity: 0.12 !important;
  stroke: rgba(255, 255, 255, 0.2) !important;
}

.shipping-route-line.highlighted-route {
  stroke: #F4BA5E !important;
  stroke-width: 2.8px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 6px rgba(200, 128, 26, 0.9));
  animation: dashRoute 2.2s linear infinite;
}

.vessel-packet {
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.vessel-packet.dimmed-packet {
  opacity: 0.08 !important;
}

.vessel-packet.highlighted-packet {
  opacity: 1 !important;
  filter: drop-shadow(0 0 8px rgba(244, 186, 94, 0.95));
}

.origin-node,
.port-node {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.port-node.dimmed-port {
  opacity: 0.25 !important;
}

.port-node circle {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.25s var(--ease-out-expo), fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

.port-node:hover circle,
.port-node.active-port circle {
  transform: scale(1.6);
  fill: #FFFFFF !important;
  stroke: #F4BA5E !important;
  filter: drop-shadow(0 0 10px rgba(244, 186, 94, 0.95));
}

.port-node text {
  transition: fill 0.25s ease, opacity 0.25s ease;
}

.port-node:hover text,
.port-node.active-port text {
  fill: #F4BA5E !important;
}

.maritime-tab {
  cursor: pointer;
  user-select: none;
}

.maritime-tab.active {
  background: var(--color-turmeric) !important;
  border-color: var(--color-turmeric) !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 14px rgba(200, 128, 26, 0.4);
}

/* Port Interactive Tooltip */
.map-port-tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(4px);
  transition: opacity 0.2s var(--ease-out-expo), transform 0.2s var(--ease-out-expo);
  z-index: 30;
}

.map-port-tooltip.active {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-10px);
}

/* --------------------------------------------------------------------------
   Social Proof Marquee (Ticker) — Smooth & Respectful
   -------------------------------------------------------------------------- */
.trade-ticker-container {
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
}

.trade-ticker-track {
  display: flex;
  width: max-content;
  animation: tradeMarquee 38s linear infinite;
}

.trade-ticker-track:hover {
  animation-play-state: paused;
}

@keyframes tradeMarquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* --------------------------------------------------------------------------
   Card Lift & Feature Tile Effects
   -------------------------------------------------------------------------- */
.feature-card {
  transition: transform 0.35s var(--ease-out-expo), box-shadow 0.35s var(--ease-out-expo), border-color 0.35s ease;
  will-change: transform, box-shadow;
}

.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px -8px rgba(34, 28, 21, 0.12), 0 4px 12px rgba(200, 128, 26, 0.08);
  border-color: rgba(200, 128, 26, 0.45);
}

/* --------------------------------------------------------------------------
   Global Scroll Reveal System
   -------------------------------------------------------------------------- */
.scroll-reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.scroll-reveal.visible,
.no-js .scroll-reveal {
  opacity: 1;
  transform: translateY(0);
}

html.gsap-active .scroll-reveal {
  transition: none !important;
}

/* Stagger delay utilities */
.stagger-1 { transition-delay: 80ms; }
.stagger-2 { transition-delay: 160ms; }
.stagger-3 { transition-delay: 240ms; }
.stagger-4 { transition-delay: 320ms; }
.stagger-5 { transition-delay: 400ms; }
.stagger-6 { transition-delay: 480ms; }

/* --------------------------------------------------------------------------
   Floating Badges & Micro-Animations
   -------------------------------------------------------------------------- */
@keyframes badgeFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.badge-float {
  animation: badgeFloat 4s ease-in-out infinite;
}

@keyframes pulseBadge {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(200, 128, 26, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(200, 128, 26, 0);
  }
}

.pulse-badge {
  animation: pulseBadge 2.8s infinite;
}

/* Section Heading Accent Line Reveal */
.heading-accent {
  position: relative;
  display: inline-block;
}

.heading-accent::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 44px;
  height: 3px;
  background: var(--color-turmeric);
  border-radius: 2px;
  transition: width 0.45s var(--ease-out-expo);
}

.heading-accent:hover::after {
  width: 100%;
}

/* Image Zoom on Hover Container */
.img-zoom-hover {
  overflow: hidden;
}

.img-zoom-hover img {
  transition: transform 0.75s var(--ease-out-expo);
}

.img-zoom-hover:hover img {
  transform: scale(1.06);
}

/* Form inputs micro-interactions */
input, select, textarea {
  transition: border-color 0.25s var(--ease-out-expo), box-shadow 0.25s var(--ease-out-expo), transform 0.25s var(--ease-out-expo);
}

input:focus, select:focus, textarea:focus {
  transform: translateY(-1px);
  border-color: var(--color-turmeric) !important;
  box-shadow: 0 0 0 3px rgba(200, 128, 26, 0.16) !important;
}

/* --------------------------------------------------------------------------
   Back to Top Button
   -------------------------------------------------------------------------- */
#back-to-top {
  position: fixed;
  bottom: 24px;
  right: 88px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--color-ink);
  border: 1px solid rgba(34, 28, 21, 0.12);
  box-shadow: 0 4px 14px rgba(34, 28, 21, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 190;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.9);
  transition: opacity 0.3s var(--ease-out-expo), visibility 0.3s var(--ease-out-expo), transform 0.3s var(--ease-out-expo), background-color 0.2s, color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

#back-to-top:hover {
  background: var(--color-turmeric);
  color: #FFFFFF;
  border-color: var(--color-turmeric);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(200, 128, 26, 0.3);
}

/* --------------------------------------------------------------------------
   Floating WhatsApp Button Micro-Interactions & Ambient Pulse
   -------------------------------------------------------------------------- */
@keyframes waRhythmPulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 6px 18px rgba(31, 168, 85, 0.36);
  }
  50% {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 26px rgba(31, 168, 85, 0.52), 0 0 0 8px rgba(31, 168, 85, 0.16);
  }
}

.whatsapp-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  animation: waRhythmPulse 3.2s ease-in-out infinite;
  transition: transform 0.25s var(--ease-out-expo), box-shadow 0.25s var(--ease-out-expo);
  box-shadow: 0 6px 18px rgba(31, 168, 85, 0.35);
}

.whatsapp-fab:hover {
  animation: none;
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 12px 28px rgba(31, 168, 85, 0.55);
}

.whatsapp-fab:active {
  transform: translateY(0) scale(0.96);
}

/* --------------------------------------------------------------------------
   Accordion Transitions (FAQs / Trade Inquiries)
   -------------------------------------------------------------------------- */
.faq-accordion-item {
  border-bottom: 1px solid rgba(34, 28, 21, 0.1);
  transition: background-color 0.2s;
}

.faq-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  text-align: left;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--color-ink);
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s;
}

.faq-header:hover {
  color: var(--color-turmeric-deep);
}

.faq-chevron {
  transition: transform 0.3s var(--ease-out-expo);
  flex-shrink: 0;
}

.faq-accordion-item.open .faq-chevron {
  transform: rotate(180deg);
}

.faq-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0, 1, 0, 1);
  color: var(--color-ink-soft);
  font-size: 0.95rem;
  line-height: 1.65;
}

.faq-accordion-item.open .faq-content {
  max-height: 500px;
  transition: max-height 0.4s ease-in-out;
}

/* --------------------------------------------------------------------------
   Mobile-First Responsiveness & Cross-Device Hardening
   -------------------------------------------------------------------------- */

/* Global container overflow guard */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* Ensure no text content or codes force horizontal viewport expansion */
p, span, a, h1, h2, h3, h4, h5, h6, td, th, li, div {
  overflow-wrap: break-word;
}

.break-words-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Mobile Nav Drawer Hardening */
#mobile-nav {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background-color: rgba(34, 28, 21, 0.98);
}

#nav-toggle {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#nav-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile Touch & Form Inputs (Prevents iOS Safari auto-zoom on focus) */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Responsive Floating Elements (No overlap on 320px - 640px) */
@media (max-width: 640px) {
  .whatsapp-fab {
    bottom: 16px !important;
    right: 16px !important;
    width: 48px !important;
    height: 48px !important;
  }
  .whatsapp-fab svg {
    width: 24px !important;
    height: 24px !important;
  }
  #back-to-top {
    bottom: 16px !important;
    right: 72px !important;
    width: 40px !important;
    height: 40px !important;
  }
  .arx-badge {
    bottom: 12px !important;
    left: 12px !important;
    max-width: calc(100vw - 128px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 8.5px !important;
    padding: 2px 8px !important;
  }
}

/* Ultra-Compact Screens (320px - 380px) */
@media (max-width: 380px) {
  .site-header .h-16 {
    height: 3.75rem;
  }
  .site-header img {
    width: 38px !important;
    height: 38px !important;
  }
  .site-header .font-display {
    font-size: 1.15rem !important;
  }
  .hero-animate-in {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  .hero-animate-in span.font-mono {
    font-size: 9.5px !important;
    letter-spacing: 0.08em !important;
  }
  #back-to-top {
    right: 68px !important;
  }
}

/* Responsive Product 3D Flip Card sizing on small devices */
@media (max-width: 480px) {
  .product-card-3d {
    height: 480px !important;
  }
  .product-card-front,
  .product-card-back {
    padding: 1.15rem !important;
  }
  .product-card-back {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .product-card-back .space-y-2\.5 {
    gap: 0.4rem;
  }
  .product-card-back .font-display {
    font-size: 19px !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.75rem !important;
  }
}

/* Table and specs scroll safety */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Horizontal scrollbar hiding for swipe containers */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --------------------------------------------------------------------------
   Accessible Reduced Motion
   -------------------------------------------------------------------------- */
@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;
  }
  .trade-ticker-track {
    animation: none;
    transform: none;
  }
}

