/**
 * bloco-caca-palavras.css
 * Estilos autocontidos para o Bloco Gutenberg de Caça-Palavras
 * Todos os seletores têm escopo via .bloco-cp-wrapper para evitar conflitos
 */

/* =====================================================
   Container Principal
   ===================================================== */

.bloco-cp-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 30px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bloco-cp-wrapper *,
.bloco-cp-wrapper *::before,
.bloco-cp-wrapper *::after {
    box-sizing: border-box;
}

/* =====================================================
   Barra de Dificuldade
   ===================================================== */

.bloco-cp-wrapper .cp-difficulty-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    background: #f8fdff;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #e0f2f1;
    flex-wrap: wrap;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.bloco-cp-wrapper .cp-difficulty-label {
    font-size: 1.1rem;
    color: #456;
    text-align: center;
}

.bloco-cp-wrapper .cp-difficulty-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85rem;
    margin-left: 5px;
}

.bloco-cp-wrapper .cp-diff-facil .cp-difficulty-badge {
    background-color: #d1fae5;
    color: #065f46;
}

.bloco-cp-wrapper .cp-diff-medio .cp-difficulty-badge {
    background-color: #dbeafe;
    color: #1e40af;
}

.bloco-cp-wrapper .cp-diff-dificil .cp-difficulty-badge {
    background-color: #fee2e2;
    color: #991b1b;
}

.bloco-cp-wrapper .cp-difficulty-options {
    display: flex;
    gap: 10px;
    align-items: center;
}

.bloco-cp-wrapper .cp-btn-difficulty {
    text-decoration: none !important;
    background-color: #fff;
    border: 2px solid #7cb9b9;
    color: #2c4747 !important;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
}

.bloco-cp-wrapper .cp-btn-difficulty:hover {
    background-color: #7cb9b9;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(124, 185, 185, 0.4);
}

@media (max-width: 600px) {
    .bloco-cp-wrapper .cp-difficulty-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .bloco-cp-wrapper .cp-difficulty-options {
        justify-content: center;
        width: 100%;
    }
}

/* =====================================================
   Timer — Modo Difícil
   ===================================================== */

.bloco-cp-wrapper .cp-timer-container {
    display: none;
    max-width: 500px;
    width: 90%;
    margin: 0 auto 20px auto;
    background-color: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 2px solid #e0f2f1;
}

.bloco-cp-wrapper .cp-timer-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bloco-cp-wrapper .cp-timer-text {
    font-size: 1.1rem;
    font-weight: bold;
    color: #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.bloco-cp-wrapper .cp-timer-counter {
    font-size: 1.3rem;
    color: #1a5555;
    font-family: monospace;
}

.bloco-cp-wrapper .cp-timer-progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.bloco-cp-wrapper .cp-timer-progress-fill {
    height: 100%;
    background-color: #10b981;
    border-radius: 4px;
    width: 100%;
    transition: width 1s linear, background-color 0.5s ease;
}

.bloco-cp-wrapper .cp-timer-progress-fill.warning {
    background-color: #f59e0b;
}

.bloco-cp-wrapper .cp-timer-progress-fill.danger {
    background-color: #ef4444;
    animation: cpPulseRed 1s infinite alternate;
}

.bloco-cp-wrapper .cp-timer-bonus-popup {
    font-size: 1.1rem;
    font-weight: bold;
    color: #10b981;
    margin-left: 8px;
    opacity: 0;
    display: inline-block;
    vertical-align: middle;
}

.bloco-cp-wrapper .cp-timer-bonus-popup.animate {
    animation: cpFloatUpBonus 1.2s ease-out forwards;
}

/* =====================================================
   Overlay de Início — Modo Difícil
   ===================================================== */

.bloco-cp-wrapper .cp-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
    animation: cpFadeInOverlay 0.3s ease-out forwards;
}

.bloco-cp-wrapper .cp-start-content {
    background-color: #ffffff;
    border: 3px solid #ffca85;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: scale(0.9);
    animation: cpPopIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.bloco-cp-wrapper .cp-start-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
    animation: cpPulseIcon 2s infinite ease-in-out;
}

.bloco-cp-wrapper .cp-start-overlay h3 {
    margin: 0 0 10px 0;
    color: #b45309;
    font-size: 1.5rem;
    font-weight: bold;
}

.bloco-cp-wrapper .cp-start-overlay p {
    color: #4b5563;
    font-size: 1rem;
    margin: 0 0 15px 0;
}

.bloco-cp-wrapper .cp-bonus-notice {
    font-size: 0.95rem;
    font-weight: bold;
    color: #10b981;
    background-color: #ecfdf5;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px dashed #a7f3d0;
    margin-bottom: 20px !important;
}

/* =====================================================
   Game Container, Grid e Cells
   ===================================================== */

.bloco-cp-wrapper .cp-game-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    position: relative;
}

.bloco-cp-wrapper .cp-grid-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #eaf2f2;
    border-radius: 5px;
    min-width: 465px;
    min-height: 465px;
    color: #666;
    border: 2px dashed #7cb9b9;
}

