/* ==========================================================================
   MobileWrenchMaster — shared stylesheet
   Single source of truth for:
     - Mobile nav / hamburger
     - Scroll-reveal animations
     - Card hover lift
     - Sticky header scroll state
     - Slideshow transitions (fade / kenburns / slide / zoom)
     - FOUC prevention for Tailwind CDN
   ========================================================================== */

:root {
  --mwm-theme-primary: #3b82f6;
  --mwm-theme-secondary: #f59e0b;
  --mwm-theme-background: #111827;
  --mwm-theme-surface: #1f2937;
  --mwm-theme-text: #f9fafb;
  --mwm-theme-text-secondary: #d1d5db;
  --mwm-header-height: 96px;
}

/* ---------- FOUC prevention: hide until Tailwind CDN + theme applied ------- */
html:not(.mwm-ready) body { visibility: hidden; }

/* Sections anchored from the sticky nav shouldn't hide under it */
[id="hero"], [id="services"], [id="specials"], [id="contact"],
[id^="section-"] { scroll-margin-top: var(--mwm-header-height); }

/* ==========================================================================
   Sticky header scroll state
   ========================================================================== */
.mwm-header {
  transition: backdrop-filter .25s ease, background-color .25s ease,
              box-shadow .25s ease, border-color .25s ease;
}
.mwm-header.is-scrolled {
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  background-color: color-mix(in srgb, var(--mwm-theme-surface) 82%, transparent);
  box-shadow: 0 8px 24px -12px rgba(0,0,0,.55);
}

/* ==========================================================================
   Mobile menu (moved from per-template <style>)
   ========================================================================== */
#mobile-menu {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100vh;
  background-color: var(--mwm-theme-surface);
  z-index: 1000;
  padding-top: 80px;
  overflow-y: auto;
}
#mobile-menu.active { display: block; }
#mobile-menu a {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--mwm-theme-text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.1);
  transition: background-color .3s ease;
}
#mobile-menu a:hover {
  background-color: rgba(255,255,255,.1);
  color: var(--mwm-theme-secondary);
}
#mobile-menu-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: .5rem;
  z-index: 1001;
  background: transparent;
  border: 0;
}
#mobile-menu-toggle span {
  width: 25px;
  height: 3px;
  background-color: var(--mwm-theme-text);
  margin: 3px 0;
  transition: .3s;
  border-radius: 2px;
}
#mobile-menu-toggle.active span:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
#mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
#mobile-menu-toggle.active span:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }

@media (max-width: 767px) {
  #mobile-menu-toggle { display: flex !important; }
  .desktop-nav { display: none !important; }
  #mobile-menu.active { display: block !important; }
}
@media (min-width: 768px) {
  #mobile-menu { display: none !important; }
  #mobile-menu-toggle { display: none !important; }
  .desktop-nav { display: flex !important; }
}

/* ==========================================================================
   Scroll-reveal (IntersectionObserver driven)
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s cubic-bezier(.2,.7,.2,1),
              transform .7s cubic-bezier(.2,.7,.2,1);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }
.reveal[data-reveal-delay="1"] { transition-delay: .08s; }
.reveal[data-reveal-delay="2"] { transition-delay: .16s; }
.reveal[data-reveal-delay="3"] { transition-delay: .24s; }
.reveal[data-reveal-delay="4"] { transition-delay: .32s; }
.reveal[data-reveal-delay="5"] { transition-delay: .40s; }
.reveal[data-reveal-delay="6"] { transition-delay: .48s; }

/* ==========================================================================
   Card hover lift (service cards, special cards)
   ========================================================================== */
.mwm-card {
  transition: transform .35s cubic-bezier(.2,.7,.2,1),
              box-shadow .35s ease,
              border-color .35s ease;
}
.mwm-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 22px 40px -20px rgba(0,0,0,.65),
              0 0 0 1px color-mix(in srgb, var(--mwm-theme-primary) 35%, transparent);
  border-color: color-mix(in srgb, var(--mwm-theme-primary) 40%, transparent);
}
.mwm-card-img-wrap { overflow: hidden; }
.mwm-card-img {
  transition: transform .6s cubic-bezier(.2,.7,.2,1);
}
.mwm-card:hover .mwm-card-img { transform: scale(1.07); }

