/* =====================================================================
   Интерактивные задания ЭФУ — оформление
   Опирается на переменные :root из css/style.css (--primary, --bg-2 и пр.)
===================================================================== */

/* Кнопка 📝 в общей панели #controls наследует базовый стиль кнопок.
   Неактивное состояние — когда на текущих страницах заданий нет. */
#btn-tasks {
    position: relative;
}
#btn-tasks.is-empty {
    opacity: 0.4;
    cursor: default;
}
#btn-tasks.is-empty:hover {
    background: var(--bg-2);
    color: var(--primary);
    transform: none;
}
/* Счётчик заданий на бейдже */
#btn-tasks .fbt-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(30, 41, 59, 0.25);
}
#btn-tasks.is-empty .fbt-badge { display: none; }

/* =====================================================================
   Оверлей и карточка
===================================================================== */
.fbt-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(30, 41, 59, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fbt-fade 0.2s ease;
}
@keyframes fbt-fade { from { opacity: 0; } to { opacity: 1; } }

.fbt-card {
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft), 0 24px 60px rgba(30, 41, 59, 0.22);
    padding: 28px;
    animation: fbt-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fbt-pop {
    from { transform: scale(0.92) translateY(10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.fbt-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
}
.fbt-title {
    flex: 1;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.3;
}
.fbt-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--bg-2);
    color: var(--text-muted);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}
