/* ═══════════════════════════════════════════
   LEARNING MODE  —  full-viewport overlay
   z-index 320 (above map 0, below sidebar 350)
   ═══════════════════════════════════════════ */

#learning-mode {
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  z-index: 320;
  display: none;
  background: #F5EEE8;
  --lm-accent: #C4826A;          /* overridden per-domain by JS */
  --lm-accent-soft: rgba(196,130,106,0.12);
}
#learning-mode.active { display: flex; }

/* Subtle radial glow behind content, tinted by domain colour */
#learning-mode::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 0%,
    var(--lm-accent-soft) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
#learning-mode > * { position: relative; z-index: 1; }


/* ═══════════════════════════════════════════
   SHARED  —  view toggling
   ═══════════════════════════════════════════ */
.lm-view { display: none; width: 100%; height: 100%; }
.lm-view.active { display: flex; }


/* ═══════════════════════════════════════════
   VIEW 1  —  LEARNING PATH  (#lm-path)
   ═══════════════════════════════════════════ */
#lm-path {
  flex-direction: column;
  overflow: hidden;
}

/* ── path header ── */
.lm-path-header {
  flex-shrink: 0;
  padding: 22px 28px 18px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid rgba(58,48,40,0.08);
}
.lm-back-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: rgba(58,48,40,0.07);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6E6358; flex-shrink: 0; margin-top: 3px;
  transition: background 0.14s;
}
.lm-back-btn:hover { background: rgba(58,48,40,0.13); }

.lm-path-meta { flex: 1; min-width: 0; }
.lm-path-crumb {
  font-size: 12px; color: #3A3028;
  font-weight: 500; letter-spacing: 0.2px; margin-bottom: 5px;
}
.lm-path-title {
  font-size: 20px; font-weight: 720;
  color: #2C2820; line-height: 1.2;
  letter-spacing: -0.3px;
}
.lm-path-subtitle {
  font-size: 12px; color: #9A8E86;
  margin-top: 5px;
}

/* progress bar */
.lm-progress-track {
  height: 5px;
  background: rgba(58,48,40,0.09);
  border-radius: 3px;
  margin: 16px 28px 0;
  overflow: hidden;
}
.lm-progress-fill {
  height: 100%;
  background: var(--lm-accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.lm-progress-label {
  font-size: 13px; color: #3A3028;
  font-weight: 500;
  padding: 8px 28px 14px;
}

/* ── knobit list ── */
.lm-knobit-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 20px 32px;
}
.lm-knobit-list::-webkit-scrollbar { width: 3px; }
.lm-knobit-list::-webkit-scrollbar-thumb { background: rgba(58,48,40,0.14); border-radius: 2px; }

.lm-knobit-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.13s;
  position: relative;
}
.lm-knobit-item:hover { background: rgba(58,48,40,0.05); }
.lm-knobit-item.current {
  background: linear-gradient(135deg,
    rgba(255,255,255,0.85) 0%,
    rgba(248,240,252,0.85) 100%);
  border: 1px solid rgba(58,48,40,0.09);
  box-shadow: 0 2px 10px rgba(58,48,40,0.07);
}
.lm-knobit-item.locked {
  cursor: default;
  opacity: 0.45;
}
.lm-knobit-item.locked:hover { background: transparent; }

/* index circle */
.kn-index {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  background: rgba(58,48,40,0.08);
  color: #6E6358;
  transition: background 0.13s;
}
.lm-knobit-item.current .kn-index {
  background: var(--lm-accent);
  color: #fff;
}
.lm-knobit-item.done .kn-index {
  background: rgba(139,173,126,0.25);
  color: #5E9052;
}
.lm-knobit-item.locked .kn-index {
  background: rgba(58,48,40,0.05);
  color: #B0A496;
}