.bloco-cp-wrapper .cp-loading-spinner {
    border: 4px solid #ccc;
    border-top: 4px solid #7cb9b9;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: cpSpin 1s linear infinite;
    margin-bottom: 10px;
}

.bloco-cp-wrapper .cp-word-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-size, 13), 35px);
    gap: 2px;
    background-color: #7cb9b9;
    padding: 5px;
    z-index: 10;
}

.bloco-cp-wrapper .cp-grid-cell {
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s, transform 0.1s;
    background-color: #ecfff2;
    border-radius: 2px;
    font-size: 0.95rem;
}

.bloco-cp-wrapper .cp-grid-cell:hover {
    background-color: #a0e9eb;
    transform: scale(1.1);
}

.bloco-cp-wrapper .cp-grid-cell.selected {
    background-color: #a0e9eb;
    transition: background-color 0.1s, transform 0.1s;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.bloco-cp-wrapper .cp-grid-cell.found-word {
    background-color: #90EE90;
    transform: none;
}

.bloco-cp-wrapper .cp-grid-cell.found-word:hover {
    background-color: #90EE90;
    transform: none;
}

.bloco-cp-wrapper .cp-grid-cell.gabarito-visible {
    background-color: #ffeb3b !important;
    color: #000;
    box-shadow: inset 0 0 0 2px #fbc02d;
}

/* Modo fácil: cells maiores */
.bloco-cp-wrapper .cp-easy-mode-grid .cp-grid-cell {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
}

.bloco-cp-wrapper .cp-word-grid.cp-easy-mode-grid {
    grid-template-columns: repeat(var(--grid-size, 10), 45px);
}

/* Blur para modo difícil */
.bloco-cp-wrapper .cp-blurred {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.3s ease;
}

/* =====================================================
   Word List
   ===================================================== */

.bloco-cp-wrapper .cp-word-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    justify-content: center;
    background-color: #3e999d;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.bloco-cp-wrapper .cp-word-item {
    font-size: .85rem;
    padding: 5px;
    line-height: normal;
    transition: all 0.5s;
    background-color: #9dd6d6ff;
    border-radius: 5px;
    font-weight: bold;
    letter-spacing: .15rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.bloco-cp-wrapper .cp-word-item.found {
    color: #2c4747;
    background-color: #82fdff;
    transform: scale(1.05);
    font-weight: bold;
    box-shadow: 0 0 10px #aaffff;
}

.bloco-cp-wrapper .cp-word-item.found::after {
    content: '✓';
    position: absolute;
    z-index: 10;
    top: -50%;
    right: 5px;
    color: #ff0f0f;
    font-size: 1.75rem;
    animation: cpBounce 0.5s;
}

/* =====================================================
   Botões de Ação
   ===================================================== */

.bloco-cp-wrapper .cp-btn {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 15px 30px;
    background-color: #ffd880;
    color: black;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 3px #e58f0f;
    width: 100%;
}

.bloco-cp-wrapper .cp-btn:hover {
    background-color: #ffca50;
    transform: translateY(-1px);
}

.bloco-cp-wrapper .cp-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px #e58f0f;
}

.bloco-cp-wrapper .cp-btn-gabarito {
    background-color: #fff;
    border: 2px solid #ffd880;
    color: #d97706;
}

.bloco-cp-wrapper .cp-btn-gabarito:hover {
    background-color: #fff8e8;
}

.bloco-cp-wrapper .cp-btn .cp-btn-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, .3);
    border-radius: 50%;
    border-top-color: #000;
    animation: cpSpin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}

.bloco-cp-wrapper .cp-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

/* =====================================================
   Feedback de Sucesso
   ===================================================== */

.cp-success-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min-content;
    transform: translate(-50%, -50%) scale(0.5);
    background-color: #90EE90;
    color: black;
    text-align: center;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 2rem;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cp-success-feedback.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* =====================================================
   Tela de Parabéns / Confetti
   ===================================================== */

.cp-congrats-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background-color 0.5s ease-in-out;
    pointer-events: none;
    overflow: hidden;
}

.cp-congrats-screen.visible {
    display: flex;
    font-weight: 900;
    text-transform: uppercase;
    color: white;
    font-size: 4rem;
    pointer-events: auto;
}

.cp-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1001;
}

.cp-confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--color);
    top: -10px;
    z-index: 1001;
    animation: cpConfetti var(--duration) ease-in forwards;
    will-change: transform;
}

/* =====================================================
   Responsividade Mobile
   ===================================================== */

