/* ==========================================================================
   Livio — "Livio Live" nav item + hover dropdown
   Opens on hover and on keyboard focus (:focus-within), so it is reachable
   without a mouse. Tokens come from the :root block in each page.
   All selectors are namespaced .nav-live* — nothing existing is touched.
   ========================================================================== */

.nav-live {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Trigger — matches .nav-links a exactly, but is a real <button> since it
   opens a menu rather than navigating anywhere.
   -------------------------------------------------------------------------- */
.nav-live-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--display, 'Archivo', system-ui, sans-serif);
  font-weight: 600;
  font-size: 14px;
  line-height: inherit;
  color: rgba(255, 255, 255, .92);      /* the bar is dark in both states */
  transition: color .2s;
}

.nav-live-btn:hover,
.nav-live:hover .nav-live-btn,
.nav-live:focus-within .nav-live-btn { color: #fff; }

.nav-live-btn:focus-visible {
  outline: 3px solid var(--lime, #C7D92C);
  outline-offset: 4px;
  border-radius: 4px;
}

.nav-live-caret {
  width: 11px;
  height: 11px;
  flex: none;
  stroke: currentColor;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .25s ease;
}

.nav-live:hover .nav-live-caret,
.nav-live:focus-within .nav-live-caret { transform: rotate(180deg); }

/* --------------------------------------------------------------------------
   Popover wrapper — transparent, and its padding-top is the hover bridge that
   keeps the menu open while the pointer crosses the gap from the trigger.
   -------------------------------------------------------------------------- */
.nav-live-pop {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 100;
  padding-top: 14px;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s, translate .22s ease;
  translate: 0 -6px;
}

/* .is-forced is set by the script when the trigger is tapped — touch devices
   have no hover, so the menu has to be pinned open. */
.nav-live:hover .nav-live-pop,
.nav-live:focus-within .nav-live-pop,
.nav-live.is-forced .nav-live-pop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  translate: 0 0;
}

/* --------------------------------------------------------------------------
   Panel — same frosted navy language as the live races card.
   -------------------------------------------------------------------------- */
.nav-live-panel {
  position: relative;
  min-width: 232px;
  padding: 8px;
  list-style: none;
  margin: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(13, 34, 53, .94);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 54px -18px rgba(8, 19, 31, .75),
              0 2px 8px -4px rgba(8, 19, 31, .5);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nav-live-panel { background: rgba(13, 34, 53, .99); }
}

/* Notch pointing back at the trigger. */
.nav-live-panel::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  transform: rotate(45deg);
  background: rgba(13, 34, 53, .94);
  border-left: 1px solid rgba(255, 255, 255, .12);
  border-top: 1px solid rgba(255, 255, 255, .12);
  border-radius: 2px 0 0 0;
}

/* --------------------------------------------------------------------------
   Items
   -------------------------------------------------------------------------- */
.nav-live-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  font-family: var(--display, 'Archivo', system-ui, sans-serif);
  font-weight: 600;
  font-size: 14px;
  color: rgba(255, 255, 255, .92);
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-live-item + .nav-live-item { margin-top: 2px; }

.nav-live-item:hover,
.nav-live-item:focus-visible {
  background: rgba(255, 255, 255, .07);
  color: #fff;
  transform: translateX(2px);
}

.nav-live-item:focus-visible {
  outline: 2px solid var(--lime, #C7D92C);
  outline-offset: -2px;
}

/* No bullet markers — the label is the whole item. Note for future edits: any
   marker here must be a pseudo-element, never a child <span>. deepTranslate()
   in each page only rewrites an element whose children are all <svg>, so a
   real child element silently blocks NL/FR translation of the label. */

/* --------------------------------------------------------------------------
   "Log in" — lives in .nav-right, outside .nav-links, so it inherits none of
   the nav link styling and has to restate it.
   -------------------------------------------------------------------------- */
.nav-login {
  font-family: var(--display, 'Archivo', system-ui, sans-serif);
  font-weight: 600;
  font-size: 14px;
  color: rgba(255, 255, 255, .92);
  white-space: nowrap;
  transition: color .2s;
}

.nav-login:hover { color: #fff; }

.nav-login:focus-visible {
  outline: 3px solid var(--lime, #C7D92C);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   <=900px — the nav collapses into the light paper panel, so the dropdown
   becomes a plain indented sub-list instead of a floating popover.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* Hidden alongside .nav-right .btn, which the page CSS already hides here. */
  .nav-login { display: none; }

  .nav-live {
    display: block;
    width: 100%;
  }

  .nav-live-btn {
    width: 100%;
    justify-content: space-between;
    padding: 8px 0;
    color: var(--ink, #0D2235);
  }
  .nav-live-btn:hover,
  .nav-live:hover .nav-live-btn,
  .nav-live:focus-within .nav-live-btn { color: var(--ink-soft, #5B7088); }

  /* Always open in the mobile panel — no hover on touch. */
  .nav-live-pop {
    position: static;
    padding-top: 2px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    translate: none;
  }

  .nav-live-caret { display: none; }

  .nav-live-panel {
    min-width: 0;
    padding: 0 0 0 14px;
    border: 0;
    border-left: 1px solid var(--mist, #D7E0DA);
    border-radius: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  .nav-live-panel::before { display: none; }

  .nav-live-item {
    padding: 7px 0;
    color: var(--ink, #0D2235);
    font-weight: 500;
  }
  .nav-live-item:hover,
  .nav-live-item:focus-visible {
    background: none;
    color: var(--ink-soft, #5B7088);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-live-pop,
  .nav-live-caret,
  .nav-live-item { transition: none !important; }
  .nav-live-item:hover { transform: none; }
}
