/* ==========================================================================
   MG Coptic Virtual Keyboard (Gboard Style - Exact Screenshot Layout)
   ========================================================================== */

@font-face {
  font-family: 'girges';
  src: url('../girges.woff') format('woff'),
       url('./girges.woff') format('woff'),
       url('/girges.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Coptic Girges';
  src: url('../girges.woff') format('woff'),
       url('./girges.woff') format('woff'),
       url('/girges.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Keyboard Container */
.coptic-keyboard-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100vw;
  background: #1b1c20;
  background: linear-gradient(180deg, #22242a 0%, #1a1b1f 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.65), 0 -1px 2px rgba(0, 0, 0, 0.5);
  z-index: 9999999;
  transform: translateY(110%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  direction: ltr !important;
  box-sizing: border-box;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 6px)) 4px;
  font-family: 'girges', 'Coptic Girges', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.coptic-keyboard-container.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header Bar */
.coptic-kb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 5px;
}

.coptic-kb-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.4px;
}

.coptic-kb-brand-icon {
  font-family: 'girges', 'Coptic Girges', sans-serif;
  font-size: 1.15rem;
  color: #5ea8ff;
  line-height: 1;
}

.coptic-kb-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.coptic-kb-action-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.coptic-kb-action-btn:hover,
.coptic-kb-action-btn:active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Keyboard Main Layout */
.coptic-kb-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* Keyboard Row */
.coptic-kb-row {
  display: flex;
  width: 100%;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

/* Keyboard Key Base */
.coptic-kb-key {
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  background: #2d3036;
  border: none;
  outline: none;
  border-radius: 7px;
  color: #e5e7eb;
  font-size: 1.32rem;
  font-family: 'girges', 'Coptic Girges', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  box-shadow: 0 1.5px 2.5px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, background 0.1s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
  padding: 0;
  margin: 0;
  line-height: 1;
}

.coptic-kb-key:hover {
  background: #383c44;
}

.coptic-kb-key:active,
.coptic-kb-key.pressed {
  background: #464c57 !important;
  transform: scale(0.93);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.6) !important;
}

/* Small Hint Number (e.g. 1 2 3 ... 0 on top row) */
.coptic-kb-key .key-hint {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.64rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: rgba(255, 255, 255, 0.42);
  font-weight: 600;
  pointer-events: none;
  line-height: 1;
}

/* Diacritic key styling (Jenkim) */
.coptic-kb-key.key-diacritic {
  font-size: 1.35rem;
  color: #f6e05e;
}

/* Special Function Keys (Shift, Backspace, ?123, Hide) */
.coptic-kb-key.key-special {
  background: #363a42;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}

.coptic-kb-key.key-special:hover {
  background: #40454f;
}

.coptic-kb-key.key-special:active,
.coptic-kb-key.key-special.pressed {
  background: #4d5360 !important;
}

/* Shift Key & Capital Active Indicator */
.coptic-kb-key.key-shift {
  flex: 1.4;
  font-size: 1.25rem;
}

.coptic-kb-key.key-shift.shift-active {
  background: #e5e7eb !important;
  color: #1a1b1f !important;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.coptic-kb-key.key-shift.shift-active svg path {
  fill: #1a1b1f;
  stroke: #1a1b1f;
}

/* Backspace Key */
.coptic-kb-key.key-backspace {
  flex: 1.4;
  font-size: 1.25rem;
}

/* Mode (?123 / ABC) */
.coptic-kb-key.key-mode {
  flex: 1.35;
  font-size: 0.88rem;
  font-weight: 700;
}

/* Space Key */
.coptic-kb-key.key-space {
  flex: 4.8;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.5px;
}

/* Hide Button (⌄) */
.coptic-kb-key.key-hide {
  flex: 1.25;
  font-size: 1.25rem;
  color: #cbd5e1;
}

/* Key Popup Preview (Like Gboard Magnify) */
.coptic-kb-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  width: 52px;
  height: 58px;
  background: #2d3036;
  border-radius: 9px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'girges', 'Coptic Girges', sans-serif;
  font-size: 2.1rem;
  color: #ffffff;
  pointer-events: none;
  z-index: 10;
  animation: copticKbPopIn 0.08s ease-out;
}

.coptic-kb-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #2d3036 transparent transparent transparent;
}

