/* ==========================================================================
   TermaType — On-screen Tibetan Keyboard
   Slides up from bottom, dark aesthetic matching the title bar.
   Each key shows Tibetan character + English letter.
   ========================================================================== */

/* ── CONTAINER ─────────────────────────────────────────────────────────────── */
.kb-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 600;
  background: #1C1916;
  border-top: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3), 0 -1px 6px rgba(0,0,0,0.15);
  padding: 10px 12px 14px;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease;
  will-change: transform;
}

.kb-container.kb-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── CLOSE BUTTON ──────────────────────────────────────────────────────────── */
.kb-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.35);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  z-index: 2;
}
.kb-close:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.1);
}

/* ── BODY ──────────────────────────────────────────────────────────────────── */
.kb-body {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── ROW ───────────────────────────────────────────────────────────────────── */
.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* ── KEY ───────────────────────────────────────────────────────────────────── */
.kb-key {
  flex: 1;
  min-width: 0;
  max-width: 62px;
  height: 54px;
  background: linear-gradient(to bottom, #2E2A26, #252220);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom: 2px solid rgba(0,0,0,0.4);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  user-select: none;
  transition: transform 0.08s ease, background 0.08s ease,
              box-shadow 0.08s ease, border-color 0.08s ease;
  overflow: hidden;
  gap: 0;
  padding: 2px 2px 4px;
}

.kb-key:hover {
  background: linear-gradient(to bottom, #3A3530, #302C28);
  border-color: rgba(255,255,255,0.12);
}

/* ── PRESSED STATE ─────────────────────────────────────────────────────────── */
.kb-key.kb-pressed {
  transform: scale(0.93);
  background: linear-gradient(to bottom, #C97A1E, #A36418) !important;
  border-color: rgba(201,122,30,0.6) !important;
  border-bottom-width: 1px;
  box-shadow: 0 0 12px rgba(201,122,30,0.35);
}
.kb-key.kb-pressed .kb-tib { color: white; }
.kb-key.kb-pressed .kb-eng { color: rgba(255,255,255,0.8); }
.kb-key.kb-pressed .kb-sub { color: rgba(255,255,255,0.6); }

/* ── HIGHLIGHT STATE (typing tutor next-key) ───────────────────────────────── */
.kb-key.kb-highlight {
  background: linear-gradient(to bottom, #3A3025, #302820);
  border-color: var(--c-accent, #C97A1E);
  box-shadow: 0 0 0 1px var(--c-accent, #C97A1E),
              0 0 16px rgba(201,122,30,0.2);
}
.kb-key.kb-highlight .kb-eng {
  color: var(--c-accent-light, #E8A94B);
}

/* ── KEY LABELS ────────────────────────────────────────────────────────────── */
.kb-tib {
  font-family: 'Jomolhari', 'Noto Serif Tibetan', serif;
  font-size: 17px;
  line-height: 1.1;
  color: var(--c-accent-light, #E8A94B);
  letter-spacing: 0;
}

.kb-sub {
  font-family: 'Jomolhari', 'Noto Serif Tibetan', serif;
  font-size: 13px;
  line-height: 1;
  color: rgba(255,255,255,0.35);
  position: absolute;
  top: 2px;
  right: 3px;
}

.kb-eng {
  font-family: var(--font-mono, 'SF Mono', Consolas, monospace);
  font-size: 11px;
  line-height: 1;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.3px;
  margin-top: 1px;
}

/* ── FUNCTION KEYS ─────────────────────────────────────────────────────────── */
.kb-key.kb-fn {
  max-width: none;
  background: linear-gradient(to bottom, #262320, #1E1B18);
}

.kb-fn-label {
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

/* ── SPACE BAR ─────────────────────────────────────────────────────────────── */
.kb-key.kb-space {
  max-width: none;
  height: 42px;
  flex-direction: row;
  gap: 8px;
}

.kb-key.kb-space .kb-tib {
  font-size: 18px;
}
.kb-key.kb-space .kb-eng {
  font-size: 10px;
  margin-top: 0;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kb-key {
    height: 48px;
    max-width: 52px;
  }
  .kb-tib { font-size: 15px; }
  .kb-eng { font-size: 9px; }
  .kb-sub { font-size: 11px; }
  .kb-body { max-width: 700px; }
}

@media (max-width: 600px) {
  .kb-container { padding: 6px 4px 10px; }
  .kb-key {
    height: 42px;
    max-width: 44px;
    border-radius: 4px;
  }
  .kb-row { gap: 2px; }
  .kb-body { gap: 2px; }
  .kb-tib { font-size: 13px; }
  .kb-eng { font-size: 8px; }
  .kb-sub { font-size: 10px; }
  .kb-key.kb-space { height: 36px; }
}

/* ── Adjust editor layout when keyboard is visible ─────────────────────────── */
body.kb-active #status-bar {
  display: none;
}

body.kb-active #editor-scroll {
  padding-bottom: 32px;
}
