/* Bedre Byttede — Header (V2)
   File: themes/bedrebyttede/assets/css/components/header.css
   Budget: small, no framework dependency (uses token.css)
   v2.0.1 - Cache Busting Refinement
*/

/* ========== Container & chrome ========== */
.bb-header .app-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-4);
}

@media (min-width: 48rem) {
  .bb-header .app-header__inner {
    padding-inline: var(--space-6)
  }
}

/* ========== Brand ========== */
.bb-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .2px
}

.bb-brand__wordmark {
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--text)
}

.bb-brand__mark {
  display: none
}

@media (min-width: 48rem) {
  .bb-brand__mark {
    display: block
  }
}

/* ========== Nav layout ========== */
.bb-nav {
  margin-inline-start: auto
}

.bb-nav__list {
  display: flex;
  align-items: center;
  gap: .8rem
}

/* ========== Nav link (row stays stable) ========== */
.bb-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--tap);
  /* reserve a hidden slot on the right for the label on desktop to avoid reflow */
  --nav-label-slot: 0px;
  /* mobile default */
  padding: 10px 10px;
  /* y x */
  padding-right: calc(10px + var(--nav-label-slot));
  border-radius: var(--radius-2);
  color: var(--text);
  background: transparent;
  border: var(--border-1) solid transparent;
  transition: background var(--dur-2);
  text-decoration: none;
  /* never underline icons/links in header */
}

.bb-nav__link i {
  font-size: var(--fs-lg);
}

/* Header nav: never underline the icon/link; labels can style themselves */
.bb-header .bb-nav__link,
.bb-header .bb-nav__link:hover,
.bb-header .bb-nav__link:focus-visible {
  text-decoration: none;
}

/* desktop/tablet: reserve label slot so hover doesn’t jitter the row */
@media (min-width: 64rem) {
  .bb-nav__link {
    --nav-label-slot: 120px;
  }
}

/* ========== Label (hidden by default; hover/focus only) ========== */
.bb-nav__label {
  position: absolute;
  right: 110%;
  bottom: -50%;
  margin-left: 8px;
  /* visual gap */
  transform: translate(-6px, -50%);
  /* tiny peel-in */
  white-space: nowrap;
  pointer-events: none;
  /* purely visual hover aid */
  opacity: 0;
  z-index: 10;
  /* sits above neighboring icons */
  /* “logo” background using brand gradient from tokens.css */
  background: var(--grad-move);
  color: #fff;
  border: 1px solid color-mix(in oklab, #fff, transparent 85%);
  border-radius: var(--radius-2);
  padding: 6px 10px;
  box-shadow: var(--shadow-1);

  transition:
    opacity 200ms var(--ease-in-out),
    transform 200ms var(--ease-in-out);
}

.bb-nav__link:hover .bb-nav__label,
.bb-nav__link:focus-visible .bb-nav__label {
  opacity: 1;
  transform: translate(0, -50%);
}

/* Neutralize any legacy auto-reveal flags */
.bb-nav__list.is-revealed .bb-nav__label {
  opacity: 0;
  transform: translate(-6px, -50%);
}

/* ========== Active styling (underline + green icon) ========== */
.bb-nav__link.is-active i,
.bb-nav__link[aria-current="page"] i {
  color: var(--brand);
}

.bb-nav__link.is-active::after,
.bb-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
  pointer-events: none;
}

/* ========== Mobile: label BELOW the icon, centered (hover/focus only) ========== */
@media (max-width: 47.99rem) {
  .bb-nav__link {
    --nav-label-slot: 0px;
  }

  /* no reservation on mobile */

  .bb-nav__label {
    left: 50%;
    top: calc(100% + 8px);
    /* below the icon */
    margin-left: 0;
    transform: translate(-50%, -4px);
    /* start slightly up for ease */
    opacity: 0;
    pointer-events: none;

    /* keep it on screen */
    width: max-content;
    max-width: calc(100vw - 24px);
    white-space: normal;
    /* allow wrap if necessary */
    text-align: center;
    z-index: 12;
    /* above neighboring icons */
  }

  /* show only on interaction (hover for completeness; focus for tap/keyboard) */
  .bb-nav__link:hover .bb-nav__label,
  .bb-nav__link:focus .bb-nav__label,
  .bb-nav__link:focus-visible .bb-nav__label {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  .bb-nav__label {
    transition: none;
  }
}

/* ========== Focus ring ========== */
.bb-nav__link:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--brand), transparent 75%);
  outline-offset: 2px;
}

