/* ============================================================
   Views, accounts and the route home.
   Owned by assets/roles.js. Loads after v2.css.

   The old switcher styled one control that meant two things: preview
   another view, and be another account. This layer styles them as the
   two separate things they are, and adds the piece that was missing
   entirely, a route home that is visible at rest on every surface.

   Class names reused on purpose, already defined in v2.css and not
   redefined here: .rs__av .rs__chev .rs__lock .rsmenu__h .rsmenu__t
   .rsmenu__n .rsmenu__go .pin .pinback and everything under .pin.
   ============================================================ */

/* ---------- the control in the topbar ---------------------------- */

.vswitch {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

/* The one click route home. Not in the menu, not behind a hover. If you
   are not on the view your account belongs to, this is on screen. */
.vswitch__home {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 11px 6px 9px;
  border: 1px solid var(--plum-050);
  border-radius: 999px;
  background: var(--plum-050);
  color: var(--plum-700);
  font-size: 12.5px;
  font-weight: 620;
  white-space: nowrap;
  transition:
    background 0.14s,
    border-color 0.14s;
}
.vswitch__home:hover {
  background: #fff;
  border-color: var(--plum);
}
.vswitch__home svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.vswitch__btn {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 11px 4px 4px;
  min-width: 0;
  transition:
    border-color 0.14s,
    box-shadow 0.14s;
}
.vswitch__btn:hover {
  border-color: var(--plum);
  box-shadow: 0 1px 3px rgba(36, 28, 43, 0.08);
}
.vswitch__id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  min-width: 0;
}
.vswitch__r {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
}
.vswitch__p {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.vswitch.open .rs__chev {
  transform: rotate(180deg);
}

/* An account that cannot open the surface it is looking at. Says so
   rather than pretending, and the route home is already next to it. */
.vswitch--out .vswitch__btn {
  border-color: var(--amber);
  background: var(--amber-050);
}
.vswitch--out .vswitch__p {
  color: var(--amber);
  font-weight: 600;
}

/* The member surface ships no topbar. Same control, floated at the same
   corner, so the model does not change shape between surfaces. */
.vfloat {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 850;
}
.vswitch--float .vswitch__btn,
.vswitch--float .vswitch__home {
  box-shadow: var(--shadow-sm);
}
.vswitch--float .vswitch__btn {
  background: var(--surface);
}

/* ---------- the menu --------------------------------------------- */

.vsmenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 372px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 7px;
  z-index: 900;
  opacity: 0;
  transform: translateY(-6px) scale(0.985);
  pointer-events: none;
  transform-origin: top right;
  transition:
    opacity 0.15s ease,
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.vswitch.open .vsmenu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* who you are. The email is the point: an account is an email plus a
   role, and that is the thing being granted. */
.vsme {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 10px 11px;
  border-bottom: 1px solid var(--line);
}
.vsme__t {
  min-width: 0;
}
.vsme__t b {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
}
.vsme__t code {
  display: block;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--teal);
  word-break: break-all;
}
.vsme__t small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.vsnote {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 8px 4px 2px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--amber-050);
  border-left: 2px solid var(--amber);
}
.vsnote--quiet {
  background: none;
  border-left: 0;
  color: var(--muted);
  padding: 8px 10px 2px;
  margin: 0;
}

.vslist {
  display: block;
}
.vsrow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
}
.vsrow.is-open {
  transition: background 0.12s;
}
.vsrow.is-open:hover {
  background: var(--surface-2);
}
.vsrow.is-open:hover .rsmenu__go {
  color: var(--muted);
}
.vsrow.is-here {
  background: var(--plum-050);
}
.vsrow__now {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--plum-700);
}

/* A view this account cannot open. Visible and explained, never hidden,
   and not clickable, because there is nothing behind it to click. A PIN
   does not open it. Only a grant does. */
.vsrow.is-locked {
  cursor: default;
}
.vsrow.is-locked .rsmenu__t {
  background: var(--surface-2);
  color: var(--muted);
}
.vsrow.is-locked .rsmenu__n b {
  color: var(--muted);
}
.vsrow.is-locked .rsmenu__n small {
  color: var(--amber);
}

/* the jump bar preference, in a place you can find by looking */
.vspref {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 0;
  padding: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.vspref input {
  width: 15px;
  height: 15px;
  flex: none;
  accent-color: var(--plum);
  cursor: pointer;
}
.vspref span {
  flex: 1;
  min-width: 0;
}
.vspref kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--muted);
}

