/* The top bar's right side (assets/js/topbar.js, global-search.js): MPMA
   MPMA Pathways' chrome, dressed in EMS US. Navy #2A3890 / #162063,
   red #BE1E2D, Lato for text and Oswald for names. The Pathways menu motion:
   drops 14px and grows from 96% out of its button's corner, and closes as
   smoothly as it opens (visibility waits for the fade). */
:root {
  --tb-ease-pop: cubic-bezier(0.18, 0.9, 0.2, 1);
  --tb-ease-soft: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tb-ink: #1c2333;
  --tb-muted: #5b6478;
  --tb-line: #e3e7f2;
  --tb-wash: #f2f4fb;
}

/* One row: logo, name, search (centred in the space left), then the demo
   switch, bell and you, 8px apart. */
.app-topbar { gap: 8px; }
.app-topbar .app-topbar-powered { margin-right: 8px; white-space: nowrap; }
/* Logo + name = one link home (app.js topbarHome). */
.app-topbar .app-topbar-home { display: flex; align-items: center; gap: inherit; flex: none; color: inherit; text-decoration: none; border-radius: 10px; cursor: pointer; }
.app-topbar .app-topbar-home:hover .app-topbar-powered { color: var(--ems-navy-700, #162063); }
.app-topbar .app-topbar-home:focus-visible { outline: 2px solid var(--ems-navy-500, #2A3890); outline-offset: 4px; }
.app-topbar .demo-switch-tb { margin-left: 8px; }
.tb-search[hidden], .acct-wrap[hidden] { display: none; }
@media (max-width: 1180px) { .app-topbar .app-topbar-powered { font-size: 16px; } }
@media (max-width: 1040px) { .app-topbar .app-topbar-powered { display: none; } }

/* A menu inside the bar is capped by the bar's own stacking context (z 20):
   while one is open the bar lifts above the demo ribbon (60) and every other
   floating layer, so a menu is never under anything. Pathways 10-08. The
   delayed z-index transition holds the level until the close fade ends. */
.app-topbar { transition: z-index 0s linear .34s; }
.app-topbar:has(.is-open) { z-index: 1000; transition: none; }

/* Round icon buttons: search (phone). The bell shares the look (bell.css). */
.tb-ic {
  position: relative; width: 38px; height: 38px; border-radius: 50%; border: 0; padding: 0; flex: none;
  display: grid; place-items: center; cursor: pointer; background: transparent; color: var(--ems-navy, #2A3890);
  transition: background .18s var(--tb-ease-soft), transform .18s ease;
}
.tb-ic:hover, .tb-ic[aria-expanded="true"] { background: var(--tb-wash); }
.tb-ic:focus-visible { outline: 3px solid var(--ems-red, #BE1E2D); outline-offset: 2px; }

/* ── search ───────────────────────────────────────────────────────────── */
.tb-search { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; margin: 0 8px 0 12px; }
.tb-search-open { display: none; }
.tb-search-box {
  position: relative; flex: 0 1 460px; min-width: 180px; display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 10px 0 12px; box-sizing: border-box; border-radius: 999px;
  border: 1px solid #d6dcee; background: var(--tb-wash); color: var(--tb-muted);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.tb-search-box:hover { border-color: #b9c2e2; }
.tb-search-box:focus-within { background: #fff; border-color: var(--ems-navy, #2A3890); box-shadow: 0 0 0 3px rgba(42, 56, 144, .14); }
.tb-search-ic { display: grid; place-items: center; flex: none; color: var(--ems-navy, #2A3890); }
.tb-search-box input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent; outline: none; padding: 0; height: 100%;
  font: 400 14.5px/1 Lato, "Segoe UI", sans-serif; color: var(--tb-ink);
}
.tb-search-box input::placeholder { color: #7a839c; }
.tb-search-box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.tb-search-key { flex: none; font: 700 11px/1 Lato, sans-serif; color: #7a839c; border: 1px solid #cfd5ea; border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; background: #fff; }
.tb-search-box:focus-within .tb-search-key { display: none; }

/* The results: a command palette under the box. */
.gs {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); min-width: 340px; z-index: 70;
  background: #fff; border: 1px solid rgba(15, 23, 42, .08); border-radius: 12px; box-shadow: 0 22px 56px rgba(15, 23, 42, .26);
  max-height: min(560px, calc(100vh - 96px)); overflow-y: auto; overscroll-behavior: contain; color: var(--tb-ink);
  opacity: 0; transform: translateY(-8px); transition: opacity .2s var(--tb-ease-soft), transform .24s var(--tb-ease-pop);
}
.gs.gs-in { opacity: 1; transform: none; }
.gs[hidden] { display: none; }
.gs-inner { padding: 6px; }
.gs-head { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 10px 4px; font: 700 11px Lato, sans-serif; letter-spacing: .07em; text-transform: uppercase; color: #6b7390; }
.gs-head span { text-transform: none; letter-spacing: 0; font-weight: 600; }
.gs-row {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: inherit; text-decoration: none;
  transition: background .12s ease;
}
.gs-row[aria-selected="true"] { background: var(--primary-tint, #eef1fb); }
.gs-ic { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-tint, #eef1fb); color: var(--ems-navy, #2A3890); }
.gs-ic svg { width: 17px; height: 17px; }
.gs-k-tool .gs-ic { background: #f1f3f8; color: #3c4560; }
.gs-k-person .gs-ic { background: #fdecee; color: var(--ems-red, #BE1E2D); }
.gs-k-resource .gs-ic { background: #e8f3ee; color: #2f6f4e; }
.gs-txt { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.gs-lbl { font-size: 14px; font-weight: 700; color: var(--tb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-txt small { font-size: 12px; color: var(--tb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-go { flex: none; color: #9aa2bb; font-size: 13px; opacity: 0; }
.gs-row[aria-selected="true"] .gs-go { opacity: 1; }
.gs-where { flex: none; font: 700 10.5px Lato, sans-serif; color: #2f6f4e; background: #e8f3ee; padding: 3px 7px; border-radius: 99px; }
.gs-pill-wrap { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 6px; }
.gs-row.gs-pill { gap: 7px; padding: 5px 11px 5px 5px; border: 1px solid var(--tb-line); border-radius: 99px; font-size: 13px; font-weight: 700; background: #fff; }
.gs-row.gs-pill .gs-ic { width: 24px; height: 24px; border-radius: 50%; }
.gs-row.gs-pill .gs-ic svg { width: 14px; height: 14px; }
.gs-row.gs-pill[aria-selected="true"] { border-color: var(--ems-navy, #2A3890); background: var(--primary-tint, #eef1fb); }
.gs-none { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 22px 16px 10px; color: var(--tb-muted); font-size: 13.5px; }
.gs-none p { margin: 8px 0 0; line-height: 1.5; }
.gs-none-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--tb-wash); color: var(--ems-navy, #2A3890); }
.gs-foot { display: flex; gap: 14px; justify-content: flex-end; padding: 8px 10px 4px; margin-top: 6px; border-top: 1px solid var(--tb-line); font-size: 11.5px; color: #7a839c; }
.gs-foot kbd { font: 700 10.5px Lato, sans-serif; border: 1px solid #cfd5ea; border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; margin-right: 3px; background: #fff; color: #4a5370; }

.acct-menu {
  position: absolute; right: 0; top: calc(100% + 12px); background: #fff; border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 12px; box-shadow: 0 22px 56px rgba(15, 23, 42, .28); z-index: 60; color: var(--tb-ink);
  box-sizing: border-box; transform-origin: top right;
  max-height: calc(100vh - 96px); overflow-y: auto; overscroll-behavior: contain;
  opacity: 0; transform: translateY(-14px) scale(.96); visibility: hidden; pointer-events: none;
  transition: opacity .30s var(--tb-ease-soft), transform .34s var(--tb-ease-pop), visibility 0s linear .30s;
}
.acct-menu.is-open {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity .30s var(--tb-ease-soft), transform .34s var(--tb-ease-pop), visibility 0s;
}
.acct-menu[hidden] { display: none; }
.tb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── you: the avatar and its menu ─────────────────────────────────────── */
.acct-wrap { position: relative; flex: none; margin-left: 2px; }
.acct-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; padding: 0; overflow: hidden; box-sizing: border-box;
  background: linear-gradient(135deg, var(--ems-navy, #2A3890), var(--ems-navy-deep, #162063)); background-clip: padding-box; color: #fff;
  font: 700 13px/1 var(--ems-display, Oswald, sans-serif); letter-spacing: .04em; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(190, 30, 45, .0);
  transition: border-color .2s ease, box-shadow .2s ease, transform .18s ease;
}
.acct-btn.has-photo { background: #fff; }
.acct-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { border-color: var(--ems-red, #BE1E2D); box-shadow: 0 4px 14px rgba(22, 32, 99, .22); transform: translateY(-1px); }
.acct-btn:focus-visible { outline: 3px solid var(--ems-red, #BE1E2D); outline-offset: 3px; }

.acct-menu { width: 304px; max-width: calc(100vw - 24px); padding: 10px; }
.acct-head { padding: 0 0 10px; border-bottom: 1px solid var(--tb-line); margin-bottom: 8px; }
.acct-head-link {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: none;
  color: inherit; text-align: left; font: inherit; cursor: pointer; transition: background .18s var(--tb-ease-soft);
}
.acct-head-link:hover, .acct-head-link:focus-visible { background: var(--tb-wash); outline: none; }
.acct-head-av {
  width: 42px; height: 42px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ems-navy, #2A3890), var(--ems-navy-deep, #162063)); color: #fff;
  font: 700 14px/1 var(--ems-display, Oswald, sans-serif); letter-spacing: .04em;
}
.acct-head-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acct-head-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; align-items: flex-start; }
.acct-head-txt b { font-family: var(--ems-display, Oswald, sans-serif); font-weight: 600; font-size: 16px; letter-spacing: .01em; color: var(--ems-navy-deep, #162063); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-head-txt > span { font-size: 12.5px; color: var(--tb-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-pill { margin-top: 4px; font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--ems-navy, #2A3890); border-radius: 999px; padding: 2px 9px; }
.acct-links { display: flex; flex-direction: column; gap: 6px; }
.acct-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; box-sizing: border-box;
  padding: 9px 11px; border-radius: 9px; border: 1px solid rgba(15, 23, 42, .1); background: #f8f9fc;
  color: var(--tb-ink); text-decoration: none; font: 700 13.5px Lato, "Segoe UI", sans-serif; text-align: left; cursor: pointer;
  transition: transform .18s var(--tb-ease-pop), background .18s var(--tb-ease-soft), box-shadow .18s var(--tb-ease-soft), border-color .18s var(--tb-ease-soft);
}
.acct-item-l { display: inline-flex; align-items: center; gap: 9px; }
.acct-item-l svg { color: var(--ems-navy, #2A3890); opacity: .85; }
.acct-item-r { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; color: #6b7390; text-transform: none; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-item:hover, .acct-item:focus-visible { background: var(--primary-tint, #eef1fb); border-color: rgba(42, 56, 144, .3); transform: translateY(-1px); box-shadow: 0 10px 18px rgba(15, 23, 42, .1); outline: none; }
/* The demo switch, as a switch. */
.acct-sw { position: relative; flex: none; width: 30px; height: 17px; border-radius: 999px; background: #c9cfe3; transition: background .2s ease; }
.acct-sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s cubic-bezier(.2, .9, .3, 1.3); }
.acct-sw.is-on { background: var(--ems-red, #BE1E2D); }
.acct-sw.is-on::after { transform: translateX(13px); }
.acct-demo-row.is-on { border-color: rgba(190, 30, 45, .35); background: #fdf3f4; }
.acct-demo-row.is-on .acct-item-r { color: var(--ems-red, #BE1E2D); }
.acct-item.acct-signout { margin-top: 4px; background: #fff1f2; border-color: #fecdd3; color: #b91c1c; }
.acct-item.acct-signout .acct-item-l svg { color: #b91c1c; }
.acct-item.acct-signout:hover { background: #fecaca; color: #991b1b; box-shadow: 0 10px 18px rgba(220, 38, 38, .2); }

/* ── My profile ───────────────────────────────────────────────────────── */
.tb-dlg { border: 0; padding: 0; border-radius: 14px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(15, 23, 42, .35); color: var(--tb-ink); }
.tb-dlg::backdrop { background: rgba(14, 21, 71, .45); }
.tb-dlg-card { padding: 18px 20px 18px; margin: 0; }
.tb-dlg-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tb-dlg-top h2 { margin: 0; font-family: var(--ems-display, Oswald, sans-serif); font-weight: 600; font-size: 20px; text-transform: uppercase; letter-spacing: .02em; color: var(--ems-navy-deep, #162063); }
.tb-dlg-x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--tb-muted); }
.tb-dlg-x:hover { background: var(--tb-wash); color: var(--tb-ink); }
/* Your photo (topbar.js openProfile): the photo and nothing else - a round
   crop you drag and zoom, Change photo, Remove, Save. */
.tb-photo-dlg { width: min(400px, calc(100vw - 32px)); }
.tb-crop {
  position: relative; width: min(280px, 70vw); aspect-ratio: 1; margin: 6px auto 0; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; touch-action: none; user-select: none;
  background: linear-gradient(135deg, var(--ems-navy, #2A3890), var(--ems-navy-deep, #162063)); color: #fff;
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px rgba(190, 30, 45, .5), 0 18px 40px -18px rgba(14, 21, 71, .55);
}
.tb-crop.has-photo { cursor: grab; background: #e9ecf5; }
.tb-crop.is-drag { cursor: grabbing; }
.tb-crop:focus-visible { outline: 3px solid var(--ems-red, #BE1E2D); outline-offset: 6px; }
.tb-crop img { position: absolute; left: 50%; top: 50%; max-width: none; pointer-events: none; -webkit-user-drag: none; }
.tb-crop-ini { font: 700 64px/1 var(--ems-display, Oswald, sans-serif); }
.tb-zoom { display: flex; align-items: center; gap: 10px; width: min(240px, 64vw); margin: 18px auto 0; color: var(--tb-muted); font: 700 16px/1 Lato, sans-serif; }
.tb-zoom input { flex: 1; accent-color: var(--ems-navy, #2A3890); }
.tb-crop-hint { margin: 6px 0 0; text-align: center; font-size: 12.5px; color: var(--tb-muted); }
.tb-dlg-foot.tb-photo-foot { justify-content: flex-start; margin-top: 8px; }
.tb-photo-save { margin-left: auto; }
.tb-btn.tb-btn-quiet { border-color: transparent; color: var(--tb-muted); }
.tb-prof-msg { min-height: 1.2em; margin: 10px 0 4px; font-size: 13px; font-weight: 700; color: var(--ems-navy, #2A3890); }
.tb-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid #cfd5ea; background: #fff; color: var(--ems-navy-deep, #162063); font: 700 13.5px Lato, sans-serif;
}
.tb-btn:hover { background: var(--tb-wash); }
.tb-btn:focus-visible, .tb-btn:focus-within { outline: 3px solid var(--ems-red, #BE1E2D); outline-offset: 2px; }
.tb-btn-primary { background: var(--ems-navy, #2A3890); border-color: var(--ems-navy, #2A3890); color: #fff; }
.tb-btn-primary:hover { background: var(--ems-navy-deep, #162063); }
.tb-dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Where a notification or a search row landed: a brief glow on the thing. */
@keyframes tb-flash { 0%, 100% { box-shadow: 0 0 0 0 rgba(190, 30, 45, 0); } 20%, 60% { box-shadow: 0 0 0 4px rgba(190, 30, 45, .35); } }
.tb-flash { animation: tb-flash 2.2s ease 1; border-radius: 8px; }

/* ── phone ────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .app-topbar { padding: 0 12px; gap: 4px; }
  .app-topbar-logo { height: 36px; }
  /* The box folds to an icon; tapped, it opens as a full-width panel under the bar. */
  .tb-search { flex: 0 0 auto; margin: 0 0 0 auto; }
  .tb-search-open { display: grid; }
  .tb-search-box {
    position: fixed; left: 12px; right: 12px; top: 72px; height: 46px; min-width: 0; z-index: 75;
    background: #fff; box-shadow: 0 18px 44px rgba(15, 23, 42, .28); border-color: var(--ems-navy, #2A3890);
    opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none;
    transition: opacity .22s var(--tb-ease-soft), transform .26s var(--tb-ease-pop), visibility 0s linear .22s;
  }
  .tb-search.is-open .tb-search-box { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity .22s var(--tb-ease-soft), transform .26s var(--tb-ease-pop), visibility 0s; }
  .tb-search-key { display: none; }
  .gs { min-width: 0; left: -1px; right: -1px; max-height: calc(100vh - 140px); }
  .gs-foot { display: none; }
  .app-topbar:has(.tb-search.is-open) { z-index: 1000; transition: none; }
  .app-topbar .demo-switch-tb { margin-left: 2px; }
  .acct-menu { position: fixed; left: 12px; right: 12px; top: 70px; width: auto; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .acct-menu, .acct-menu.is-open, .gs, .tb-search-box, .acct-item, .acct-btn, .acct-sw::after { transition: none; }
  .tb-flash { animation: none; outline: 3px solid var(--ems-red, #BE1E2D); }
}

/* A new photo arrives: it fades and settles in where the old face was (11-15),
   on the avatar button, the menu's head and Settings' account card alike. */
@keyframes ems-face-in { from { opacity: 0; transform: scale(.82); filter: blur(6px); } 60% { opacity: 1; filter: blur(0); } to { opacity: 1; transform: none; filter: none; } }
.is-fresh > img, .is-fresh > span > img { animation: ems-face-in .55s cubic-bezier(.2, .8, .2, 1) both; }
/* The photo pop-up opens and closes softly instead of snapping. */
.tb-dlg[open] { animation: tb-dlg-in .26s cubic-bezier(.2, .8, .2, 1); }
.tb-dlg[open]::backdrop { animation: tb-fade-in .26s ease; }
@keyframes tb-dlg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes tb-fade-in { from { opacity: 0; } to { opacity: 1; } }
.tb-crop img { animation: ems-face-in .4s cubic-bezier(.2, .8, .2, 1) both; }
.tb-crop.is-drag img { animation: none; }
@media (prefers-reduced-motion: reduce) { .is-fresh > img, .is-fresh > span > img, .tb-dlg[open], .tb-dlg[open]::backdrop, .tb-crop img { animation: none; } }
