/**
 * Navigation refinements for the debtsunset_nav menus (loaded after
 * style.css, which holds the bar, the mobile toggle and the base pills).
 *
 * - Member steps: a numbered circle before My debts / My plan / My progress,
 *   and a marigold "Next" badge on the step to do next.
 * - Descriptions: one plain line under each submenu label; under top-level
 *   labels on phones only (desktop shows them as the hover tooltip).
 * - Toggle parents (Tools, Account): the chevron is part of the link.
 * - Account: Sign in (ghost) + Start free (marigold) for visitors; an Account
 *   dropdown, right-aligned, for members, on phones too.
 */

/* --- Link contents --------------------------------------------------------- */

.debtsunset-navbar .menu-link__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.debtsunset-navbar .menu-link__desc {
  margin-top: 0.15rem;
  color: var(--ds-muted-night);          /* on night 8.2, on twilight 6.4 */
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.3;
  white-space: normal;
}

.debtsunset-navbar .menu-link__step {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.55rem;
  border: 2px solid color-mix(in srgb, var(--ds-sand) 55%, transparent);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

/* The step you are on: a filled circle. */
.debtsunset-primary .menu-item--active-trail > a .menu-link__step,
.debtsunset-primary a.is-active .menu-link__step {
  border-color: var(--ds-marigold);
  background: var(--ds-marigold);
  color: var(--ds-night);
}

.debtsunset-navbar .menu-link__badge {
  flex: 0 0 auto;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-marigold);
  color: var(--ds-night);                /* night on marigold 9.6 */
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* --- Toggle parents: chevron inside the link ------------------------------- */

.debtsunset-navbar .menu-item--toggle > a::after {
  content: "";
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin-left: 0.4rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FBEEE2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / 1rem no-repeat;
}

.debtsunset-navbar .menu-item--toggle.is-open > a::after {
  transform: rotate(180deg);
}

/* The Account pill is linen with night text: a night chevron. */
.debtsunset-account .menu-item--toggle > a::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230A1A33' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Toggle links carry role="button" (nav.js), which the theme's button rule
   paints as an ember pill: in the bar they must look like the other links. */
.debtsunset-primary .menu--level-0 > .menu-item > a[data-ds-toggle] {
  justify-content: flex-start;
  border-top-width: 0;
  border-right-width: 0;
  background-color: transparent;
  color: var(--ds-sand);
  font-size: 1rem;
  text-align: left;
}

@media (min-width: 900px) {
  .debtsunset-primary .menu--level-0 > .menu-item > a[data-ds-toggle] {
    border-left-width: 0;
  }
}

.debtsunset-account .menu-item > a[data-ds-toggle] {
  font-size: 1rem;
}

/* Toggle parents have no separate chevron button, so keep their padding. */
.debtsunset-primary .menu--level-0 > .menu-item--toggle > a {
  padding-right: 1.1rem;
}

/* --- Submenus: label + description rows ------------------------------------ */

.debtsunset-primary .menu--sub {
  min-width: 17rem;
}

.debtsunset-navbar .menu--sub > .menu-item > a {
  align-items: flex-start;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border-radius: 12px;                   /* two-line rows: a soft box, not a pill */
  white-space: normal;
}

.debtsunset-navbar .menu--sub .menu-link__label {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* --- Desktop: top-level descriptions are tooltips, not text ---------------- */

@media (min-width: 900px) {
  .debtsunset-primary .menu--level-0 > .menu-item > a .menu-link__desc {
    display: none;
  }

  .debtsunset-primary .menu--level-0 > .menu-item > a {
    padding: 0 1rem;
  }
}

/* --- Account area ---------------------------------------------------------- */

.debtsunset-account .menu-item {
  position: relative;
}

/* Visitors: "Start free" is the primary action. */
.debtsunset-account .menu-item > a.menu-link--cta {
  border-color: var(--ds-marigold);
  background-color: var(--ds-marigold);
  color: var(--ds-night);
}

.debtsunset-account .menu-item > a.menu-link--cta:is(:hover, :focus-visible) {
  border-color: var(--ds-amber);
  background-color: var(--ds-amber);
  color: var(--ds-night);
}

/* The CTA's description is its tooltip only. */
.debtsunset-account .menu--level-0 > .menu-item > a .menu-link__desc {
  display: none;
}

/* Members: the Account dropdown, right-aligned under its pill. */
.debtsunset-account .menu--sub {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 60;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  width: max-content;
  min-width: 16rem;
  max-width: calc(100vw - 2rem);
  margin: 0;
  padding: 0.5rem;
  list-style: none;
  border-radius: var(--ds-radius-container);
  background-color: var(--ds-night);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.35);
}

.debtsunset-account .menu-item.is-open > .menu--sub,
.debtsunset-account .menu-item:has(> .menu--sub :focus-visible) > .menu--sub {
  display: flex;
}

@media (hover: hover) and (pointer: fine) {
  .debtsunset-account .menu-item--has-children:hover > .menu--sub {
    display: flex;
  }

  /* Bridge the 0.5rem gap so the pointer can travel into the panel. */
  .debtsunset-account .menu-item--has-children:hover::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    height: 0.5rem;
  }
}

