/* Режим обучения: боковая панель справа (js/learn/LearningMode.js). Ниже модалок (z-index 1000). */
.learn-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100vh;
    background: var(--nm-background, #e6e9ef);
    box-shadow: -6px 0 20px rgba(0, 0, 0, 0.12);
    z-index: 950;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    color: var(--nm-text-primary, #2a2a2a);
}

.learn-panel.open {
    transform: translateX(0);
}

/* Значок «i» карты (z-index 1000) иначе перекрывает панель */
body.learn-panel-open .map-info-icon {
    visibility: hidden;
}

.learn-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 12px 8px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.learn-panel-tabs {
    display: flex;
    gap: 6px;
}

.learn-tab {
    border: none;
    background: transparent;
    border-radius: var(--nm-radius-full, 9999px);
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    color: var(--nm-text-secondary, #666);
}

.learn-tab.active {
    background: var(--nm-background, #e6e9ef);
    box-shadow: var(--nm-shadow-inset);
    color: var(--nm-primary, #5b78f6);
}

.learn-tab:disabled {
    opacity: 0.4;
    cursor: default;
}

.learn-panel-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--nm-text-secondary, #666);
    padding: 4px 8px;
}

.learn-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 24px;
    font-size: 14px;
    line-height: 1.55;
}

.learn-title {
    margin: 4px 0 12px;
    font-size: 17px;
}

.learn-content h4 {
    margin: 16px 0 6px;
    font-size: 15px;
    color: var(--nm-primary, #5b78f6);
}

.learn-content p {
    margin: 0 0 8px;
}

.learn-content ul,
.learn-content ol {
    margin: 0 0 8px;
    padding-left: 20px;
}

.learn-loading,
.learn-hint {
    color: var(--nm-text-secondary, #666);
}

.learn-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid var(--nm-primary, #5b78f6);
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: middle;
    animation: learn-spin 0.8s linear infinite;
}

@keyframes learn-spin {
    to { transform: rotate(360deg); }
}

.learn-error {
    color: #c0392b;
    margin-bottom: 12px;
}

.learn-primary,
.learn-secondary {
    border: none;
    border-radius: var(--nm-radius-medium, 12px);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
}

.learn-primary {
    background: var(--nm-gradient-primary, #5b78f6);
    color: #fff;
}

.learn-primary:disabled {
    opacity: 0.5;
    cursor: default;
}

.learn-secondary {
    background: var(--nm-background, #e6e9ef);
    box-shadow: var(--nm-shadow-small);
    color: var(--nm-text-secondary, #666);
    margin-top: 12px;
}

.learn-progress {
    height: 8px;
    border-radius: var(--nm-radius-full, 9999px);
    box-shadow: var(--nm-shadow-inset);
    overflow: hidden;
}

.learn-progress-bar {
    height: 100%;
    background: var(--nm-gradient-primary, #5b78f6);
    transition: width 0.3s ease;
}

.learn-progress-label {
    font-size: 12px;
    color: var(--nm-text-secondary, #666);
    margin: 4px 0 12px;
}

.learn-route {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: learn-step;
}

.learn-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    counter-increment: learn-step;
}

.learn-step-body {
    flex: 1;
}

.learn-step-text::before {
    content: counter(learn-step) '. ';
    color: var(--nm-text-secondary, #666);
}

.learn-step-why {
    font-size: 12px;
    color: var(--nm-text-secondary, #666);
}

.learn-step.status-known .learn-step-text {
    color: var(--nm-text-secondary, #666);
    text-decoration: line-through;
}

.learn-status,
.learn-step-explain {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.4;
    padding: 0 2px;
}

.learn-step.status-learning .learn-status {
    color: var(--nm-accent, #ffa62e);
}

.learn-step.status-known .learn-status {
    color: #27ae60;
}

.learn-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--nm-text-secondary, #666);
}

/* Мигающий курсор, пока объяснение печатается */
.learn-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--nm-primary, #5b78f6);
    animation: learn-blink 1s steps(2, start) infinite;
}

@keyframes learn-blink {
    to { visibility: hidden; }
}

/* Отметка статуса в маршруте — заметный «чекбокс» */
.learn-step .learn-status {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border: 2px solid #b5bccb;
    border-radius: 50%;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    padding: 0;
    transition: transform 0.1s ease, border-color 0.2s ease;
}

.learn-step .learn-status:hover {
    border-color: var(--nm-primary, #5b78f6);
    transform: scale(1.1);
}

.learn-step.status-learning .learn-status {
    border-color: var(--nm-accent, #ffa62e);
    color: var(--nm-accent, #ffa62e);
}

.learn-step.status-known .learn-status {
    border-color: #27ae60;
    background: #27ae60;
    color: #fff;
}

.learn-step-text.clickable {
    cursor: pointer;
}

.learn-step-text.clickable:hover {
    color: var(--nm-primary, #5b78f6);
}

.learn-route-hint {
    font-size: 12px;
    margin: 0 0 8px;
}

.learn-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.learn-actions .learn-secondary {
    margin-top: 0;
}

.learn-mark {
    border: none;
    border-radius: var(--nm-radius-medium, 12px);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    background: #27ae60;
    color: #fff;
}

.learn-mark.done {
    background: var(--nm-background, #e6e9ef);
    box-shadow: var(--nm-shadow-small);
    color: #27ae60;
}

/* Иконка «объяснение» на карточке узла (js/learn/LearningMode.js decorateNodesWithLearnIcons) */
.learn-node-icon {
    position: absolute;
    z-index: 2; /* выше зоны-триггера меню (div::before, z-index 1) */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #8a94a6;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

/* «Прямоугольники»: круглый значок на нижней рамке карточки, левее угла и кружка сворачивания */
.learn-node-icon.in-card {
    right: 14px;
    bottom: -14px;
    background: #fff;
    border: 1px solid #d5d9e2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    opacity: 0.85;
}

.learn-node-icon.in-card:hover {
    background: #eef1fe;
    border-color: var(--nm-primary, #5b78f6);
}

/* Простой стиль: карточки нет, справа — кружок сворачивания и открывается меню узла,
   поэтому иконка слева перед текстом и только при наведении на узел */
.learn-node-icon.beside-text {
    left: -22px;
    top: -2px;
    opacity: 0;
    pointer-events: none;
}

.markmap-node:hover .learn-node-icon.beside-text {
    pointer-events: auto;
}

.markmap-node:hover .learn-node-icon,
.learn-node-icon:focus-visible {
    opacity: 0.9;
}

.learn-node-icon:hover {
    opacity: 1;
    color: var(--nm-primary, #5b78f6);
    background: rgba(91, 120, 246, 0.12);
}

.learn-node-icon.known {
    color: #27ae60;
}

.learn-node-icon.in-card.known {
    opacity: 1;
    border-color: #27ae60;
}

/* Узел с сохранённым объяснением */
.learn-node-icon.has-explanation {
    color: var(--nm-primary, #5b78f6);
    opacity: 0.95;
}

.learn-node-icon.in-card.has-explanation {
    border-color: var(--nm-primary, #5b78f6);
}

/* Ширина панели мышью и экспорт (js/learn/LearningMode.js setupResize / exportMarkdown) */
.learn-panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.learn-export {
    border: none;
    background: transparent;
    border-radius: var(--nm-radius-full, 9999px);
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    color: var(--nm-primary, #5b78f6);
}

.learn-export:hover:not(:disabled) {
    box-shadow: var(--nm-shadow-small);
}

.learn-export:disabled {
    color: var(--nm-text-secondary, #666);
    opacity: 0.4;
    cursor: default;
}

.learn-resize-handle {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    z-index: 1;
    touch-action: none;
}

.learn-resize-handle::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    width: 2px;
    height: 40px;
    margin-top: -20px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.learn-resize-handle:hover::after,
.learn-panel.resizing .learn-resize-handle::after {
    opacity: 1;
}

.learn-panel.resizing {
    transition: none;
    user-select: none;
}

@media (max-width: 600px) {
    .learn-panel {
        width: 100vw !important;
    }

    .learn-resize-handle {
        display: none;
    }
}
