/**
 * Custom CSS - Construtec Theme
 *
 * Supplements Tailwind CSS with custom utilities and component styles
 *
 * @package Construtec
 */

/* ─── Font Face ─── */
@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Montserrat';
  src: url('../fonts/Montserrat-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* ─── Custom Animations ─── */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out;
}

.animate-fade-up {
  animation: fade-up 0.5s ease-out;
}

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

.animate-pulse-green {
  animation: pulse-green 2s ease-in-out infinite;
}

/* ─── Navigation ─── */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: #22c55e;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.current-menu-item::after,
.nav-link.active::after {
  width: 100%;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.dark ::-webkit-scrollbar-track {
  background: #1e293b;
}

.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ─── Scrollbar Hide ─── */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ─── Selection ─── */
::selection {
  background-color: rgba(34, 197, 94, 0.3);
  color: inherit;
}

/* ─── WordPress Specific ─── */
.wp-caption {
  max-width: 100%;
}

.wp-caption img {
  border-radius: 0.75rem;
}

.wp-caption-text {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.5rem;
  text-align: center;
}

.alignleft {
  float: left;
  margin-right: 1.5rem;
  margin-bottom: 1rem;
}

.alignright {
  float: right;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Pagination ─── */
.pagination .nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  transition: all 0.3s ease;
}

.dark .pagination .page-numbers {
  background: #374151;
  color: #9ca3af;
}

.pagination .page-numbers:hover {
  background: #22c55e;
  color: white;
}

.pagination .page-numbers.current {
  background: #22c55e;
  color: white;
}

.pagination .page-numbers.dots {
  background: transparent;
  color: #9ca3af;
}

.pagination .page-numbers.prev,
.pagination .page-numbers.next {
  background: transparent;
  color: #22c55e;
  font-weight: 700;
}

.pagination .page-numbers.prev:hover,
.pagination .page-numbers.next:hover {
  background: rgba(34, 197, 94, 0.1);
}

/* ─── Prose Overrides ─── */
.prose h2 {
  position: relative;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.prose h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 3rem;
  height: 3px;
  background: #22c55e;
  border-radius: 2px;
}

.prose a {
  text-decoration: none;
  border-bottom: 2px solid rgba(34, 197, 94, 0.3);
  transition: all 0.3s;
}

.prose a:hover {
  border-bottom-color: #22c55e;
  color: #22c55e;
}

.prose img {
  border-radius: 1rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.prose blockquote {
  border-left-color: #22c55e;
  background: #f0fdf4;
  border-radius: 0 0.75rem 0.75rem 0;
  padding: 1rem 1.5rem;
}

.dark .prose blockquote {
  background: rgba(34, 197, 94, 0.05);
}

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

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

/* ─── Client Logo Blend ───
   Removes white PNG backgrounds from client logos
   Light mode: mix-blend-multiply blends white into container
   Dark mode: shows logos normally with good visibility */
.client-logo-blend {
  max-height: 4rem;
  width: auto;
  object-fit: contain;
  mix-blend-mode: multiply;
  filter: grayscale(1);
  opacity: 0.6;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .client-logo-blend {
  filter: grayscale(0);
  opacity: 1;
  mix-blend-mode: multiply;
}

.dark .client-logo-blend {
  mix-blend-mode: normal;
  filter: grayscale(0.3) brightness(1.1);
  opacity: 0.75;
}

.dark .group:hover .client-logo-blend {
  filter: grayscale(0) brightness(1.1);
  opacity: 1;
}

/* Cards that keep white bg in dark mode — multiply still works */
.dark .client-logo-blend.client-logo-whitebg {
  mix-blend-mode: multiply;
  filter: grayscale(1);
  opacity: 0.6;
}

.dark .group:hover .client-logo-blend.client-logo-whitebg {
  filter: grayscale(0);
  opacity: 1;
  mix-blend-mode: multiply;
}

/* Larger variant for clients page cards */
.client-logo-blend-lg {
  max-height: 5rem;
  width: auto;
  object-fit: contain;
  mix-blend-mode: multiply;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .client-logo-blend-lg {
  mix-blend-mode: multiply;
  transform: scale(1.05);
}

.dark .client-logo-blend-lg {
  mix-blend-mode: normal;
  filter: grayscale(0.3) brightness(1.1);
  opacity: 0.8;
}

.dark .group:hover .client-logo-blend-lg {
  filter: grayscale(0) brightness(1.1);
  opacity: 1;
  transform: scale(1.05);
}

/* -lg variant on white bg cards — keep multiply blend */
.dark .client-logo-blend-lg.client-logo-whitebg {
  mix-blend-mode: multiply;
  filter: none;
  opacity: 1;
}

.dark .group:hover .client-logo-blend-lg.client-logo-whitebg {
  mix-blend-mode: multiply;
  filter: none;
  opacity: 1;
  transform: scale(1.05);
}

/* ─── WP Editor Content Styling ─── */
.wp-editor-content {
  max-width: none;
}

.wp-editor-content > *:first-child {
  margin-top: 0;
}

.wp-editor-content > *:last-child {
  margin-bottom: 0;
}

/* ─── WhatsApp Button ─── */
.whatsapp-float {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s;
}

.whatsapp-float:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
}

/* ─── Form Focus ─── */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* ─── Skip Link ─── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: #22c55e;
  color: white;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* ─── Hero Slideshow ─── */
#hero-slideshow {
  min-height: 85vh;
}

.hero-slide {
  opacity: 0;
  z-index: 1;
  transition: opacity 0.8s ease-in-out;
  pointer-events: none;
}

.hero-slide.slide-active {
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

.hero-slide.slide-entering {
  opacity: 1;
  z-index: 3;
}

.hero-slide.slide-leaving {
  opacity: 0;
  z-index: 2;
}

/* Ken Burns zoom effect */
.hero-slide-image {
  animation: kenburns 18s ease-in-out infinite alternate;
  will-change: transform;
}

.hero-slide:nth-child(odd) .hero-slide-image {
  animation-name: kenburns;
}

.hero-slide:nth-child(even) .hero-slide-image {
  animation-name: kenburns-reverse;
}

@keyframes kenburns {
  0% {
    transform: scale(1) translate(0, 0);
  }
  100% {
    transform: scale(1.12) translate(-1.5%, -1%);
  }
}

@keyframes kenburns-reverse {
  0% {
    transform: scale(1.08) translate(-1%, 0);
  }
  100% {
    transform: scale(1) translate(1%, 1%);
  }
}

/* Slide text entrance animation */
[data-slide-anim] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.slide-active [data-slide-anim] {
  opacity: 1;
  transform: translateY(0);
}

.slide-active [data-slide-anim]:nth-child(1) { transition-delay: 0.1s; }
.slide-active [data-slide-anim]:nth-child(2) { transition-delay: 0.25s; }
.slide-active [data-slide-anim]:nth-child(3) { transition-delay: 0.4s; }
.slide-active [data-slide-anim]:nth-child(4) { transition-delay: 0.55s; }

/* Progress bar pulse */
[data-slide-progress] {
  transition: width 0.3s linear;
}

/* ─── Smooth Page Transitions ─── */
html {
  scroll-behavior: smooth;
}

/* ─── Toast Notifications ─── */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100% - 3rem);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid;
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.3),
              0 8px 20px -8px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.21, 1.02, 0.73, 1),
              opacity 0.4s ease;
}

