/* Back-to-top button (injected by /assets/js/site.js initScrollTop) */
.scroll-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50; /* above sticky header (z-40) and page content */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 2px solid #3ee6a0;
  border-radius: 50%;
  background-color: #12141c;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s,
    background-color 0.15s ease, color 0.15s ease;
}

.scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0s,
    background-color 0.15s ease, color 0.15s ease;
}

.scroll-top svg {
  display: block;
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.scroll-top:hover,
.scroll-top:focus-visible {
  background-color: #3ee6a0;
  color: #12141c;
}

.scroll-top:focus {
  outline: none;
}

.scroll-top:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

@media (max-width: 767px) {
  .scroll-top {
    right: 16px;
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-top,
  .scroll-top.is-visible {
    transition: none;
    transform: none;
  }
}

/* ------------------------------------------------------------------
   Site header: sticky + mobile menu (behaviour in /assets/js/site.js initMenu)
   Plain CSS so it does not depend on the compiled Tailwind build.
   ------------------------------------------------------------------ */
html {
  scroll-padding-top: 88px; /* header (~65-69px) + breathing room */
}

.site-header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 40; /* below .scroll-top (50) */
  border-bottom: 1px solid #2f3445;
  background-color: rgba(18, 20, 28, 0.95);
  color: #f2f3f7;
}

.site-header > div > a:first-child {
  color: #3ee6a0;
}

.site-header nav > a {
  color: #f2f3f7;
}

.site-header nav > a:hover {
  background-color: #252938;
}

.site-header nav > a[aria-current="page"] {
  background-color: #252938;
  color: #3ee6a0;
}

.site-header nav > a:focus-visible,
.site-header .nav-toggle:focus-visible,
.site-header .site-mobile-menu__cta:focus-visible {
  outline: 2px solid #3ee6a0;
  outline-offset: 2px;
}

/* Desktop: nav + CTA visible, toggle hidden, mobile panel never shown */
@media (min-width: 768px) {
  .site-header > div > nav {
    display: flex !important;
  }
  .site-header > div > div.ms-auto {
    display: block !important;
  }
  .site-header > div > button,
  .site-header .site-mobile-menu {
    display: none !important;
  }
}

/* Mobile */
@media (max-width: 767px) {
  /* No JS: the toggle does nothing, so hide it and show the nav as a wrapping row */
  .site-header:not(.has-mobile-nav) > div {
    flex-wrap: wrap;
  }
  .site-header:not(.has-mobile-nav) > div > button {
    display: none !important;
  }
  .site-header:not(.has-mobile-nav) > div > nav {
    display: flex !important;
    flex-wrap: wrap;
    flex-basis: 100%;
    order: 3;
  }

  /* JS enhanced: collapse the nav behind the toggle */
  .site-header.has-mobile-nav > div > nav.site-nav {
    display: none !important;
  }

  .site-header.has-mobile-nav .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin-inline-start: auto;
    margin-block: -2px; /* 44px tap target without growing the 65px header row */
    padding: 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #f2f3f7;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }

  .site-header.has-mobile-nav .nav-toggle:hover,
  .site-header.has-mobile-nav .nav-toggle[aria-expanded="true"] {
    background-color: #252938;
    border-color: #2f3445;
    color: #3ee6a0;
  }

  .site-header.has-mobile-nav .nav-toggle svg {
    display: block;
    pointer-events: none;
  }

  .site-header .site-mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 66px);
    max-height: calc(100dvh - 66px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 16px;
    border-top: 1px solid #2f3445;
    border-bottom: 1px solid #2f3445;
    background-color: #12141c;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
    animation: site-menu-in 0.16s ease-out;
  }

  .site-header .site-mobile-menu[hidden] {
    display: none;
  }

  .site-mobile-menu__link {
    display: block;
    padding: 14px 12px;
    border-bottom: 1px solid #2f3445;
    color: #f2f3f7;
    font-weight: 600;
    text-decoration: none;
  }

  .site-mobile-menu__link:last-of-type {
    border-bottom: 0;
  }

  .site-mobile-menu__link:hover,
  .site-mobile-menu__link:focus-visible {
    background-color: #252938;
    outline: none;
  }

  .site-mobile-menu__link[aria-current="page"] {
    background-color: #252938;
    color: #3ee6a0;
    border-radius: 8px;
  }

  .site-mobile-menu__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 12px;
    padding: 0 20px;
    border-radius: 8px;
    background-color: #3ee6a0;
    color: #0b1a13;
    font-weight: 700;
    text-decoration: none;
  }

  .site-mobile-menu__cta:hover {
    background-color: #5ff0b4;
  }
}

@keyframes site-menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .site-header .site-mobile-menu {
    animation: none;
  }
  .site-header .nav-toggle {
    transition: none;
  }
}