/* ==========================================================================
   Fade-in used by hero headline on first paint
   ========================================================================== */
@keyframes mwm-fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: none; }
}
.mwm-fade-up       { animation: mwm-fade-up .9s cubic-bezier(.2,.7,.2,1) both; }
.mwm-fade-up-delay { animation: mwm-fade-up .9s cubic-bezier(.2,.7,.2,1) .25s both; }

/* ==========================================================================
   Slideshow
   ========================================================================== */
.mwm-slideshow { position: relative; overflow: hidden; isolation: isolate; }
.mwm-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s cubic-bezier(.2,.7,.2,1);
}
.mwm-slide.is-active { opacity: 1; pointer-events: auto; z-index: 2; }

/* The image layer. Focal point is set via CSS vars. */
.mwm-slide-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: calc(var(--fx, .5) * 100%) calc(var(--fy, .5) * 100%);
  transform-origin: calc(var(--fx, .5) * 100%) calc(var(--fy, .5) * 100%);
  will-change: transform, opacity;
}

/* Transition: fade — image static */
.mwm-slide[data-transition="fade"] .mwm-slide-img { transform: scale(1.02); }

/* Transition: kenburns — slow pan + zoom once the slide becomes active */
@keyframes mwm-kenburns {
  from { transform: scale(1.02) translate3d(0,0,0); }
  to   { transform: scale(1.18) translate3d(var(--kb-tx, 2%), var(--kb-ty, -1%), 0); }
}
.mwm-slide[data-transition="kenburns"].is-active .mwm-slide-img {
  animation: mwm-kenburns var(--kb-dur, 8s) linear both;
}

/* Transition: zoom — subtle zoom-in, no pan */
@keyframes mwm-zoom {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}
.mwm-slide[data-transition="zoom"].is-active .mwm-slide-img {
  animation: mwm-zoom var(--kb-dur, 8s) ease-out both;
}

/* Transition: slide — horizontal parallax entry */
.mwm-slide[data-transition="slide"] .mwm-slide-img { transform: translateX(6%); }
.mwm-slide[data-transition="slide"].is-active .mwm-slide-img {
  animation: mwm-slide-in 1.1s cubic-bezier(.2,.7,.2,1) both,
             mwm-zoom var(--kb-dur, 10s) ease-out 1.1s both;
}
@keyframes mwm-slide-in {
  from { transform: translateX(6%); }
  to   { transform: translateX(0); }
}

/* Overlay gradient */
.mwm-slide-overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at top, rgba(0,0,0,.25), transparent 60%),
    linear-gradient(to bottom, rgba(0,0,0,.55) 0%, rgba(0,0,0,.25) 40%, rgba(0,0,0,.75) 100%);
}

/* Caption stack */
.mwm-slide-caption {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem 1rem;
}
.mwm-slide-caption > * { opacity: 0; transform: translateY(18px); }
.mwm-slide.is-active .mwm-slide-caption-title    { animation: mwm-fade-up .9s cubic-bezier(.2,.7,.2,1) .25s both; }
.mwm-slide.is-active .mwm-slide-caption-subtitle { animation: mwm-fade-up .9s cubic-bezier(.2,.7,.2,1) .45s both; }
.mwm-slide.is-active .mwm-slide-caption-cta      { animation: mwm-fade-up .9s cubic-bezier(.2,.7,.2,1) .65s both; }

/* Controls */
.mwm-slide-ctrl {
  background: rgba(0,0,0,.45);
  color: #fff;
  border: 0;
  padding: 1rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: transform .2s ease, background-color .2s ease;
}
.mwm-slide-ctrl:hover { background: rgba(0,0,0,.7); transform: scale(1.08); }
.mwm-slide-ctrl:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Dots */
.mwm-slide-dots {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: .6rem;
}
.mwm-slide-dot {
  width: 10px; height: 10px;
  border-radius: 9999px;
  background: rgba(255,255,255,.45);
  border: 0; padding: 0;
  cursor: pointer;
  transition: transform .2s ease, background-color .2s ease, width .3s ease;
}
.mwm-slide-dot:hover { background: rgba(255,255,255,.8); }
.mwm-slide-dot.is-active {
  background: #fff;
  width: 28px;
}

