/* Toolantern Controls: shared eye / hand / keyboard / mouse controls for browser games.
   Loaded inside each game page. No external requests. Class prefix: tlc-.
   The bar sits above the game canvas and must never block game input when
   collapsed or when the mode is Keyboard or Mouse+Touch. */

.tlc-bar {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2147483000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: #111;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #c9c9c9;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  max-width: min(320px, calc(100vw - 16px));
  touch-action: auto;
  -webkit-user-select: none;
  user-select: none;
}

.tlc-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}

.tlc-toggle {
  appearance: none;
  border: 1px solid #999;
  background: #f2f2f2;
  color: #111;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  touch-action: auto;
}

.tlc-toggle:hover { background: #e4e4e4; }

.tlc-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tlc-body { padding: 0 8px 8px 8px; }
.tlc-bar.tlc-collapsed .tlc-body { display: none; }
.tlc-bar.tlc-collapsed .tlc-title { display: none; }
.tlc-bar.tlc-collapsed { background: rgba(255, 255, 255, 0.88); }

.tlc-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 8px 0;
}

.tlc-mode {
  appearance: none;
  border: 1px solid #999;
  background: #fff;
  color: #111;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  touch-action: auto;
}

.tlc-mode.tlc-active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.tlc-label { display: block; margin: 8px 0 4px 0; font-weight: 600; font-size: 12px; }

.tlc-select,
.tlc-btn {
  appearance: none;
  border: 1px solid #999;
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  touch-action: auto;
}

.tlc-btn:hover, .tlc-select:hover { background: #f2f2f2; }

.tlc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.tlc-status {
  margin-top: 8px;
  font-size: 12px;
  color: #333;
  min-height: 1.2em;
}

.tlc-status.tlc-error {
  color: #8b0000;
  font-weight: 600;
}

.tlc-privacy {
  margin-top: 8px;
  font-size: 11px;
  color: #444;
  border-top: 1px solid #ddd;
  padding-top: 8px;
}

/* Gaze / hand cursor: a ring that never captures input. Hidden unless
   Eye or Hand mode is active. */
.tlc-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  border: 3px solid #ff3b30;
  border-radius: 50%;
  background: rgba(255, 59, 48, 0.08);
  pointer-events: none;
  z-index: 2147482999;
  display: none;
  will-change: transform;
}

.tlc-cursor.tlc-visible { display: block; }

/* Dwell progress ring, drawn as an SVG circle around the cursor. */
.tlc-dwell {
  position: fixed;
  left: 0;
  top: 0;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  pointer-events: none;
  z-index: 2147482999;
  display: none;
  will-change: transform;
}

.tlc-dwell.tlc-visible { display: block; }

.tlc-dwell circle {
  fill: none;
  stroke: #0b7a00;
  stroke-width: 4;
  stroke-linecap: round;
}

/* 9-point calibration overlay. */
.tlc-cal {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  background: rgba(10, 10, 10, 0.88);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  touch-action: auto;
}

.tlc-cal-inner {
  position: absolute;
  inset: 0;
  padding: 16px;
  box-sizing: border-box;
}

.tlc-cal-head {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.tlc-cal-head h2 { margin: 8px 0 4px 0; font-size: 20px; }
.tlc-cal-head p { margin: 4px 0; font-size: 14px; color: #ddd; }
.tlc-cal-head .tlc-privacy { color: #ddd; border-top-color: #555; }

.tlc-cal-point {
  position: absolute;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ff3b30;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  touch-action: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tlc-cal-point.tlc-done { background: #0b7a00; border-color: #b6ffb0; }
.tlc-cal-point.tlc-next { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.35); }

.tlc-cal-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  text-align: center;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.tlc-cal-foot .tlc-btn { font-size: 13px; }

/* On-screen keyboard. Fixed at the bottom, never blocks the canvas
   while it is closed. */
.tlc-kbd {
  position: fixed;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 2147483000;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #c9c9c9;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  padding: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  touch-action: auto;
  max-width: calc(100vw - 16px);
}

.tlc-kbd.tlc-hidden { display: none; }

.tlc-kbd-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

.tlc-kbd-rows { display: flex; flex-direction: column; gap: 5px; }
.tlc-kbd-row { display: flex; gap: 5px; justify-content: center; }

.tlc-key {
  appearance: none;
  border: 1px solid #999;
  background: #fff;
  color: #111;
  border-radius: 8px;
  min-width: 34px;
  min-height: 42px;
  padding: 0 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: auto;
}

.tlc-key:hover { background: #eef4ff; }
.tlc-key.tlc-key-wide { min-width: 64px; font-size: 13px; }
.tlc-key.tlc-key-dwell { background: #dff3dd; border-color: #0b7a00; }

/* Small camera preview used by the Eye and Hand engines. */
.tlc-preview {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 2147482998;
  background: #000;
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  width: 176px;
  height: 132px;
}

.tlc-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tlc-preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tlc-preview-label {
  position: absolute;
  left: 4px;
  top: 2px;
  color: #fff;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
}