.kn-info { flex: 1; min-width: 0; }
.kn-name {
  font-size: 14px; font-weight: 550;
  color: #2C2820; line-height: 1.3;
}
.kn-arrow { color: #C4B8B0; flex-shrink: 0; }

/* ── start button (bottom of path view) ── */
.lm-start-bar {
  flex-shrink: 0;
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(58,48,40,0.07);
}
.lm-start-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--lm-accent) 0%, #B06848 100%);
  color: #fff;
  border: none; border-radius: 14px;
  font-size: 15px; font-weight: 650;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  letter-spacing: 0.1px;
  transition: opacity 0.15s, transform 0.1s;
}
.lm-start-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.lm-start-btn:active { transform: translateY(0); }


/* ═══════════════════════════════════════════
   VIEW 2  —  KNOBIT LESSON  (#lm-knobit)
   ═══════════════════════════════════════════ */
#lm-knobit {
  flex-direction: column;
  overflow: hidden;
}

/* ── knobit sub-nav bar ── */
.kn-nav {
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(58,48,40,0.08);
  background: rgba(245,238,232,0.7);
}
.kn-nav-back {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(58,48,40,0.07); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6E6358; flex-shrink: 0;
  transition: background 0.14s;
}
.kn-nav-back:hover { background: rgba(58,48,40,0.13); }

.kn-progress-wrap {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.kn-nav-label {
  font-size: 11px; font-weight: 600;
  color: #7A6E65; letter-spacing: 0.3px;
}
.kn-progress-track {
  height: 4px;
  background: rgba(58,48,40,0.09);
  border-radius: 2px;
  overflow: hidden;
}
.kn-progress-fill {
  height: 100%;
  background: var(--lm-accent);
  border-radius: 2px;
  transition: width 0.35s ease;
}

/* phase chips strip */
.kn-phase-chips {
  display: flex; gap: 5px; flex-shrink: 0;
}
.kn-chip {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  background: rgba(58,48,40,0.07);
  color: #9A8E86;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}
.kn-chip.active {
  background: var(--lm-accent);
  color: #fff;
}
.kn-chip.done-chip {
  background: rgba(139,173,126,0.22);
  color: #508046;
}


/* ═══════════════════════════════════════════
   VIEW 2  —  BLOCK STREAM
   ═══════════════════════════════════════════ */

/* ── stream container ── */
.kn-stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 8px;
  display: flex;
  flex-direction: column;
}
.kn-stream::-webkit-scrollbar { width: 3px; }
.kn-stream::-webkit-scrollbar-thumb { background: rgba(58,48,40,0.14); border-radius: 2px; }

/* ── phase divider ── */
.phase-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 14px;
  flex-shrink: 0;
}
.phase-divider span {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--lm-accent);
  white-space: nowrap;
  opacity: 0.75;
}
.phase-divider::before,
.phase-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--lm-accent);
  opacity: 0.18;
}

/* ── block base ── */
@keyframes blockAppear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.block {
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 10px;
  animation: blockAppear 0.15s ease both;
  flex-shrink: 0;
}

/* ── block types ── */
.block-byte {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(58,48,40,0.08);
  box-shadow: 0 1px 6px rgba(58,48,40,0.04);
}