@media (max-width: 768px) {
    .bloco-cp-wrapper .cp-game-container {
        flex-direction: column;
        align-items: center;
        padding: 0;
    }

    .bloco-cp-wrapper .cp-word-grid {
        width: 100%;
        max-width: 100%;
        grid-template-columns: repeat(var(--grid-size, 13), 1fr);
        gap: 1px;
        touch-action: none;
        padding: 2px;
    }

    .bloco-cp-wrapper .cp-grid-cell {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        font-size: clamp(8px, 3vw, 14px);
        min-width: 0;
    }

    .bloco-cp-wrapper .cp-word-list {
        width: 100%;
    }

    .bloco-cp-wrapper .cp-word-item {
        font-size: 14px;
        padding: 3px 6px;
    }

    .bloco-cp-wrapper .cp-grid-placeholder {
        min-width: 90%;
        min-height: 300px;
    }

    .bloco-cp-wrapper .cp-easy-mode-grid .cp-grid-cell {
        font-size: clamp(12px, 5vw, 18px);
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .bloco-cp-wrapper .cp-word-grid.cp-easy-mode-grid {
        grid-template-columns: repeat(var(--grid-size, 10), 1fr);
    }
}

@media (max-width: 480px) {
    .bloco-cp-wrapper .cp-word-grid {
        padding: 1px;
        gap: 2px;
    }

    .bloco-cp-wrapper .cp-word-list {
        flex-direction: initial !important;
        flex-wrap: wrap;
        justify-content: center;
        border-radius: 0 !important;
    }

    .bloco-cp-wrapper .cp-grid-cell {
        font-size: clamp(10px, 4vw, 14px);
        font-weight: bold;
    }

    .bloco-cp-wrapper .cp-word-item {
        font-size: 14px;
        padding: 5px 8px;
    }
}


/* =====================================================
   Frontend Preview Card
   ===================================================== */

.bloco-cp-wrapper .cp-preview {
    border: 2px dashed #7cb9b9;
    border-radius: 10px;
    padding: 30px 20px;
    background: #f8fdff;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.bloco-cp-wrapper .cp-preview-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

.bloco-cp-wrapper .cp-preview-title {
    font-size: 1.5rem !important;
    font-weight: bold !important;
    color: #2c4747 !important;
    margin: 0 auto 15px auto !important;
    font-family: inherit;
    text-align: center;
    display: block;
}

.bloco-cp-wrapper .cp-preview-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 15px 0;
}

.bloco-cp-wrapper .cp-preview-word-chip {
    background: #9dd6d6;
    color: #2c4747;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    display: inline-block;
}

.bloco-cp-wrapper .cp-preview-difficulty {
    margin-top: 15px;
    font-size: 0.95rem;
    color: #666;
}

.bloco-cp-wrapper .cp-preview-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 12px 25px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    width: auto;
    min-width: 200px;
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-jogar {
    background-color: #ffd880;
    color: black;
    border: none;
    box-shadow: 0 3px #e58f0f;
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-jogar:hover {
    background-color: #ffca50;
    transform: translateY(-1px);
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-jogar:active {
    transform: translateY(2px);
    box-shadow: 0 1px #e58f0f;
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-print {
    background-color: #fff;
    border: 2px solid #ffd880;
    color: #d97706;
    box-shadow: 0 3px #ffd88022;
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-print:hover {
    background-color: #fff8e8;
    transform: translateY(-1px);
}

.bloco-cp-wrapper .cp-preview-actions .cp-btn-print:active {
    transform: translateY(2px);
}

/* =====================================================
   Editor Gutenberg — Preview
   ===================================================== */


.bloco-caca-palavras-editor {
    border: 2px dashed #7cb9b9;
    border-radius: 10px;
    padding: 20px;
    background: #f8fdff;
    text-align: center;
}

.bloco-caca-palavras-editor .cp-editor-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.bloco-caca-palavras-editor .cp-editor-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c4747;
    margin-bottom: 15px;
}

.bloco-caca-palavras-editor .cp-editor-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
}

.bloco-caca-palavras-editor .cp-editor-word-chip {
    background: #9dd6d6;
    color: #2c4747;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.bloco-caca-palavras-editor .cp-editor-difficulty {
    margin-top: 12px;
    font-size: 0.9rem;
    color: #666;
}

.bloco-caca-palavras-editor .placeholder {
    color: #999;
    font-style: italic;
    padding: 40px 20px;
}

/* =====================================================
   Keyframes
   ===================================================== */

@keyframes cpBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes cpConfetti {
    0% { transform: translate(0, 0) rotateX(0) rotateY(0); }
    100% { transform: translate(var(--translate-x), 100vh) rotateX(360deg) rotateY(360deg); }
}

@keyframes cpSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes cpPulseRed {
    0% { opacity: 0.8; }
    100% { opacity: 1; }
}

@keyframes cpFloatUpBonus {
    0% { opacity: 0; transform: translateY(0); }
    20% { opacity: 1; transform: translateY(-5px); }
    80% { opacity: 1; transform: translateY(-10px); }
    100% { opacity: 0; transform: translateY(-20px); }
}

@keyframes cpFadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cpPopIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes cpPulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* =====================================================
   Transitions & Animations
   ===================================================== */

.bloco-cp-wrapper .cp-game-area.cp-active {
    display: block !important;
    animation: cpSlideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cpSlideUpFade {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