/* Progress bar at bottom of slideshow */
.mwm-slide-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  width: 0%;
  z-index: 3;
  background: linear-gradient(90deg, var(--mwm-theme-primary), var(--mwm-theme-secondary));
  pointer-events: none;
}

/* "Slide N of M" a11y indicator */
.mwm-slide-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ==========================================================================
   Admin slideshow: thumbnail grid + drag/drop
   ========================================================================== */
.mwm-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.mwm-thumb {
  position: relative;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: .75rem;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.mwm-thumb:hover { transform: translateY(-2px); border-color: #4b5563; }
.mwm-thumb.is-dragging { opacity: .5; }
.mwm-thumb.is-ghost {
  border: 2px dashed var(--mwm-theme-primary);
  background: rgba(59,130,246,.08);
}
.mwm-thumb-aspect {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #111827;
  cursor: crosshair;
}
.mwm-thumb-aspect img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mwm-thumb-focal {
  position: absolute;
  width: 28px; height: 28px;
  border-radius: 9999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: transparent;
}
.mwm-thumb-focal::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 9999px;
  background: #fff;
}
.mwm-thumb-handle {
  position: absolute;
  top: .5rem; left: .5rem;
  background: rgba(0,0,0,.55);
  color: #fff;
  border-radius: .375rem;
  padding: .25rem .5rem;
  font-size: .75rem;
  cursor: grab;
  user-select: none;
}
.mwm-thumb-handle:active { cursor: grabbing; }
.mwm-thumb-index {
  position: absolute;
  top: .5rem; right: .5rem;
  background: rgba(0,0,0,.55);
  color: #fff;
  border-radius: 9999px;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 .5rem;
  font-size: .75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Bulk upload queue */
.mwm-upload-queue { display: grid; gap: .5rem; }
.mwm-upload-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: .75rem;
  align-items: center;
  background: #374151;
  padding: .6rem .75rem;
  border-radius: .5rem;
  font-size: .875rem;
}
.mwm-upload-thumb {
  width: 44px; height: 44px;
  border-radius: .375rem;
  object-fit: cover;
  background: #111827;
}
.mwm-upload-bar {
  height: 6px;
  background: #1f2937;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: .25rem;
}
.mwm-upload-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mwm-theme-primary), var(--mwm-theme-secondary));
  width: 0%;
  transition: width .2s ease;
}

/* Slideshow preview modal */
.mwm-preview-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.mwm-preview-modal.is-open { display: flex; }
.mwm-preview-frame {
  position: relative;
  width: min(1200px, 100%);
  aspect-ratio: 16/9;
  background: #000;
  border-radius: .75rem;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0,0,0,.6);
}
.mwm-preview-close {
  position: absolute;
  top: .75rem; right: .75rem;
  z-index: 5;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: 0;
  border-radius: 9999px;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 1rem;
}

/* ==========================================================================
   Inquiry form: success toast + loading button
   ========================================================================== */
.mwm-toast {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #111827;
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  padding: .9rem 1.25rem;
  border-radius: .75rem;
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
  font-weight: 600;
  z-index: 5000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.mwm-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.mwm-toast.is-ok  { border-color: rgba(52,211,153,.5); }
.mwm-toast.is-err { border-color: rgba(248,113,113,.5); }

.mwm-btn[aria-busy="true"] {
  cursor: progress;
  opacity: .75;
  pointer-events: none;
}

/* ==========================================================================
   Respect prefers-reduced-motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
  .mwm-slide-img,
  .mwm-slide[data-transition="kenburns"].is-active .mwm-slide-img,
  .mwm-slide[data-transition="zoom"].is-active .mwm-slide-img,
  .mwm-slide[data-transition="slide"].is-active .mwm-slide-img {
    animation: none !important;
    transform: none !important;
  }
}
