/* Ristsona lahendamislehe stiilid */

.section.solve-section {
    padding: 1rem 1.5rem !important;
}

@media screen and (max-width: 768px) {
    .section.solve-section {
        padding: 0.5rem 0.75rem !important;
    }
    /* is-6 vahe (1.5rem negatiivne veeris) on suurem kui sektsiooni polster → leht kerib külgsuunas */
    .solve-section .columns.is-variable.is-6 {
        --bulma-column-gap: 0.75rem;
    }
}

.solve-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
}

.solve-header .title {
    margin-bottom: 0.25rem !important;
}

.grid-zoom-controls {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    justify-content: flex-end;
    align-items: center;
}

.grid-zoom-controls #zoomResetBtn {
    min-width: 3.5rem;
    font-size: 0.85rem;
}

/* Aktiivse küsimuse riba — ainult kitsal ekraanil, kus küsimuste nimekiri jääb ruudustiku alla */
.solve-clue-bar {
    display: none;
}

@media screen and (max-width: 768px) {
    .solve-clue-bar {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        position: sticky;
        top: 0;
        z-index: 5;
        margin-bottom: 0.5rem;
        padding: 0.35rem;
        background: #eff6ff;
        border: 1px solid #bfdbfe;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    .solve-clue-bar[hidden] {
        display: none;
    }
}

.solve-clue-bar-text {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    line-height: 1.3;
    color: #1e293b;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.solve-clue-bar-text.is-hint {
    color: #64748b;
    font-style: italic;
}

.solve-clue-bar-nav {
    flex-shrink: 0;
    min-width: 2.25rem;
    height: 2.25rem;
}

.crossword-grid-container {
    overflow: auto;
    margin: 0;
    padding: 0;
    max-height: calc(100vh - 140px);
}

#puzzleGrid {
    zoom: var(--cw-zoom, 1);
    width: fit-content;
    margin: 0 auto;
}

.crossword-grid-container .solve-table {
    margin: 0 auto;
}

/* Ristsona tabel */
.solve-table {
    border-collapse: collapse;
    table-layout: fixed;
    user-select: none;
    -webkit-user-select: none;
}

.solve-table td {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    text-align: center;
    vertical-align: middle;
    position: relative;
    padding: 0;
    box-sizing: border-box;
    font-weight: bold;
    font-size: 1.2rem;
}

.solve-cell {
    background: white;
    border: 1px solid #bbb;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.solve-cell:hover {
    background-color: #f0f4ff;
}

.solve-cell-empty {
    background: transparent;
    border: none;
}

/* Lahendussona rida (lihtne ristsona) */
.solve-cell.solution-row {
    background: #e8e8e8;
}

/* Aktiivne lahter */
.solve-cell.active {
    border: 2px solid #3273dc;
    z-index: 1;
}

/* Aktiivne sona (esile tostmine) */
.solve-cell.active-word {
    background-color: #dbeafe;
}

.solve-cell.solution-row.active-word {
    background-color: #c8d8f0;
}

/* Tahe lahtris */
.cell-letter {
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Lahtri number */
.cell-num {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 0.55rem;
    font-weight: normal;
    color: #333;
    line-height: 1;
}

/* Kontroll: oige */
.solve-cell.cell-correct {
    background-color: #d1fae5 !important;
    border-color: #34d399;
}

/* Kontroll: vale */
.solve-cell.cell-wrong {
    background-color: #fee2e2 !important;
    border-color: #f87171;
}

/* Kontroll: tyhi (viga) */
.solve-cell.cell-empty-error {
    box-shadow: inset 0 0 0 2px #f87171;
}

/* Lahendatud sona */
.solve-cell.cell-solved {
    background-color: #d1fae5 !important;
    border-color: #6ee7b7;
}

/* Lahendussõna lahendatud lahtrid on kuldsed — sõna kerkib rohelise seast esile juba lahendamise ajal */
.solve-cell.solution-row.cell-solved {
    background-color: #fef3c7 !important;
    border-color: #f59e0b;
    color: #78350f;
}

/* Kogu ristsõna lahendatud: lahendussõna rida süttib vasakult paremale */
#puzzleGrid.is-complete .solve-cell.solution-row {
    background-color: #fcd34d !important;
    color: #451a03;
    box-shadow: inset 0 0 0 2px #d97706;
    animation: solution-reveal 0.45s ease-out both;
    animation-delay: calc(var(--reveal-i, 0) * 90ms);
}

@keyframes solution-reveal {
    0% { transform: scale(1); }
    50% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    #puzzleGrid.is-complete .solve-cell.solution-row {
        animation: none;
    }
}

