/* ========================================================================
   MishaLive Companion page — design tokens + layout
   Scoped to .misha-wrap, не влияет на остальной сайт.
   Источник: design_handoff_mishalive/README.md + MishaLive.html
   ======================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

.misha-wrap {
    /* ── default palette (soft pastel) ──────────────────────────────── */
    --m-bg:        #F7F2EA;
    --m-surface:   #FFFBF4;
    --m-surface-2: #EFE6D3;
    --m-ink:       #2B2A28;
    --m-ink-soft:  #6B645A;
    --m-ink-mute:  #A39A8C;
    --m-line:      #E3D9C5;
    --m-accent-1:  #A8C4A2;  /* sage   — success / calm */
    --m-accent-2:  #E8B298;  /* apricot — warm / attention */
    --m-accent-3:  #C4B5D9;  /* lavender — thinking */
    --m-accent-4:  #F2D589;  /* honey — highlight */
    --m-face-skin: #F3E0CB;

    /* radii / motion */
    --m-r-sm: 10px;
    --m-r-md: 16px;
    --m-r-lg: 24px;
    --m-r-xl: 32px;
    --m-dur-1: 180ms;
    --m-dur-2: 360ms;
    --m-dur-3: 600ms;
    --m-ease:  cubic-bezier(.3,.1,.2,1);

    background: var(--m-bg);
    color: var(--m-ink);
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    font-size: 18px;
    line-height: 1.45;
    min-height: calc(100vh - 64px);  /* под sidebar */
    padding: 24px;
    border-radius: var(--m-r-xl);
}

/* palette variants — включаются через data-attribute на .misha-wrap */
.misha-wrap[data-palette="calm"] {
    --m-bg:        #EEF1F4;
    --m-surface:   #F7F9FB;
    --m-surface-2: #DCE3EA;
    --m-ink:       #263038;
    --m-ink-soft:  #5B6975;
    --m-ink-mute:  #9DA9B3;
    --m-line:      #D0D9E1;
    --m-accent-1:  #9FB8C8;
    --m-accent-2:  #B9C6D3;
    --m-accent-3:  #C2CEDA;
    --m-accent-4:  #D8E1E8;
    --m-face-skin: #CFDAE3;
}
.misha-wrap[data-palette="bright"] {
    --m-bg:        #FFF6E5;
    --m-surface:   #FFFDF5;
    --m-surface-2: #FFE7B2;
    --m-ink:       #1F1B14;
    --m-ink-soft:  #6B5A3A;
    --m-ink-mute:  #A89777;
    --m-line:      #F0D88A;
    --m-accent-1:  #7ACFA8;
    --m-accent-2:  #FF9A7A;
    --m-accent-3:  #A48BE0;
    --m-accent-4:  #FFD24A;
    --m-face-skin: #FFD98A;
}

/* ── Dark theme ─────────────────────────────────────────────────
   Site-wide html.dark forces light text (var(--app-text)) on all
   h1/p/span/div/... Without a matching dark palette, .misha-wrap
   keeps its cream background → light-on-light text is invisible.
   Override tokens so ink becomes light and surfaces become dark. */
html.dark .misha-wrap {
    --m-bg:        #1a1714;
    --m-surface:   #24201c;
    --m-surface-2: #322c26;
    --m-ink:       #f1ece3;
    --m-ink-soft:  #b8afa1;
    --m-ink-mute:  #8a8175;
    --m-line:      #3a332c;
    --m-accent-1:  #7fb396;  /* sage (slightly deeper) */
    --m-accent-2:  #d89a7f;  /* apricot */
    --m-accent-3:  #a99bcc;  /* lavender */
    --m-accent-4:  #d9bd6f;  /* honey */
    --m-face-skin: #3a3229;
}

/* Force contrast for text inside .misha-wrap in dark mode so the
   global html.dark color rule does not wash out content against
   the palette’s dark surfaces. */
