/* ui/SignIn — the account row and the sign-in panel. Contract: ./SignIn.spec.md
   Tokens only (ui/Theme C8): no colour literals live here. */

/* The layer is inert: only the row and the two panels take a pointer, so the
   menu behind keeps its carousel, its paint picker and Enter Arena. */
.qc-signin {
  position: fixed;
  inset: 0;
  z-index: 41;
  pointer-events: none;
  font-family: var(--qc-font-ui);
}

/* --------------------------------------------------------------- the row --- */

/* ui/Settings puts a 44px gear 14px from the right edge; the row starts clear
   of it, so the two never overlap at any width. */
.qc-signin__row {
  pointer-events: auto;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: calc(env(safe-area-inset-right, 0px) + 66px);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 96px);
  padding: 0 4px 0 14px;
  min-height: 44px;
  color: var(--qc-text-dim);
  background: color-mix(in oklab, var(--qc-space-1) 78%, transparent);
  border: 1px solid var(--qc-line-strong);
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

.qc-signin__name {
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--qc-text);
}

/* The pilot level: written out, with the bar only reinforcing it. */
.qc-signin__pilot {
  position: relative;
  display: inline-block;
  padding-bottom: 5px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--qc-text-faint);
}

.qc-signin__pilot::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--qc-xp) calc(var(--fill, 0) * 100%),
    var(--qc-line-strong) calc(var(--fill, 0) * 100%)
  );
}

/* On a narrow menu the row shares the top strip with the title, so the level
   chip steps aside — the menu header already says "Pilot level 10" in full. */
@media (max-width: 640px) {
  .qc-signin__pilot {
    display: none;
  }
}

.qc-signin__spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--qc-line-strong);
  border-top-color: var(--qc-accent-2);
  animation: qc-signin-spin 900ms linear infinite;
}

@keyframes qc-signin-spin {
  to { transform: rotate(360deg); }
}

.qc-signin__action {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--qc-accent-2);
  border-radius: 999px;
}

.qc-signin__action:hover {
  color: var(--qc-text);
}

/* ------------------------------------------------------------- the panel --- */

.qc-signin__panel,
.qc-signin__merge {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 68px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  width: min(360px, calc(100vw - 28px));
  padding: 16px;
  color: var(--qc-text);
  background: var(--qc-glass);
  border: 1px solid var(--qc-line-strong);
  border-radius: var(--qc-radius);
  backdrop-filter: blur(14px);
  animation: qc-signin-in var(--qc-dur) var(--qc-ease-out);
}

.qc-signin__panel {
  pointer-events: auto;
  max-height: calc(100dvh - 96px - env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
}

.qc-signin__merge {
  pointer-events: auto;
  max-height: calc(100dvh - 96px - env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
}

@keyframes qc-signin-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.qc-signin__title {
  margin: 0 44px 10px 0;
  color: var(--qc-text-dim);
}

.qc-signin__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qc-signin__close {
  min-width: 44px;
  min-height: 44px;
}

.qc-signin__close--icon {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  color: var(--qc-text-faint);
  border-radius: 999px;
}

.qc-signin__close--icon:hover {
  color: var(--qc-text);
}

.qc-signin__intro,
.qc-signin__sent,
.qc-signin__note,
.qc-signin__attempts,
.qc-signin__merge-ship,
.qc-signin__merge-results {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--qc-text-dim);
}

.qc-signin__note {
  font-size: 11px;
  color: var(--qc-text-faint);
}

.qc-signin__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qc-signin__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qc-signin__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--qc-text-faint);
}

.qc-signin__input {
  min-height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--qc-text);
  background: var(--qc-space-0);
  border: 1px solid var(--qc-line-strong);
  border-radius: var(--qc-radius-sm);
}

.qc-signin__input:focus-visible {
  border-color: var(--qc-accent-2);
}

.qc-signin__input:disabled {
  color: var(--qc-text-faint);
  background: var(--qc-space-2);
}

.qc-signin__input--code {
  font-family: var(--qc-font-mono);
  font-size: 22px;
  letter-spacing: 0.4em;
  text-align: center;
}

.qc-signin__submit {
  min-height: 44px;
}

.qc-signin__error {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--qc-danger);
}

.qc-signin__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qc-signin__actions .qc-button {
  flex: 1 1 auto;
  min-height: 40px;
  font-size: 12px;
}

.qc-signin__merge-ship {
  color: var(--qc-text);
}

.qc-signin__done {
  width: 100%;
  margin-top: 4px;
}
