/* The ID badge menu: the account menu of a design tool, as an ID badge on a retractable reel. The reel is the button;
   the badge that comes out of it on its cord is the menu, with the second level on its back. The script moves the
   badge, the cord and the shadow; the colours are here. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #17181c;           /* the words */
  --muted: #6c6f79;         /* the email, the notes */
  --icon: #7d808b;          /* the items' icons */
  --card: #fcfbf8;          /* the badge's plastic */
  --card-edge: #d9d5cc;     /* its thickness, seen edge-on */
  --reel: #26262d;          /* the reel's body */
  --cord: #2c2c34;          /* the cord */
  --braid: #74747f;         /* the braid along the cord */
  --ring: #9b9fa9;          /* the split ring */
  --danger: #c23a2b;        /* Sign out */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Host Grotesk Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* the falling badge never makes the page scroll */
.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  overflow: clip;
}

/* ---------------------------------------------------------------- the room the badge hangs in */
.account {
  position: relative;
  width: min(320px, 100%);
  height: 560px;
}

/* ---------------------------------------------------------------- the reel: the button */
.reel {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 4;
  width: 54px;
  height: 62px;
  margin-left: -27px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.reel__body {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #5a5a65, var(--reel) 52%, #18181c 100%);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.3),
    0 12px 20px -9px rgba(18, 18, 30, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: transform 0.2s var(--ease-out), box-shadow 0.25s ease;
}

/* the face, with a thin ring in the colour of the workspace */
.reel__face {
  position: absolute;
  inset: 5px;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--ws-ring, #0d5c58);
  transition: box-shadow 0.4s ease;
}

.reel__portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the resin dome over the portrait */
.reel__dome {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 66% 50% at 36% 22%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 62%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 64%, rgba(10, 10, 20, 0.22) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.24),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  transition: background-position 0.4s var(--ease-out);
  pointer-events: none;
}

/* where the cord comes out */
.reel__nozzle {
  position: absolute;
  left: 50%;
  top: 47px;
  width: 15px;
  height: 12px;
  margin-left: -7.5px;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(180deg, #34343c, #18181c);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.reel__nozzle::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 5px;
  height: 2px;
  margin-left: -2.5px;
  border-radius: 1px;
  background: #050507;
}

@media (hover: hover) and (pointer: fine) {
  .reel:hover .reel__body {
    transform: translateY(-1px) scale(1.03);
    box-shadow:
      0 1px 1px rgba(0, 0, 0, 0.3),
      0 16px 24px -10px rgba(18, 18, 30, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }
}

.reel:active .reel__body {
  transform: scale(0.95);
  transition-duration: 0.1s;
}

.reel:focus-visible {
  outline: none;
}

.reel:focus-visible .reel__body {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* signed out: the portrait gives way to an empty face */
[data-face-out] {
  opacity: 0;
}

.account.is-out [data-face-out] {
  opacity: 1;
}

.account.is-out [data-face-in] {
  opacity: 0;
}

[data-face-in],
[data-face-out] {
  transition: opacity 0.45s ease;
}

.account__note {
  position: absolute;
  left: 0;
  right: 0;
  top: 74px;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.account__note b {
  color: var(--ink);
  font-weight: 620;
}

/* it comes in softly, and goes at once: the cord comes out right through it */
.account.is-out .account__note {
  opacity: 1;
  transform: none;
  transition: opacity 0.3s ease, transform 0.4s var(--ease-out);
  cursor: pointer;
  pointer-events: auto;
}

/* ---------------------------------------------------------------- the cord */
.cord {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.cord__base {
  stroke: var(--cord);
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* the braid: a pattern held at the ring's end, so it comes out of the reel with the cord */
.cord__braid {
  stroke: var(--braid);
  stroke-width: 2.2;
  stroke-dasharray: 1.2 1.8;
}

.ring circle {
  fill: none;
  stroke: var(--ring);
  stroke-width: 1.8;
}

.ring__glint {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 0.9;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the badge */
.badge,
.shade {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  visibility: hidden;
}

.badge {
  z-index: 2;
  transform-style: preserve-3d;
}

.shade {
  z-index: 0;
}

.badge.is-out,
.shade.is-out {
  visibility: visible;
}

.badge__card,
.shade__card {
  position: absolute;
  left: -132px;
  top: 24px;
  width: 264px;
  height: 414px;
}

.badge__card {
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* the shadow it casts on the wall behind: a soft patch a little smaller than the badge, never an outline */
.shade__card {
  left: -124px;
  top: 34px;
  width: 248px;
  height: 398px;
  border-radius: 18px;
  background: rgba(24, 26, 44, 0.2);
  filter: blur(14px);
}

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(23, 24, 34, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.face--back {
  transform: rotateY(180deg);
}

/* the thickness of the card */
.edge {
  position: absolute;
  top: 7px;
  bottom: 7px;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, #e9e6df, var(--card-edge));
}

.edge--left {
  left: 0;
  transform: rotateY(90deg);
}

.edge--right {
  left: 100%;
  transform: rotateY(90deg);
}

/* at rest the badge is drawn flat, so the words stay sharp */
.badge[data-flat] .edge {
  visibility: hidden;
}

.badge[data-flat='front'] .face--back,
.badge[data-flat='back'] .face--front {
  visibility: hidden;
}

.badge[data-flat='back'] .face--back {
  transform: none;
}

/* the light on the plastic: a gloss that slides with the angles, and the shade of a face turning away */
.face__sheen,
.face__dim {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.face__sheen {
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.42) 47%, rgba(255, 255, 255, 0) 57%);
  background-size: 280% 100%;
  background-position: 62% 0;
  opacity: 0.5;
}

.face__dim {
  background: #0c0e16;
  opacity: 0;
}

/* ---------------------------------------------------------------- the clip strap */
.strap {
  position: absolute;
  left: 50%;
  top: -21px;
  z-index: 3;
  width: 13px;
  height: 36px;
  margin-left: -6.5px;
  border-radius: 3px 3px 2px 2px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.65) 0 1.5px, rgba(255, 255, 255, 0) 3px),
    linear-gradient(180deg, rgba(186, 204, 222, 0.62), rgba(170, 190, 212, 0.48));
  box-shadow:
    inset 0 0 0 1px rgba(80, 98, 120, 0.3),
    0 1px 2px rgba(20, 26, 40, 0.18);
  pointer-events: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* a hair in front of each face, so it is drawn over it */
.strap--front {
  transform: translateZ(0.6px);
}

.strap--back {
  transform: rotateY(180deg) translateZ(0.6px);
}

.badge[data-flat='front'] .strap--back,
.badge[data-flat='back'] .strap--front {
  visibility: hidden;
}

.badge[data-flat] .strap {
  transform: none;
}

/* the snap: a ring of nickel, not a dot */
.strap__snap {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #8d929c 0 1.6px, #e6e8ec 2.2px, #a7abb4 3.4px, #6f747e 4.5px);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

/* ---------------------------------------------------------------- the front */
.band {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 24px 14px 0 16px;
  background: var(--ws);
  color: #ffffff;
}

.slot {
  position: absolute;
  left: 50%;
  top: 9px;
  width: 36px;
  height: 7px;
  margin-left: -18px;
  border-radius: 4px;
  background: rgba(4, 12, 16, 0.34);
  box-shadow: inset 0 1px 1.5px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255, 255, 255, 0.2);
}

.band__logo {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ws);
}

.band__logo svg,
.ws__logo svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.band__name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.005em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.band__role {
  padding: 3px 8px 3.5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.02em;
}

.who {
  display: grid;
  grid-template-columns: 58px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 13px;
  height: 84px;
  padding: 0 16px;
}

.who__photo {
  grid-row: span 2;
  width: 58px;
  height: 58px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(20, 22, 30, 0.07), 0 3px 8px -3px rgba(20, 22, 30, 0.28);
}

.who__name {
  align-self: end;
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.who__mail {
  align-self: start;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- the menus */
.menu {
  position: relative;
  padding: 4px 6px;
  outline: none;
}

/* one highlight per menu, gliding from item to item */
.menu__hl {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ws) 10%, transparent);
  opacity: 0;
  pointer-events: none;
}

.menu__hl.is-danger {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}

.menu__rule {
  position: relative;
  height: 9px;
}

.menu__rule::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 4px;
  height: 1px;
  background: rgba(23, 24, 28, 0.08);
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 40px;
  padding: 0 12px 0 11px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 520;
  letter-spacing: -0.003em;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.row__icon,
.row__chevron,
.row__check {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: var(--icon);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.18s ease;
}

.row__chevron {
  width: 16px;
  height: 16px;
}

.row.is-active .row__icon,
.row.is-active .row__chevron {
  stroke: var(--ws);
}

.row__meta {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 480;
  letter-spacing: 0.01em;
}

.row--danger {
  color: var(--danger);
}

.row--danger .row__icon,
.row--danger.is-active .row__icon {
  stroke: currentColor;
}

/* the keys: the active item gets a ring too */
html[data-using='keys'] .row.is-active {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ws) 55%, transparent);
}

html[data-using='keys'] .row--danger.is-active {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--danger) 50%, transparent);
}

/* ---------------------------------------------------------------- the back */
.back__top {
  position: relative;
  height: 32px;
}

.back__top .slot {
  background: rgba(20, 22, 30, 0.2);
  box-shadow: inset 0 1px 1.5px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.9);
}

.page[hidden] {
  display: none;
}

.row--back {
  grid-template-columns: 20px 1fr;
  font-weight: 640;
}

.row--ws {
  grid-template-columns: 30px 1fr 20px;
  height: 50px;
}

.ws__logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--ws);
  color: #ffffff;
}

