/* Stage1Energy — liquid glass top bar (ported from pre-v2.0 index). */

:root {
  --top-bar-reserve: 5rem;
  --page-gutter: var(--gutter);
  --top-bar-radius: var(--radius-pill);
  --scroll-progress: 0;
  --nav-spread: 1;
  --lime-deep: #9ab80e;
}

html.has-top-bar {
  scroll-padding-top: calc(var(--top-bar-reserve) + 1rem);
}

html.has-top-bar [id] {
  scroll-margin-top: calc(var(--top-bar-reserve) + 1rem);
}

/* ---------- Floating glass pill ---------- */

.top-bar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  margin-inline: auto;
  z-index: 50;
  width: min(calc(100vw * 2 / 3), calc(100vw - 2 * var(--page-gutter)));
  max-width: 100%;
  transform: none;
  box-sizing: border-box;
  min-height: 3.35rem;
  border-radius: var(--top-bar-radius);
  padding: 0.58rem 0.75rem 0.58rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  overflow: visible;
  background: linear-gradient(130deg, rgba(248, 255, 248, 0.34), rgba(240, 249, 241, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.54), 0 18px 28px rgba(19, 35, 22, 0.2);
  -webkit-backdrop-filter: blur(22px) saturate(152%);
  backdrop-filter: blur(22px) saturate(152%);
  opacity: 0;
  animation: none;
  transition: background-color 280ms ease, box-shadow 280ms ease, transform 280ms ease, color 200ms ease;
}

/* First visit this session — animate in (non-landing pages) */
html:not(.top-bar-returning):not(.hero-loading) body:not(.page-landing) .top-bar {
  animation: top-bar-enter 1.85s cubic-bezier(0.22, 1, 0.36, 1) 0.22s forwards;
}

/* First visit — landing waits for hero image */
body.page-landing .top-bar {
  opacity: 0;
  animation: none;
}

html.hero-load-complete:not(.top-bar-returning) body.page-landing .top-bar {
  animation: top-bar-enter 1.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* In-session page navigations — show instantly, no fade */
html.top-bar-returning .top-bar {
  opacity: 1 !important;
  animation: none !important;
  filter: none !important;
  clip-path: none !important;
}

html.hero-loading body.page-landing .top-bar {
  opacity: 0 !important;
  animation: none !important;
  filter: none;
  clip-path: none;
}

.top-bar-track {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.top-bar .wordmark,
.top-bar .top-bar-cluster,
.top-bar .top-bar-actions {
  position: relative;
  z-index: 1;
}

/* ---------- Progress bar ---------- */

.top-bar-progress {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  height: 3px;
  border-radius: 0 0 calc(var(--top-bar-radius) - 1px) calc(var(--top-bar-radius) - 1px);
  overflow: hidden;
  pointer-events: none;
}

.top-bar-progress-dim {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--scroll-progress, 0));
  background: linear-gradient(90deg, var(--lime-deep), var(--lime));
  opacity: 0.2;
}

.top-bar-progress-active {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 100%;
  width: 0;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lime-deep), var(--lime));
  opacity: 0.95;
  transition: left 0.16s ease, width 0.16s ease, opacity 0.16s ease;
}

.top-bar-progress-active.is-hidden {
  opacity: 0;
}

/* ---------- Cluster + wordmark ---------- */

.top-bar-cluster {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: clamp(0.35rem, 1.2vw, 0.85rem);
}

