/* ===========================================
   Expert Checklist DV — frontend styles v2.2.0
   Все цвета вынесены в CSS-переменные.
   Значения по умолчанию = Default Blue.
   Пресеты переопределяют их через assets/presets/ec-preset-{slug}.css
   =========================================== */

/* ---------- Переменные по умолчанию (фолбэк, если пресет не подключён) ---------- */
:root {
    --ec-primary:         #2563eb;
    --ec-accent:          #7c3aed;
    --ec-warning:         #f59e0b;
    --ec-bg:              #ffffff;
    --ec-bg-card:         #ffffff;
    --ec-bg-header:       #f8fafc;
    --ec-bg-progress:     #f5f7fa;
    --ec-border:          #e2e8f0;
    --ec-text-base:       #1a1a2e;
    --ec-text-muted:      #64748b;
    --ec-text-checked:    #94a3b8;
    --ec-item-hover:      #f8fafc;
    --ec-progress-track:  #dde3ed;
    --ec-warning-bg:      #fff8e1;
    --ec-warning-text:    #78350f;
    --ec-complete-bg:     #f0fdf4;
    --ec-complete-border: #bbf7d0;
    --ec-complete-text:   #15803d;
    --ec-time-bg:         #e0e7ff;
    --ec-time-text:       #3730a3;
    --ec-card-radius:     12px;
    --ec-checkbox-radius: 4px;
    --ec-shadow:          0 1px 4px rgba(0,0,0,.05);
    --ec-shadow-hover:    0 4px 16px rgba(0,0,0,.09);
}

/* ---------- Wrapper ---------- */
.ec-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 760px;
    margin: 2em auto;
    color: var(--ec-text-base);
    background: var(--ec-bg);
    border-radius: var(--ec-card-radius);
}

.ec-main-title {
    font-size: 1.4em !important;
    font-weight: 700 !important;
    margin-top: 0 !important;
    margin-bottom: 1em !important;
    padding: 20px 4px 0 !important;
    line-height: 1.3 !important;
    color: var(--ec-text-base) !important;
    border: none !important;
}

/* ---------- Прогресс ---------- */
.ec-progress-container {
    background: var(--ec-bg-progress);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
    border: 1px solid var(--ec-border);
}
.ec-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875em;
    color: var(--ec-text-muted);
    margin-bottom: 8px;
}
.ec-progress-percent {
    font-weight: 700;
    font-size: 1em;
    color: var(--ec-primary);
}
.ec-progress-bar-bg {
    height: 8px;
    background: var(--ec-progress-track);
    border-radius: 999px;
    overflow: hidden;
}
.ec-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--ec-primary), var(--ec-accent));
    border-radius: 999px;
    transition: width 0.4s ease;
}
.ec-progress-bar-fill.ec-done {
    background: linear-gradient(90deg, #16a34a, #22c55e);
}

/* ---------- Предупреждение ---------- */
.ec-warning {
    background: var(--ec-warning-bg);
    border-left: 4px solid var(--ec-warning);
    border-radius: 0 6px 6px 0;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--ec-warning-text);
}
.ec-warn-label { font-weight: 700; }

/* ---------- Карточки ---------- */
.ec-cards { display: flex; flex-direction: column; gap: 12px; }

.ec-card {
    background: var(--ec-bg-card);
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-card-radius);
    /* v2.7.1: overflow visible — нужно чтобы hint-popup не обрезался */
    box-shadow: var(--ec-shadow);
    transition: box-shadow 0.2s, opacity 0.35s;
}
/* Скруглять углы у первого/последнего элементов списка вместо overflow:hidden */
.ec-card .ec-list .ec-item:last-child {
    border-bottom: none;
}
.ec-card:hover { box-shadow: var(--ec-shadow-hover); }

/* Пошаговый режим: заблокированная карточка */
.ec-card.ec-card-locked {
    opacity: 0.38;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    filter: grayscale(0.4);
}
.ec-card.ec-card-locked .ec-card-header {
    background: var(--ec-bg-header);
    filter: grayscale(1);
}
.ec-card.ec-card-locked .ec-card-title::after {
    content: "🔒";
    font-size: 0.85em;
    margin-left: 4px;
    opacity: 0.55;
}

