/* ==========================================================================
   Matura Engine — Moduł: Literowy Szyfr (Wordle) | Course Light Mode
   Geometria akordeonu dziedziczona 1:1 z matura.css i matura-mobile.css
   ========================================================================== */

/* Motyw kolorystyczny karty --wordle (bez nadpisywania wysokości, paddingu i typografii z matura.css) */
.matura-module-accordion.matura-module-accordion--wordle {
    border-color: #bbf7d0;
}

.matura-module-accordion.matura-module-accordion--wordle[open] {
    border-color: #86efac;
}

.matura-module-accordion.matura-module-accordion--wordle > summary {
    background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 100%);
}

.matura-module-accordion.matura-module-accordion--wordle > summary .matura-module-icon {
    background: #dcfce7;
    color: #15803d;
    border-color: #86efac;
}

.matura-module-accordion.matura-module-accordion--wordle > summary .mw-cloned-chevron {
    border-color: #bbf7d0;
    color: #15803d;
}

/* Fallback wyłącznie gdy na lekcji nie ma jeszcze żadnego akordeonu z matura-widgets.js */
.matura-module-accordion--wordle > summary.mw-fallback-summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    cursor: pointer;
    user-select: none;
}

.matura-module-accordion--wordle > summary.mw-fallback-summary::-webkit-details-marker {
    display: none;
}

.matura-module-accordion--wordle > summary.mw-fallback-summary h3 {
    flex: 1;
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: #041f3f;
}

.matura-module-accordion--wordle > summary.mw-fallback-summary .mw-fallback-chevron {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #bbf7d0;
    color: #15803d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.matura-module-accordion--wordle[open] > summary.mw-fallback-summary .mw-fallback-chevron {
    transform: rotate(180deg);
}

/* Wnętrze modułu gry */
.mw-accordion-body {
    padding: 20px 18px 24px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}

/* Wewnętrzna bryła aplikacji (jak .mm-app-shell) */
.mw-app-shell {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #1e293b;
    font-family: inherit;
    user-select: none;
}

/* Ukrycie klawiatury po zakończeniu rundy — w jej miejscu wchodzi panel wyniku */
.mw-app-shell.is-round-over .mw-keyboard-dock {
    display: none;
}

/* Stan ukończenia całego zestawu */
.mw-app-shell.is-finished .mw-intro-box,
.mw-app-shell.is-finished .mw-clue-card,
.mw-app-shell.is-finished .mw-toast,
.mw-app-shell.is-finished .mw-board-wrap,
.mw-app-shell.is-finished .mw-keyboard-dock,
.mw-app-shell.is-finished .mw-result-panel {
    display: none;
}

/* Pasek postępu i narzędzia */
.mw-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mw-progress-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.mw-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
}

.mw-progress-track {
    width: 100%;
    height: 7px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.mw-progress-fill {
    height: 100%;
    width: 0%;
    background: #5da733;
    border-radius: 999px;
    transition: width 0.35s ease;
}

.mw-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mw-icon-btn {
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #041f3f;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    touch-action: manipulation;
}

.mw-icon-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* Przycisk "?" widoczny tylko na mobile (na desktopie instrukcja jest stale rozwinięta) */
.mw-help-btn {
    display: none;
}

.mw-help-btn[aria-expanded="true"] {
    background: #041f3f;
    border-color: #041f3f;
    color: #ffffff;
}

/* Krótka instrukcja gry */
.mw-intro-box {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #041f3f;
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mw-intro-text {
    font-size: 13px;
    line-height: 1.45;
    color: #334155;
    margin: 0;
}

.mw-intro-text strong {
    color: #041f3f;
}

.mw-kbd-pill {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #041f3f;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
    vertical-align: 1px;
}

.mw-legend {
    display: flex;
    gap: 8px 14px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 12px;
    color: #475569;
    font-weight: 600;
}

.mw-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mw-legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

/* Karta polskiego hasła */
.mw-clue-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(4, 31, 63, 0.04);
}

.mw-clue-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.mw-clue-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.mw-pl-prompt {
    font-size: 21px;
    font-weight: 800;
    color: #041f3f;
    line-height: 1.22;
    word-break: normal;
    hyphens: none;
}

.mw-clue-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mw-length-pill {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 6px 11px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}

.mw-hint-btn {
    height: 36px;
    padding: 0 13px;
    border-radius: 10px;
    border: 1px solid #fcd34d;
    background: #fef3c7;
    color: #92400e;
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.1s ease;
    touch-action: manipulation;
}

.mw-hint-btn:hover {
    background: #fde68a;
}

.mw-hint-btn:active {
    transform: translateY(1px);
}

/* Status / Komunikat */
.mw-toast {
    min-height: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-align: center;
    line-height: 1.25;
}

.mw-toast.is-warn {
    color: #b45309;
}

.mw-toast.is-ok {
    color: #15803d;
}

/* Siatka Wordle */
.mw-board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 4px 0 6px;
}