html.dark .misha-wrap,
html.dark .misha-wrap h1,
html.dark .misha-wrap .subtitle,
html.dark .misha-wrap .misha-bubble,
html.dark .misha-wrap .misha-task-title,
html.dark .misha-wrap .misha-app-tile,
html.dark .misha-wrap .misha-btn,
html.dark .misha-wrap .misha-help-card {
    color: var(--m-ink);
}

html.dark .misha-wrap .misha-bubble-intent,
html.dark .misha-wrap .misha-bubble-empty,
html.dark .misha-wrap .misha-app-tile-level,
html.dark .misha-wrap .misha-toggle,
html.dark .misha-wrap .misha-empty,
html.dark .misha-wrap .misha-history summary,
html.dark .misha-wrap .misha-history-turn-meta,
html.dark .misha-wrap .misha-btn-ghost {
    color: var(--m-ink-mute);
}

/* Native select inside task header uses Bootstrap default colors —
   align with dark surface so the level selector stays readable. */
html.dark .misha-wrap .form-select {
    background-color: var(--m-surface-2);
    color: var(--m-ink);
    border-color: var(--m-line);
}

/* motion preferences */
.misha-wrap[data-motion="low"] *,
.misha-wrap[data-motion="low"] *::before,
.misha-wrap[data-motion="low"] *::after {
    animation-duration: 0ms !important;
    transition-duration: 60ms !important;
}
.misha-wrap[data-motion="off"] *,
.misha-wrap[data-motion="off"] *::before,
.misha-wrap[data-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
}

/* ── Top bar ────────────────────────────────────────────────────── */
.misha-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--m-line);
    margin-bottom: 24px;
}
.misha-topbar h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--m-ink);
}
.misha-topbar .subtitle {
    font-size: 14px;
    color: var(--m-ink-soft);
    margin-top: 2px;
}

/* ── Hero: face + bubble ────────────────────────────────────────── */
.misha-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px;
}

/* Face 220×220 — квадрат с тёплым фоном, эмоджи крупно по центру */
.misha-face {
    width: 220px;
    height: 220px;
    background: var(--m-face-skin);
    border-radius: var(--m-r-xl);
    box-shadow: 0 2px 14px rgba(43,42,40,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 120px;
    line-height: 1;
    flex-shrink: 0;
    animation: misha-breathe 4s var(--m-ease) infinite;
}

@keyframes misha-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.01); }
}

/* Speech bubble — слева от лица, max-width 520 */
.misha-bubble {
    position: relative;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    padding: 20px 24px;
    max-width: 520px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--m-ink);
    box-shadow: 0 2px 10px rgba(43,42,40,0.04);
    animation: misha-float-in var(--m-dur-3) var(--m-ease) both;
}

/* Пузырь-хвост к лицу */
.misha-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 40px;
    width: 20px;
    height: 20px;
    background: var(--m-surface);
    border-left: 1px solid var(--m-line);
    border-bottom: 1px solid var(--m-line);
    transform: rotate(45deg);
}

.misha-bubble-intent {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--m-ink-mute);
    margin-bottom: 6px;
}
.misha-bubble-empty {
    color: var(--m-ink-mute);
    font-size: 18px;
    font-weight: 400;
    font-style: italic;
}

@keyframes misha-float-in {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ── Task area ──────────────────────────────────────────────────── */
.misha-task {
    max-width: 900px;
    margin: 0 auto 32px;
    padding: 24px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    box-shadow: 0 2px 10px rgba(43,42,40,0.04);
}
.misha-task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--m-line);
}
.misha-task-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--m-ink);
}

/* Section label ("📚 Задания" / "🎮 Игры") над соответствующей сеткой */
.misha-section-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--m-ink-soft);
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

/* Apps grid — когда приложение не запущено */
.misha-apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

/* Иконка на тайле (emoji или в будущем — <img>). */
.misha-app-tile-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 8px;
}
.misha-app-tile-icon img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--m-r-sm);
    display: block;
    margin: 0 auto;
}

