/* Header: top navigation bar, logo, login button, mobile hamburger menu */

/* Skip to main content link - visually hidden until focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  padding: 12px 20px;
  background-color: var(--color-blue);
  color: white;
  font-family: Montserrat, -apple-system, Roboto, Helvetica, sans-serif;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.3s ease;
  border-radius: 0 0 4px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

.header {
  position: sticky;
  top: 0;
  width: 100%;
  background-color: white;
  /* or your desired background color */
  z-index: 1000;
  /* ensure it stays above other content */
  transition: box-shadow 0.3s ease-in-out;
}

/* Add shadow only when scrolled - works with scroll event script */
.header.scrolled {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navigation {
  font-family: Montserrat, -apple-system, Roboto, Helvetica, sans-serif;
  font-size: 14px;
  width: 100%;
}

.navigation-wrapper {
  display: flex;
  width: 90%;
  padding: 12px 70px 19px;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.navigation-container {
  display: flex;
  margin-left: 17px;
  width: 100%;
  max-width: 1607px;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.menu-section {
  display: flex;
  margin-top: auto;
  margin-bottom: auto;
  align-items: center;
  gap: 40px clamp(32px, calc(9.5vw - 69px), 68px);
  color: var(--color-gray-900);
  font-weight: 400;
  flex-wrap: wrap;
}

/* Blog pages wrap the logo in a link: centre it in the row like the bare logo on the home page */
.navigation-container > a {
  display: flex;
  align-self: stretch;
}

.company-logo {
  aspect-ratio: 4.55;
  object-fit: contain;
  object-position: center;
  width: 109px;
  align-self: stretch;
  flex-shrink: 0;
  max-width: 100%;
}

.nav-link:hover,
.nav-link:focus {
  color: var(--color-blue);
}

/* Add underline effect */
.nav-link::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: var(--color-blue);
  /* Same blue color */
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link:focus::after {
  width: 100%;
  /* Expand the underline on hover */
}

/* Ensure active state has similar styling */
.nav-link.active {
  font-weight: 600;
  color: var(--color-blue);
}

.nav-link.active::after {
  width: 100%;
}

.contact-section {
  display: flex;
  margin-top: auto;
  margin-bottom: auto;
  align-items: center;
  gap: 16px;
  color: var(--color-gray-700);
  font-weight: 400;
  position: relative;
}

/* Create a tooltip element for the login button */
/* Login link: no inline line box around the image, so it centres with the language switcher */
.contact-section > a {
  display: flex;
  /* keeps the header at its previous height */
  padding: 3px 0;
}

.contact-section::after {
  content: "Coming soon";
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

/* Show tooltip on hover over the contact section */
.contact-section:has(> a:hover)::after {
  opacity: 1;
  visibility: hidden;
}

/* Add arrow pointing up to the icon */
.contact-section::before {
  content: "";
  position: absolute;
  bottom: -9px;
  /* Position arrow closer to the button */
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

/* Show arrow on hover */
.contact-section:has(> a:hover)::before {
  opacity: 1;
  visibility: hidden;
}

.contact-icon {
  aspect-ratio: 2.55;
  object-fit: contain;
  object-position: center;
  width: 102px;
  flex-shrink: 0;
  max-width: 100%;
  position: relative;
  cursor: pointer;
}

/* Navigation hover effects to match active state */
.nav-link {
  align-self: stretch;
  margin-top: auto;
  margin-bottom: auto;
  color: inherit;
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

/* Hover effect styling that matches active state */
.nav-link:hover:not(.nav-link-active) {
  color: var(--color-blue);
}

.nav-link:hover:not(.nav-link-active)::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-blue);
  animation: navFadeIn 0.3s ease;
}

/* Ensure hover doesn't show when item is already active */
.nav-link-active:hover::after {
  animation: none;
}

@media screen and (max-width: 1200px) {
  .navigation-container {
    flex-wrap: nowrap;
    /* Prevent wrapping to next line */
    align-items: center;
  }

  .menu-section {
    flex-wrap: nowrap;
    /* Prevent wrapping inside menu */
    overflow-x: auto;
    /* Enable horizontal scrolling */
    -ms-overflow-style: none;
    /* Hide scrollbar in IE/Edge */
    scrollbar-width: none;
    /* Hide scrollbar in Firefox */
    white-space: nowrap;
    /* Prevent text wrapping */
    gap: 20px;
    /* Reduce gap between items */
    padding-right: 10px;
    /* Add space for scrolling */
  }

  .menu-section::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar in Chrome/Safari/Opera */
  }

  .nav-link {
    padding: 0 6px;
    /* Reduce horizontal padding */
  }

  .contact-section {
    flex-shrink: 0;
    /* Prevent contact section from shrinking */
  }
}

@media (max-width: 991px) {
  .navigation-wrapper {
    max-width: 100%;
    padding-left: 20px;
    padding-right: 0px;
  }

  .navigation-container {
    max-width: 100%;
    gap: 0;
  }

  .menu-section {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .navigation-container {
    position: relative;
    gap: 0;
  }

  .menu-section.active {
    display: flex;
  }

  .hamburger-menu {
    display: block;
    /* Show hamburger icon */
    position: absolute;
    left: 20px;
    /* Centred on the header row (logo and login button are centred at 35px) */
    top: 26px;
    width: 25px;
    height: 18px;
    cursor: pointer;
    z-index: 1000;
  }

  /* Bars 8px apart: whole device pixels at every common pixel ratio (1.25, 2.625, 3...), so all
     three render with the same thickness */
  .hamburger-menu span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--color-gray-600);
    transition: .3s all ease;
  }

  .hamburger-menu span:nth-child(1) {
    top: 0;
  }

  .hamburger-menu span:nth-child(2) {
    top: 8px;
  }

  .hamburger-menu span:nth-child(3) {
    top: 16px;
  }

  /* Active hamburger state */
  .hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 8px;
  }

  .hamburger-menu.active span:nth-child(2) {
    opacity: 0;
  }

  .hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 8px;
  }

  .company-logo {
    margin-left: 30px;
    /* Added to create space for hamburger menu */
  }

  .menu-section {
    display: none;
    /* Hide the regular menu */
    right: 0;
    position: absolute;
    top: 60px;
    left: 0;
    /* Changed from right: 0 */
    background-color: white;
    width: 200px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border-radius: 4px;
    flex-direction: column;
    gap: 20px;
  }

  .contact-section {
    gap: 8px;
    /* Hide the contact section on mobile */
  }
}

