/* ==========================================================================
   Alkando — site header.

   Layout follows structured.app: a floating bar inset from the edges, brand
   and links on the left, the call to action on the right. Everything it is
   made of comes from the app instead (see tokens.css):

     bar       the tab island — a capsule of brand glass
     links     tab island item colours: white at 78%, full white when active
     CTA       onboarding's primary button — white capsule, #241A5B label
     menu      onboarding cards — brand glass, radius 22, mode-tinted tiles
     toggle    AlkandoHeaderButton — a 36px glass circle
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 14px 16px 0;
  /* The bar floats; only it and its menus should take pointer events, not
     the transparent strip it sits in. */
  pointer-events: none;
  font-family: var(--ak-font-ui);
}

.nav__bar {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1240px;
  /* Sized against the benchmark: structured.app runs a 78px bar with 16px
     links. At 64/15 ours read as a toolbar rather than a header. */
  height: 74px;
  margin: 0 auto;
  padding: 0 12px 0 16px;
  border-radius: 999px;
  background: var(--ak-glass-fill);
  border: 1px solid var(--ak-glass-stroke);
  backdrop-filter: var(--ak-glass-blur);
  -webkit-backdrop-filter: var(--ak-glass-blur);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 12px 32px rgba(10, 6, 30, 0.28);
}

/* --- brand --- */

.nav__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 6px 4px;
  border-radius: 999px;
  color: var(--ak-text);
  text-decoration: none;
  flex-shrink: 0;
}

.nav__brand img {
  display: block;
  width: 40px;
  height: 40px;
  /* iOS app-icon corner: 22.37% of the edge. */
  border-radius: 22.37%;
  box-shadow: 0 2px 8px rgba(8, 4, 24, 0.35);
}

.nav__wordmark {
  font-family: var(--ak-font-rounded);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* The app is in beta; the version rides the name as its exponent, set on the
   wordmark's cap line rather than beside it as a separate badge. */
.nav__beta {
  flex-shrink: 0;
  align-self: flex-start;
  margin: 7px 0 0 -8px;
  color: #c9bcff;
  font: 800 11px/1 var(--ak-font-rounded);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* --- links --- */

.nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 18px;
}

.nav__item {
  position: relative;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font: 600 16px/1 var(--ak-font-ui);
  text-decoration: none;
  cursor: pointer;
  transition:
    color var(--ak-dur-tap) ease,
    background-color var(--ak-dur-tap) ease;
}

.nav__link[aria-expanded="true"],
.nav__link[aria-current="page"] {
  color: var(--ak-text);
  /* Tab island selection pill. */
  background: rgba(255, 255, 255, 0.14);
}

@media (hover: hover) and (pointer: fine) {
  .nav__link:hover {
    color: var(--ak-text);
    background: rgba(255, 255, 255, 0.1);
  }
}

.nav__chevron {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--ak-dur-sheet) var(--ak-ease-out);
}

.nav__link[aria-expanded="true"] .nav__chevron {
  transform: rotate(180deg);
}

/* --- call to action --- */

/* Pushed right as one group, so "Account" stays attached to the button it
   belongs with rather than trailing the section links. */
.nav__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.nav__cta {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--ak-on-white);
  font: 700 17px/1 var(--ak-font-ui);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(8, 4, 24, 0.22);
  transition: transform var(--ak-dur-tap) var(--ak-ease-out);
}

.nav__cta svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav__cta:active {
  transform: scale(0.97);
}

/* --- shared --- */

.nav .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- shared: focus --- */

.nav a:focus-visible,
.nav button:focus-visible {
  outline: 2px solid var(--ak-accent);
  outline-offset: 2px;
}

/* --- panels: the Features dropdown and the mobile menu --- */

.nav__panel {
  position: absolute;
  z-index: 1;
  padding: 10px;
  border-radius: var(--ak-radius-panel);
  background: var(--ak-glass-fill);
  border: 1px solid var(--ak-glass-stroke);
  backdrop-filter: var(--ak-glass-blur);
  -webkit-backdrop-filter: var(--ak-glass-blur);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 22px 48px rgba(8, 4, 24, 0.4);

  /* Closed. visibility rather than display so the exit can animate, and so
     the links inside leave the tab order while it is shut. */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  /* Exit is quicker than entry, and visibility flips only once the fade has
     finished. */
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    visibility 0s linear 120ms;
}

.nav__panel.is-open {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--ak-dur-sheet) var(--ak-ease-out),
    transform var(--ak-dur-sheet) var(--ak-ease-out),
    visibility 0s;
}

.nav__panel--features {
  top: calc(100% + 12px);
  left: -6px;
  /* Never wider than the window it drops into. */
  width: min(560px, calc(100vw - 32px));
  /* Grows out of the trigger, not out of its own centre. */
  transform-origin: 32px top;
}

.nav__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

/* One feature: the app's onboarding perk row — a tile in the feature's own
   colour, the name, and the same one-line description the app uses. */
.nav__feature {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 11px 12px;
  border-radius: var(--ak-radius-tile);
  text-decoration: none;
  transition: background-color var(--ak-dur-tap) ease;
}

@media (hover: hover) and (pointer: fine) {
  .nav__feature:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

.nav__feature-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ak-text);
  font: 600 16.5px/1.25 var(--ak-font-ui);
}

.nav__feature-desc {
  display: block;
  margin-top: 3px;
  color: var(--ak-text-2);
  font: 400 12.5px/1.45 var(--ak-font-ui);
}

