@font-face {
  font-family: 'Montserrat';
  src: url('/assets/tipography/Tipografías/Montserrat/static/Montserrat-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Raleway';
  src: url('/assets/tipography/Tipografías/Raleway/static/Raleway-Bold.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

html,
body {
  position: relative;
  min-height: 100vh;
  font-family: 'Montserrat', Arial, sans-serif;
  display: flex !important;
  flex-direction: column;
  width: 100%;
  grid-template-rows: none !important;
}

header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  background-image: linear-gradient(to top, rgba(0, 0, 0, 0), rgba(255, 255, 255, 0.9));
  backdrop-filter: blur(0px);
  position: relative;
  z-index: 10;
}

footer {
  width: 100%;
  position: relative;
  overflow: visible;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(20px, 5vw, 40px) clamp(20px, 5vw, 48px);
  background: rgba(255, 255, 255, 0.4);
  z-index: 10;
  flex-shrink: 0;
}

main {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin: 0;
  padding: clamp(0.5rem, 2vw, 1rem);
  background: url('../assets/images/imgs_web/backgrounds/background_services.png') no-repeat center center fixed;
  background-size: cover;
  flex: 1;
}

.column {
  margin: 0 auto;
  max-width: 1600px;
  width: 100%;
}

.hero-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vw, 2rem);
  padding: clamp(1rem, 4vw, 2rem) 0;
  text-align: left;
}

.hero-content h1 {
  font-family: 'Raleway', sans-serif;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  color: #0388a6;
  line-height: 1.2;
}

.hero-content p {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 400;
  color: #01303a;
  line-height: 1.6;
  max-width: 800px;
  margin: 0;
}

.card {
  flex: 1;
  width: 100%;
  max-width: 550px;
  height: clamp(500px, 55vh, 600px);
  /* FIXED HEIGHT FOR ALL CARDS */
  box-shadow: 12px 17px 51px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
  border-radius: clamp(16px, 4vw, 32px);
  text-align: center;
  cursor: pointer;
  transition: all 0.5s;
  user-select: none;
  color: white;
  position: relative;
  perspective: 1000px;
  background: #ffffff;
  justify-self: center;
}

/* Horizontal row for cards */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: clamp(1rem, 3vw, 2rem);
  justify-items: center;
  align-items: stretch;
  /* ENSURES ALL CARDS SAME HEIGHT */
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem) 0;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 16px 25px 60px rgba(0, 0, 0, 0.25);
}

.card:active {
  transform: scale(0.95);
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* PREVENTS TEXT OVERFLOW */
  background: #ffffff;
  border-radius: inherit;
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: clamp(1.5rem, 4vw, 2rem);
  border-radius: inherit;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 1;
  transform: translateY(0) scale(1);
  z-index: 1;
  overflow: hidden;
  /* PREVENTS CONTENT OVERFLOW */
}

.card-back {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  z-index: 0;
  pointer-events: none;
  background: #ffffff;
}

.card.flipped .card-front {
  opacity: 0;
  transform: translateY(-30px) scale(0.95);
  z-index: 0;
  pointer-events: none;
  background: #ffffff;
}

.card.flipped .card-back {
  opacity: 1;
  transform: translateY(0) scale(1);
  z-index: 1;
  pointer-events: auto;
  background: #ffffff;
}

.card-face:hover {
  background-color: #f0f0f0 !important;
}

.card-face.hovered {
  background-color: #f0f0f0 !important;
}

.image-placeholder {
  width: 100%;
  max-width: 320px;
  height: clamp(140px, 18vh, 200px);
  /* RESPONSIVE IMAGE HEIGHT */
  object-fit: cover;
  border-radius: clamp(8px, 2vw, 16px);
  margin-bottom: clamp(1rem, 2vh, 1.5rem);
  flex-shrink: 0;
  background-color: #f0f0f0;
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  transition: opacity 0.3s ease;
}

.image-placeholder.loading {
  opacity: 0.7;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 0.4;
  }
}

/* Ensure third card image loads properly on mobile */
#flipCard3 .image-placeholder {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  min-height: 140px;
  background-color: #e8f4f8 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-opacity='0.1'%3E%3Cpolygon fill='%23000' points='50 0 60 40 100 50 60 60 50 100 40 60 0 50 40 40'/%3E%3C/g%3E%3C/svg%3E") !important;
  background-size: 50px 50px !important;
}

@media (max-width: 768px) {

  /* Force third card visibility on mobile */
  #flipCard3 .image-placeholder {
    display: block !important;
    min-height: 140px;
    background-color: #f0f0f0;
  }

  /* Ensure all card images are visible on mobile */
  .card .image-placeholder {
    display: block !important;
    opacity: 1 !important;
  }
}

.card-face h3 {
  font-family: 'Raleway';
  font-size: clamp(1.2rem, 3vw, 2rem);
  /* SLIGHTLY SMALLER FOR BETTER FIT */
  font-weight: 500;
  align-self: start;
  color: #0388a6;
  margin: 0 0 clamp(0.8rem, 2vh, 1.2rem) 0;
  text-align: start;
  line-height: 1.2;
  /* TIGHTER LINE HEIGHT */
  flex-shrink: 0;
  overflow-wrap: break-word;
  /* PREVENTS OVERFLOW */
}

