/* English Legacy — главная.
 * Принцип: на странице ровно два цветных акцента — «Доска» (индиго) и
 * «Кабинет» (оранжевый). Они одинаковы в шапке и на первом экране, чтобы
 * ребёнок узнавал их по цвету и иконке, не читая. Всё остальное нейтральное. */

:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --ink: #1c2440;
    --muted: #66708a;
    --line: #e3e7f0;

    --board: #4f46e5;
    --board-2: #7c6cff;
    --board-soft: #eef0ff;
    --cabinet: #f06d0f;
    --cabinet-2: #ffa31a;
    --cabinet-soft: #fff1e3;
    --live: #ef4444;

    --radius: 22px;
    --shadow: 0 1px 2px rgba(28, 36, 64, .05), 0 6px 20px rgba(28, 36, 64, .06);
    --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Nunito, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #6366f1; outline-offset: 3px; border-radius: 10px; }
svg { display: block; }

/* Гость / вошедший: одна разметка, класс на <html> ставится до отрисовки. */
html[data-auth="guest"] .only-user,
html[data-auth="user"] .only-guest { display: none !important; }
html[data-auth="guest"] .topbar-doors,
html[data-auth="guest"] .account,
html[data-auth="user"] .btn-login { display: none; }

/* ── Шапка ──────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.05rem; margin-right: auto; }
.brand-mark {
    display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 12px;
    background: var(--ink); color: #fff;
    font-size: .85rem; letter-spacing: .02em;
}

.topbar-doors { display: flex; gap: 8px; }
.pill {
    display: inline-flex; align-items: center; gap: 7px;
    height: 42px; padding: 0 16px 0 12px;
    border-radius: 999px;
    font-weight: 800; font-size: .95rem;
    color: #fff;
    transition: transform .15s ease, box-shadow .2s ease;
}
.pill svg { width: 21px; height: 21px; }
.pill--board { background: var(--board); box-shadow: 0 4px 12px rgba(79, 70, 229, .3); }
.pill--cabinet { background: var(--cabinet); box-shadow: 0 4px 12px rgba(240, 109, 15, .3); }
.pill:hover { transform: translateY(-1px); }

.btn-login {
    display: inline-flex; align-items: center;
    height: 42px; padding: 0 20px;
    border-radius: 999px;
    background: var(--ink); color: #fff;
    font-weight: 800;
}

.account { position: relative; }
.account summary {
    display: flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 12px 0 4px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    list-style: none;
    cursor: pointer;
    font-weight: 700;
}
.account summary::-webkit-details-marker { display: none; }
.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #c7d2fe, #fde68a);
    font-weight: 900; font-size: .9rem;
}
.account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-pop {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 200px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(28, 36, 64, .14);
}
.account-pop a, .account-pop button {
    display: block; width: 100%;
    padding: 10px 12px;
    border: 0; border-radius: 10px;
    background: none;
    text-align: left; font-weight: 700;
}
.account-pop a:hover, .account-pop button:hover { background: var(--bg); }
.account-pop button { color: #c2410c; }

/* ── Страница ───────────────────────────────────────────────────────── */
.page { max-width: 1120px; margin: 0 auto; padding: 28px var(--gutter) 48px; }

.hero-head { margin-bottom: 22px; }
.hero h1 { margin: 0; font-size: clamp(1.9rem, 4.6vw, 2.9rem); font-weight: 900; line-height: 1.1; letter-spacing: -.01em; }
.hero-sub { margin: 8px 0 0; font-size: clamp(1.02rem, 2vw, 1.2rem); color: var(--muted); font-weight: 600; }
.t-board { color: var(--board); }
.t-cabinet { color: var(--cabinet); }

