/* =========================================================
   WRW Trailers — custom styles & animations
   (fine-tuning on top of Tailwind CDN utility classes)
========================================================= */

/* overflow-x on html too: iOS Safari ignores it on body alone and
   lets the whole page drift sideways. clip (where supported) does it
   without turning body into a scroll container. */
html {
  scroll-behavior: smooth;
  --ticker-height: 44px;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  overflow-x: clip;
  position: relative;
  /* Room at the bottom so the fixed news ticker never covers the footer. */
  padding-bottom: var(--ticker-height);
}

/* ---------- News ticker (fixed above everything, scrolling marquee) ---------- */
.ticker-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: var(--ticker-height);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  width: max-content;
  animation: ticker-scroll 45s linear infinite;
}

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

.ticker-item {
  flex-shrink: 0;
  white-space: nowrap;
  padding-right: 3rem;
  color: #ecfdf5;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ticker-item a {
  color: #ffffff;
  font-weight: 700;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    animation: none;
  }
}

/* ---------- Sticky header shadow on scroll ---------- */
#site-header.scrolled {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

/* ---------- Nav links ---------- */
.nav-link {
  position: relative;
  transition: color 0.2s ease;
}

/* ---------- Language flag buttons ---------- */
.flag-btn {
  font-size: 1.15rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  cursor: pointer;
  background: transparent;
  border: none;
  opacity: 0.45;
  transform: scale(0.92);
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.flag-btn:hover {
  opacity: 0.8;
}

.flag-btn.active {
  opacity: 1;
  transform: scale(1.08);
  background-color: rgba(240, 196, 25, 0.15);
  box-shadow: 0 0 0 2px rgba(240, 196, 25, 0.4);
}

/* ---------- Hero background ---------- */
/* Flat dark fallback only (no illustration) — this shows only in the
   split second before the video paints, or if it fails to load. */
.hero-bg {
  background-color: #14171c;
  position: relative;
  overflow: hidden;
}

/* Plain CSS (not dependent on Tailwind utility classes) so the video
   still fills the hero correctly even if the Tailwind CDN script
   fails to load — e.g. no internet connection. Without this, the
   video loses its "absolute inset-0 w-full h-full object-cover"
   sizing and the flat background above would show through beside it. */
.hero-bg > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Hero text legibility ----------
   The video overlay is intentionally light now, so the title and
   subtitle need their own contrast boost to stay readable over
   bright frames (sunny water, white boats, etc.). */
.hero-text-shadow {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ---------- Hero sound toggle ----------
   Top-right corner of the hero video, out of the way of the
   bottom-right button stack (chat, back-to-top). */
#hero-sound-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
}

/* Desktop/tablet: back inside the hero (.hero-bg is relative), so it
   isn't hidden behind the fixed header or left floating over the page. */
@media (min-width: 640px) {
  #hero-sound-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
  }
}

/* ---------- Hero video reveal ----------
   The video starts clipped to a small centered window and slowly
   opens outward on load, like a shutter/iris revealing the shot. */
@keyframes heroVideoReveal {
  0% {
    clip-path: inset(32% 40% 32% 40%);
  }
  100% {
    clip-path: inset(0% 0% 0% 0%);
  }
}

.hero-video-reveal {
  clip-path: inset(32% 40% 32% 40%);
  animation: heroVideoReveal 3.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: 0.15s;
}

@media (prefers-reduced-motion: reduce) {
  .hero-video-reveal {
    animation: none;
    clip-path: none;
  }
}

/* ---------- Wave pattern overlay (Why Choose WRW) ---------- */
.wave-pattern {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cpath d='M0 20 Q30 0 60 20 T120 20' stroke='white' fill='none' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ---------- Trailer icon hover ---------- */
.trailer-icon {
  transition: transform 0.35s ease;
}

.group:hover .trailer-icon {
  transform: translateY(-4px) scale(1.03);
}

/* ---------- Fade-in-up entrance ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.8s ease-out both;
}

/* ---------- Reveal-on-scroll utility (toggled via JS) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Mobile menu animation ---------- */
#mobile-menu {
  animation: fadeInUp 0.25s ease-out both;
}

/* ---------- Form success message ---------- */
#form-success {
  animation: fadeInUp 0.4s ease-out both;
}

/* ---------- WhatsApp floating button ---------- */
/* On phones, WhatsApp + chat live in the hero's mobile action bar
   instead of floating over the video — avoids the cluttered stack
   of overlapping buttons on small screens. */
#whatsapp-btn {
  position: fixed;
  left: 1.25rem;
  bottom: calc(1.25rem + var(--ticker-height));
  z-index: 50;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background-color: #25d366;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
  transition: transform 0.2s ease, background-color 0.2s ease;
  animation: whatsappPulse 2.4s ease-in-out infinite;
}

#whatsapp-btn:hover {
  background-color: #1ebe5d;
  transform: scale(1.08);
  animation-play-state: paused;
}