.ws__text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ws__name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
}

.ws__meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
}

.row__check {
  stroke: var(--ink);
  stroke-width: 2;
  opacity: 0;
}

.row--ws[aria-checked='true'] .row__check {
  opacity: 1;
}

/* the magnetic stripe on the back of the card */
.back__stripe {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  height: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 40%, rgba(0, 0, 0, 0.18)),
    #2e2a26;
}

.back__print {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 15px;
  margin: 0;
  color: #a3a6ae;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-align: center;
}

/* the question before signing out */
.page--ask {
  display: grid;
  justify-items: center;
  padding: 18px 18px 0;
  text-align: center;
}

.ask__door {
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  padding: 3px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--danger) 9%, var(--card));
  overflow: visible;
}

.ask__frame,
.ask__arrow {
  fill: none;
  stroke: var(--danger);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ask__title {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -0.015em;
  line-height: 1.25;
  text-wrap: balance;
}

.ask__text {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: pretty;
}

.menu--ask {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 0;
}

.menu--ask .menu__hl {
  display: none;
}

.pill {
  grid-template-columns: 1fr;
  justify-items: center;
  height: 42px;
  border-radius: 999px;
  background: #f0f0f3;
  font-weight: 620;
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.pill--danger {
  background: var(--danger);
  color: #ffffff;
}

.pill.is-active {
  background: #e6e6eb;
}

.pill--danger.is-active {
  background: color-mix(in srgb, var(--danger) 88%, #000000);
}

html[data-using='keys'] .pill.is-active {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
}

html[data-using='keys'] .pill--danger.is-active {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--danger);
}

/* ---------------------------------------------------------------- grabbing the badge */
.band,
.who,
.back__top,
.ask__door {
  cursor: grab;
  touch-action: none;
}

.account.is-held,
.account.is-held * {
  cursor: grabbing;
}

@media (pointer: coarse) {
  .row__meta[data-keys] {
    display: none;
  }
}

@media (max-width: 360px) {
  .account {
    transform: scale(0.9);
    transform-origin: 50% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reel__body {
    transition: none;
  }

  .account__note,
  .account.is-out .account__note {
    transform: none;
  }

  .reel:active .reel__body {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .reel:hover .reel__body {
    transform: none;
  }
}