.block-example {
  background: linear-gradient(135deg, #fff 0%, #F5F0FA 100%);
  border: 1px solid rgba(155,143,181,0.20);
}

.block-practice {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(58,48,40,0.10);
  box-shadow: 0 1px 6px rgba(58,48,40,0.04);
}

.block-feedback {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  margin-top: -4px;        /* tuck slightly under the practice block */
  animation: blockAppear 0.15s ease both;
  flex-shrink: 0;
}
.block-feedback.feedback-correct {
  background: linear-gradient(135deg,
    rgba(139,173,126,0.12) 0%, rgba(139,173,126,0.20) 100%);
  border: 1px solid rgba(139,173,126,0.32);
}
.block-feedback.feedback-incorrect {
  background: linear-gradient(135deg,
    rgba(196,130,106,0.10) 0%, rgba(196,130,106,0.16) 100%);
  border: 1px solid rgba(196,130,106,0.28);
}

.block-meaning {
  background: linear-gradient(135deg,
    rgba(255,255,255,0.88) 0%, rgba(248,244,255,0.88) 100%);
  border: 1px solid rgba(58,48,40,0.08);
  border-left: 3px solid var(--lm-accent);
  padding-left: 15px;
  box-shadow: 0 2px 12px rgba(58,48,40,0.06);
}

.block-user {
  align-self: flex-end;
  background: var(--lm-accent);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 11px 16px;
  max-width: 78%;
  margin-left: auto;
  margin-bottom: 8px;
  font-size: 13px; line-height: 1.5;
  animation: blockAppear 0.15s ease both;
  flex-shrink: 0;
}

.block-note {
  background: rgba(58,48,40,0.04);
  border: 1px dashed rgba(58,48,40,0.15);
  font-size: 13px; color: #6E6358; line-height: 1.6;
}

/* ── block content elements ── */
.block-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.9px;
  text-transform: uppercase;
  margin-bottom: 9px;
}
.block-byte    .block-label { color: #9B8FB5; }
.block-example .block-label { color: #8A7E72; }
.block-practice .block-label { color: var(--lm-accent); }
.block-meaning .block-label { color: var(--lm-accent); }
.block-feedback .block-label { font-size: 11px; margin-bottom: 6px; }
.block-feedback.feedback-correct .block-label { color: #508046; }
.block-feedback.feedback-incorrect .block-label { color: #A0502A; }

.block-body {
  font-size: 14px; color: #3A3028; line-height: 1.72;
}
.block-meaning .block-body { font-size: 14px; line-height: 1.78; }
.block-feedback .block-body { font-size: 13px; line-height: 1.65; color: #3A3028; }
.block-note .block-body { font-size: 13px; }

.block-example-footer {
  font-size: 12px; color: #9A8E86; line-height: 1.6;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(58,48,40,0.07);
  font-style: italic;
}

/* ── choice indicator (appended to block after choice made) ── */
.choice-indicator {
  margin-top: 12px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
  color: #9A8E86;
  background: rgba(58,48,40,0.04);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ── practice input ── */
.practice-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 13px;
  align-items: stretch;
}
.practice-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid rgba(58,48,40,0.14);
  border-radius: 10px;
  font-size: 15px; font-family: inherit; color: #2C2820;
  background: #fff;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.practice-input:focus {
  border-color: var(--lm-accent);
  box-shadow: 0 0 0 3px var(--lm-accent-soft);
}
.practice-input:disabled {
  background: rgba(58,48,40,0.04);
  color: #9A8E86;
}
.practice-submit {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--lm-accent) 0%, #B06848 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 650; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s;
}
.practice-submit:hover { opacity: 0.88; }
.practice-submit:disabled { opacity: 0.35; cursor: default; }

.practice-echo {
  margin-top: 10px;
  padding: 8px 13px;
  background: rgba(58,48,40,0.05);
  border-radius: 8px;
  font-size: 13px; color: #6E6358;
  font-style: italic;
}

/* ── diagram block (for "show me a drawing" response) ── */
.block-diagram {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(58,48,40,0.08);
  text-align: center;
  padding: 18px;
}
.block-diagram svg, .block-diagram pre {
  max-width: 100%;
}
.block-diagram pre {
  font-family: 'Courier New', monospace;
  font-size: 12px; color: #4A4038;
  line-height: 1.6;
  text-align: left;
  display: inline-block;
}


/* ═══════════════════════════════════════════
   VIEW 2  —  ACTION AREA (sticky bottom)
   ═══════════════════════════════════════════ */
.kn-action-area {
  flex-shrink: 0;
  border-top: 1px solid rgba(58,48,40,0.07);
  background: rgba(245,238,232,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* ── button row ── */
.kn-button-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.kn-button-row:empty { display: none; }

/* shared button base */
.btn {
  padding: 10px 16px;
  border-radius: 11px;
  border: 1.5px solid rgba(58,48,40,0.14);
  background: rgba(255,255,255,0.82);
  color: #3A3028;
  font-size: 13px; font-weight: 550; font-family: inherit;
  cursor: pointer; min-height: 44px;
  transition: border-color 0.13s, background 0.13s, color 0.13s, opacity 0.13s;
  line-height: 1.3;
}
.btn:hover {
  border-color: var(--lm-accent);
  background: var(--lm-accent-soft);
}
.btn.btn-primary {
  background: linear-gradient(135deg, var(--lm-accent) 0%, #B06848 100%);
  color: #fff; border-color: transparent;
  font-weight: 650;
}
.btn.btn-primary:hover { opacity: 0.88; background: linear-gradient(135deg, var(--lm-accent) 0%, #B06848 100%); }
.btn.btn-secondary {
  background: rgba(155,143,181,0.15);
  border-color: rgba(155,143,181,0.28);
  color: #6050A0;
}
.btn.btn-secondary:hover {
  background: rgba(155,143,181,0.24);
  border-color: rgba(155,143,181,0.45);
}

/* choice-locked: applied to .kn-button-row when locked */
.kn-button-row.choice-locked {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.1s;
}

/* ── ask bar ── */
.ask-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ask-input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid rgba(58,48,40,0.12);
  border-radius: 10px;
  font-size: 13px; font-family: inherit; color: #2C2820;
  background: rgba(255,255,255,0.80);
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.ask-input:focus {
  border-color: var(--lm-accent);
  box-shadow: 0 0 0 3px var(--lm-accent-soft);
}
.ask-input::placeholder { color: #B0A496; }
.ask-send {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 9px;
  background: rgba(58,48,40,0.07);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6E6358;
  transition: background 0.13s, color 0.13s;
}
.ask-send:hover {
  background: var(--lm-accent);
  color: #fff;
}


/* ═══════════════════════════════════════════
   VIEW 3  —  UNIT COMPLETE  (#lm-complete)
   ═══════════════════════════════════════════ */
#lm-complete {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  text-align: center;
  overflow-y: auto;
}

.lm-complete-badge {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg,
    rgba(196,130,106,0.18) 0%,
    rgba(139,173,126,0.22) 100%);
  border: 2.5px solid rgba(196,130,106,0.30);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
  animation: badge-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes badge-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.lm-complete-title {
  font-size: 26px; font-weight: 720;
  color: #2C2820; letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.lm-complete-sub {
  font-size: 14px; color: #9A8E86;
  line-height: 1.6; max-width: 320px;
  margin: 0 auto 32px;
}

.lm-complete-stats {
  display: flex; gap: 14px;
  margin-bottom: 32px;
}
.lm-complete-stat {
  background: linear-gradient(135deg, #fff 0%, #F8F0F5 100%);
  border: 1px solid rgba(58,48,40,0.08);
  border-radius: 16px;
  padding: 18px 22px;
  min-width: 90px;
  text-align: center;
}
.lm-cstat-num {
  font-size: 28px; font-weight: 720;
  color: #2C2820; letter-spacing: -0.6px;
}
.lm-cstat-label {
  font-size: 11px; color: #B0A496;
  margin-top: 4px; line-height: 1.3;
}

.lm-complete-actions {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 320px;
}
.lm-complete-btn-primary {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--lm-accent) 0%, #B06848 100%);
  color: #fff; border: none; border-radius: 14px;
  font-size: 15px; font-weight: 650; font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.lm-complete-btn-primary:hover { opacity: 0.91; transform: translateY(-1px); }

.lm-complete-btn-ghost {
  width: 100%; padding: 13px;
  background: transparent; color: #6E6358;
  border: 1.5px solid rgba(58,48,40,0.14);
  border-radius: 14px;
  font-size: 14px; font-weight: 550; font-family: inherit;
  cursor: pointer;
  transition: background 0.14s;
}
.lm-complete-btn-ghost:hover { background: rgba(58,48,40,0.05); }
