/* ============================================================
   learn-panel.css — Learn Mode Sidebar UI
   ============================================================ */

.learn-panel {
  position: fixed;
  top: 0;
  left: 0; /* RTL handles this natively if we use logical props, but we force LTR/RTL via transform */
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  display: flex;
  visibility: hidden;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.3s;
  overflow: hidden;
}

[dir="rtl"] .learn-panel {
  left: auto;
  right: 0;
  transform: translateX(100%);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.learn-panel.is-open {
  visibility: visible;
  transition-delay: 0s;
  transform: translateX(0);
}

.learn-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--accent);
  color: var(--on-accent);
}

.learn-panel__header-title {
  font-weight: 600;
  font-size: 1.1rem;
  flex-grow: 1;
  text-align: center;
}

.learn-panel__close, .learn-panel__back {
  background: none;
  border: none;
  color: var(--on-accent);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.learn-panel__close:hover, .learn-panel__back:hover {
  opacity: 1;
}

.learn-panel__body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* Modules View */
.learn-panel__modules {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.learn-module-card {
  display: flex;
  align-items: center;
  text-align: start;
  gap: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-soft);
  padding: 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.learn-module-card:hover {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.learn-module-card.is-done {
  background: var(--accent-tint);
  border-color: var(--accent);
}

.learn-module-card__status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface);
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--accent);
}

.learn-module-card__body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.learn-module-card__title {
  font-weight: 600;
  color: var(--text);
}

.learn-module-card__meta {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* Steps View */
.learn-panel__step-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.learn-panel__step-title {
  font-size: 1.25rem;
  color: var(--accent-strong);
  margin-block-end: 16px;
}

.learn-panel__step-content {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  flex-grow: 1;
}

.learn-panel__step-content b {
  color: var(--accent-strong);
}

/* Progress & Navigation */
.learn-panel__progress {
  margin-block: 24px 16px;
}

.learn-panel__progress-track {
  height: 6px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-block-end: 8px;
}

.learn-panel__progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.learn-panel__step-counter {
  font-size: 0.85rem;
  color: var(--text-soft);
  display: block;
  text-align: center;
}

.learn-panel__nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.learn-panel__nav button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.learn-panel__prev {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text);
}

.learn-panel__prev:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.learn-panel__next {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--on-accent);
}

.learn-panel__next:disabled {
  background: var(--border);
  border-color: var(--border);
  cursor: not-allowed;
}

/* Checkpoint Quiz */
.learn-checkpoint {
  background: var(--surface-sunken);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
}

.learn-checkpoint__icon {
  font-size: 2rem;
  margin-block-end: 12px;
}

.learn-checkpoint__question {
  font-weight: 600;
  margin-block-end: 20px;
  color: var(--text);
}

.learn-checkpoint__options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.learn-checkpoint__option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  text-align: start;
}

.learn-checkpoint__option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.learn-checkpoint__letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--surface-sunken);
  font-weight: bold;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.learn-checkpoint__option.is-correct {
  background: #ecfdf5;
  border-color: #10b981;
}

.learn-checkpoint__option.is-correct .learn-checkpoint__letter {
  background: #10b981;
  color: white;
}

.learn-checkpoint__option.is-wrong {
  background: #fef2f2;
  border-color: #ef4444;
}

.learn-checkpoint__feedback {
  margin-block: 20px 10px;
  font-weight: bold;
}
.learn-checkpoint__feedback.is-correct { color: #10b981; }
.learn-checkpoint__feedback.is-wrong { color: #ef4444; }

.learn-checkpoint__continue, .learn-panel__finish-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-block-start: 12px;
}

/* Welcome Overlay */
.learn-welcome {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}

.learn-welcome.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.learn-welcome__card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
}

.learn-welcome__title { font-size: 1.5rem; color: var(--accent-strong); margin-block-end: 8px; }
.learn-welcome__text { color: var(--text-soft); margin-block-end: 24px; }
.learn-welcome__options { display: flex; flex-direction: column; gap: 12px; }

.learn-welcome__btn {
  display: flex;
  align-items: center;
  text-align: start;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
}

.learn-welcome__btn:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.learn-welcome__btn-icon { font-size: 1.5rem; }
.learn-welcome__btn-label { display: block; font-weight: bold; color: var(--text); }
.learn-welcome__btn-hint { display: block; font-size: 0.8rem; color: var(--text-soft); }

.learn-welcome__skip {
  margin-block-start: 24px;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
}
.learn-welcome__skip:hover { color: var(--text); }

/* Global App state when learn mode is active (pushes content on desktop) */
@media (min-width: 1024px) {
  body:has(.learn-panel.is-open) .app {
    margin-inline-start: 360px;
    transition: margin-inline-start 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}