.vsfoot {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 6px;
}
.vsfoot__b {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal);
  transition: background 0.12s;
}
.vsfoot__b:hover {
  background: var(--teal-050);
}
.vsfoot__b--back {
  color: var(--plum-700);
}
.vsfoot__b--back:hover {
  background: var(--plum-050);
}

/* ---------- dialogs ---------------------------------------------- */

.vdlg {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 20px;
  width: 360px;
  max-width: 100%;
  text-align: center;
  animation: pinup 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.vdlg--wide {
  width: 500px;
  text-align: left;
  padding: 24px 24px 18px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}
.vdlg h2 {
  font-family: var(--font-brand);
  font-size: 23px;
  font-weight: 700;
  margin: 0 0 6px;
}
.vdlg > p {
  color: var(--ink-2);
  font-size: 13.5px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.vdlg__f {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.vdlg__hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.vacctl {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.vacct {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  transition:
    border-color 0.14s,
    background 0.12s;
}
.vacct:hover {
  border-color: var(--plum);
  background: var(--plum-050);
}
.vacct.on {
  border-color: var(--plum);
  background: var(--plum-050);
}
.vacct__t {
  flex: 1;
  min-width: 0;
}
.vacct__t b {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
}
.vacct__t code {
  display: block;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--teal);
  word-break: break-all;
}
.vacct__t small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.vacct__n {
  flex: none;
  text-align: right;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-2);
}
.vacct__n small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
}
.vacct__now {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--plum-700);
}

/* ---------- D1. Making the jump bar findable ---------------------
   The handle and the dismiss both existed. Neither read as a control,
   and nothing was said at the moment the bar disappeared, so the client
   dismissed it and could not get it back. Three fixes, all here. */

/* 1. The dismiss is a labelled button that is visible at rest. It was a
      bare multiplication sign that only appeared on hover, which is a
      control you can only discover by having already used it. */
.hotbar__off {
  max-width: none;
  opacity: 0.72;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 11px 7px 9px;
  margin-left: 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0 999px 999px 0;
}
.hotbar:hover .hotbar__off {
  max-width: none;
  opacity: 1;
}

/* 2. The handle is a pill lifted off the screen edge, at the size of a
      thing you are meant to press. Flush with the bottom of the window
      it read as a rendering artefact. */
.hotdock {
  bottom: 14px;
  padding: 8px 14px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 30px rgba(20, 12, 28, 0.28);
}
.hotdock.on {
  transform: translateX(-50%) translateY(0);
}
.hotdock svg {
  width: 14px;
  height: 14px;
  opacity: 0.9;
}
/* it announces itself once, at the moment it becomes the only route back */
.hotdock.pulse {
  animation: hotdockPulse 1.1s ease-out 2;
}
@keyframes hotdockPulse {
  0%,
  100% {
    box-shadow: 0 8px 30px rgba(20, 12, 28, 0.28);
  }
  45% {
    box-shadow:
      0 8px 30px rgba(20, 12, 28, 0.28),
      0 0 0 5px rgba(183, 122, 30, 0.45);
  }
}

/* 3. Say where it went, at the moment it goes, and offer the undo. */
.vtoast {
  position: fixed;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  z-index: 860;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 11px 12px 11px 15px;
  border-radius: var(--r);
  background: rgba(30, 22, 38, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 34px rgba(20, 12, 28, 0.32);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12.5px;
  line-height: 1.45;
  animation: vtoastIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes vtoastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}
.vtoast kbd {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.vtoast button {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 650;
  padding: 6px 13px;
  border-radius: 999px;
}
.vtoast button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- narrow ------------------------------------------------ */

@media (max-width: 1080px) {
  .vswitch__id {
    display: none;
  }
  .vswitch__btn {
    padding: 4px 8px 4px 4px;
  }
}
@media (max-width: 860px) {
  .vswitch__home span {
    display: none;
  }
  .vswitch__home {
    padding: 7px 9px;
  }
  .vsmenu {
    width: calc(100vw - 24px);
  }
  .vtoast {
    bottom: 66px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vsmenu,
  .vswitch__btn,
  .vswitch__home,
  .vacct {
    transition: none;
  }
  .vdlg,
  .vtoast {
    animation: none;
  }
  .hotdock.pulse {
    animation: none;
    box-shadow:
      0 8px 30px rgba(20, 12, 28, 0.28),
      0 0 0 4px rgba(183, 122, 30, 0.5);
  }
}
