/**
 * Route phone layouts — MOBILE-UI-VARIANT P2
 * Login / Gateway / Universe. Only when html.msqd-phone-chrome (≤640px or ?phone=1).
 * Desktop without the class: zero change.
 *
 * Doctrine: knowledge/design/MOBILE_UI_VARIANT.md
 */

/* Mode chip (shared with Artemis P1 id) */
html.msqd-phone-chrome #msqd-phone-mode-chip {
  display: block;
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10060;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e2e8f0;
  background: rgba(13, 17, 23, 0.82);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  padding: 6px 12px;
  pointer-events: none;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

/* ═══════════════════════════════════════════════════════════
   LOGIN — thumb-safe form (no desktop auth-* changes)
   ═══════════════════════════════════════════════════════════ */
/* Login: do not require body.auth-body — cinematic overlays may replace body classes */
html.msqd-phone-chrome:has(.auth-wrap),
html.msqd-phone-chrome body:has(> .auth-wrap) {
  align-items: flex-start;
  justify-content: flex-start;
  padding: max(52px, calc(env(safe-area-inset-top, 0px) + 44px))
    max(14px, env(safe-area-inset-right, 0px))
    max(20px, env(safe-area-inset-bottom, 0px))
    max(14px, env(safe-area-inset-left, 0px));
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.msqd-phone-chrome .auth-back {
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
}

html.msqd-phone-chrome .auth-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 4px;
  font-size: 0.78rem;
}

html.msqd-phone-chrome .auth-top-right {
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
}

html.msqd-phone-chrome .auth-wrap {
  max-width: none;
  width: 100%;
  margin-top: 8px;
}

html.msqd-phone-chrome .auth-logo {
  margin-bottom: 1.25rem;
}

html.msqd-phone-chrome .auth-logo-img {
  width: 64px;
  height: 64px;
}

html.msqd-phone-chrome .auth-card {
  padding: 1.25rem 1.1rem 1.4rem;
  border-radius: 16px;
}

html.msqd-phone-chrome .auth-tab {
  min-height: 48px;
  font-size: 0.85rem;
  padding: 0.85rem 0.5rem;
  touch-action: manipulation;
}

html.msqd-phone-chrome .auth-input {
  /* 16px+ prevents iOS focus zoom */
  font-size: 16px !important;
  min-height: 48px;
  padding: 0.85rem 1rem;
  border-radius: 12px;
}

html.msqd-phone-chrome .auth-check {
  min-height: 44px;
  font-size: 0.9rem;
  gap: 0.65rem;
}

html.msqd-phone-chrome .auth-check input {
  width: 20px;
  height: 20px;
}

html.msqd-phone-chrome .auth-btn {
  min-height: 52px !important;
  font-size: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  touch-action: manipulation;
}

html.msqd-phone-chrome .auth-google {
  min-height: 48px;
  font-size: 0.95rem;
  padding: 0.85rem 1rem;
  touch-action: manipulation;
}

html.msqd-phone-chrome .auth-forgot a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.85rem;
}

html.msqd-phone-chrome .auth-orb {
  opacity: 0.28;
}

/* ═══════════════════════════════════════════════════════════
   GATEWAY — stacked route, larger stations
   ═══════════════════════════════════════════════════════════ */
html.msqd-phone-chrome:has(.wire) body,
html.msqd-phone-chrome body:has(.wire) {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

html.msqd-phone-chrome .bar {
  padding: max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    10px max(12px, env(safe-area-inset-left, 0px));
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 6px;
}

html.msqd-phone-chrome .bar .tag {
  display: none;
}

html.msqd-phone-chrome .bar .links {
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}

html.msqd-phone-chrome .bar .links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  touch-action: manipulation;
}

html.msqd-phone-chrome .stage {
  height: auto;
  min-height: 100dvh;
  padding: 72px 0 max(120px, calc(env(safe-area-inset-bottom, 0px) + 100px));
  align-items: flex-start;
}

html.msqd-phone-chrome .wire {
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 420px;
  padding: 8px 16px 0;
}

html.msqd-phone-chrome .link {
  width: 2px;
  height: 36px;
  min-width: 0;
  max-width: none;
  margin: 0;
  align-self: center;
}

html.msqd-phone-chrome .link .rail {
  width: 2px;
  left: 50%;
  transform: translateX(-50%);
}

html.msqd-phone-chrome .link.cyan .rail {
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.05), rgba(0, 229, 255, 0.4));
}

html.msqd-phone-chrome .link.amber .rail {
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.3), rgba(245, 179, 1, 0.5));
}

