/* City Viewer — account drawer (push navigation, design options 2c/2d).
   One component, two altitudes: root = grouped account menu;
   rows push subviews that replace the drawer content (never the app behind). */

.drawer-scrim {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);

  &.is-open { opacity: 1; pointer-events: auto; }
}

.drawer {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 31;
  width: min(314px, 86cqw);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  box-shadow: var(--shadow-drawer);
  transform: translateX(108%);
  transition: transform var(--dur-slow) var(--ease-decel);
  visibility: hidden; /* keep the closed drawer out of the tab order */
  transition-property: transform, visibility;

  /* Opening flips visibility INSTANTLY (second duration 0s) — open() moves focus into the
     dialog synchronously, and a visibility that's still transitioning from hidden rejects
     focus(). Closing inherits the base duration, keeping the panel visible while it slides
     out. */
  &.is-open { transform: none; visibility: visible; transition-duration: var(--dur-slow), 0s; }

  @container app (min-width: 700px) {
    & { width: 360px; }
  }

  /* ---- Header: identity at root, ‹ title when pushed ---- */
  & .drawer-header {
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: calc(env(safe-area-inset-top, 0px) + var(--space-5)) var(--space-4) var(--space-4);
    background: var(--brand);
    color: var(--ink-on-brand);

    & .avatar {
      width: 2.6rem;
      height: 2.6rem;
      flex: none;
      display: grid;
      place-items: center;
      border-radius: var(--radius-pill);
      background: rgba(255, 255, 255, .16);
      font-weight: 700;
      font-size: .95rem;
    }
    & .avatar svg { width: 1.3rem; height: 1.3rem; }

    & .drawer-back {
      width: 2rem;
      height: 2rem;
      flex: none;
      display: grid;
      place-items: center;
      border: 0;
      border-radius: var(--radius-pill);
      background: rgba(255, 255, 255, .16);
      color: var(--ink-on-brand);
      font: inherit;
      font-size: 1.3rem;
      line-height: 1;
      cursor: pointer;
    }

    & .drawer-id { min-width: 0; }
    & .drawer-title { font-weight: 700; font-size: 1rem; line-height: 1.2; }
    & .drawer-subtitle { font-size: .78rem; opacity: .8; }
  }

  & .drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: var(--space-2) var(--space-3) var(--space-3);
  }

  & .drawer-footer {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4) calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
    border-top: 1px solid var(--line);
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-muted);

    & button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  }
}

/* ---- Grouped menu (drawer root) ---------------------------------------- */
/* Group header names the linked account and carries its capability tier. */
.account-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-3) var(--space-1) var(--space-1);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Capability tier badges — native / partial / link-out */
.tier {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;

  &.is-native { background: var(--success-bg); color: var(--success); }
  &.is-partial { background: var(--warning-bg); color: #8a5a00; }
  &.is-link { background: var(--info-bg); color: var(--brand); }
}

/* Menu row: pushes a subview (›) or launches an external portal (↗) */
/* Family view — the account's library cards side by side; the active card heads its nested menu. */
.card-row.is-active {
  font-weight: 700;

  & .menu-meta {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--accent-green, var(--ink-muted));
  }
}
.card-menu {
  padding-inline-start: var(--space-4);
  border-inline-start: 2px solid var(--line-soft);
  margin-inline-start: var(--space-2);
}

.menu-item {
  width: 100%;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-1);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;

  & svg { width: 1.15rem; height: 1.15rem; color: var(--brand); flex: none; }

  & .menu-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink-muted);
    white-space: nowrap;
  }
}

/* Status pill inside a row's meta ("1 ready") */
.status-pill {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--success-bg);
  color: var(--success);
  white-space: nowrap;
}

/* ---- Pushed subview extras --------------------------------------------- */
/* Library card barcode */
.barcode-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-block: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: #fff; /* a scannable barcode needs dark bars on a light field */
  border: 1px solid var(--line);
  border-radius: var(--radius-md);

  & svg { max-width: 100%; }

  & .barcode-number {
    font-family: var(--font-mono);
    letter-spacing: .16em;
    font-size: .85rem;
    color: var(--brand);
  }
}
