/* ==========================================================================
   LEARN TO TYPE — STYLESHEET (learn-to-type.css)
   Harmonized with "The Anvil" design system, 7 biblical color profiles,
   and printable Scribe Academy drill certificates.
   ========================================================================== */

@import url('anvil.css');

/* ==========================================================================
   TYPING ARENA (CENTERED & 50PX TYPOGRAPHY)
   ========================================================================== */
.typing-arena {
  position: relative;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: 1rem;
  padding: clamp(1rem, 2.5vw, 2rem) clamp(1.25rem, 4vw, 3rem);
  min-height: clamp(12rem, 30vh, 32rem);
  height: clamp(10rem, 32vh, 32rem);
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: text;
  outline: none;
  margin-top: 0.25rem;
  transition: border-color 180ms ease, background-color 220ms ease;
}

.scripture-display {
  position: relative;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 50px;
  line-height: 1.4;
  letter-spacing: 2px; /* Dynamically adjusted via JS: 6px for 1.1-1.3; 2px for rest */
  display: block;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  margin: 0 auto;
}

/* Current letter underline */
.char-glyph.current {
  color: var(--text-chalk);
  text-shadow: 0 0 10px rgba(245, 245, 244, 0.5);
  text-decoration: underline !important;
  text-decoration-thickness: 3px !important;
  text-underline-offset: 7px !important;
  text-decoration-color: var(--ui-accent-strong) !important;
}

[data-theme="parchment-gold"] .char-glyph.current {
  text-shadow: none;
  color: var(--ui-accent-strong);
  text-decoration: underline !important;
  text-decoration-thickness: 3px !important;
  text-underline-offset: 7px !important;
  text-decoration-color: var(--ui-accent-strong) !important;
}

/* Wider spaces for unmistakable word boundaries */
.char-glyph.space-glyph {
  display: inline-block;
  width: 0.55em;
  position: relative;
}

.char-glyph.space-glyph.current {
  text-decoration: underline !important;
  text-decoration-thickness: 3px !important;
  text-underline-offset: 7px !important;
  text-decoration-color: var(--ui-accent-strong) !important;
}

/* ==========================================================================
   CENTERED DRILL NAVIGATION PROMPT (UNDER ARENA & ABOVE KEYBOARD)
   ========================================================================== */
.drill-nav-prompt {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  margin: 0.2rem auto 0;
  width: 100%;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  color: var(--ui-muted);
}

.nav-shortcut-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--ui-muted);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 150ms ease, background-color 150ms ease;
}

.nav-shortcut-btn:hover {
  color: var(--ui-ink);
  background: var(--ui-surface-2);
}

.drill-nav-prompt .nav-divider {
  color: var(--ui-line);
  font-weight: 400;
  user-select: none;
}

/* ==========================================================================
   TEACHER'S LECTERN BANNER
   ========================================================================== */
.teacher-lectern {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: 0.85rem;
  padding: 0.75rem 1.25rem;
  margin-top: 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.lectern-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.teacher-avatar {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  border-radius: 50%;
  color: var(--ui-accent-strong);
  flex-shrink: 0;
}

.teacher-tag {
  font-family: var(--font-ui);
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-accent);
}

.teacher-advice {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ui-ink);
  line-height: 1.35;
  margin-top: 0.1rem;
}

.lectern-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

/* Target Finger Guidance Pill */
.finger-guidance-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  border-left: 1px solid var(--ui-line);
  padding-left: 0.85rem;
}

.finger-sub {
  font-family: var(--font-ui);
  font-size: 0.52rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ui-muted);
}

.finger-main {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ui-ink);
}

/* ==========================================================================
   VIRTUAL KEYBOARD SECTION
   ========================================================================== */
.virtual-keyboard-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.9rem 1rem 1rem;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: 1rem;
  transition: opacity 200ms ease;
}

.virtual-keyboard-section[hidden] {
  display: none !important;
}

.virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  width: 100%;
  max-width: 860px;
}

.kb-row {
  display: flex;
  gap: 0.32rem;
  justify-content: center;
  width: 100%;
}

.kb-key {
  appearance: none;
  border: 1px solid var(--ui-line);
  position: relative;
  flex: 1;
  min-width: 0;
  height: clamp(2.2rem, 3.8vw, 3rem);
  background: var(--ui-surface-2);
  border-radius: 0.45rem;
  color: var(--ui-ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.72rem, 1.1vw, 0.92rem);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ui-line);
  user-select: none;
  transition: all 120ms ease;
}

.kb-key:hover {
  background: var(--ui-surface);
  border-color: var(--ui-accent);
}

/* Tactile bumps on F and J */
.kb-bump-key {
  position: relative;
}

.kb-bump {
  position: absolute;
  bottom: 5px;
  width: 9px;
  height: 2px;
  background: var(--ui-muted);
  border-radius: 1px;
}

/* Modifiers sizing */
.kb-backspace { flex: 1.5; font-size: 0.8rem; }
.kb-tab       { flex: 1.4; font-size: 0.72rem; }
.kb-caps      { flex: 1.6; font-size: 0.72rem; }
.kb-enter     { flex: 1.8; font-size: 0.75rem; }
.kb-shift     { flex: 2.1; font-size: 0.72rem; }
.kb-space     { flex: 6.2; font-size: 0.75rem; }
.kb-mod       { flex: 1.2; font-size: 0.68rem; color: var(--ui-muted); }

