/* Sticky nav, brand, language switcher, mobile overlay menu */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  transition:
    background 0.5s var(--ease),
    border-color 0.5s var(--ease);
}
.nav.scrolled {
  background: rgba(21, 15, 11, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
}
.nav:has(.menu-toggle.active) {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-bottom-color: transparent !important;
}
.nav-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.4rem 3.2rem;
  display: flex;
  align-items: center;
  gap: 2.6rem;
  transition: padding 0.5s var(--ease);
}
.nav.scrolled .nav-inner {
  padding: 0.75rem 3.2rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-right: auto;
  text-decoration: none;
  transition: transform 0.6s var(--ease);
}
.brand img {
  height: 40px;
  display: block;
}
.nav-links {
  display: flex;
  list-style: none;
  gap: 2.2rem;
  align-items: center;
  margin: 0;
  padding: 0;
  transition: transform 0.6s var(--ease);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transition: transform 0.6s var(--ease);
}
.language-switcher {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(21, 15, 11, 0.45);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
}
.language-switcher button {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 1.9rem;
  padding: 0.34rem 0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--cream-faint);
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-align: center;
  transition: color 160ms var(--ease-out);
}
.language-switcher button.active {
  color: var(--espresso);
}
.lang-thumb {
  position: absolute;
  z-index: 0;
  top: 0.2rem;
  bottom: 0.2rem;
  left: 0.2rem;
  right: 50%;
  background: var(--gold);
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(199, 160, 89, 0.28);
  transition: transform 220ms var(--ease-out);
  pointer-events: none;
}
.language-switcher:has(button[data-language="fi"].active) .lang-thumb {
  transform: translateX(100%);
}
.language-switcher button:focus-visible {
  outline: 1px solid var(--gold-soft);
  outline-offset: 2px;
}
.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--cream-dim);
  position: relative;
  padding-bottom: 3px;
  transition: color 0.3s ease;
}
.nav-links a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--gold);
  transition: width 0.35s var(--ease);
}
.menu-toggle {
  display: none;
  cursor: pointer;
  z-index: 1001;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: rgba(21, 15, 11, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(247, 241, 230, 0.16);
  color: var(--cream);
  transition:
    background 0.45s var(--ease-out),
    border-color 0.45s var(--ease-out),
    color 0.45s var(--ease-out),
    transform 0.45s var(--ease-out);
  position: relative;
}
.menu-toggle:active {
  transform: scale(0.96);
}
.menu-toggle:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 3px;
}
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 14px;
  height: 10px;
  justify-content: center;
  transition: opacity 0.3s var(--ease);
}
.hamburger span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.menu-toggle.active .hamburger {
  opacity: 0;
  pointer-events: none;
}
.close-icon {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.menu-toggle.active .close-icon {
  display: block;
  opacity: 1;
}
.mobile-nav-links a:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 6px;
  border-radius: 4px;
}
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 15, 11, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.02);
  transition:
    opacity 0.45s var(--ease),
    transform 0.45s var(--ease),
    visibility 0s linear 0.45s;
  overscroll-behavior: contain;
  touch-action: none;
}
.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  transition:
    opacity 0.45s var(--ease),
    transform 0.45s var(--ease),
    visibility 0s linear;
}
.mobile-nav-links {
  list-style: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
  margin: 0;
  padding: 0;
}
.mobile-nav-links a {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 400;
  font-style: italic;
  color: var(--cream);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s var(--ease);
  text-decoration: none;
}
.mobile-overlay.active .mobile-nav-links a {
  opacity: 1;
  transform: translateY(0);
}
.mobile-overlay.active .mobile-nav-links a:nth-child(1) {
  transition-delay: 0.06s;
}
.mobile-overlay.active .mobile-nav-links a:nth-child(2) {
  transition-delay: 0.12s;
}
.mobile-overlay.active .mobile-nav-links a:nth-child(3) {
  transition-delay: 0.18s;
}
.mobile-overlay.active .mobile-nav-links a:nth-child(4) {
  transition-delay: 0.24s;
}

/* Hover effects only for devices that truly support hover (mouse/trackpad).
   Prevents tap-and-hold "stuck" hover states on touch devices. */
@media (hover: hover) and (pointer: fine) {
  .language-switcher button:not(.active):hover {
    color: var(--cream-faint);
  }
  .nav-links a:hover {
    color: var(--cream);
  }
  .nav-links a:hover::after {
    width: 100%;
  }
  .menu-toggle:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--espresso);
    transform: scale(1.06);
  }
  .mobile-nav-links a:hover {
    color: var(--gold);
  }
}

/* Desktop-only: on entering the scrolled/compact bar, ease the brand and the
   nav-links + language-switcher cluster slightly outward toward the edges,
   opening a touch more breathing room in the middle as a subtle settle effect. */
@media (min-width: 769px) {
  .nav.scrolled .brand {
    transform: translateX(-14px);
  }
  .nav.scrolled .nav-links,
  .nav.scrolled .nav-right {
    transform: translateX(14px);
  }
}