/* Gold-to-coral capsule — the app's own "NOWE" pill. */
.nav__badge {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 999px;
  background: linear-gradient(100deg, var(--ak-tint-gold), var(--ak-tint-game));
  color: #2a1330;
  font: 800 10px/1 var(--ak-font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The app cascades these rows in; so does this, one step per row. */
.nav__panel.is-open .nav__feature {
  animation: navFeatureIn 260ms var(--ak-ease-out) both;
  animation-delay: calc(var(--i) * 28ms);
}

@keyframes navFeatureIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.nav__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--ak-radius-button);
  color: var(--ak-text);
  font: 600 15px/1.2 var(--ak-font-ui);
  text-decoration: none;
  transition: background-color var(--ak-dur-tap) ease;
}

@media (hover: hover) and (pointer: fine) {
  .nav__row:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Tinted glyph tile — the bolt tile from onboarding: the tint at 24% behind
   a glyph in the tint itself. */
.nav__tile {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--tint) 24%, transparent);
  color: var(--tint);
}

.nav__tile svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav__row-arrow {
  width: 14px;
  height: 14px;
  margin-left: auto;
  stroke: var(--ak-text-3);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- mobile --- */

.nav__toggle {
  display: none;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ak-text);
  cursor: pointer;
  transition: transform var(--ak-dur-tap) var(--ak-ease-out);
}

.nav__toggle:active {
  transform: scale(0.92);
}

.nav__toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
}

.nav__toggle-line {
  transform-origin: 12px 12px;
  transition:
    transform var(--ak-dur-sheet) var(--ak-ease-out),
    opacity var(--ak-dur-tap) ease;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-line--top {
  transform: translateY(4px) rotate(45deg);
}

.nav__toggle[aria-expanded="true"] .nav__toggle-line--bottom {
  transform: translateY(-4px) rotate(-45deg);
}

.nav__panel--mobile {
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  padding: 10px;
  transform-origin: center top;
}

.nav__section {
  margin: 8px 10px 6px;
  color: var(--ak-section);
  font: 800 11px/1 var(--ak-font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav__divider {
  height: 1px;
  margin: 8px 10px;
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 760px) {
  .nav {
    padding: 10px 10px 0;
  }

  .nav__bar {
    height: 64px;
    gap: 6px;
    padding: 0 8px 0 10px;
  }

  .nav__brand {
    gap: 8px;
    padding: 6px 4px 6px 2px;
  }

  .nav__brand img {
    width: 34px;
    height: 34px;
  }

  .nav__wordmark {
    font-size: 1.2rem;
  }

  .nav__links,
  .nav__link--account {
    display: none;
  }

  .nav__toggle {
    display: grid;
  }

  .nav__cta {
    height: 44px;
    padding: 0 14px;
    font-size: 15px;
  }

  .nav__toggle {
    width: 40px;
    height: 40px;
  }

  .nav__tile {
    width: 40px;
    height: 40px;
  }

  .nav__cta svg {
    display: none;
  }

  /* One column, and the descriptions come off: on a phone the menu should
     be a list you can scan, not six paragraphs. */
  .nav__panel--mobile .nav__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav__panel--mobile .nav__feature-desc {
    display: none;
  }
}

/* Below this the bar has no room for the badge; a first-time visitor still
   gets the dialog. */
@media (max-width: 520px) {
  .nav__beta {
    display: none;
  }
}

/* Measured at 375px, the most common phone width: with the tightened
   metrics above, the longest CTA label (French, "Télécharger l’app") still
   leaves the wordmark room. Below 340px it no longer fits — the icon alone
   carries the brand there. */
@media (max-width: 340px) {
  .nav__wordmark {
    display: none;
  }
}

@media (min-width: 761px) {
  .nav__panel--mobile {
    display: none;
  }
}

/* --- beta dialog --- */

.beta {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: calc(100vw - 32px);
}

.beta__card {
  width: 330px;
  max-width: 100%;
  padding: 18px 20px 20px;
  border: 1px solid var(--ak-glass-stroke);
  border-radius: var(--ak-radius-card);
  background: var(--ak-glass-fill);
  backdrop-filter: var(--ak-glass-blur);
  -webkit-backdrop-filter: var(--ak-glass-blur);
  box-shadow: 0 24px 60px rgba(8, 4, 24, 0.45);
  animation: betaIn var(--ak-dur-sheet) var(--ak-ease-out) both;
}

@keyframes betaIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.beta__tag {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  background: linear-gradient(100deg, var(--ak-tint-gold), var(--ak-tint-game));
  color: #2a1330;
  font: 800 10.5px/1 var(--ak-font-ui);
  letter-spacing: 0.04em;
}

.beta__title {
  margin: 12px 0 6px;
  color: var(--ak-text);
  font: 700 17px/1.3 var(--ak-font-ui);
}

.beta__body {
  margin: 0;
  color: var(--ak-text-2);
  font: 400 14.5px/1.5 var(--ak-font-ui);
}

.beta__ok {
  width: 100%;
  height: 42px;
  margin-top: 16px;
  border: 0;
  border-radius: var(--ak-radius-button);
  background: #fff;
  color: var(--ak-on-white);
  font: 700 14.5px/1 var(--ak-font-ui);
  cursor: pointer;
  transition: transform var(--ak-dur-tap) var(--ak-ease-out);
}

.beta__ok:active {
  transform: scale(0.98);
}

.beta__ok:focus-visible {
  outline: 2px solid var(--ak-accent);
  outline-offset: 2px;
}

/* Reduced motion keeps the fades and drops the movement. */
@media (prefers-reduced-motion: reduce) {
  .nav__panel,
  .nav__panel.is-open {
    transform: none;
  }

  .nav__panel.is-open .nav__feature {
    animation: none;
  }

  .nav__chevron,
  .nav__toggle-line,
  .nav__cta,
  .nav__toggle,
  .beta__ok {
    transition: none;
  }

  .beta__card {
    animation: none;
  }
}