/* Finger Color Zones on Keyboard */
.kb-key.f-lp { border-bottom-color: #ef4444; }
.kb-key.f-lr { border-bottom-color: #f97316; }
.kb-key.f-lm { border-bottom-color: #eab308; }
.kb-key.f-li { border-bottom-color: #22c55e; }
.kb-key.f-ri { border-bottom-color: #06b6d4; }
.kb-key.f-rm { border-bottom-color: #3b82f6; }
.kb-key.f-rr { border-bottom-color: #8b5cf6; }
.kb-key.f-rp { border-bottom-color: #ec4899; }
.kb-key.f-thumb { border-bottom-color: var(--ui-accent); }

/* ==========================================================================
   TARGET KEY HIGHLIGHTING (STYLED WITH --text-untyped)
   ========================================================================== */
.kb-key.active-target {
  background: var(--text-untyped) !important;
  border-color: var(--ui-accent-strong) !important;
  color: var(--ui-ink) !important;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.12), 0 2px 0 var(--ui-line) !important;
  transform: translateY(-2px);
  animation: key-target-pulse 1.3s ease-in-out infinite alternate;
}

[data-theme="slate-emerald"] .kb-key.active-target,
[data-theme="sunset-fire"] .kb-key.active-target,
[data-theme="heavenly-blue"] .kb-key.active-target {
  color: var(--ui-surface) !important;
}

@keyframes key-target-pulse {
  0% { box-shadow: 0 0 4px var(--text-untyped); }
  100% { box-shadow: 0 0 12px var(--text-untyped), 0 2px 0 var(--ui-line); }
}

.kb-key.active-shift {
  background: var(--text-untyped) !important;
  border-color: var(--ui-line) !important;
  color: var(--ui-ink) !important;
  opacity: 0.9;
}

[data-theme="slate-emerald"] .kb-key.active-shift,
[data-theme="sunset-fire"] .kb-key.active-shift,
[data-theme="heavenly-blue"] .kb-key.active-shift {
  color: var(--ui-surface) !important;
}

/* Key Pressed Feedback */
.kb-key.pressed {
  transform: translateY(2px) !important;
  box-shadow: 0 0 0 transparent !important;
  background: var(--ui-accent-soft) !important;
}

/* Finger Legend */
.finger-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.2rem;
}

.legend-chip {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ui-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-chip::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-chip.c-lp::before { background: #ef4444; }
.legend-chip.c-lr::before { background: #f97316; }
.legend-chip.c-lm::before { background: #eab308; }
.legend-chip.c-li::before { background: #22c55e; }
.legend-chip.c-thumb::before { background: var(--ui-accent); }
.legend-chip.c-ri::before { background: #06b6d4; }
.legend-chip.c-rm::before { background: #3b82f6; }
.legend-chip.c-rr::before { background: #8b5cf6; }
.legend-chip.c-rp::before { background: #ec4899; }

/* ==========================================================================
   LEVEL SELECTOR POPOVER MODAL
   ========================================================================== */
.level-popover {
  width: min(520px, calc(100vw - 2rem));
  max-height: 80vh;
  overflow-y: auto;
}

.popover-subtitle-text {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--ui-muted);
  margin-bottom: 0.85rem;
}

.level-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.level-tier-group {
  border: 1px solid var(--ui-line);
  border-radius: 0.65rem;
  padding: 0.65rem;
  background: var(--ui-surface-2);
}

.tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ui-ink);
  margin-bottom: 0.45rem;
  padding: 0 0.2rem;
}

.tier-tag {
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--ui-accent-strong);
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.tier-lessons-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.lesson-selector-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  text-align: left;
  cursor: pointer;
  transition: all 140ms ease;
}

.lesson-selector-item:hover {
  border-color: var(--ui-accent);
  background: var(--ui-surface);
  transform: translateX(2px);
}

.lesson-selector-item.active {
  border-color: var(--ui-accent-strong);
  background: var(--ui-accent-soft);
}

.lesson-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ui-accent-strong);
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  padding: 0.25rem 0.45rem;
  border-radius: 0.35rem;
}

.lesson-meta strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ui-ink);
}

.lesson-meta small {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.64rem;
  color: var(--ui-muted);
}

.popover-actions-row {
  display: flex;
  justify-content: flex-end;
}

.regenerate-drill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ui-ink);
  cursor: pointer;
  transition: all 160ms ease;
}

.regenerate-drill-btn:hover {
  background: var(--ui-surface-2);
  border-color: var(--ui-accent);
  color: var(--ui-accent-strong);
}

/* ==========================================================================
   COMPLETION RESULTS MODAL & ACTIONS
   ========================================================================== */
.completion-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.completion-action.secondary {
  appearance: none;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  padding: 0.45rem 1.15rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ui-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 140ms ease;
}

.completion-action.secondary:hover {
  background: var(--ui-surface);
  border-color: var(--ui-accent);
  color: var(--ui-accent-strong);
}

/* ==========================================================================
   ACCURACY BADGE EVALUATION BANNER (IN RESULTS MODAL)
   ========================================================================== */
.modal-shortcut-strip {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1.6rem;
  background: var(--ui-surface-2);
  border-top: 1px solid var(--ui-line);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--ui-muted);
}

.modal-shortcut-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--ui-ink);
}

.modal-shortcut-divider {
  color: var(--ui-line);
}

.badge-evaluation-banner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.15rem 1.6rem;
  border-top: 1px solid var(--ui-line);
  background: var(--ui-surface-2);
}

.badge-icon-box {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  border: 1px solid var(--ui-line);
  background: var(--ui-surface);
}

.badge-rank-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ui-ink);
}

.badge-evaluation-text {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  color: var(--ui-muted);
  line-height: 1.4;
  margin-top: 0.2rem;
}

/* Badge Color Treatments */
.badge-evaluation-banner.badge-gold .badge-icon-box {
  border-color: #ca8a04;
  background: rgba(202, 138, 4, 0.15);
  color: #ca8a04;
}
.badge-evaluation-banner.badge-silver .badge-icon-box {
  border-color: #94a3b8;
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
}
.badge-evaluation-banner.badge-bronze .badge-icon-box {
  border-color: #b45309;
  background: rgba(180, 83, 9, 0.15);
  color: #b45309;
}
.badge-evaluation-banner.badge-diligent .badge-icon-box {
  border-color: var(--ui-line);
  background: var(--ui-surface);
  color: var(--ui-muted);
}