/* Dropdown rows: undo the linen pill that top-level account links get. */
.debtsunset-account .menu--sub > .menu-item > a {
  display: flex;
  width: 100%;
  border: 2px solid transparent;
  background-color: transparent;
  color: var(--ds-sand);                 /* sand on night 15.25 */
  font-weight: 500;
}

.debtsunset-account .menu--sub > .menu-item > a:is(:hover, :focus-visible, .is-active) {
  border-color: var(--ds-marigold);
  background-color: var(--ds-twilight);
  color: var(--ds-sand);
}

/* "Sign out" sits apart from the rest. */
.debtsunset-account .menu--sub > .menu-item:last-child {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid color-mix(in srgb, var(--ds-sand) 18%, transparent);
}

/* --- Phones and small tablets ---------------------------------------------- */

@media (max-width: 899px) {
  /* Rows grow to fit the description line. */
  .debtsunset-primary .menu--level-0 > .menu-item > a {
    min-height: 3.25rem;
    padding-block: 0.55rem;
  }

  .debtsunset-primary .menu--level-0 > .menu-item--toggle > a {
    padding-right: 1rem;
  }

  /* Toggle parents: the chevron sits at the far right, like the buttons. */
  .debtsunset-primary .menu-item--toggle > a::after {
    margin-left: auto;
  }
}

@media (max-width: 400px) {
  .debtsunset-account .menu {
    gap: 0.4rem;
  }

  .debtsunset-account .menu--level-0 > .menu-item > a {
    padding: 0 0.85rem;
  }
}

/* ===========================================================================
   Refinements: frosted dropdowns, gentle motion, full-strength hover
   =========================================================================== */

/* Dropdown panels (desktop main menu, and the Account menu everywhere): a
   very slightly translucent night, the page behind blurred so it never reads
   as clutter. Rows rest a touch softer; the row you point at or focus is at
   full strength. Without backdrop-filter the panel stays solid. */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  @media (min-width: 900px) {
    .debtsunset-primary .menu--sub {
      background-color: color-mix(in srgb, var(--ds-night) 90%, transparent);
      -webkit-backdrop-filter: blur(14px) saturate(140%);
      backdrop-filter: blur(14px) saturate(140%);
    }
  }

  .debtsunset-account .menu--sub {
    background-color: color-mix(in srgb, var(--ds-night) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
  }
}

@media (min-width: 900px) {
  .debtsunset-primary .menu--sub {
    border: 1px solid color-mix(in srgb, var(--ds-sand) 10%, transparent);
    border-top: 0;
    box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.18);
  }
}

.debtsunset-account .menu--sub {
  border: 1px solid color-mix(in srgb, var(--ds-sand) 10%, transparent);
  box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.45), 0 2px 6px rgb(0 0 0 / 0.18);
}