/* ========== Hide-on-scroll chrome (desktop; toggled by JS .is-hidden) ========== */
.bb-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header, 60);
  transition: transform var(--dur-3) var(--ease-in-out);
  will-change: transform;
}

.bb-header.is-hidden {
  transform: translateY(calc(-1 * var(--header-h)));
  pointer-events: none;
}

/* ========== Minor spacing nudges ========== */
.bb-header .bb-nav__item {
  position: relative;
}

/* compact touch frame */
.bb-header .bb-nav__link {
  padding-inline: 8px;
}

/* no extra icon gap */
.bb-header .bb-nav__link>i {
  margin-inline: 0;
}


.bb-nav__badge {
  position: absolute;
  top: 0.05rem;
  right: 0.1rem;
  min-width: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  line-height: 1.2rem;
  text-align: center;
  background: var(--brand-600);
  box-shadow: var(--shadow-1);
  color: var(--text);
  pointer-events: none;
}

/* ========== Notification Tooltip ========== */
.bb-nav__tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  width: 280px;
  /* Wider for readability */
  background: var(--surface);
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  padding: 0;
  /* Layout handled by children */
  z-index: 1000;
  display: none;
  margin-top: var(--space-2);

  /* Flex layout for Pinned + Scrollable */
  display: flex;
  /* Hidden toggled via [hidden] attrib, handled below */
  flex-direction: column;
  max-height: 400px;
  /* Cap height */
  overflow: hidden;
}

/* Mobile Tooltip: Fixed dropout */
@media (max-width: 47.99rem) {
  .bb-nav__tooltip {
    position: fixed;
    top: calc(var(--header-h) - 4px);
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 60vh;
    box-shadow: var(--shadow-3);
  }
}

/* Base override for [hidden] to ensure it wins over display:flex */
.bb-nav__tooltip[hidden] {
  display: none !important;
}

/* Explicit dark-mode contrast check */
@media (prefers-color-scheme: dark) {
  .bb-nav__tooltip {
    background: var(--surface);
    border-color: var(--line);
  }
}

.bb-nav__tooltip:not([hidden]) {
  animation: bb-fade-in var(--dur-2) var(--ease-out);
}

/* --- Pinned Section --- */
.bb-tooltip-pinned {
  flex-shrink: 0;
  border-bottom: var(--border-1) solid var(--line);
  background: var(--bg);
  z-index: 2;
}

.bb-tooltip-row {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--dur-1);
  gap: var(--space-3);
  font-variant-numeric: tabular-nums;
}

.bb-tooltip-row:hover {
  color: var(--text);
}

/* Static Header Row (Info) */
.bb-tooltip-header-row {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  gap: var(--space-2);
  background: var(--surface-2);
  /* Slight contrast for header */
  border-top: var(--border-1) solid var(--line);
}

.bb-icon-muted {
  opacity: 0.7;
}

/* Counts */
.bb-tooltip-row .count {
  background: var(--brand);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-round);
  font-size: var(--fs-xxs);
  font-weight: 800;
  min-width: 24px;
  text-align: center;
}

.bb-tooltip-row[data-val="0"] .count {
  background: var(--surface-2);
  color: var(--text-3);
}

/* --- Scrollable Section --- */
.bb-tooltip-scrollable {
  flex-grow: 1;
  overflow-y: auto;
  min-height: 0;
  /* Flexbox scrolling magic */
  background: var(--surface);
}

/* Notification Items */
.bb-notification-item {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-1) solid var(--line);
  text-decoration: none;
  color: var(--text);
  transition: background var(--dur-1);
}

.bb-notification-item:last-child {
  border-bottom: none;
}

.bb-noti-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2px;
}

.bb-noti-label {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.bb-noti-time {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
  margin-left: var(--space-2);
}

.bb-noti-sub {
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Unread Indicator */
.bb-notification-item.is-unread {
  background: color-mix(in oklab, var(--brand) 5%, var(--surface));
}

.bb-notification-item.is-unread:hover {
  background: color-mix(in oklab, var(--brand) 8%, var(--surface));
}

.bb-notification-item.is-unread .bb-noti-label::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--brand);
  border-radius: 50%;
  margin-left: 6px;
  transform: translateY(-1px);
}

/* Empty State */
.bb-notifications-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-style: italic;
}

@keyframes bb-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}