.fbt-close:hover { background: var(--accent-2); color: #fff; }

/* =====================================================================
   Прогресс прохождения (задание N из M)
===================================================================== */
.fbt-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -6px 0 18px;
    flex-wrap: wrap;
}
.fbt-progress-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.fbt-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.fbt-dot {
    width: 14px; height: 14px;
    border: none; padding: 0;
    border-radius: 50%;
    background: var(--bg-2);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease;
}
.fbt-dot:hover { transform: scale(1.2); }
.fbt-dot.past { background: var(--primary-hover); }
.fbt-dot.cur {
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    transform: scale(1.25);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* =====================================================================
   Список заданий
===================================================================== */
.fbt-list { display: flex; flex-direction: column; gap: 12px; }
.fbt-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-2);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.fbt-list-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: #fff;
}
.fbt-list-ico {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fbt-list-txt { flex: 1; }
.fbt-list-kind { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.03em; }
.fbt-list-q { font-size: 16px; font-weight: 600; color: var(--text); margin-top: 2px; line-height: 1.35; }

/* =====================================================================
   Общие элементы заданий
===================================================================== */
.fbt-body { font-size: 17px; line-height: 1.7; color: var(--text); }

.fbt-prompt { font-size: 16px; color: var(--text-muted); font-weight: 500; margin-bottom: 18px; line-height: 1.5; }

.fbt-options { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.fbt-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-2);
    border: 2px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
    user-select: none;
}
.fbt-opt:hover { border-color: var(--primary-hover); }
.fbt-opt.sel { border-color: var(--primary); background: #fff; }
.fbt-opt .fbt-mark {
    flex-shrink: 0;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.fbt-opt.multi .fbt-mark { border-radius: 7px; }
.fbt-opt.sel .fbt-mark { background: var(--primary); border-color: var(--primary); }
/* состояние после проверки */
.fbt-opt.ok  { border-color: #22c55e; background: #f0fdf4; }
.fbt-opt.ok  .fbt-mark { background: #22c55e; border-color: #22c55e; }
.fbt-opt.bad { border-color: #ef4444; background: #fef2f2; }
.fbt-opt.bad .fbt-mark { background: #ef4444; border-color: #ef4444; }
.fbt-opt.lock { pointer-events: none; }

/* Выбор изображений */
.fbt-imggrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fbt-imgopt {
    position: relative;
    border: 3px solid transparent;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-2);
    aspect-ratio: 4 / 3;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.fbt-imgopt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fbt-imgopt:hover { transform: translateY(-2px); }
.fbt-imgopt.sel { border-color: var(--primary); }
.fbt-imgopt.sel::after {
    content: '✓';
    position: absolute; top: 8px; right: 8px;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 16px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.fbt-imgopt.ok  { border-color: #22c55e; }
.fbt-imgopt.bad { border-color: #ef4444; }
.fbt-imgmissing {
    display: flex; align-items: center; justify-content: center;
    height: 100%; color: var(--text-muted); font-size: 13px; padding: 8px; text-align: center;
}

/* Пропуски (перетаскивание / вписывание) */
.fbt-fill { font-size: 18px; line-height: 2.2; }
.fbt-slot {
    display: inline-block;
    min-width: 80px;
    padding: 4px 10px;
    margin: 0 2px;
    border-radius: 10px;
    border: 2px dashed var(--primary);
    background: var(--bg-2);
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    vertical-align: middle;
    cursor: pointer;
    min-height: 36px;
    line-height: 28px;
}
.fbt-slot.filled { border-style: solid; background: #fff; color: var(--text); }
.fbt-slot.ok  { border-color: #22c55e; background: #f0fdf4; color: #166534; }
.fbt-slot.bad { border-color: #ef4444; background: #fef2f2; color: #991b1b; }
.fbt-blank-input {
    display: inline-block;
    width: 64px;
    padding: 4px 6px;
    margin: 0 2px;
    border-radius: 10px;
    border: 2px solid var(--primary);
    background: var(--bg-2);
    text-align: center;
    font-weight: 700;
    font-size: 17px;
    font-family: inherit;
    color: var(--text);
    vertical-align: middle;
}
.fbt-blank-input:focus { outline: none; background: #fff; }
.fbt-blank-input.ok  { border-color: #22c55e; background: #f0fdf4; }
.fbt-blank-input.bad { border-color: #ef4444; background: #fef2f2; }

.fbt-bank { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border); }
.fbt-chip {
    padding: 10px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: transform 0.1s ease, opacity 0.15s ease;
    user-select: none;
}
.fbt-chip:hover { transform: translateY(-2px); }
.fbt-chip.sel { outline: 3px solid var(--accent); }
.fbt-chip.used { opacity: 0.3; pointer-events: none; }

/* Расставить по порядку */
.fbt-order { display: flex; flex-direction: column; gap: 10px; }
.fbt-order-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--bg-2);
    border-radius: 14px;
    font-size: 16px; font-weight: 600; color: var(--text);
}
.fbt-order-num {
    flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--primary); color: #fff;
    font-weight: 800; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.fbt-order-label { flex: 1; }
.fbt-order-btns { display: flex; flex-direction: column; gap: 4px; }
.fbt-order-btns button {
    width: 30px; height: 22px;
    border: none; border-radius: 7px;
    background: var(--surface); color: var(--primary);
    cursor: pointer; font-size: 12px; line-height: 1;
    box-shadow: var(--shadow-soft);
}
.fbt-order-btns button:hover { background: var(--primary); color: #fff; }
.fbt-order-btns button:disabled { opacity: 0.3; cursor: default; }
.fbt-order-item.ok  { background: #f0fdf4; }
.fbt-order-item.ok  .fbt-order-num { background: #22c55e; }
.fbt-order-item.bad .fbt-order-num { background: #ef4444; }

/* Матрица слов */
.fbt-matrix-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.fbt-matrix {
    display: grid;
    gap: 4px;
    width: 100%;
    max-width: 420px;
    touch-action: none;
    user-select: none;
}
.fbt-cell {
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: 9px;
    background: var(--bg-2);
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(13px, 4.2vw, 18px);
    font-weight: 700; color: var(--text);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
}
.fbt-cell.pick { background: var(--accent); color: #fff; }
.fbt-cell.found { background: #22c55e; color: #fff; }
.fbt-words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.fbt-word {
    padding: 6px 12px; border-radius: 999px;
    background: var(--bg-2); color: var(--text);
    font-weight: 700; font-size: 15px;
}
.fbt-word.done { background: #f0fdf4; color: #166534; text-decoration: line-through; }

/* Медиа */
.fbt-media { margin: 6px 0 18px; }
.fbt-media video, .fbt-media iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 16px;
    background: #000;
    display: block;
}
.fbt-audio { width: 100%; margin: 10px 0; }
.fbt-readtext {
    font-size: 19px; line-height: 1.8; color: var(--text);
    background: var(--bg-2); border-radius: 16px; padding: 20px 22px;
}
.fbt-videolink {
    display: inline-block; margin-top: 8px;
    color: var(--primary); font-weight: 700; text-decoration: none;
}
.fbt-videolink:hover { text-decoration: underline; }

/* =====================================================================
   Подвал: проверка и обратная связь
===================================================================== */
.fbt-foot { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.fbt-feedback {
    display: none;
    align-items: center; gap: 10px;
    padding: 14px 18px; border-radius: 14px;
    font-size: 16px; font-weight: 700;
}
.fbt-feedback.show { display: flex; }
.fbt-feedback.win  { background: #f0fdf4; color: #166534; }
.fbt-feedback.lose { background: #fef2f2; color: #991b1b; }
.fbt-actions { display: flex; gap: 12px; }
.fbt-btn {
    flex: 1;
    padding: 16px;
    border: none; border-radius: 16px;
    font-size: 17px; font-weight: 800; font-family: inherit;
    cursor: pointer; letter-spacing: -0.01em;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.fbt-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}
.fbt-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45); }
.fbt-btn-ghost { background: var(--bg-2); color: var(--primary); }
.fbt-btn-ghost:hover { background: var(--primary); color: #fff; }
.fbt-btn:active { transform: translateY(0) scale(0.98); }

/* =====================================================================
   Адаптив
===================================================================== */
@media (max-width: 600px) {
    .fbt-card { padding: 20px; border-radius: 20px; max-height: 92vh; }
    .fbt-title { font-size: 18px; }
    .fbt-body { font-size: 16px; }
    .fbt-imggrid { gap: 10px; }
    .fbt-fill { font-size: 17px; line-height: 2.1; }
    .fbt-btn { padding: 14px; font-size: 16px; }
}