.ec-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--ec-bg-header);
    border-bottom: 1px solid var(--ec-border);
}
.ec-card-title { display: flex; align-items: center; gap: 10px; }
.ec-icon { font-size: 1.4em; line-height: 1; flex-shrink: 0; }
.ec-head-text { font-weight: 700; font-size: 1em; color: var(--ec-text-base); }
.ec-time {
    background: var(--ec-time-bg);
    color: var(--ec-time-text);
    font-size: 0.78em;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ---------- Список ---------- */
.ec-list { list-style: none; margin: 0; padding: 8px 0; }

.ec-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 18px;
    font-size: 0.9em;
    line-height: 1.45;
    cursor: pointer;
    border-bottom: 1px solid var(--ec-border);
    transition: background 0.12s;
    user-select: none;
    -webkit-user-select: none;
    color: var(--ec-text-base);
}
.ec-item:last-child { border-bottom: none; }
.ec-item:hover { background: var(--ec-item-hover); }

/* Кастомный чекбокс */
.ec-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    border: 2px solid var(--ec-border);
    border-radius: var(--ec-checkbox-radius);
    background: var(--ec-bg-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    pointer-events: none;
}

/* Отмеченный пункт */
.ec-item.ec-checked .ec-item-text {
    color: var(--ec-text-checked);
    text-decoration: line-through;
}
.ec-item.ec-checked .ec-checkbox {
    background: var(--ec-primary);
    border-color: var(--ec-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1' stroke='%23fff' stroke-width='2.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 11px 9px;
}

/* Карточка 100% выполнена */
.ec-card.ec-card-complete .ec-card-header {
    background: var(--ec-complete-bg);
    border-bottom-color: var(--ec-complete-border);
}
.ec-card.ec-card-complete .ec-head-text { color: var(--ec-complete-text); }

/* ---------- Кнопка сброса ---------- */
.ec-reset-btn {
    display: block;
    margin: 16px auto 0;
    background: var(--ec-bg-card);
    border: 1px solid var(--ec-border);
    border-radius: 8px;
    padding: 8px 22px;
    font-size: 0.85em;
    color: var(--ec-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.ec-reset-btn:hover {
    background: var(--ec-bg-header);
    border-color: var(--ec-text-muted);
    color: var(--ec-text-base);
}

/* Отступ-фон после кнопки сброса */
.ec-reset-wrap {
    padding-bottom: 20px;
    background: var(--ec-bg);
}

@media (max-width: 600px) {
    .ec-card-header { flex-wrap: wrap; gap: 8px; }
    .ec-main-title  { font-size: 1.15em; }
}

/* ---------- Общее время (v1.3) ---------- */
.ec-total-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ec-time-bg);
    border: 1px solid var(--ec-border);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.85em;
    color: var(--ec-time-text);
    margin-bottom: 14px;
    font-weight: 500;
}
.ec-total-time strong { color: var(--ec-primary); }

/* ---------- v1.5: Reveal-in-place ---------- */
.ec-card.ec-card-hidden { display: none; }

@keyframes ec-card-reveal {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ec-card.ec-card-reveal-animate {
    animation: ec-card-reveal 0.35s ease forwards;
}

/* ---------- v1.7: Блок завершения ---------- */
.ec-complete-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ec-complete-bg);
    border: 1px solid var(--ec-complete-border);
    border-radius: 10px;
    padding: 14px 20px;
    margin-top: 16px;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--ec-complete-text);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.ec-complete-banner--visible { opacity: 1; transform: translateY(0); }
.ec-complete-icon { font-size: 1.3em; flex-shrink: 0; }

/* ---------- v1.7: a11y focus ---------- */
.ec-item:focus {
    outline: 2px solid var(--ec-primary);
    outline-offset: -2px;
    border-radius: 4px;
    background: var(--ec-item-hover);
}

/* ---------- v1.9: CTA-блок ---------- */
:root {
    --ec-cta-bg:        #1e40af;
    --ec-cta-text:      #ffffff;
    --ec-cta-btn-bg:    #facc15;
    --ec-cta-btn-color: #1e293b;
}

