/**
 * Company Switcher Styles
 * Modern gradient design with responsive dropdown/horizontal layout
 */

.north-company-switcher {
  background: linear-gradient(
    90deg,
    #B97E36 0%,   /* gruppen */
    #0B83C5 20%,  /* industri */
    #2963AF 40%,  /* eiendom */
    #BE5E32 60%,  /* enter */
    #C05BA3 80%,  /* henrys */
    #7E3393 100%  /* marketing */
  );
  color: #FFFFFF;
  padding: 0.5rem 0;
  position: sticky;
  top: 0;
  z-index: 1500; /* Above header */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.north-company-switcher .container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
  position: relative;
}

.company-nav {
  display: flex;
  align-items: center;
  justify-content: center; /* Center switcher horizontally */
  gap: 0.5rem;
}

/* Toggle button (hidden on desktop, shown mobile) */
.switcher-label {
  display: none;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.25);
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background .2s ease;
}

.switcher-label:hover {
  background: rgba(255,255,255,0.35);
}

.switcher-label {
  font-weight: 600;
  color: #111827; /* Svart for desktop */
  white-space: nowrap;
  font-size: 0.7rem; /* Litt mindre totaltekst */
}

/* Desktop: Horizontal scrollable list */
.company-list {
  display: flex;
  gap: 0.25rem; /* Enda litt tighter for laptop */
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.company-list::-webkit-scrollbar {
  height: 4px;
}

.company-list::-webkit-scrollbar-track {
  background: transparent;
}

.company-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 100px;
}

.company-item {
  margin: 0;
}

.company-link {
  display: inline-block;
  padding: 0.3rem 0.6rem; /* Ytterligere kniping for laptop */
  color: #FFFFFF;
  text-decoration: none;
  border-radius: 0.5rem;
  font-size: 0.7rem; /* Mindre font for total velger */
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  backdrop-filter: blur(0px);
}

.company-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: #FFFFFF;
  transition: width 0.3s ease;
}

.company-link:hover {
  background: var(--company-color);
  color: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.company-link:hover::before {
  width: calc(100% - 2rem);
}

.company-link:focus-visible {
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

.company-item.is-current .company-link {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  font-weight: 600;
}

.company-item.is-current .company-link::before {
  width: calc(100% - 2rem);
}
  .company-item.is-current .company-link {
    background: var(--company-color);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  }
  .company-item.is-current .company-link::before {
    width: calc(100% - 2rem);
    background: #FFFFFF;
  }

/* Mobile: Dropdown menu */
@media (max-width: 768px) {
  .north-company-switcher {
    padding: 0.5rem 0;
  }

  .company-nav {
    position: relative;
    flex-direction: column;
    align-items: center; /* Sentrer innhold horisontalt */
    justify-content: flex-start;
  }

  .switcher-label {
    display: flex;
    align-items: center;
    justify-content: center; /* Tekst midtstilles */
    width: auto; /* Ikke full bredde */
    padding: 0.5rem 0.8rem;
    margin: 0 auto; /* Plasser midt i container */
  }

  .company-list {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    width: min(320px, calc(100% - 2rem));
    margin: 0 auto; /* Midtstilt uten transform for å unngå subpiksel overflow */
    flex-direction: column;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    border-radius: 0.6rem;
    padding: 0.5rem;
    box-shadow: 0 16px 32px rgba(0,0,0,0.25);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1600; /* Above header & switcher */
  }

  .company-list.is-open {
    max-height: 420px;
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto;
  }

  .company-link {
    width: 100%;
    font-size: 0.9rem;
    color: #111827;
    background: transparent;
    padding: 0.6rem 0.65rem;
    border-radius: 0.45rem;
  }

  .company-link::before { display: none; }

  .company-link:hover {
    background: var(--company-color);
    color: #FFFFFF;
    transform: translateX(4px);
    box-shadow: none;
  }

  .company-item.is-current .company-link {
    background: var(--company-color);
    color: #FFFFFF;
    font-weight: 600;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .company-link,
  .company-link::before,
  .company-list,
  .switcher-label::after {
    transition: none;
  }
  
  .company-link:hover {
    transform: none;
  }
}