@keyframes copticKbPopIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px) scale(1);
  }
}

/* Responsive Sizing */
@media (min-width: 768px) {
  .coptic-keyboard-container {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 6px)) 12px;
  }
  .coptic-kb-row {
    gap: 5px;
  }
  .coptic-kb-key {
    height: 48px;
    font-size: 1.45rem;
    border-radius: 8px;
  }
  .coptic-kb-key .key-hint {
    font-size: 0.72rem;
  }
}

@media (max-width: 480px) {
  .coptic-keyboard-container {
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 6px)) 2px;
  }
  .coptic-kb-row {
    gap: 3px;
  }
  .coptic-kb-key {
    height: 44px;
    font-size: 1.25rem;
    border-radius: 6px;
  }
  .coptic-kb-key.key-diacritic {
    font-size: 1.18rem;
  }
  .coptic-kb-key.key-space {
    font-size: 0.82rem;
  }
  .coptic-kb-key .key-hint {
    font-size: 0.58rem;
    top: 1px;
    right: 2px;
  }
}

/* Highlight styling for active coptic inputs */
.coptic-input:focus,
input.coptic:focus,
textarea.coptic:focus {
  outline: 2px solid #5ea8ff !important;
  box-shadow: 0 0 0 4px rgba(94, 168, 255, 0.22) !important;
}

/* ==========================================================================
   Fill in the Blank Challenge Styles
   ========================================================================== */
.fill-blank-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 540px;
  margin: 10px auto 20px auto;
}

.fill-blank-input-wrapper {
  width: 100%;
  position: relative;
  display: flex;
  justify-content: center;
}

.coptic-input,
.fill-blank-input,
.listen-write-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 2.5px dashed #C5A059;
  background: #FAF7EE;
  font-family: 'girges', 'Coptic Girges', sans-serif !important;
  font-size: 1.7rem;
  font-weight: 800;
  color: #6B1530;
  text-align: center;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  outline: none;
  box-shadow: 0 4px 15px rgba(36, 27, 18, 0.06);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-sizing: border-box;
}

.fill-blank-input:focus,
.listen-write-input:focus {
  border-style: solid;
  border-color: #5ea8ff !important;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(94, 168, 255, 0.22), 0 8px 24px rgba(94, 168, 255, 0.12) !important;
}

.fill-blank-input.correct,
.listen-write-input.correct {
  border-style: solid;
  border-color: #2E6B3E !important;
  background: #EDF7F0 !important;
  color: #2E6B3E !important;
  box-shadow: 0 0 0 4px rgba(46, 107, 62, 0.2) !important;
}

.fill-blank-input.wrong,
.listen-write-input.wrong {
  border-style: solid;
  border-color: #B02A37 !important;
  background: #FDF0ED !important;
  color: #B02A37 !important;
  box-shadow: 0 0 0 4px rgba(176, 42, 55, 0.2) !important;
}

.fill-blank-options-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #6E6254;
  text-align: center;
  margin-top: 4px;
}

.fill-blank-chips-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}

.fill-blank-chip {
  background: #FAF7EE;
  border: 2px solid rgba(168, 130, 58, 0.35);
  border-radius: 12px;
  padding: 10px 18px;
  font-family: 'girges', 'Coptic Girges', sans-serif !important;
  font-size: 1.25rem;
  font-weight: 800;
  color: #2E2018;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(168, 130, 58, 0.25);
  transition: all 0.15s ease;
  user-select: none;
  touch-action: manipulation;
}

.fill-blank-chip:hover {
  transform: translateY(-2px);
  border-color: #6B1530;
  background: #FFFFFF;
}

.fill-blank-chip.selected {
  border-color: #6B1530;
  background: #6B1530;
  color: #FFFFFF;
  box-shadow: 0 3px 0 #4A0E21;
}