.solution-word-text {
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Võiduteade on mõlemas teemas sama roheline, seega nupp on mõlemas valge (is-white muutuks tumedas läbipaistvaks) */
.button.solve-restart-btn,
[data-theme="dark"] .button.solve-restart-btn {
    background-color: #fff;
    border-color: transparent;
    color: #14532d;
    font-weight: 600;
}

.button.solve-restart-btn:hover,
.button.solve-restart-btn:focus-visible,
[data-theme="dark"] .button.solve-restart-btn:hover,
[data-theme="dark"] .button.solve-restart-btn:focus-visible {
    background-color: #f0fdf4;
    color: #14532d;
}

/* Kusimuste paneel */
.crossword-clues-panel {
    background: #f5f5f5;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.clues-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid #3273dc;
}

.clue-item {
    padding: 0.2rem 0rem;
    margin-bottom: 0.1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-size: 0.9rem;
    line-height: 1.25;
}

.clue-item:hover {
    background-color: #e8e8e8;
}

.clue-item.active-clue {
    background-color: #dbeafe;
    font-weight: 600;
}

.clue-item.solved-clue {
    color: #059669;
    text-decoration: line-through;
    opacity: 0.7;
}

/* Peidetud input mobiili jaoks */
#crosswordInput {
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* Responsiivsus */
@media screen and (max-width: 1024px) {
    .solve-table td {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        max-width: 36px;
        max-height: 36px;
        font-size: 1.1rem;
    }
}

@media screen and (max-width: 768px) {
    .solve-table td {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        max-width: 30px;
        max-height: 30px;
        font-size: 0.95rem;
    }

    .cell-num {
        font-size: 0.45rem;
    }

    .crossword-clues-panel {
        max-height: none;
    }
}

@media screen and (max-width: 480px) {
    .solve-table td {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
        max-width: 26px;
        max-height: 26px;
        font-size: 0.85rem;
    }

    .cell-num {
        font-size: 0.4rem;
    }
}

/* ========================================
   TUMEDA REZIIMI STIILID
   ======================================== */
[data-theme="dark"] .crossword-grid-container {
    background: transparent;
}

[data-theme="dark"] .solve-cell {
    background: var(--bg-card, #1f2940);
    border-color: #4a5568;
    color: #e4e4e7;
}

[data-theme="dark"] .solve-cell:hover {
    background-color: #2d3a52;
}

[data-theme="dark"] .solve-cell-empty {
    background: transparent;
}

[data-theme="dark"] .solve-cell.solution-row {
    background: #2a3448;
}

[data-theme="dark"] .solve-cell.active {
    border-color: #60a5fa;
}

[data-theme="dark"] .solve-cell.active-word {
    background-color: #1e3a5f;
}

[data-theme="dark"] .solve-cell.solution-row.active-word {
    background-color: #1e3a5f;
}

[data-theme="dark"] .solve-cell.cell-correct {
    background-color: #064e3b !important;
    border-color: #34d399;
}

[data-theme="dark"] .solve-cell.cell-wrong {
    background-color: #7f1d1d !important;
    border-color: #f87171;
}

[data-theme="dark"] .solve-cell.cell-solved {
    background-color: #064e3b !important;
    border-color: #6ee7b7;
}

[data-theme="dark"] .solve-clue-bar {
    background: #1e3a5f;
    border-color: #2d4f7c;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .solve-clue-bar-text {
    color: #e4e4e7;
}

[data-theme="dark"] .solve-clue-bar-text.is-hint {
    color: #a1a1aa;
}

[data-theme="dark"] .solve-cell.solution-row.cell-solved {
    background-color: #573f0d !important;
    border-color: #f59e0b;
    color: #fde68a;
}

[data-theme="dark"] #puzzleGrid.is-complete .solve-cell.solution-row {
    background-color: #b45309 !important;
    color: #fffbeb;
    box-shadow: inset 0 0 0 2px #fbbf24;
}

[data-theme="dark"] .solve-cell.solution-row.cell-solved .cell-num,
[data-theme="dark"] #puzzleGrid.is-complete .solve-cell.solution-row .cell-num {
    color: #fde68a;
}

[data-theme="dark"] .cell-num {
    color: #9ca3af;
}

[data-theme="dark"] .solve-header {
    border-bottom-color: #4a5568;
}

[data-theme="dark"] .crossword-clues-panel {
    background: var(--bg-card, #1f2940);
    color: #e4e4e7;
}

[data-theme="dark"] .clues-section h3 {
    border-bottom-color: #60a5fa;
}

[data-theme="dark"] .clue-item:hover {
    background-color: #2d3a52;
}

[data-theme="dark"] .clue-item.active-clue {
    background-color: #1e3a5f;
}

[data-theme="dark"] .clue-item.solved-clue {
    color: #34d399;
}