/* ==========================================================================
   RESPONSIVE OPTIMIZATIONS
   ========================================================================== */
@media (max-width: 768px) {
  .teacher-lectern {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .lectern-right {
    width: 100%;
    justify-content: flex-start;
  }
  .finger-guidance-pill {
    padding-left: 0;
    border-left: none;
    align-items: flex-start;
    text-align: left;
  }
  .drill-nav-prompt {
    flex-direction: column;
    gap: 0.35rem;
  }
  .drill-nav-prompt .nav-divider {
    display: none;
  }
  .virtual-keyboard {
    transform: scale(0.96);
    transform-origin: center top;
  }
  .completion-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

/* ==========================================================================
   PRINT STYLESHEET (CLEAN SCRIBE SCORECARD / DRILL CERTIFICATE)
   ========================================================================== */
@media print {
  /* Hide all interactive panels, site headers, navigation, canvas, and backgrounds */
  #siteNavbar,
  #userProfileBarWrapper,
  #particles-canvas,
  .passage-header-strip,
  .visual-control-strip,
  .teacher-lectern,
  .typing-arena,
  .drill-nav-prompt,
  .virtual-keyboard-section,
  .workspace-footer,
  .site-footer,
  .completion-actions,
  .completion-x,
  .modal-shortcut-strip,
  .app-toast,
  .desktop-required-notice,
  .cookie-banner-wrap {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 1.5cm !important;
    font-size: 11pt !important;
  }

  .editorial-main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .completion-panel {
    position: static !important;
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  .completion-card {
    max-width: 100% !important;
    border: 2px solid #000000 !important;
    box-shadow: none !important;
    padding: 2.2rem !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    page-break-inside: avoid !important;
  }

  /* Formal Official Certificate Header */
  .completion-card::before {
    content: "SCRIBE ACADEMY OF THE ANVIL — OFFICIAL DRILL RECORD";
    display: block;
    font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    font-size: 9pt;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-align: center;
    color: #334155;
    border-bottom: 2px solid #000000;
    padding-bottom: 0.8rem;
    margin-bottom: 1.8rem;
  }

  .completion-header h2 {
    color: #000000 !important;
    font-size: 20pt !important;
    margin-bottom: 0.4rem !important;
  }

  .completion-header .eyebrow {
    color: #475569 !important;
    font-size: 9pt !important;
  }

  /* Metric Cards in 4-column layout */
  .completion-metrics {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1rem !important;
    margin: 1.8rem 0 !important;
  }

  .completion-metrics div,
  .completion-detail-card {
    border: 1px solid #94a3b8 !important;
    background: #f8fafc !important;
    color: #000000 !important;
    padding: 0.85rem !important;
    border-radius: 4px !important;
  }

  .completion-metrics div span,
  .completion-detail-card span {
    color: #475569 !important;
    font-size: 8pt !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
  }

  .completion-metrics div strong,
  .completion-detail-card strong {
    color: #000000 !important;
    font-size: 16pt !important;
  }

  .completion-details {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.85rem !important;
    margin-top: 1.2rem !important;
  }

  /* Badge and Commendation */
  .badge-evaluation-banner {
    border: 1px solid #94a3b8 !important;
    background: #f8fafc !important;
    padding: 1.2rem 1.4rem !important;
    border-radius: 6px !important;
    margin-bottom: 1.5rem !important;
  }

  .badge-icon-box {
    border: 1px solid #64748b !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  .badge-rank-title {
    color: #000000 !important;
    font-size: 14pt !important;
  }

  .badge-evaluation-text {
    color: #1e293b !important;
    font-size: 9.5pt !important;
  }
}