html.msqd-phone-chrome .link .flow {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  animation: msqdRouteFlowV 2.4s linear infinite;
}

html.msqd-phone-chrome .link .arrowhead {
  right: auto;
  bottom: -4px;
  top: auto;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
}

@keyframes msqdRouteFlowV {
  0% {
    top: 0;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

html.msqd-phone-chrome .station {
  gap: 12px;
  width: 100%;
  padding: 8px 0;
  touch-action: manipulation;
}

html.msqd-phone-chrome .node {
  width: min(148px, 42vw);
  height: min(148px, 42vw);
}

html.msqd-phone-chrome .station .name {
  font-size: 0.95rem;
  letter-spacing: 2px;
}

html.msqd-phone-chrome .station .role {
  font-size: 0.68rem;
  max-width: 240px;
}

html.msqd-phone-chrome .art .enter {
  margin-top: 6px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  padding: 12px 28px;
  border-radius: 999px;
}

html.msqd-phone-chrome .uni .gatelabel {
  position: static;
  transform: none;
  margin-bottom: 4px;
}

html.msqd-phone-chrome .uni .lock {
  width: 36px;
  height: 36px;
  font-size: 16px;
}

html.msqd-phone-chrome .caption {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(2, 4, 8, 0.92) 28%);
}

html.msqd-phone-chrome .caption .line {
  font-size: 0.78rem;
  line-height: 1.45;
}

html.msqd-phone-chrome .caption .sub {
  font-size: 0.58rem;
  margin-top: 10px;
}

html.msqd-phone-chrome .toast {
  bottom: max(140px, calc(env(safe-area-inset-bottom, 0px) + 120px));
  max-width: calc(100vw - 32px);
  text-align: center;
  line-height: 1.35;
  padding: 12px 16px;
  font-size: 0.68rem;
}

/* ═══════════════════════════════════════════════════════════
   UNIVERSE — list fallback polish (3D hidden by buildMobile)
   ═══════════════════════════════════════════════════════════ */
html.msqd-phone-chrome #mobile {
  display: block;
  padding: max(64px, calc(env(safe-area-inset-top, 0px) + 52px))
    max(14px, env(safe-area-inset-right, 0px))
    max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px))
    max(14px, env(safe-area-inset-left, 0px));
  -webkit-overflow-scrolling: touch;
}

html.msqd-phone-chrome #mobile .m-head h1 {
  font-size: 1.45rem;
  letter-spacing: 3px;
}

html.msqd-phone-chrome #mobile .m-head p {
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0 8px;
}

html.msqd-phone-chrome .m-card {
  min-height: 64px;
  padding: 14px 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  touch-action: manipulation;
}

html.msqd-phone-chrome .m-card .em {
  font-size: 1.65rem;
}

html.msqd-phone-chrome .m-card .body .t {
  font-size: 0.95rem;
}

html.msqd-phone-chrome .m-card .body .d {
  font-size: 0.82rem;
  line-height: 1.35;
}

html.msqd-phone-chrome .m-card .go {
  font-size: 1.2rem;
  min-width: 28px;
  text-align: center;
}

html.msqd-phone-chrome #filters {
  top: max(52px, calc(env(safe-area-inset-top, 0px) + 44px));
  left: 8px;
  right: 8px;
  transform: none;
  width: auto;
  max-width: none;
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 4px;
  border-radius: 16px;
  padding: 6px;
  scrollbar-width: none;
}

html.msqd-phone-chrome #filters::-webkit-scrollbar {
  display: none;
}

html.msqd-phone-chrome .fbtn {
  flex: none;
  min-height: 40px;
  padding: 10px 14px;
  font-size: 0.58rem;
  touch-action: manipulation;
}

html.msqd-phone-chrome #topbar {
  height: auto;
  min-height: 52px;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    8px max(12px, env(safe-area-inset-left, 0px));
  flex-wrap: wrap;
  gap: 8px;
}

html.msqd-phone-chrome #topbar .wordmark {
  font-size: 0.92rem;
}

html.msqd-phone-chrome #flavor {
  display: none;
}

html.msqd-phone-chrome #bottombar {
  display: none;
}

html.msqd-phone-chrome #hint {
  display: none !important;
}

html.msqd-phone-chrome #parts-dock {
  display: none !important;
}

html.msqd-phone-chrome #a52-panel {
  width: min(360px, calc(100vw - 24px));
  padding: 22px 18px;
}

html.msqd-phone-chrome #a52-pin {
  font-size: 1.35rem;
  min-height: 52px;
}

html.msqd-phone-chrome .a52-btns button {
  min-height: 48px;
  touch-action: manipulation;
}