.mw-grid {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: center;
}

.mw-row {
    display: flex;
    gap: 7px;
    justify-content: center;
}

.mw-row.is-shake {
    animation: mwRowShake 0.38s ease;
}

@keyframes mwRowShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.mw-tile {
    width: var(--mw-tile-size, 50px);
    height: var(--mw-tile-size, 50px);
    font-size: var(--mw-tile-font, 23px);
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    text-transform: uppercase;
    color: #041f3f;
    transition: border-color 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.mw-tile.is-space {
    width: 12px;
    background: transparent;
    border: none;
}

.mw-tile.is-hyphen {
    width: 18px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
}

.mw-tile.is-filled {
    border-color: #041f3f;
    animation: mwPop 0.12s ease-out;
}

.mw-tile.is-locked {
    border-color: #5da733;
    background: #f0fdf4;
    color: #166534;
    box-shadow: inset 0 0 0 1px rgba(93, 167, 51, 0.2);
}

.mw-tile.is-correct {
    background: #5da733;
    border-color: #5da733;
    color: #ffffff;
}

.mw-tile.is-present {
    background: #d97706;
    border-color: #d97706;
    color: #ffffff;
}

.mw-tile.is-absent {
    background: #64748b;
    border-color: #64748b;
    color: #ffffff;
}

.mw-tile.is-flip {
    animation: mwFlip 0.42s ease forwards;
}

.mw-tile.is-bounce {
    animation: mwBounce 0.5s ease;
}

@keyframes mwPop {
    0% { transform: scale(0.88); }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes mwFlip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

@keyframes mwBounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-9px); }
    70% { transform: translateY(-3px); }
}

/* Klawiatura ekranowa QWERTY — ukryta na komputerach (> 768px), aktywna na mobile (<= 768px) */
.mw-keyboard-dock {
    display: none;
    width: 100%;
    padding: 8px 6px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
}

.mw-keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mw-kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.mw-kb-key {
    flex: 1;
    max-width: 50px;
    height: 44px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #ffffff;
    color: #041f3f;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-shadow: 0 2px 0 #cbd5e1;
    transition: transform 0.08s ease, background-color 0.15s ease, color 0.15s ease;
    touch-action: manipulation;
}

.mw-kb-key:active {
    transform: translateY(2px);
    box-shadow: none;
}

.mw-kb-key.is-wide {
    flex: 1.65;
    max-width: 84px;
    font-size: 11px;
    background: #eef2f6;
}

.mw-kb-key.is-enter {
    background: #041f3f;
    border-color: #041f3f;
    color: #ffffff;
    box-shadow: 0 2px 0 #021124;
}

.mw-kb-key.is-correct {
    background: #5da733;
    border-color: #478524;
    color: #ffffff;
    box-shadow: 0 2px 0 #478524;
}

.mw-kb-key.is-present {
    background: #d97706;
    border-color: #b45309;
    color: #ffffff;
    box-shadow: 0 2px 0 #b45309;
}

.mw-kb-key.is-absent {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #94a3b8;
    box-shadow: none;
}

/* Panel wyniku rundy i ekran zakończenia */
.mw-result-panel,
.mw-complete-panel {
    display: none;
    width: 100%;
    border-radius: 14px;
    padding: 14px 16px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-left: 4px solid #5da733;
    flex-direction: column;
    gap: 10px;
    animation: mwSlideUp 0.22s ease-out;
}