@keyframes whatsappPulse {
  0%, 100% {
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45), 0 0 0 0 rgba(37, 211, 102, 0.45);
  }
  50% {
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45), 0 0 0 10px rgba(37, 211, 102, 0);
  }
}

@media (min-width: 640px) {
  #whatsapp-btn {
    left: 2rem;
    bottom: calc(2rem + var(--ticker-height));
  }
}

/* ---------- Back to top button ---------- */
#back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + var(--ticker-height));
  z-index: 50;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  background-color: #0d9488;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease, visibility 0.3s;
}

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

#back-to-top:hover {
  background-color: #f0c419;
  color: #14171c;
}

@media (min-width: 640px) {
  #back-to-top {
    right: 2rem;
    bottom: calc(2rem + var(--ticker-height));
  }
}

/* ---------- Frame (Industrial Heritage) ----------
   A clean rectangle outline in WR Big Rig's brand green, sampled
   from their logo, to visually set that block apart from the rest
   of the page as its own callout. */
.sketch-frame {
  border: 3px solid #84c341;
}

/* ---------- AI chat widget ----------
   Bottom-left corner, stacked above the WhatsApp button on the
   same axis. Dark Metallic panel with WR Big Rig's industrial
   green as the accent. Hidden by default (feature-flagged in
   app.js) until it's tested and approved to go live. */
#ai-chat-btn {
  position: fixed;
  left: 1.25rem;
  bottom: calc(1.25rem + var(--ticker-height) + 68px);
  z-index: 50;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  background-color: #84c341;
  color: #14171c;
  box-shadow: 0 6px 18px rgba(132, 195, 65, 0.45);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

#ai-chat-btn:hover {
  background-color: #71a836;
  transform: scale(1.08);
}

@media (min-width: 640px) {
  #ai-chat-btn {
    left: 2rem;
    bottom: calc(2rem + var(--ticker-height) + 68px);
  }
}

#ai-chat-panel {
  position: fixed;
  left: 1.25rem;
  bottom: calc(1.25rem + var(--ticker-height) + 136px);
  z-index: 55;
  width: min(340px, calc(100vw - 2.5rem));
  max-height: min(480px, calc(100vh - 220px));
  display: flex;
  flex-direction: column;
  background-color: #1f2530;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

#ai-chat-panel[hidden] {
  display: none;
}

@media (min-width: 640px) {
  #ai-chat-panel {
    left: 2rem;
    bottom: calc(2rem + var(--ticker-height) + 136px);
  }
}

.ai-chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background-color: #14171c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-family: "Oswald", sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.ai-chat-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background-color: #84c341;
  box-shadow: 0 0 0 2px rgba(132, 195, 65, 0.3);
}

#ai-chat-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.25rem;
}

#ai-chat-close:hover {
  color: #ffffff;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.ai-chat-msg {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.ai-chat-msg-bot {
  align-self: flex-start;
  background-color: #2a3038;
  color: #cbd5e1;
  border-bottom-left-radius: 0.2rem;
}

.ai-chat-typing {
  display: flex;
  gap: 0.25rem;
  padding: 0.7rem 0.8rem;
}

.ai-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: #84c341;
  animation: aiChatTyping 1.2s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes aiChatTyping {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.ai-chat-msg-user {
  align-self: flex-end;
  background-color: #84c341;
  color: #14171c;
  border-bottom-right-radius: 0.2rem;
}

.ai-chat-msg-error {
  align-self: flex-start;
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-bottom-left-radius: 0.2rem;
}

.ai-chat-form {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-chat-form input {
  flex: 1;
  min-width: 0;
  background-color: #141820;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: #ffffff;
  font-size: 0.85rem;
}

.ai-chat-form input::placeholder {
  color: #64748b;
}

.ai-chat-form input:focus {
  outline: none;
  border-color: #84c341;
}

.ai-chat-form button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 0.5rem;
  border: none;
  background-color: #84c341;
  color: #14171c;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.ai-chat-form button:hover {
  background-color: #71a836;
}

.ai-chat-form button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Scrollbar polish (WebKit) ---------- */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: #14171c;
}
::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #f0c419;
}

/* ---------- Mobile: stack audio/WhatsApp/chat top-right over the video ----------
   Placed at the end of the file so it wins the cascade over the
   desktop rules above (same specificity, later wins). Desktop/
   tablet keeps audio top-right-of-video and WhatsApp+chat
   bottom-left, unaffected above this breakpoint. */
@media (max-width: 639px) {
  /* Below the fixed 7rem (h-28) header, which otherwise covers them */
  #hero-sound-toggle {
    top: 7.75rem;
    right: 1rem;
    bottom: auto;
    left: auto;
    z-index: 50;
  }
  #whatsapp-btn {
    top: 11.25rem;
    right: 1rem;
    bottom: auto;
    left: auto;
  }
  #ai-chat-btn {
    top: 15.5rem;
    right: 1rem;
    bottom: auto;
    left: auto;
  }
}