/* Rows at rest: a touch softer (still well over 12:1 on night). */
:is(.debtsunset-primary, .debtsunset-account) .menu--sub > .menu-item > a {
  color: color-mix(in srgb, var(--ds-sand) 88%, transparent);
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

:is(.debtsunset-primary, .debtsunset-account) .menu--sub > .menu-item > a .menu-link__desc {
  transition: color 0.15s ease;
}

/* The row you point at, focus or are on: full strength, opaque. */
:is(.debtsunset-primary, .debtsunset-account) .menu--sub > .menu-item > a:is(:hover, :focus-visible, .is-active) {
  color: var(--ds-sand);
  background-color: var(--ds-twilight);
}

:is(.debtsunset-primary, .debtsunset-account) .menu--sub > .menu-item > a:is(:hover, :focus-visible) .menu-link__desc {
  color: color-mix(in srgb, var(--ds-sand) 82%, transparent);
}

/* The top bar's marigold underline and block fade in rather than snap. */
.debtsunset-primary .menu--level-0 > .menu-item > :is(a, .submenu-toggle) {
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.debtsunset-navbar .menu-item--toggle > a::after {
  transition: transform 0.2s ease;
}

/* --- Panels fade and settle into place (and fade out briefly, which also
       forgives a pointer that slips off for a moment). Browsers without
       @starting-style simply show and hide them as before. --------------- */

@media (min-width: 900px) {
  .debtsunset-primary .menu--sub {
    opacity: 0;
    translate: 0 -6px;
    transition: opacity 0.12s ease, translate 0.12s ease, display 0.12s allow-discrete;
  }

  .debtsunset-primary .menu-item.is-open > .menu--sub,
  .debtsunset-primary .menu-item:has(> .menu--sub :focus-visible) > .menu--sub {
    opacity: 1;
    translate: 0 0;
    transition-duration: 0.16s;
  }

  @starting-style {
    .debtsunset-primary .menu-item.is-open > .menu--sub,
    .debtsunset-primary .menu-item:has(> .menu--sub :focus-visible) > .menu--sub {
      opacity: 0;
      translate: 0 -6px;
    }
  }
}

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .debtsunset-primary .menu-item:hover > .menu--sub {
    opacity: 1;
    translate: 0 0;
    transition-duration: 0.16s;
  }

  @starting-style {
    .debtsunset-primary .menu-item:hover > .menu--sub {
      opacity: 0;
      translate: 0 -6px;
    }
  }
}

.debtsunset-account .menu--sub {
  opacity: 0;
  translate: 0 -6px;
  transition: opacity 0.12s ease, translate 0.12s ease, display 0.12s allow-discrete;
}

.debtsunset-account .menu-item.is-open > .menu--sub,
.debtsunset-account .menu-item:has(> .menu--sub :focus-visible) > .menu--sub {
  opacity: 1;
  translate: 0 0;
  transition-duration: 0.16s;
}

@starting-style {
  .debtsunset-account .menu-item.is-open > .menu--sub,
  .debtsunset-account .menu-item:has(> .menu--sub :focus-visible) > .menu--sub {
    opacity: 0;
    translate: 0 -6px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .debtsunset-account .menu-item--has-children:hover > .menu--sub {
    opacity: 1;
    translate: 0 0;
    transition-duration: 0.16s;
  }

  @starting-style {
    .debtsunset-account .menu-item--has-children:hover > .menu--sub {
      opacity: 0;
      translate: 0 -6px;
    }
  }
}

/* Phones: the opened menu fades in gently. */
@media (max-width: 899px) {
  .debtsunset-primary.is-open {
    transition: opacity 0.18s ease, translate 0.18s ease;
  }

  @starting-style {
    .debtsunset-primary.is-open {
      opacity: 0;
      translate: 0 -4px;
    }
  }
}

/* --- Accessibility -------------------------------------------------------- */

/* Less motion, when asked for: everything simply appears. */
@media (prefers-reduced-motion: reduce) {
  .debtsunset-navbar *,
  .debtsunset-navbar *::after,
  .debtsunset-primary.is-open {
    transition: none !important;
  }

  .debtsunset-primary .menu--sub,
  .debtsunset-account .menu--sub {
    translate: none !important;
  }
}

/* Windows High Contrast / forced colours: panels need a real edge, and the
   current page a marker that is not just a colour. */
@media (forced-colors: active) {
  .debtsunset-primary .menu--sub,
  .debtsunset-account .menu--sub {
    border: 1px solid CanvasText;
  }

  .debtsunset-navbar a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-thickness: 2px;
  }

  .debtsunset-primary .menu--level-0 > .menu-item > :is(a, .submenu-toggle):is(:hover, :focus-visible) {
    border-bottom-color: Highlight;
  }
}