.toast--visible {
  transform: translateX(0);
  opacity: 1;
}

.toast--hiding {
  transform: translateX(120%);
  opacity: 0;
}

/* Success variant */
.toast--success {
  background: rgba(240, 253, 244, 0.97);
  border-color: #86efac;
  color: #166534;
}

.dark .toast--success {
  background: rgba(20, 83, 45, 0.92);
  border-color: rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.toast--success .toast__icon {
  color: #22c55e;
}

.dark .toast--success .toast__icon {
  color: #4ade80;
}

.toast--success .toast__progress {
  background: #22c55e;
}

/* Error variant */
.toast--error {
  background: rgba(254, 242, 242, 0.97);
  border-color: #fca5a5;
  color: #991b1b;
}

.dark .toast--error {
  background: rgba(127, 29, 29, 0.92);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.toast--error .toast__icon {
  color: #ef4444;
}

.dark .toast--error .toast__icon {
  color: #f87171;
}

.toast--error .toast__progress {
  background: #ef4444;
}

/* Toast elements */
.toast__icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25rem;
}

.toast__text {
  font-size: 0.875rem;
  line-height: 1.25rem;
  margin-top: 0.125rem;
  opacity: 0.85;
}

.toast__close {
  flex-shrink: 0;
  padding: 0.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
}

.toast__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.dark .toast__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.toast__close svg {
  width: 1rem;
  height: 1rem;
}

.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  border-radius: 0 0 0.75rem 0.75rem;
}

/* Mobile: full width */
@media (max-width: 480px) {
  #toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
