/* Global topbar. Self-contained; player and page styles live elsewhere. */

.topbar {
  position: sticky;
  top: var(--desktop-nav-h);
  z-index: var(--z-topbar);
  min-height: var(--topbar-h);
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: minmax(220px, 620px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 26px;
  background: rgba(2, 16, 20, .96);
  border-bottom: 1px solid rgba(0, 180, 166, .12);
  backdrop-filter: blur(24px) saturate(135%);
}

.topbar-search-layer {
  min-width: 0;
}

.global-search {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: rgba(231, 241, 239, .72);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 15px;
  box-shadow: 0 8px 26px rgba(27, 38, 40, .055), inset 0 1px rgba(255, 255, 255, .85);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.global-search:focus-within {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(0, 180, 166, .55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .08);
}

.global-search-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: rgba(231,241,239,.62);
}

.global-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink-inverse);
  background: transparent;
  font-size: .73333em;
}

.global-search input::placeholder { color: rgba(214, 227, 225, .48); }

.global-search kbd {
  padding: 3px 7px;
  color: rgba(230,239,238,.65);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 6px;
  font: 500 .53333em var(--font-mono);
  white-space: nowrap;
}

.top-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.today-label { display: none; }

.topbar-search-trigger,
.topbar-search-close {
  display: none;
}

.gamification-chip {
  min-height: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: rgba(232,241,240,.78);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  font-size: .6em;
  box-shadow: none;
}

.gamification-chip strong {
  color: #f8faf9;
  font-family: var(--font-display);
  font-size: 1.33333em;
  font-weight: 800;
}

.gamification-chip-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 14px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,.12);
  line-height: 1;
}

.student-plan-badge {
  min-height: 29px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  color: #62ddd2;
  background: rgba(0,180,166,.11);
  border: 1px solid rgba(0,180,166,.18);
  border-radius: var(--r-pill);
  font-size: .46667em;
  font-weight: 800;
  letter-spacing: .10em;
}

.student-plan-badge.is-premium {
  color: #805e18;
  background: var(--gold-soft);
  border-color: rgba(201, 141, 32, .14);
}

/* profile-chip owned by topbar.css; guest and authenticated states live together here. */
.profile-chip.is-guest-login {
  min-height: 35px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: .7em;
  font-weight: 750;
}

.profile-chip:not(.is-guest-login) {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: #f8f5ed;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(16, 32, 39, .12);
  font-family: var(--font-display);
  font-size: .66667em;
  font-weight: 800;
  letter-spacing: .02em;
}

.profile-chip:not(.is-guest-login):hover { background: #ffffff; }
.profile-chip:not(.is-guest-login)[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.12); }


@media (max-width: 900px) {
  .topbar { top: 0; }
}

@media (max-width: 700px) {
  :root { --topbar-h: 62px; }

  .topbar {
    position: sticky;
    top: 0;
    min-height: var(--topbar-h);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 10px;
  }

  .topbar-search-layer {
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 0px));
    right: 10px;
    bottom: auto;
    left: 10px;
    z-index: var(--z-account-menu);
    display: none;
    align-items: center;
    gap: 7px;
  }

  .topbar.is-search-open .topbar-search-layer {
    display: flex;
  }

  .topbar.is-search-open .top-actions {
    visibility: hidden;
    pointer-events: none;
  }

  .global-search {
    flex: 1;
    width: auto;
    min-height: 46px;
    height: 46px;
    padding: 0 13px;
    background: #0b2428;
    border-color: rgba(0,180,166,.38);
    border-radius: 13px;
    box-shadow: var(--shadow-md);
  }

  .global-search input { font-size: .8em; }
  .global-search kbd { display: none; }

  .topbar-search-close {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-inverse);
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 11px;
    font-size: 1.2em;
    line-height: 1;
  }

  .top-actions {
    min-height: 46px;
    gap: 6px;
  }

  .topbar-search-trigger {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-inverse);
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 11px;
  }

  .topbar-search-trigger svg {
    width: 17px;
    height: 17px;
  }

  .gamification-chip {
    display: flex;
    height: 38px;
    min-height: 38px;
    gap: 5px;
    padding: 0 9px;
    border-radius: 11px;
  }

  .gamification-chip strong { font-size: 1.22222em; }
  .gamification-chip-streak { padding-left: 6px; }

  .student-plan-badge {
    display: inline-flex;
    height: 29px;
    min-height: 29px;
    padding: 0 8px;
    font-size: .46667em;
  }

  .profile-chip:not(.is-guest-login) {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    max-width: none;
    border-radius: 11px;
  }

  .student-account-menu {
    position: fixed;
    top: 70px;
    right: 10px;
    width: min(360px, calc(100vw - 20px));
    max-height: calc(100dvh - 84px);
    overflow: auto;
  }

}

@media (max-width: 420px) {
  .topbar { padding-left: 8px; padding-right: 8px; gap: 4px; }
  .top-actions { gap: 4px; }
  .gamification-chip { padding-left: 7px; padding-right: 7px; }
  .student-plan-badge { padding-left: 7px; padding-right: 7px; }
  .topbar-search-trigger,
  .profile-chip:not(.is-guest-login) { width: 36px; min-width: 36px; height: 36px; min-height: 36px; }
}

.topbar .student-register-trigger { color: #77dacf; }
.topbar .profile-chip.is-guest-login { color: var(--ink-inverse); border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.07); }

/* V34 — desktop search joins the primary navigation bar; mobile/tablet rules stay unchanged. */
@media (min-width: 901px) {
  .topbar {
    position: fixed;
    top: 0;
    right: 22px;
    left: auto;
    width: auto;
    min-height: var(--desktop-nav-h);
    height: var(--desktop-nav-h);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0;
    background: transparent;
    border-bottom: 0;
    backdrop-filter: none;
  }

  .top-actions {
    height: 100%;
  }

  .topbar-search-trigger {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-inverse);
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 11px;
  }

  .topbar-search-trigger svg {
    width: 17px;
    height: 17px;
  }

  .topbar-search-layer {
    position: absolute;
    top: 50%;
    right: calc(100% + 8px);
    z-index: 2;
    width: min(480px, calc(100vw - 360px));
    display: none;
    align-items: center;
    gap: 7px;
    padding: 4px;
    background: #071c20;
    border-radius: 15px;
    box-shadow: 0 14px 34px rgba(0,0,0,.28);
    transform: translateY(-50%);
  }

  .topbar.is-search-open .topbar-search-layer {
    display: flex;
  }

  .global-search {
    flex: 1 1 auto;
    width: auto;
    min-height: 42px;
    background: #0b2428;
    border-color: rgba(0,180,166,.30);
    box-shadow: none;
  }

  .topbar-search-layer .global-search:focus-within {
    background: #0b2428;
  }

  .topbar-search-close {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink-inverse);
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    font-size: 1.06667em;
    line-height: 1;
  }
}