.level {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 14px 0 0; padding: 6px 14px 6px 6px;
    background: var(--card); border: 1px solid var(--line); border-radius: 999px;
    font-weight: 700; font-size: .9rem; color: var(--muted);
}
.level[hidden] { display: none; }
.level-num {
    display: grid; place-items: center;
    min-width: 30px; height: 30px; padding: 0 6px; border-radius: 999px;
    background: #fde68a; color: #7c4a03; font-weight: 900;
}
.level-bar { width: 90px; height: 8px; border-radius: 99px; background: #eef1f6; overflow: hidden; }
.level-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #facc15, #f97316); transition: width .6s ease; }

/* ── Двери ──────────────────────────────────────────────────────────── */
.tutor-lesson {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 24px;
    margin-bottom: 20px; padding: 22px 24px;
    background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--board);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.tutor-lesson[hidden], .lesson-action[hidden], .tutor-lesson-calls[hidden] { display: none; }
html[data-auth="guest"] .tutor-lesson { display: none; }
.tutor-lesson h2 { margin: 0; font-size: 1.15rem; font-weight: 900; }
.tutor-lesson p { margin: 6px 0 0; }
.tutor-lesson-status { color: var(--muted); font-size: .9rem; font-weight: 700; }
.tutor-lesson-countdown { color: var(--board); font-weight: 900; font-variant-numeric: tabular-nums; }
.tutor-lesson-students { display: block; margin-top: 10px; font-size: 1.4rem; overflow-wrap: anywhere; }
.tutor-lesson-students:empty, .tutor-lesson p:empty, .tutor-lesson-time:empty { display: none; }
.tutor-lesson-title { color: var(--muted); }
.tutor-lesson-time { display: block; margin-top: 6px; font-weight: 800; }
.tutor-lesson-note { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.tutor-lesson-actions, .tutor-lesson-calls { display: flex; flex-direction: column; gap: 8px; }
.tutor-lesson-actions { justify-content: center; }
.lesson-action {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 10px 16px; border-radius: 12px; font-weight: 800; text-align: center;
}
.lesson-action svg { width: 22px; height: 22px; flex: none; }
.lesson-action--board { background: var(--board); color: #fff; }
.lesson-action--call { background: var(--cabinet-soft); color: #a54b05; }
.lesson-action--prepare { border: 1px solid var(--line); color: var(--board); }
.lesson-action:hover { filter: brightness(.96); }
.tutor-lesson-schedule { color: var(--muted); font-weight: 700; font-size: .9rem; text-align: center; padding: 4px; }
.tutor-lesson[data-state="live"] { border-left-color: var(--live); }
.tutor-lesson[data-state="live"] .tutor-lesson-status { color: #b91c1c; }
.tutor-lesson[data-state="live"] .tutor-lesson-countdown { color: #b91c1c; }
@media (max-width: 720px) {
    .tutor-lesson { grid-template-columns: 1fr; padding: 18px; gap: 14px; }
}

.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.door {
    position: relative;
    display: flex; flex-direction: column;
    min-height: 260px;
    padding: 26px 26px 22px;
    border-radius: 28px;
    color: #fff;
    overflow: hidden;
    isolation: isolate;
    transition: transform .2s ease, box-shadow .25s ease;
}
/* Мягкий световой круг за иконкой — без картинок, только градиент. */
.door::before {
    content: "";
    position: absolute; z-index: -1;
    right: -70px; top: -70px;
    width: 260px; height: 260px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 70%);
}
.door--board {
    background: linear-gradient(140deg, var(--board-2), var(--board) 60%, #3b33c4);
    box-shadow: 0 14px 34px rgba(79, 70, 229, .32);
}
.door--cabinet {
    background: linear-gradient(140deg, var(--cabinet-2), var(--cabinet) 65%, #d9560a);
    box-shadow: 0 14px 34px rgba(240, 109, 15, .3);
}
.door:hover { transform: translateY(-3px); }
.door:active { transform: translateY(0) scale(.99); }

.door-icon {
    display: grid; place-items: center;
    width: 72px; height: 72px; border-radius: 22px;
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .35);
    margin-bottom: 18px;
}
.door-icon svg { width: 40px; height: 40px; }
.door-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.door-kicker { font-size: .95rem; font-weight: 700; opacity: .9; }
.door-title { font-size: clamp(2rem, 4.2vw, 2.6rem); font-weight: 900; line-height: 1.05; letter-spacing: -.01em; }
.door-status { margin-top: 6px; font-size: 1.05rem; font-weight: 700; }
.door-note { font-size: .92rem; opacity: .85; font-weight: 600; }
.door-note:empty { display: none; }
.door-go {
    display: inline-flex; align-items: center; gap: 8px;
    align-self: flex-start;
    margin-top: 18px;
    height: 48px; padding: 0 20px;
    border-radius: 999px;
    background: #fff;
    font-weight: 900; font-size: 1rem;
}
.door--board .door-go { color: var(--board); }
.door--cabinet .door-go { color: var(--cabinet); }
.door-go svg { width: 20px; height: 20px; transition: transform .2s ease; }
.door:hover .door-go svg { transform: translateX(3px); }

/* Урок идёт: ярлык и мягкое кольцо. Подсветка — состояние, а не украшение. */
.door-live {
    display: none;
    position: absolute; top: 20px; right: 20px;
    align-items: center; gap: 7px;
    padding: 6px 12px 6px 10px;
    border-radius: 999px;
    background: #fff; color: var(--live);
    font-weight: 900; font-size: .85rem;
}
.door-live::before {
    content: ""; width: 9px; height: 9px; border-radius: 50%;
    background: var(--live);
    animation: livePulse 1.4s ease-in-out infinite;
}
.door.is-live .door-live { display: inline-flex; }
.door.is-live { animation: doorRing 2s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .35; } }
@keyframes doorRing {
    0%, 100% { box-shadow: 0 14px 34px rgba(79, 70, 229, .32), 0 0 0 0 rgba(124, 108, 255, .5); }
    50% { box-shadow: 0 14px 34px rgba(79, 70, 229, .32), 0 0 0 10px rgba(124, 108, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .door, .door-go svg, .pill { transition: none; }
    .door.is-live, .door-live::before { animation: none; }
    .door.is-live { box-shadow: 0 0 0 4px rgba(124, 108, 255, .55), 0 14px 34px rgba(79, 70, 229, .32); }
}

/* ── Звонок, задание, слово ─────────────────────────────────────────── */
.extras { display: grid; gap: 10px; margin-top: 16px; }
.extras:not(:has(> :not([hidden]))) { display: none; }
.extra {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.extra[hidden] { display: none; }
.extra-ico { font-size: 1.6rem; line-height: 1; flex: none; }
.extra-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.extra-text strong { font-weight: 800; }
.extra-text small { color: var(--muted); font-weight: 600; }
.extra-arrow { width: 20px; height: 20px; color: var(--muted); flex: none; }
.extra-btn {
    flex: none; padding: 9px 16px; border-radius: 999px;
    background: #fee2e2; color: #b91c1c; font-weight: 900;
}
.extra--call.is-live { border-color: #fecaca; background: #fff5f5; }
.extra--call.is-live strong { color: #b91c1c; }
.extra--task { border-color: #fecaca; }

.word { color: var(--board); }
.word-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.word-options button {
    padding: 8px 14px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--bg);
    font-weight: 700;
}
.word-options button:hover:not(:disabled) { border-color: var(--board); }
.word-options button.is-right { background: #dcfce7; border-color: #22c55e; color: #166534; }
.word-options button.is-wrong { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.word-options button:disabled { cursor: default; }

/* ── Нижние блоки ───────────────────────────────────────────────────── */
.block { margin-top: 44px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.block-head h2 { margin: 0; font-size: 1.45rem; font-weight: 900; }
.block-head p { margin: 0; color: var(--muted); font-weight: 600; }

.skills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.skill {
    display: flex; flex-direction: column; gap: 2px;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--tone);
    color: var(--ink);
    transition: transform .15s ease;
}
.skill:hover { transform: translateY(-2px); }
.skill-ico { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.skill strong { font-size: 1.15rem; font-weight: 900; color: var(--ink); }
.skill small { color: var(--ink); opacity: .7; font-weight: 600; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.game, .more-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    text-align: left;
    transition: border-color .15s ease, transform .15s ease;
}
.game:hover, .more-item:hover { border-color: #c7cdf9; transform: translateY(-1px); }
.game-ico, .more-item > span:first-child {
    display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--bg);
    font-size: 1.4rem;
}
.game-hero {
    display: flex; align-items: center; gap: 14px; margin-bottom: 12px;
    padding: 16px 18px; border-radius: 20px;
    background: #6B3FE8; color: #fff;
    box-shadow: 0 4px 0 #4A22B5;
    transition: transform .1s ease, box-shadow .1s ease;
}
.game-hero:active { transform: translateY(4px); box-shadow: 0 0 0 #4A22B5; }
@media (hover: hover) { .game-hero:hover { background: #7A52EE; } }
.game-hero-ico { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.18); font-size: 1.7rem; }
.game-hero-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.game-hero-text strong { font-weight: 900; font-size: 1.15rem; }
.game-hero-text small { font-weight: 700; font-size: .85rem; opacity: .85; }
.game-hero-go { flex: none; padding: 8px 14px; border-radius: 999px; background: #fff; color: #4A22B5; font-weight: 900; font-size: .9rem; }
@media (max-width: 380px) { .game-hero-go { display: none; } }
.game span:last-child, .more-item span:last-child { display: flex; flex-direction: column; min-width: 0; }
.game strong, .more-item strong { font-weight: 800; }
.game small, .more-item small { color: var(--muted); font-weight: 600; font-size: .85rem; }

.topic-picker {
    margin-top: 12px;
    background: var(--card);
    border: 1px dashed #cdd3e2;
    border-radius: 16px;
}
.topic-picker summary { padding: 12px 16px; cursor: pointer; font-weight: 800; color: var(--muted); }
.topic-picker[open] summary { color: var(--ink); }
.topic-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 0 16px 12px; }
.topic-form label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; font-size: .85rem; font-weight: 700; color: var(--muted); }
.topic-form select {
    height: 44px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--bg);
    font-weight: 700; color: var(--ink);
}
.topic-form button {
    height: 44px; padding: 0 22px;
    border: 0; border-radius: 12px;
    background: var(--ink); color: #fff; font-weight: 800;
}
.topic-preview { margin: 0; padding: 0 16px 14px; color: var(--muted); font-size: .9rem; }
.topic-preview:empty { display: none; }

.more { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-item { width: 100%; font: inherit; color: inherit; cursor: pointer; }

.footer { padding: 24px var(--gutter) 36px; text-align: center; color: var(--muted); font-size: .9rem; }
.footer-legal { display: block; margin-top: 6px; font-size: .8rem; }
.footer-legal a { color: inherit; text-decoration: underline; }

/* ── Узкие экраны ───────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .skills { grid-template-columns: repeat(2, 1fr); }
    .more { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .page { padding-top: 20px; }
    .doors { grid-template-columns: 1fr; gap: 12px; }
    .door { min-height: 0; padding: 20px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 16px; }
    .door-icon { width: 60px; height: 60px; margin: 0; border-radius: 18px; }
    .door-icon svg { width: 34px; height: 34px; }
    .door-text { flex: 1 1 0; min-width: 0; }
    .door-go { width: 100%; justify-content: center; margin-top: 16px; }
    .door-live { top: 14px; right: 14px; }
    /* Ярлык «Урок идёт» занимает место подписи — подпись в этот момент лишняя. */
    .door.is-live .door-kicker { display: none; }
    .account-name { display: none; }
    .account summary { padding: 0 4px; }
}
@media (max-width: 520px) {
    .brand-name { display: none; }
    .pill { padding: 0 12px 0 10px; }
    .topbar-inner { gap: 6px; }
}
@media (max-width: 380px) {
    .pill span { display: none; }
    .pill { width: 42px; padding: 0; justify-content: center; }
}