/* ---------- Mobile: chat panel fits the screen ----------
   Anchored just below the fixed 7rem header, full width, and sized
   to the *visible* viewport (--chat-vv-h / --chat-vv-top are set by
   app.js from window.visualViewport) so it shrinks above the
   on-screen keyboard instead of hiding the Send button behind it.
   The 16px input font stops iOS Safari auto-zooming on focus. */
@media (max-width: 639px) {
  #ai-chat-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    top: calc(var(--chat-vv-top, 0px) + 7.5rem);
    bottom: auto;
    height: min(520px, calc(var(--chat-vv-h, 100dvh) - 7.5rem - 0.75rem));
    max-height: none;
  }
  .ai-chat-form input {
    font-size: 16px;
  }
}

/* ---------- 3D-style icon tiles ----------
   Dark rounded tile with a soft top light and drop shadow, so the
   full-color icons (metal, tire, paint...) read as small objects. */
.icon-3d {
  background: radial-gradient(circle at 30% 20%, #343a45, #181b21 70%);
  box-shadow: inset 0 1px 0 #ffffff1f, 0 10px 24px #00000080, 0 0 0 1px #ffffff12;
}

/* ---------- Model card carousels ----------
   Stacked slides cross-fade; dots sit over the bottom of the image
   on a soft dark fade so they read on any photo. */
.carousel-slide {
  opacity: 0;
  transition: opacity 0.8s ease, transform 0.3s ease;
}

.carousel-slide.is-active {
  opacity: 1;
}

.carousel-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 0 0.6rem;
  background: linear-gradient(to top, rgba(20, 23, 28, 0.65), transparent);
}

.carousel-dot {
  width: 9px;
  height: 9px;
  border-radius: 9999px;
  border: none;
  padding: 0;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.45);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.carousel-dot.is-active {
  width: 22px;
  background-color: #f0c419;
}

/* Paused by a click: ring around the active dot as a hint. */
.model-carousel.is-paused .carousel-dot.is-active {
  box-shadow: 0 0 0 2px rgba(240, 196, 25, 0.35);
}

/* Model cards: dots sit in their own row under the image, so the
   photo stays clean. Same height with or without dots. */
.carousel-dots-below {
  position: static;
  min-height: 9px;
  padding: 0.9rem 0 0;
  background: none;
  box-sizing: content-box;
}

.carousel-dots-below .carousel-dot {
  background-color: rgba(255, 255, 255, 0.25);
}

.carousel-dots-below .carousel-dot.is-active {
  background-color: #f0c419;
}

.carousel-dots-below.is-paused .carousel-dot.is-active {
  box-shadow: 0 0 0 2px rgba(240, 196, 25, 0.35);
}

/* ---------- Footer "Follow Us": original brand colors ----------
   Each network keeps its own color; hover lifts the button with a
   matching glow. */
.social-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.social-btn:hover {
  transform: translateY(-3px) scale(1.08);
  filter: brightness(1.1);
}

.social-facebook { background-color: #1877f2; }
.social-facebook:hover { box-shadow: 0 6px 18px rgba(24, 119, 242, 0.55); }

.social-x {
  background-color: #000000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.social-x:hover { box-shadow: 0 6px 18px rgba(255, 255, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.4); }

.social-instagram {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}
.social-instagram:hover { box-shadow: 0 6px 18px rgba(214, 36, 159, 0.55); }

.social-linkedin { background-color: #0a66c2; }
.social-linkedin:hover { box-shadow: 0 6px 18px rgba(10, 102, 194, 0.55); }

.social-youtube { background-color: #ff0000; }
.social-youtube:hover { box-shadow: 0 6px 18px rgba(255, 0, 0, 0.5); }

.social-whatsapp { background-color: #25d366; }
.social-whatsapp:hover { box-shadow: 0 6px 18px rgba(37, 211, 102, 0.55); }

/* Portrait photos in a landscape box: the whole photo in the middle,
   a blurred copy of itself filling the sides (nothing gets cropped). */
.slide-portrait {
  overflow: hidden;
}

.slide-portrait-bg {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(18px) brightness(0.55);
}

.slide-portrait-img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- Find Us map (Leaflet + OpenStreetMap) ----------
   Standard OSM tiles turned dark with a CSS filter to match the site;
   only the tiles are filtered, so the yellow pin keeps its colour. */
#find-us-map .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9) saturate(0.6);
}

#find-us-map .leaflet-control-attribution {
  background: rgba(20, 23, 28, 0.55);
  color: #8b95a3;
  font-size: 9px;
}

#find-us-map .leaflet-control-attribution a {
  color: #a7b0bc;
}

.wrw-map-pin {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
  cursor: pointer;
}

.map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f0c419;
  font-weight: 600;
}

#find-us-map .leaflet-bar a {
  background-color: #1f2530;
  color: #f0c419;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

#find-us-map .leaflet-bar a:hover {
  background-color: #2a3038;
}

#find-us-map .leaflet-bar {
  border: 1px solid rgba(255, 255, 255, 0.12);
}