.top-bar .wordmark {
  margin: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  min-width: 0;
  padding: 0.25rem 0;
  white-space: nowrap;
  font-family: var(--body);
  font-size: clamp(1.12rem, 1.85vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
  transition: color 200ms ease, text-shadow 200ms ease;
}

.top-bar a.wordmark:visited {
  color: #ffffff;
}

.top-bar .wordmark abbr {
  text-decoration: none;
  border: 0;
  cursor: inherit;
  line-height: 1;
  color: currentColor;
}

/* ---------- Nav links ---------- */

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.nav-links {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 0;
}

.nav-link-flex-gap {
  flex: calc(var(--nav-spread, 0) * 1) 1 0%;
  min-width: 0;
}

.nav-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.82rem;
  transition: background-color 170ms ease, color 170ms ease, text-shadow 170ms ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.nav-links a:active:not(.nav-link-cta) {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.top-bar-actions > .nav-link-cta {
  flex-shrink: 0;
  background: var(--lime);
  color: #10200b;
  border: 1px solid rgba(117, 194, 54, 0.76);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.45rem 1rem;
  min-height: 44px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: background-color 170ms ease, box-shadow 170ms ease, color 170ms ease;
}

.top-bar-actions > .nav-link-cta .btn__free {
  margin-left: 0;
  padding: 2px 7px;
  font-size: 0.68em;
  letter-spacing: 0.12em;
  border-radius: 3px;
}

.top-bar-actions > .nav-link-cta:hover,
.top-bar-actions > .nav-link-cta:focus-visible {
  background: var(--lime-deep);
  color: #10200b;
  box-shadow: 0 4px 14px rgba(19, 35, 22, 0.22);
}

.top-bar-actions > .nav-link-cta:active {
  box-shadow: 0 0 0 2px rgba(252, 255, 248, 0.65), 0 4px 14px rgba(19, 35, 22, 0.22);
}

/* ---------- Mobile menu ---------- */

.nav-menu {
  display: none;
  position: relative;
}

.nav-menu-summary {
  list-style: none;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  padding: 0.55rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.nav-menu-summary::-webkit-details-marker {
  display: none;
}

.nav-menu-summary::after {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.45rem;
  border-right: 2px solid rgba(255, 255, 255, 0.82);
  border-bottom: 2px solid rgba(255, 255, 255, 0.82);
  transform: rotate(45deg) translateY(-0.06em);
  transition: transform 200ms ease;
}

.nav-menu[open] > .nav-menu-summary::after {
  transform: rotate(-135deg) translateY(0.1em);
}

.nav-menu-summary:hover,
.nav-menu-summary:focus-visible {
  background: rgba(255, 255, 255, 0.38);
}

.nav-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.42rem);
  min-width: min(100vw - 2.2rem, 15rem);
  padding: 0.45rem;
  display: grid;
  gap: 0.2rem;
  border-radius: 12px;
  z-index: 20;
  background: rgba(237, 246, 236, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: 0 16px 34px rgba(19, 35, 22, 0.25);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
}

.nav-menu-dropdown a {
  text-decoration: none;
  font-size: 0.84rem;
  border-radius: var(--radius-pill);
  color: rgba(24, 38, 23, 0.9);
  padding: 0.62rem 0.85rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: background-color 180ms ease, color 180ms ease;
}

.nav-menu-dropdown a:hover,
.nav-menu-dropdown a:focus-visible {
  background: rgba(255, 255, 255, 0.55);
  color: rgba(24, 38, 23, 0.96);
}

.nav-menu-dropdown a:active:not(.nav-link-cta) {
  background: rgba(139, 212, 82, 0.38);
  color: rgba(16, 32, 11, 0.98);
  font-weight: 700;
}

.nav-menu-dropdown a.nav-link-cta {
  background: var(--lime);
  color: #10200b;
  border: 1px solid rgba(117, 194, 54, 0.76);
  font-weight: 700;
  justify-content: center;
  padding: 0.62rem 1.2rem;
}

.nav-menu-dropdown a.nav-link-cta:hover,
.nav-menu-dropdown a.nav-link-cta:focus-visible {
  background: var(--lime-deep);
  color: #10200b;
}

.nav-menu-dropdown a[aria-current="page"] {
  background: rgba(66, 99, 51, 0.12);
  color: rgba(22, 36, 19, 0.92);
  font-weight: 700;
}

/* ---------- Dark vs light chrome ---------- */

html:not(.top-bar-light-bg) .nav-links a:not([aria-current="page"]) {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

html:not(.top-bar-light-bg) .nav-links a[aria-current="page"] {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

html.top-bar-light-bg .top-bar .wordmark {
  color: #131f17;
  text-shadow: none;
}

html.top-bar-light-bg .top-bar a.wordmark:visited {
  color: #131f17;
}

html.top-bar-light-bg .nav-links a:not(.nav-link-cta) {
  color: #131f17;
  text-shadow: none;
}

html.top-bar-light-bg .nav-links a:not(.nav-link-cta):hover,
html.top-bar-light-bg .nav-links a:not(.nav-link-cta):focus-visible {
  background: rgba(19, 31, 23, 0.08);
  color: #131f17;
}

html.top-bar-light-bg .nav-links a:active:not(.nav-link-cta) {
  background: rgba(19, 31, 23, 0.14);
  color: #131f17;
  box-shadow: inset 0 0 0 1px rgba(19, 31, 23, 0.12);
}

html.top-bar-light-bg .nav-links a[aria-current="page"] {
  background: rgba(19, 31, 23, 0.1);
  color: #131f17;
  font-weight: 700;
}

html.top-bar-light-bg .top-bar-actions > .nav-link-cta {
  color: #10200b;
}

html.top-bar-light-bg .top-bar-actions > .nav-link-cta:active {
  box-shadow: 0 0 0 2px rgba(66, 99, 51, 0.35), 0 4px 14px rgba(19, 35, 22, 0.18);
}

html.top-bar-light-bg .nav-menu-summary {
  color: #131f17;
  border-color: rgba(19, 31, 23, 0.18);
  background: rgba(255, 255, 255, 0.72);
}

html.top-bar-light-bg .nav-menu-summary::after {
  border-right-color: #131f17;
  border-bottom-color: #131f17;
}

html.top-bar-light-bg .nav-menu-summary:hover,
html.top-bar-light-bg .nav-menu-summary:focus-visible {
  background: rgba(255, 255, 255, 0.92);
  color: #131f17;
}

html:not(.top-bar-light-bg) .nav-menu-summary:hover,
html:not(.top-bar-light-bg) .nav-menu-summary:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* ---------- Scrolled lift ---------- */

html.top-bar-scrolled .top-bar {
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.58), 0 14px 22px rgba(19, 35, 22, 0.24);
  background: linear-gradient(130deg, rgba(246, 255, 246, 0.42), rgba(238, 248, 239, 0.26));
  margin-top: -0.16rem;
}

/* ---------- Enter animation ---------- */

@keyframes top-bar-enter {
  0% {
    opacity: 0;
    filter: blur(11px) saturate(0.9);
  }
  52% {
    opacity: 1;
    filter: blur(2.5px) saturate(1);
  }
  100% {
    opacity: 1;
    filter: blur(0) saturate(1);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .top-bar {
    background: linear-gradient(130deg, rgba(248, 255, 248, 0.88), rgba(240, 249, 241, 0.76));
    -webkit-backdrop-filter: blur(10px) saturate(145%);
    backdrop-filter: blur(10px) saturate(145%);
  }

  .nav-menu-dropdown {
    background: rgba(237, 246, 236, 0.94);
    -webkit-backdrop-filter: blur(10px) saturate(145%);
    backdrop-filter: blur(10px) saturate(145%);
  }
}

@media (max-width: 980px) {
  :root {
    --top-bar-radius: 12px;
    --nav-spread: 0;
  }

  .nav-links {
    display: none;
  }

  .nav-menu {
    display: block;
  }

  .nav-menu-dropdown .nav-link-cta {
    display: none !important;
  }

  /* Full-screen drawer */
  html.nav-menu-open .nav-menu-dropdown {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-width: 0;
    margin: 0;
    border-radius: 0;
    border: 0;
    padding: calc(var(--top-bar-reserve) + 1.25rem) var(--page-gutter) var(--page-gutter);
    z-index: 49;
    display: grid;
    align-content: start;
    gap: 0.35rem;
    background: var(--ink);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  html.nav-menu-open .nav-menu-dropdown a {
    font-family: var(--display);
    font-size: clamp(1.45rem, 6vw, 1.85rem);
    line-height: 1.2;
    font-weight: 400;
    color: var(--paper);
    padding: 0.85rem 0;
    min-height: 0;
    border-radius: 0;
    background: transparent;
  }

  html.nav-menu-open .nav-menu-dropdown a:hover,
  html.nav-menu-open .nav-menu-dropdown a:focus-visible {
    background: transparent;
    color: var(--paper);
    text-decoration: underline;
    text-underline-offset: 0.18em;
  }

  html.nav-menu-open .nav-menu-dropdown a[aria-current="page"] {
    color: var(--lime);
    background: transparent;
    font-weight: 400;
  }

  html.nav-menu-open .nav-menu-dropdown a.nav-link-cta {
    margin-top: 1.25rem;
    font-family: var(--body);
    font-size: 0.95rem;
    font-weight: 700;
    justify-content: center;
    padding: 0.95rem 1.4rem;
    border-radius: var(--radius-pill);
    background: var(--lime);
    color: #10200b;
    text-decoration: none;
  }

  html.nav-menu-open .nav-menu-dropdown a.nav-link-cta:hover,
  html.nav-menu-open .nav-menu-dropdown a.nav-link-cta:focus-visible {
    background: var(--lime-deep);
    color: #10200b;
    text-decoration: none;
  }

  html.nav-menu-open {
    overflow: hidden;
  }

  html.nav-menu-open .top-bar {
    z-index: 55;
  }
}

@media (max-width: 700px) {
  :root {
    --top-bar-reserve: 4.65rem;
  }

  .top-bar {
    top: 10px;
    width: calc(100vw - 2 * var(--page-gutter));
  }
}

@media (max-width: 480px) {
  .top-bar {
    padding-inline: 0.62rem;
    gap: 0.52rem;
  }

  .top-bar-actions {
    gap: 0.32rem;
  }

  .nav-menu-summary {
    padding-inline: 0.78rem;
  }
}

@media (hover: none), (pointer: coarse) {
  html:not(.top-bar-returning) .top-bar,
  html.hero-load-complete .top-bar {
    opacity: 1 !important;
    animation: none !important;
    filter: none !important;
    clip-path: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.hero-loading .landing-hero__media {
    opacity: 1 !important;
  }

  .top-bar-progress {
    display: none !important;
  }

  .top-bar {
    animation: none !important;
    opacity: 1 !important;
    filter: none !important;
    clip-path: none !important;
  }

  .top-bar-progress-active {
    transition: none !important;
  }
}
