/* ====================================== */
/* NAVBAR (Burger + Overlay close)        */
/* ====================================== */

/* Container */
.mainnav,
.main-nav {
  --gap: 1rem;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin: 0;
  margin-bottom: 3rem;
  padding: 0.75rem 0;
}

/* Brand / Logo link */
.brand,
.logo {
  padding: 1rem 0;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
}
.brand a,
.logo a {
  text-decoration: none;
  color: inherit;
}

a.home-link {
  display: none !important;
}

/* Accessible hidden toggle for CSS-only control */
.nav-toggle {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Fullscreen overlay to close on outside click (bound to same toggle via label[for]) */
.nav-overlay {
  display: none;
}

/* Panel (desktop baseline) */
.nav-panel {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

/* Links list */
.menu,
.menu-links {
  display: flex;
  column-gap: 1em;
  align-items: baseline;
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu a,
.menu-links a {
  font-size: small;
  line-height: 1;
  padding: 1rem 0;
  display: block;
  text-decoration: none;
  color: inherit;
  background-image: linear-gradient(
    0deg,
    var(--color-code-purple) 0%,
    var(--color-code-blue) 100%
  );
  background-repeat: no-repeat;
  background-size: 100% 0em;
  background-position: 0 88%;
  transition: background-size 0.25s ease-in;
}
.menu a:hover,
.menu-links a:hover {
  background-size: 100% 0.25em;
}
.menu a[aria-current],
.menu-links a[aria-current] {
  background-size: 100% 0.25em;
  background-image: linear-gradient(
    0deg,
    var(--color-code-purple) 0%,
    var(--color-code-blue) 100%
  );
}
.menu a[aria-current]:hover,
.menu-links a[aria-current]:hover {
  background-size: 100% 0.5em;
}

/* Social */
.social {
  display: flex;
}
.social a {
  padding: 1rem 0.5rem;
  transform: translateY(0.3em);
  text-decoration: none;
  color: inherit;
}

/* Languages */
.languages {
  display: flex;
  gap: 0.25em;
  height: 100%;
  align-items: center;
}
.languages ul {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}
.languages .active {
  font-weight: 700;
  background: none;
}
.languages a {
  line-height: 1;
  padding: 0;
  font-size: x-small;
  text-transform: uppercase;
  text-decoration: none !important;
  width: 1.5em;
  transition: all 0.4s ease;
  color: inherit;
}
.languages a:hover,
.languages a:focus {
  font-weight: 700;
  color: var(--color-hover);
}

/* ====================================== */
/* Burger Button (CSS animated)           */
/* ====================================== */

/* Desktop: hide burger by default */
.menu-burger {
  background: none;
  border: 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 2rem;
  height: 2rem; /* fixed typo */
  -webkit-tap-highlight-color: transparent;
}
.menu-burger svg {
  width: 100%;
  height: 100%;
}
.menu-burger .line {
  fill: none;
  stroke: currentColor;
  stroke-width: 6;
  transition: stroke-dasharray 600ms cubic-bezier(0.4, 0, 0.2, 1),
    stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
}
.menu-burger .line1 {
  stroke-dasharray: 60 207;
}
.menu-burger .line2 {
  stroke-dasharray: 60 60;
}
.menu-burger .line3 {
  stroke-dasharray: 60 207;
}

/* Animate hamburger -> close when nav is open */
.nav-toggle:checked + .menu-burger .line1 {
  stroke-dasharray: 90 207;
  stroke-dashoffset: -134;
}
.nav-toggle:checked + .menu-burger .line2 {
  stroke-dasharray: 1 60;
  stroke-dashoffset: -30;
}
.nav-toggle:checked + .menu-burger .line3 {
  stroke-dasharray: 90 207;
  stroke-dashoffset: -134;
}

/* ====================================== */
/* Mobile behaviour (<700px)              */
/* ====================================== */
@media (max-width: 700px) {
  /* Mobile: show burger */
  .menu-burger {
    display: flex;
  }

  a.home-link {
    display: block !important;
  }

  /* Panel as dropdown overlay (hidden by default) */
  .nav-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: grid;
    gap: 1rem;
    padding: 1rem;
    background: var(--nav-bg, #fff);
    border: 1px solid var(--nav-border, #e5e5e5);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transform-origin: top right;
    transform: scale(0.98) translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
    z-index: 20;
    border-radius: 1em;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
  }

  /* Fullscreen overlay only when menu is open */
  .nav-toggle:checked ~ .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 19;
    cursor: default;
  }

  /* Reveal panel when open */
  .nav-toggle:checked ~ .nav-panel {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  /* Stacking adjustments */
  .menu,
  .menu-links {
    flex-direction: column;
    gap: 0.5rem;

    a {
      font-size: small;
      line-height: 1;
      padding: 1rem 0;
      display: block;
      text-decoration: none;
      color: inherit;
      padding: 0.5em 0;
      background-image: linear-gradient(
        0deg,
        var(--color-code-purple) 0%,
        var(--color-code-blue) 100%
      );
      background-repeat: no-repeat;
      background-size: 100% 0em;
      background-position: 0 88%;
      transition: background-size 0.25s ease-in;

      &:hover {
        background-size: 100% 0.25em;
      }
    }
  }
  .languages ul {
    flex-wrap: wrap;
  }
  .brand,
  .logo {
    padding: 0;
  }
}

/* Motion preference */
@media (prefers-reduced-motion: reduce) {
  .nav-panel {
    transition: none;
  }
}