.mw-result-panel.is-open,
.mw-complete-panel.is-open {
    display: flex;
}

.mw-result-panel.is-lost {
    background: #fff1f2;
    border-color: #fecdd3;
    border-left-color: #e11d48;
}

@keyframes mwSlideUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.mw-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mw-result-text {
    font-size: 15px;
    font-weight: 800;
    color: #14532d;
    line-height: 1.3;
}

.mw-result-panel.is-lost .mw-result-text {
    color: #9f1239;
}

.mw-speak-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #041f3f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
}

.mw-primary-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: #5da733;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    touch-action: manipulation;
}

.mw-primary-btn:hover {
    background: #478524;
}

.mw-complete-panel {
    align-items: center;
    text-align: center;
    padding: 24px 18px;
    border-left: 1px solid #86efac;
}

.mw-complete-title {
    font-size: 19px;
    font-weight: 800;
    color: #041f3f;
}

.mw-complete-sub {
    font-size: 14px;
    color: #475569;
}

/* ==========================================================================
   MOBILE ZERO-SCROLL LAYOUT (<= 768px) — Wszystko na 1 ekranie
   ========================================================================== */
@media (max-width: 768px) {
    .mw-accordion-body {
        padding: 10px 8px 14px;
    }

    .mw-app-shell {
        gap: 7px;
    }

    .mw-toolbar {
        gap: 8px;
    }

    .mw-progress-meta {
        font-size: 11.5px;
    }

    .mw-progress-track {
        height: 6px;
    }

    .mw-desktop-only {
        display: none;
    }

    .mw-help-btn {
        display: inline-flex;
    }

    .mw-icon-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        font-size: 14px;
    }

    /* Instrukcja domyślnie ukryta na mobile (rozwijana przyciskiem "?") */
    .mw-intro-box {
        display: none;
        padding: 9px 11px;
        gap: 6px;
    }

    .mw-intro-box.is-mobile-open {
        display: flex;
    }

    .mw-intro-text {
        font-size: 12px;
    }

    .mw-legend {
        font-size: 11px;
        gap: 6px 10px;
    }

    /* Karta hasła w jednym zwartym wierszu */
    .mw-clue-card {
        padding: 9px 11px;
        gap: 10px;
        border-radius: 12px;
    }

    .mw-clue-label {
        font-size: 10.5px;
    }

    .mw-pl-prompt {
        font-size: 16.5px;
        line-height: 1.2;
    }

    .mw-length-pill {
        display: none;
    }

    .mw-hint-btn {
        height: 38px;
        padding: 0 11px;
        font-size: 12px;
        border-radius: 9px;
    }

    .mw-toast {
        min-height: 16px;
        font-size: 12px;
    }

    .mw-app-shell.is-round-over .mw-toast {
        display: none;
    }

    .mw-board-wrap {
        padding: 2px 0;
    }

    .mw-grid {
        gap: 5px;
    }

    .mw-row {
        gap: 5px;
    }

    .mw-tile {
        border-radius: 8px;
    }

    /* Klawiatura dotykowa widoczna w trakcie zgadywania */
    .mw-keyboard-dock {
        display: block;
        padding: 7px 5px;
        border-radius: 12px;
    }

    .mw-app-shell.is-round-over .mw-keyboard-dock {
        display: none;
    }

    /* Panel wyniku wchodzi w miejsce klawiatury */
    .mw-result-panel {
        padding: 12px 13px;
        gap: 9px;
    }

    .mw-result-text {
        font-size: 14px;
    }

    .mw-primary-btn {
        min-height: 46px;
        font-size: 14.5px;
    }
}

/* Neutralizacja klejącego :hover na ekranach dotykowych */
@media (hover: none) {
    .mw-icon-btn:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
    }
    .mw-help-btn[aria-expanded="true"]:hover {
        background: #041f3f;
        border-color: #041f3f;
    }
    .mw-hint-btn:hover {
        background: #fef3c7;
    }
    .mw-primary-btn:hover {
        background: #5da733;
    }
}