/* Reward-тайлы — чуть другой акцент, чтобы игра визуально отличалась от задания. */
.misha-app-tile-reward {
    background: var(--m-accent-4);
}
.misha-app-tile-reward:hover:not(:disabled) {
    background: var(--m-accent-4);
    filter: brightness(0.96);
}
.misha-app-tile {
    padding: 20px 16px;
    background: var(--m-surface-2);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-md);
    text-align: center;
    cursor: pointer;
    transition: transform var(--m-dur-1) var(--m-ease),
                box-shadow var(--m-dur-1) var(--m-ease);
    font-size: 16px;
    font-weight: 600;
    color: var(--m-ink);
}
.misha-app-tile:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(43,42,40,0.08);
}
.misha-app-tile:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.misha-app-tile-level {
    font-size: 11px;
    font-weight: 500;
    color: var(--m-ink-mute);
    margin-top: 6px;
}

/* ── Bottom dock: contextual help ───────────────────────────────── */
.misha-help-dock {
    max-width: 1100px;
    margin: 0 auto 24px;
    display: flex;
    justify-content: center;
}
.misha-help-card {
    background: var(--m-accent-4);
    border: 1px solid var(--m-line);
    border-radius: var(--m-r-lg);
    padding: 16px 24px;
    font-weight: 700;
    font-size: 18px;
    color: var(--m-ink);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(43,42,40,0.04);
    animation: misha-float-in var(--m-dur-2) var(--m-ease) both;
    transition: transform var(--m-dur-1) var(--m-ease);
}
.misha-help-card:hover {
    transform: translateY(-2px);
}

/* ── Buttons (primary / secondary) ──────────────────────────────── */
.misha-btn {
    padding: 12px 20px;
    border-radius: var(--m-r-md);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    border: 1px solid var(--m-line);
    background: var(--m-surface);
    color: var(--m-ink);
    transition: transform var(--m-dur-1) var(--m-ease),
                background-color var(--m-dur-1) var(--m-ease);
    font-family: inherit;
}
.misha-btn:hover { transform: translateY(-1px); background: var(--m-surface-2); }
.misha-btn-primary { background: var(--m-accent-1); border-color: var(--m-accent-1); }
.misha-btn-primary:hover { background: var(--m-accent-1); filter: brightness(0.95); }
.misha-btn-ghost { background: transparent; border-color: transparent; color: var(--m-ink-soft); }
.misha-btn-ghost:hover { background: var(--m-surface-2); }

/* ── History spoiler (parent/debug, вне главного потока) ──────── */
.misha-history {
    max-width: 1100px;
    margin: 32px auto 0;
    padding: 12px 20px;
    background: transparent;
    border-top: 1px solid var(--m-line);
}
.misha-history summary {
    cursor: pointer;
    color: var(--m-ink-mute);
    font-size: 13px;
    padding: 6px 0;
    list-style: none;
    user-select: none;
}
.misha-history summary::-webkit-details-marker { display: none; }
.misha-history summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    transition: transform var(--m-dur-1) var(--m-ease);
    font-size: 10px;
}
.misha-history[open] summary::before { transform: rotate(90deg); }
.misha-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    margin-top: 12px;
    padding-right: 8px;
}
.misha-history-turn {
    padding: 10px 14px;
    border-radius: var(--m-r-sm);
    font-size: 14px;
    line-height: 1.4;
}
.misha-history-turn-meta {
    font-size: 11px;
    color: var(--m-ink-mute);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.misha-turn-companion { background: var(--m-surface); border: 1px solid var(--m-line); }
.misha-turn-child     { background: var(--m-accent-1); color: var(--m-ink); }
.misha-turn-system    { background: var(--m-surface-2); color: var(--m-ink-soft); font-style: italic; }

/* ── Toggle (auto-switch checkbox в topbar) ─────────────────────── */
.misha-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--m-ink-soft);
    cursor: pointer;
    user-select: none;
}
.misha-toggle input[type="checkbox"] {
    accent-color: var(--m-accent-1);
    width: 16px;
    height: 16px;
}

/* ── Session "empty" state ─────────────────────────────────────── */
.misha-empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--m-ink-mute);
    font-size: 16px;
}
.misha-empty-emoji {
    font-size: 72px;
    margin-bottom: 16px;
}