/* Active nav link: set by header.js on the home page, and in the markup on blog pages */
.nav-link-active {
  color: var(--color-blue);
  position: relative;
}

.nav-link-active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--color-blue);
  animation: navFadeIn 0.3s ease;
}

@keyframes navFadeIn {
  from {
    transform: scaleX(0);
    opacity: 0;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* Language switcher (built into the header by tools/build.mjs) */
.language-switcher {
  position: relative;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray-700);
}

.language-switcher summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--color-gray-200);
  border-radius: 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.language-switcher summary::-webkit-details-marker {
  display: none;
}

.language-switcher summary::after {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.language-switcher[open] summary::after {
  transform: translateY(1px) rotate(-135deg);
}

.language-switcher summary:hover,
.language-switcher[open] summary {
  border-color: var(--color-blue);
  color: var(--color-blue);
}

.language-switcher summary:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}

.language-switcher ul {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1100;
  min-width: 140px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background-color: #fff;
  border: 1px solid var(--color-gray-200);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.language-switcher li a {
  display: block;
  padding: 8px 14px;
  color: var(--color-gray-900);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.language-switcher li a:hover,
.language-switcher li a:focus-visible {
  background-color: var(--color-gray-100);
  color: var(--color-blue);
}

.language-switcher li a[aria-current="page"] {
  color: var(--color-blue);
  font-weight: 600;
}

/* Segmented language pills [EN | PT | ES | FR] (built by tools/build.mjs).
   Used at the bottom of the mobile menu drawer and in the footer; colours for the footer are in footer.css. */
.language-pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: Montserrat, -apple-system, Roboto, Helvetica, sans-serif;
}

.language-pills-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-gray-600);
}

.language-pills-track {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--color-gray-200);
  border-radius: 999px;
  background-color: var(--color-gray-100);
}

.language-pills-track a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--color-gray-700);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.language-pills-track a:hover {
  color: var(--color-blue);
}

.language-pills-track a[aria-current="page"] {
  background-color: #fff;
  color: var(--color-blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.language-pills-track a:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 1px;
}

/* Full language name: read by screen readers, not shown */
.language-pills-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The drawer pills only exist on phones; elsewhere the header dropdown is used */
.language-pills--menu {
  display: none;
}

@media (max-width: 480px) {
  /* Language is a setting: on phones it moves from the header bar into the menu drawer */
  .contact-section .language-switcher {
    display: none;
  }

  .menu-section .language-pills--menu {
    display: flex;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--color-gray-200);
  }
}

@media print {
  .language-switcher,
  .language-pills {
    display: none;
  }
}
