/* Phones and tablets (assets/js/mobile-controls.js). html.oss-touch marks a touch
   screen and html.oss-phone a small one; desktop browsers get neither. */

/* ---- A running system fills a phone's screen ---- */

/* The visible part of the page, which shrinks while the phone's keyboard is open. */
html.oss-touch #emulator.active {
  top: var(--mc-vtop, 0px);
  height: var(--mc-vh, 100dvh);
}
html.oss-phone #emulator.active {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
html.oss-phone #emulator .emu-bar { display: none; }
/* Touch screens reach Paste text, the states and the CD under More in the control bar. */
html.oss-touch .emu-tool, html.oss-touch .emu-menu { display: none; }
html.oss-touch #screen_container {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
html.oss-phone #screen_container:focus { outline: none; }

/* ---- Controls ---- */

.mc-panel {
  flex: none; display: flex; flex-direction: column; gap: 6px;
  padding: 6px 8px; background: #0d1117; border-top: 1px solid #30363d;
}
.mc-panel[hidden], .mc-row[hidden], .mc-panel button[hidden], .mc-handle[hidden], .mc-status[hidden], .mc-hint[hidden] { display: none; }
.mc-row {
  display: flex; gap: 6px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.mc-row::-webkit-scrollbar { display: none; }
.mc-panel button {
  flex: none; min-width: 42px; height: 38px; padding: 0 12px;
  border: 1px solid #30363d; border-radius: 8px; background: #21262d; color: #e6edf3;
  font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.mc-panel button:active { background: #30363d; }
.mc-panel button[aria-pressed="true"] { background: #1f6feb; border-color: #388bfd; color: #fff; }
.mc-panel button:focus-visible { outline: 2px solid #58a6ff; outline-offset: 1px; }

/* Sideways, every row shares one line that scrolls, leaving the screen its height. */
@media (orientation: landscape) {
  .mc-panel { flex-direction: row; overflow-x: auto; scrollbar-width: none; padding: 5px 8px; }
  .mc-panel::-webkit-scrollbar { display: none; }
  .mc-row { flex: none; overflow: visible; }
  .mc-row + .mc-row { padding-left: 6px; border-left: 1px solid #30363d; }
}

.mc-handle {
  position: absolute; z-index: 6;
  right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 48px; height: 48px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(22, 27, 34, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: opacity 0.4s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.mc-handle::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: 16px; height: 2px; border-radius: 1px;
  background: #e6edf3; box-shadow: 0 7px 0 #e6edf3, 0 14px 0 #e6edf3;
}
.mc-handle.is-idle { opacity: 0.35; }
.mc-handle:focus-visible { outline: 2px solid #58a6ff; outline-offset: 2px; }

.mc-status {
  position: absolute; z-index: 6; left: 50%;
  top: calc(env(safe-area-inset-top) + 10px);
  max-width: calc(100% - 32px); transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px;
  background: rgba(22, 27, 34, 0.9); border: 1px solid #30363d; color: #c9d1d9;
  font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
/* Tablets keep the launcher's toolbar at the top. */
html.oss-touch:not(.oss-phone) .mc-status { top: 64px; }

.mc-hint {
  position: absolute; z-index: 6; left: 50%;
  top: calc(env(safe-area-inset-top) + 48px);
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 32px); transform: translateX(-50%);
  padding: 8px 14px; border-radius: 12px; border: 1px solid #388bfd; background: rgba(13, 17, 23, 0.94);
  color: #e6edf3; font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.mc-hint-phone {
  flex: none; width: 14px; height: 22px; border: 2px solid #58a6ff; border-radius: 3px;
  animation: mc-turn 1.8s ease-in-out infinite;
}
@keyframes mc-turn {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

/* The phone's keyboard types into this; under 16px text iOS would zoom the page when it gets focus. */
.mc-type {
  position: absolute; left: 0; top: 0; z-index: -1;
  width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0;
  resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .mc-hint-phone { animation: none; transform: rotate(-90deg); }
  .mc-handle { transition: none; }
}