.card-face p {
  font-family: 'Montserrat';
  font-size: clamp(0.85rem, 2vw, 1.2rem);
  /* SLIGHTLY SMALLER */
  font-weight: 600;
  margin: 0;
  color: #01303a;
  text-align: start;
  line-height: 1.4;
  /* OPTIMIZED LINE HEIGHT */
  flex: 1;
  /* TAKES AVAILABLE SPACE */
  word-wrap: break-word;
  hyphens: auto;
  /* ENABLES HYPHENATION */
  padding-bottom: clamp(4rem, 8vh, 5rem);
  /* SPACE FOR ARROW BUTTON */
}

/* FRONT FACE - SHORT TEXT */
.card-front p {
  display: -webkit-box;
  -webkit-line-clamp: 10;
  /* LIMIT TO 10 LINES */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: clamp(100px, 12vh, 120px);
  /* FIXED MAX HEIGHT */
}

/* BACK FACE - FULL TEXT */
.card-back p {
  display: block;
  /* SHOW FULL TEXT */
  -webkit-line-clamp: none;
  overflow: visible;
  text-overflow: unset;
  max-height: none;
  /* NO HEIGHT LIMIT */
}

.arrow-button {
  background-repeat: no-repeat;
  background-position: center;
  background-size: clamp(20px, 5vw, 24px);
  position: absolute;
  bottom: clamp(1rem, 3vh, 2rem);
  right: clamp(1rem, 3vh, 2rem);
  background-color: #fbf4e6;
  border: none;
  border-radius: 50%;
  width: clamp(48px, 12vw, 64px);
  height: clamp(48px, 12vw, 64px);
  color: #0388a6;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
  z-index: 10;
  padding: 0px;
}

.arrow-button:hover {
  transform: scale(1.1);
}

/* Services page specific styles */
.services-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.services-container {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
  align-items: stretch;
}

.service-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  position: relative;
  height: fit-content;
  min-height: 250px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .services-content {
    padding: 1rem;
  }

  .services-container {
    padding: 0;
  }

  .services-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
  }

  .service-card {
    padding: 1.5rem;
    min-height: 200px;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Ensure cards don't get cut off */
  .service-card .card-front,
  .service-card .card-back {
    width: 100%;
    height: 100%;
    min-height: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
  }
}

/* Footer specific styles for services page */
@media (max-width: 768px) {

  /* Ensure footer sticks to bottom on mobile */
  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  main {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .services-content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  footer {
    margin-top: auto;
    position: relative;
  }
}

/* Dark mode adjustments */
body.dark-mode .service-card {
  background: rgba(18, 18, 18, 0.9);
  color: #e0e0e0;
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1200px) {
  .cards-row {
    grid-template-columns: repeat(3, 1fr);
    /* KEEP 3 COLUMNS ON LARGE TABLETS */
    gap: 1.5rem;
  }

  .card {
    height: clamp(550px, 70vh, 650px);
    /* ADJUST HEIGHT FOR MEDIUM SCREENS */
  }

  .column {
    margin: 0 clamp(1rem, 4vw, 2rem);
  }
}

@media (max-width: 900px) {
  .cards-row {
    grid-template-columns: repeat(2, 1fr);
    /* 2 COLUMNS ON MEDIUM TABLETS */
    gap: 1.5rem;
    max-width: 700px;
  }

  .card {
    height: clamp(520px, 65vh, 620px);
  }
}

@media (max-width: 768px) {
  main {
    padding: 1rem;
  }

  .column {
    margin: 0;
  }

  .cards-row {
    grid-template-columns: 1fr;
    /* SINGLE COLUMN ON MOBILE */
    gap: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem 0;
  }

  .card {
    max-width: 100%;
    height: clamp(500px, 60vh, 600px);
    /* MOBILE HEIGHT */
  }

  .card-inner {
    overflow: hidden;
  }

  .card-face {
    padding: 1.5rem;
  }

  .card-face h3 {
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    margin: 0 0 1rem 0;
  }

  .card-face p {
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    -webkit-line-clamp: 6;
    /* FEWER LINES ON MOBILE */
    padding-bottom: 3.5rem;
  }

  .image-placeholder {
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .arrow-button {
    width: 48px;
    height: 48px;
    bottom: 1rem;
    right: 1rem;
    background-size: 20px;
  }

  header {
    padding: 1rem;
  }

  footer {
    padding: 20px;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 0.5rem;
  }

  .hero-content {
    padding: 1rem 0;
  }

  .cards-row {
    gap: 1rem;
    padding: 0.5rem 0;
  }

  .card {
    height: clamp(450px, 55vh, 550px);
    /* SMALL MOBILE HEIGHT */
  }

  .card-face {
    padding: 1rem;
  }

  .card-face p {
    padding-bottom: 3rem;
    -webkit-line-clamp: 5;
    /* EVEN FEWER LINES */
  }

  .image-placeholder {
    height: clamp(100px, 12vh, 140px);
  }

  .arrow-button {
    width: 40px;
    height: 40px;
    background-size: 16px;
  }

  .column {
    margin: 0 0.5rem;
  }
}

/* Animation improvements */
@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .card-face {
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
      transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
}

@media (prefers-reduced-motion: reduce) {

  .card,
  .card-face,
  .arrow-button {
    transition: none;
  }
}