.ec-cta-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--ec-cta-bg, #1e40af);
    color: var(--ec-cta-text, #ffffff);
    border-radius: var(--ec-card-radius);
    padding: 20px 24px;
    margin-top: 16px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.ec-cta-block--visible { opacity: 1; transform: translateY(0); }
.ec-cta-text {
    margin: 0;
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.5;
    flex: 1;
    min-width: 0;
}
.ec-cta-btn {
    display: inline-block;
    background: var(--ec-cta-btn-bg, #facc15);
    color: var(--ec-cta-btn-color, #1e293b);
    border-radius: 8px;
    padding: 10px 22px;
    font-weight: 700;
    font-size: 0.9em;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}
.ec-cta-btn:hover { opacity: 0.88; transform: translateY(-1px); }

@media (max-width: 600px) {
    .ec-cta-block { flex-direction: column; align-items: stretch; text-align: center; }
    .ec-cta-btn   { text-align: center; }
}

/* ══════════════════════════════════════════════
   v2.5.0 — Lazy / Async chunk render
   ══════════════════════════════════════════════ */

/* Плейсхолдер пока карточки грузятся */
.ec-lazy-placeholder {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .6;
}

/* Спиннер */
.ec-lazy-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--ec-primary, #2563eb);
    border-top-color: transparent;
    border-radius: 50%;
    animation: ec-spin .7s linear infinite;
}

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

/* ══════════════════════════════════════════════
   v2.5.3 — prefers-reduced-motion (доступность)
   Люди с вестибулярными нарушениями могут
   отключить анимации на уровне ОС — уважаем это.
   ══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    /* Карточки: убираем slide-in при lazy-render */
    .ec-card {
        transition: none !important;
    }
    /* Прогресс-бар: мгновенное изменение ширины */
    .ec-progress-bar-fill {
        transition: none !important;
    }
    /* Баннер завершения и CTA: появляются мгновенно */
    .ec-complete-banner,
    .ec-cta-block {
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .ec-complete-banner--visible,
    .ec-cta-block--visible {
        opacity: 1 !important;
        transform: none !important;
    }
    /* Reveal-in-place анимация */
    .ec-card.ec-card-reveal-animate {
        animation: none !important;
    }
    /* Lazy-render спиннер */
    .ec-lazy-spinner {
        animation: none !important;
        border-top-color: var(--ec-primary, #2563eb) !important;
        opacity: 0.5;
    }
    /* Hover-эффекты — оставляем, они не вестибулярные */
}


/* ── v2.7.0: Подсказки к пунктам ── */

/* Пункт с подсказкой: небольшой правый padding под кнопку */
.ec-item--has-hint {
    /* v2.7.1: убрали position:relative + padding-right.
       Кнопка теперь inline, не absolute — не перекрывает область клика li */
    gap: 8px;
}

/* Кнопка-иконка «?» — inline, не absolute */
.ec-hint-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--ec-text-muted);
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    margin-left: auto; /* прижать к правому краю flex-контейнера */
}
.ec-hint-btn:hover,
.ec-hint-btn:focus-visible {
    color: var(--ec-primary);
    background: var(--ec-item-hover);
    outline: none;
}
/* Не перехватываем клики для checkbox */
/* v2.7.1: pointer-events auto is default for inline button */

/* Popup-подсказка */
.ec-hint-popup {
    display: none;
    position: fixed; /* v2.7.1: fixed вместо absolute — не обрезается overflow:hidden */
    z-index: 9999;
    background: var(--ec-text-base);
    color: var(--ec-bg);
    font-size: 0.8em;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 280px;
    min-width: 140px;
    width: max-content;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    pointer-events: none;
    word-break: break-word;
}

/* Стрелка вверх на popup (v2.7.1: всегда сверху — popup fixed под кнопкой) */
.ec-hint-popup::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 14px;
    border: 5px solid transparent;
    border-bottom-color: var(--ec-text-base);
}

/* Активный popup */
.ec-hint-popup--visible {
    display: block;
    animation: ec-hint-in 0.15s ease;
}

@keyframes ec-hint-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Зачёркнутый пункт с подсказкой — кнопка гасится */
.ec-item--has-hint.ec-checked .ec-hint-btn {
    opacity: 0.35;
}

/* Мобильные — максимальная ширина уже и JS корректирует позицию */
@media (max-width: 480px) {
    .ec-hint-popup {
        max-width: 240px;
    }
}
