.ref-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.ref-cover-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(8px, 2vw, 24px);
  /* responsive spacing */
  pointer-events: none;
  /* lets the back button remain clickable */
  z-index: 10;
}

@media (max-width: 640px) {
  .ref-cover-title {
    align-items: center;
    padding-bottom: 18px;
  }
}

.ref-cover-title h1 {
  margin: 0;
  color: #fff;
  font-weight: 800;
  line-height: 1.15;
  font-size: clamp(22px, 4vw, 46px);
  /* responsive font size only */
  text-shadow: 0 3px 12px rgba(0, 0, 0, .45);
  max-width: min(92%, 980px);
  /* prevent overly long lines */
}

.ref-cover {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 450px;
  background: transparent; /* Changed from white to transparent */
  margin-top: 110px; /* Space from header so it does not hide behind it */
  margin-bottom: 30px; /* Breathing room before the title bar */
}

.ref-cover .container {
  height: 100%;
  max-width: 1100px !important; /* Forces perfect alignment with the description/coordonne grid */
  margin: 0 auto; /* Centers the 1100px container on the screen */
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-cover-inner {
  position: relative;
  width: 100%;
  height: 480px; /* Fixed height for the image card */
  border-radius: 24px; /* Slightly softer corners for a premium feel */
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12); /* More prominent shadow for floating effect */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Breathable Formula for Logos */
.ref-cover.is-logo .ref-cover-inner {
  padding: clamp(30px, 8%, 60px);
}

.ref-cover.is-logo img {
  object-fit: contain;
}

/* .ref-back removed */

/* Navigation Bas de Page */
.ref-footer-nav {
  padding: clamp(25px, 5%, 40px) 0;
  background: #fff;
  border-top: 1px solid #edf2f7;
}

.ref-footer-nav .container {
  display: grid !important;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
}

.ref-footer-nav .nav-btn {
  text-decoration: none;
  font-weight: 700;
  color: #0B5E92;
  font-size: 1.1rem;
  transition: color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ref-footer-nav .nav-btn:hover {
  color: #064577;
  transform: translateX(var(--move, 0));
}

.ref-footer-nav .nav-btn.prev {
  --move: -5px;
  justify-self: center; /* Aligns with centered Medelec footer column */
}

.ref-footer-nav .nav-btn.next {
  --move: 5px;
  justify-self: center; /* Aligns with centered Contact footer column */
}

.ref-footer-nav .nav-btn.center {
  font-size: 0.95rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  justify-self: center;
}

.ref-footer-nav .nav-btn.center:hover {
  background: #f1f5f9;
  color: #0B5E92;
  transform: translateY(-2px);
}

.ref-footer-nav .arrow {
  font-size: 1.4rem;
  font-weight: 400;
}

@media (max-width: 640px) {
  .ref-footer-nav {
    padding: 30px 0;
  }

  .ref-footer-nav .container {
    display: flex !important;
    justify-content: space-between;
  }

  .ref-footer-nav .nav-btn {
    font-size: 1rem;
  }
  
  .ref-footer-nav .nav-btn.center {
    display: none; /* Hide on very small screens to avoid crowding */
  }
}

@media (max-width: 900px) {

  /* Clean Mobile Layout */
  .ref-title-bar .container {
    display: flex !important;
    flex-direction: column;
    position: relative !important;
    padding-bottom: 0px;
  }

  .ref-cover {
    height: 300px;
    margin-top: 15px; /* Space from header */
  }

  .ref-cover .container {
    padding: 0;
    max-width: 100%;
  }

  .ref-cover-inner {
    border-radius: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Mobile Breathable logos */
  .ref-cover.is-logo .ref-cover-inner {
    padding: 30px;
  }

  .ref-cover img {
    border-radius: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .ref-cover.is-logo img {
    object-fit: contain;
    width: auto;
    height: auto;
    max-width: 90%;
    max-height: 90%;
  }

  .ref-title-bar {
    margin-top: 0; /* Seamless connection on mobile */
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.ref-main {
  background: #fff;
  padding: clamp(20px, 4%, 48px) 0 clamp(20px, 3%, 32px) 0;
}

.ref-main-grid {
  display: flex;
  gap: 48px;
  max-width: 1100px;
  margin: 0 auto;
  align-items: flex-start;
}

.ref-desc {
  flex: 2;
}

.ref-desc h2 {
  margin-top: 0;
  color: #0B5E92;
  font-size: 1.4rem;
}

.ref-desc p {
  font-size: 1.1rem;
  color: #222;
  line-height: 1.7;
}

.ref-coords {
  flex: 1;
  background: #ffffff;
  border-radius: 20px;
  padding: clamp(20px, 3%, 32px) clamp(18px, 3%, 28px);
  box-shadow: 0 10px 40px rgba(11, 94, 146, 0.08);
  border: 1px solid rgba(11, 94, 146, 0.05);
  position: sticky;
  top: 100px;
}

.ref-coords h3 {
  margin-top: 0;
  margin-bottom: 24px;
  color: #0B5E92;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-coords h3::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, rgba(11, 94, 146, 0.2), transparent);
  border-radius: 2px;
}

.ref-coords ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ref-coords li {
  margin-bottom: 0;
  color: #475569;
  font-size: 0.95rem;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  line-height: 1.5;
}

.ref-coords li .icon {
  font-size: 1.2rem;
  min-width: 44px;
  height: 44px;
  background: #f1f8ff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0B5E92;
  transition: all 0.3s ease;
}

.ref-coords li:hover .icon {
  background: #0B5E92;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(11, 94, 146, 0.2);
}

.ref-coords li .info {
  display: flex;
  flex-direction: column;
}

.ref-coords li strong {
  display: block;
  color: #64748b;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.ref-coords li span:not(.icon) {
  display: block;
  font-weight: 600;
  color: #1e293b;
  font-size: 0.95rem;
  line-height: 1.4;
}

.ref-gallery-section {
  background: #f1f5f9;
  padding: clamp(25px, 5%, 40px) 0 clamp(35px, 7%, 60px) 0;
}

.ref-gallery-section h2 {
  text-align: center;
  color: #0B5E92;
  margin-bottom: 1.5em;
}

.ref-gallery-scroll {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 1100px;
  margin: 0 auto;
  scroll-snap-type: x mandatory;
}

.ref-gallery-scroll img {
  width: 220px;
  height: 160px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(30, 40, 90, 0.07);
}

.ref-gallery-scroll img:hover {
  box-shadow: 0 6px 24px rgba(30, 40, 90, 0.13);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  animation: fadeIn .3s;
}

.lightbox .close {
  position: absolute;
  top: 32px;
  right: 48px;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 10;
  font-weight: 300;
  transition: color 0.2s;
}

.lightbox .close:hover {
  color: #0B5E92;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(30, 40, 90, 0.18);
  margin-bottom: 24px;
}

.lightbox-thumbs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.thumb-mini {
  width: 60px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  opacity: 0.7;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border 0.2s, opacity 0.2s;
}

.thumb-mini.active,
.thumb-mini:hover {
  border: 2px solid #0B5E92;
  opacity: 1;
}

@media (max-width: 900px) {
  .ref-main-grid {
    flex-direction: column;
    gap: 24px;
  }

  .ref-coords {
    width: 100%;
    position: relative;
    top: 0;
    padding: 24px;
    order: 2; /* Move coordinates below description on mobile */
  }

  .ref-desc {
    order: 1;
  }

  .ref-title-bar {
    margin-top: 10px; /* Minimal space from cover image on mobile */
    padding: 20px 0; /* Compact title bar */
  }

  .ref-title-bar h1 {
    font-size: clamp(20px, 5vw, 32px);
  }
}

@media (max-width: 640px) {
  .ref-coords {
    padding: 20px 16px;
  }
  
  .ref-coords ul {
    gap: 15px;
  }

  .ref-coords li .icon {
    min-width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 10px;
  }
  
  .ref-coords li span:not(.icon) {
    font-size: 0.9rem;
  }
}

.ref-title-bar {
  width: 100%;
  padding: 45px 0; /* More breathing room for the title */
  background: radial-gradient(circle at 20% 20%, rgb(11, 94, 146) 0%, rgb(5, 56, 107) 45%, rgb(2, 27, 56) 70%, rgb(2, 6, 23) 100%);
  margin-top: 0; /* Seamless connection to cover image */
  border-top: 1px solid rgba(255, 255, 255, 0.08); /* Polished separation line */
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.05), 0 4px 15px rgba(0, 0, 0, 0.15);
}

.ref-title-bar .container {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  width: 100% !important;
}

.ref-title-bar h1 {
  margin: 0;
  color: #fff;
  font-weight: 800;
  line-height: 1.2;
  font-size: clamp(22px, 4vw, 42px);
  max-width: 800px;
  text-align: center;
  position: relative;
  z-index: 1;
  /* Ensure text is above potentially overlapping elements */
}

/* CTA Business Button */
.ref-cta-container {
  margin-top: 32px;
  display: flex;
  justify-content: flex-start;
}

.ref-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #0B5E92 0%, #064577 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 14px 28px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(11, 94, 146, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.ref-cta-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.ref-cta-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(11, 94, 146, 0.45);
  background: linear-gradient(135deg, #0f70ad 0%, #08538c 100%);
}

.ref-cta-btn:hover::before {
  opacity: 1;
}

.ref-cta-btn .icon {
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

@media (max-width: 640px) {
  .ref-cta-container {
    justify-content: center;
    margin-top: 40px;
  }

  .ref-cta-btn {
    width: 100%;
    /* Full width on mobile for better touch target */
    justify-content: center;
  }
}

/* Medelec Value Added - Clean List Style */
.ref-added-value {
  background: #f8fafc;
  border-left: 5px solid #0B5E92;
  border-radius: 12px;
  padding: 24px 28px;
  margin: 32px 0;
  box-shadow: 0 4px 15px rgba(11, 94, 146, 0.05);
}

.ref-added-value h3 {
  margin: 0 0 16px;
  color: #064577;
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-added-value h3 .icon {
  font-size: 1.3rem;
}

.ref-added-value ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ref-added-value li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 12px;
  color: #334155;
  font-size: 1rem;
  line-height: 1.5;
  transition: transform 0.2s ease;
}

.ref-added-value li:last-child {
  margin-bottom: 0;
}

.ref-added-value li:hover {
  transform: translateX(4px);
  color: #0B5E92;
}

.ref-added-value li::before {
  content: "✦"; /* Elegant spark/bullet */
  position: absolute;
  left: 0;
  color: #0B5E92;
  font-weight: bold;
  font-size: 1.1rem;
  top: 0;
}

/* Context Badge */
.ref-context-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  color: #0369a1;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 10px;
  margin-bottom: 24px;
  border: 1px solid rgba(186, 230, 253, 0.5);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: fit-content;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .ref-added-value {
    padding: 16px;
    margin: 24px 0;
  }
}
/* --- Dynamic Motion System --- */
@keyframes fadeInUp {
  from { 
    opacity: 0; 
    transform: translateY(30px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes slowZoom {
  from { 
    transform: scale(1.15); 
    filter: blur(5px);
    opacity: 0;
  }
  to { 
    transform: scale(1); 
    filter: blur(0);
    opacity: 1;
  }
}

@keyframes titleReveal {
  from {
    letter-spacing: 0.2em;
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    letter-spacing: normal;
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply Animations */
.ref-cover img {
  animation: slowZoom 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.ref-title-bar {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.2s;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-title-bar h1 {
  animation: titleReveal 1s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.4s;
}

.ref-desc {
  animation: fadeInUp 1s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.6s;
}

.ref-coords {
  animation: fadeInUp 1s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.8s;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-added-value {
  animation: fadeInUp 1s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.9s;
}

/* Interactive States */
.ref-coords:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(11, 94, 146, 0.12);
  border-color: rgba(11, 94, 146, 0.15);
}

.ref-gallery-scroll img {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-gallery-scroll img:hover {
  transform: scale(1.08) translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.nav-btn {
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: #f8fafc;
  transform: translateY(-2px);
}

.nav-btn:hover .arrow {
  transform: translateX(5px);
}

.nav-btn.prev:hover .arrow {
  transform: translateX(-5px);
}

/* Disable animations if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
