/**
 * Style dla poziomu I - Węże Polski
 * Specjalne style dla mechaniki poziomu pierwszego
 */

/* Główny kontener poziomu I */
.level1-game {
    border-radius: 20px;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* Nagłówek gry */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border:0;
    order: 2; /* przenieś statystyki niżej */
}

.snake-info h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 700;
}

.scientific-name {
    font-style: italic;
    color: #7f8c8d;
    font-size: 1rem;
    margin-bottom: 5px;
}

.habitat {
    color: #34495e;
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Style dla ukrytych informacji o wężu */
.snake-name-hidden,
.scientific-name-hidden,
.habitat-hidden {
    color: #bdc3c7;
    font-style: italic;
    opacity: 0.7;
}

.snake-name-revealed,
.scientific-name-revealed,
.habitat-revealed {
    animation: revealInfo 0.8s ease-in-out;
}

.snake-info-revealed {
    animation: revealContainer 0.6s ease-in-out;
}

@keyframes revealInfo {
    0% {
        opacity: 0.3;
        transform: scale(0.95);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes revealContainer {
    0% {
        background-color: transparent;
    }
    100% {
        background-color: rgba(46, 204, 113, 0.1);
        border-radius: 8px;
        padding: 10px;
    }
}

/* Statystyki gry */
.game-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    min-width: 80px;
}

.stat-item .label {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-item .value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #2c3e50;
}

.stat-item.no-attempts .value {
    color: #dc3545;
}

/* Zawartość gry */
.game-content {
    display: block;
    margin-bottom: 30px;
    order: 1; /* wąż wyżej */
}

/* Ułóż sekcję z instrukcjami, przyciskami i obrazkami w kolumnie
   i przenieś przyciski nad boxy z obrazkami */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.game-area .instructions { order: 1; }
.game-area .game-controls { order: 2; }
.game-area .images-container { order: 3; }

/* Wizualizacja węża */
.snake-visualization-container {
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    width: 100%;
}

.snake-visualization {
    position: relative;
    width: 100%;
    min-height: 440px;
    aspect-ratio: 16/12;
    overflow: visible;
}

/* Płynne odpełznięcie w lewo (od strony głowy) */
/* usunięto animację slide-left */

/* Segmentowe odpełznięcie: każdy segment znika w lewo z opóźnieniem */
/* usunięto animację segmentową */

/* Animacje pełzania wyłączone */

.snake-visualization img {
    max-width: 100%;
    height: auto;
    transition: all 0.5s ease;
    filter: grayscale(100%);
    position: relative;
    z-index: 1;
}

.letters-overlay {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    z-index: 3;
}

/* Style dla HTML inputów z position: absolute */
.letter-input-container {
    position: absolute;
    pointer-events: auto;
    cursor: text;
    width: 40px;
    height: 40px;
}

.letter-input-absolute {
    width: 100%;
    height: 100%;
    border: 2px solid #3a2b29;
    background: transparent;
    color: #111;
    font-weight: 800;
    font-size: 24px;
    text-align: center;
    outline: none;
    border-radius: 4px;
    box-sizing: border-box;
    padding: 0;
}

.letter-input-absolute:focus {
    border-color: #4A3B2E;
    box-shadow: 0 0 5px rgba(74, 59, 46, 0.5);
}

.letter-input-container.correct .letter-input-absolute {
    background: transparent;
    border-color: #4A3B2E;
}

.letter-input-container.word-start .letter-input-absolute {
    animation: glow-start 2s infinite;
}


.letters-overlay .cell-0 {
    top: 125px;
    left: 614px;
    width: 40px;
    height: 40px;
    transform: rotate(46deg);
    transform-origin: center;
}
.letters-overlay .cell-1 {
    top: 200px;
    left: 645px;
    width: 40px;
    height: 40px;
    transform: rotate(50deg);
    transform-origin: center;
}
.letters-overlay .cell-2 {
    top: 250px;
    left: 690px;
    width: 40px;
    height: 40px;
    transform-origin: center;
}
.letters-overlay .cell-3 {
    top: 230px;
    left: 760px;
    width: 40px;
    height: 40px;
    transform: rotate(-15deg);
    transform-origin: center;
}
.letters-overlay .cell-4 {
    top: 210px;
    left: 838px;
    width: 40px;
    height: 40px;
    transform: rotate(12deg);
    transform-origin: center;
}
.letters-overlay .cell-5 {
    top: 225px;
    left: 900px;
    width: 40px;
    height: 40px;
    transform: rotate(45deg);
    transform-origin: center;
}
.letters-overlay .cell-6 {
    top: 274px;
    left: 930px;
    width: 40px;
    height: 40px;
    transform: rotate(77deg);
    transform-origin: center;
}
.letters-overlay .cell-7 {
    top: 327px;
    left: 900px;
    width: 40px;
    height: 40px;
    transform: rotate(-31deg);
    transform-origin: center;
}
.letters-overlay .cell-8 {
    top: 360px;
    left: 850px;
    width: 40px;
    height: 40px;
    transform: rotate(-25deg);
    transform-origin: center;
}
.letters-overlay .cell-9 {
    top: 368px;
    left: 773px;
    width: 40px;
    height: 40px;
    transform-origin: center;
}
.letters-overlay .cell-10 {
    top: 362px;
    left: 700px;
    width: 40px;
    height: 40px;
    transform: rotate(14deg);
    transform-origin: center;
}
.letters-overlay .cell-11 {
    top: 338px;
    left: 625px;
    width: 40px;
    height: 40px;
    transform: rotate(35deg);
    transform-origin: center;
}
.letters-overlay .cell-12 {
    top: 295px;
    left: 560px;
    width: 40px;
    height: 40px;
    transform: rotate(36deg);
    transform-origin: center;
}
.letters-overlay .cell-13 {
    top: 262px;
    left: 495px;
    width: 40px;
    height: 40px;
    transform: rotate(25deg);
    transform-origin: center;
}
.letters-overlay .cell-14 {
    top: 253px;
    left: 420px;
    width: 40px;
    height: 40px;
    transform: rotate(-9deg);
    transform-origin: center;
}
.letters-overlay .cell-15 {
    top: 267px;
    left: 354px;
    width: 40px;
    height: 40px;
    transform: rotate(-34deg);
    transform-origin: center;
}
.letters-overlay .cell-16 {
    top: 297px;
    left: 305px;
    width: 40px;
    height: 40px;
    transform: rotate(-55deg);
    transform-origin: center;
}
.letters-overlay .cell-17 {
    top: 346px;
    left: 286px;
    width: 40px;
    height: 40px;
    transform: rotate(0deg);
    transform-origin: center;
}
.letters-overlay .cell-18 {
    top: 397px;
    left: 304px;
    width: 40px;
    height: 40px;
    transform: rotate(56deg);
    transform-origin: center;
}
.letters-overlay .cell-19 {
    top: 430px;
    left: 352px;
    width: 40px;
    height: 40px;
    transform: rotate(38deg);
    transform-origin: center;
}
.letters-overlay .cell-20 {
    top: 460px;
    left: 411px;
    width: 40px;
    height: 40px;
    transform: rotate(27deg);
    transform-origin: center;
}
.letters-overlay .cell-21 {
    top: 477px;
    left: 477px;
    width: 40px;
    height: 40px;
    transform: rotate(9deg);
    transform-origin: center;
}
.letters-overlay .cell-22 {
    top: 479px;
    left: 554px;
    width: 40px;
    height: 40px;
    transform: rotate(-7deg);
    transform-origin: center;
}
.letters-overlay .cell-23 {
    top: 458px;
    left: 628px;
    width: 40px;
    height: 40px;
    transform: rotate(-11deg);
    transform-origin: center;
}
.letters-overlay .cell-24 {
    top: 450px;
    left: 698px;
    width: 40px;
    height: 40px;
    transform: rotate(2deg);
    transform-origin: center;
}
.letters-overlay .cell-25 {
    top: 466px;
    left: 762px;
    width: 40px;
    height: 40px;
    transform: rotate(25deg);
    transform-origin: center;
}
.letters-overlay .cell-26 {
    top: 491px;
    left: 818px;
    width: 40px;
    height: 40px;
    transform: rotate(35deg);
    transform-origin: center;
}
.letters-overlay .cell-27 {
    top: 522px;
    left: 856px;
    width: 40px;
    height: 40px;
    transform: rotate(40deg);
    transform-origin: center;
}

.letters-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    overflow: visible;
}

.letter-input-svg {
    border: none;
    background: transparent;
    color: #111;
    font-weight: 800;
    font-size: 100%; /* Skaluje się z rozmiarem foreignObject */
    line-height: 1em;
    width: 100%; /* Wypełnia cały foreignObject */
    height: 100%; /* Wypełnia cały foreignObject */
    text-align: center;
    outline: none !important;
    text-shadow: none !important;
    overflow: visible;
    padding: 0;
    box-sizing: border-box;
}

.letter-input-svg:focus,
.letter-input-svg:focus-visible,
.letter-input-svg:focus-within {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Usuń wszystkie możliwe focus style */
input.letter-input-svg:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

.letter-segment-group {
    cursor: text;
}

.letter-segment-group.word-start {
    animation: glow-start 2s infinite;
}

.letter-segment-group.correct {
    animation: correct-glow 1s ease-in-out;
}

/* SVG polygon dla poprawnych segmentów używa fill="url(#snake-skin-pattern)" zamiast background */

@keyframes correct-glow {
    0% { 
        filter: brightness(1);
        transform: scale(1);
    }
    50% { 
        filter: brightness(1.2);
        transform: scale(1.05);
    }
    100% { 
        filter: brightness(1);
        transform: scale(1);
    }
}

@keyframes glow-start {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.snake-head {
    pointer-events: none;
    z-index: 4;
}

.snake-head image {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.snake-section.overlay {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 32%;
    max-width: 320px;
    pointer-events: auto; /* włącz interakcje z inputami */
    background: transparent;
    border: none;
    padding: 0;
}

.snake-section.overlay .section-number {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
}

.snake-section.overlay .word-input {
    background: rgba(255,255,255,0.9);
}

.snake-visualization.quarter-complete img {
    filter: grayscale(75%);
}

.snake-visualization.half-complete img {
    filter: grayscale(50%);
}

.snake-visualization.almost-complete img {
    filter: grayscale(25%);
}

.snake-visualization.completed img {
    filter: grayscale(0%);
    transform: scale(1.05);
}

/* Pasek postępu węża */
.snake-progress {
    margin-top: 20px;
    width: 100%;
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #e9ecef;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.progress-text {
    text-align: center;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

/* Obszar gry */
.game-area {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.instructions {
    background: #e3f2fd;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border-left: 5px solid #2196f3;
}

.instructions h3 {
    color: #1976d2;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.instructions p {
    color: #424242;
    margin-bottom: 10px;
    line-height: 1.5;
}

.example {
    margin-top: 10px;
    padding: 10px;
    background: rgba(33, 150, 243, 0.1);
    border-radius: 5px;
}

.example strong {
    color: #1976d2;
}

.word-chain {
    color: #1976d2;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Kontener obrazków słów */
.images-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.word-image {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.word-image:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.word-image:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    transform: translateY(-3px);
}

.word-image.selected {
    border-color: #28a745;
    background: #d4edda;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.3);
}

.word-image img {
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.word-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
    font-size: 1rem;
}

.word-description {
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.3;
}

/* Sekcje węża */
.snake-sections {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.snake-section {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    position: relative;
}

.snake-section:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.snake-section.completed {
    border-color: #8B4513;
    background-image: url('../images/grafika/skora.png');
    background-repeat: repeat;
    color: #2F1B14;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.section-number {
    position: absolute;
    top: -10px;
    left: 15px;
    background: #667eea;
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.word-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.word-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.word-input.correct {
    border-color: #8B4513;
    background-image: url('../images/grafika/skora.png');
    background-repeat: repeat;
    color: #2F1B14;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.word-input.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

.section-feedback {
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 20px;
}

.section-feedback.correct {
    color: #28a745;
}

.section-feedback.incorrect {
    color: #dc3545;
}

.section-feedback.partial {
    color: #ffc107;
}

/* Kontrolki gry */
.game-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.submit-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 150px;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

.submit-btn:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

.submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.hint-btn {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hint-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(23, 162, 184, 0.3);
}

.hint-btn:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

.restart-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

.restart-btn:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

/* Obszar feedback */
.feedback-area {
    margin-top: 20px;
    display: none; /* Ukryte domyślnie */
}

.feedback-message {
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.feedback-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

.feedback-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffc107;
}

.feedback-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 2px solid #17a2b8;
}

.feedback-message.partial {
    background: #ffeaa7;
    color: #856404;
    border: 2px solid #ffc107;
}

/* Modal instrukcji */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-body {
    padding: 16px 20px;
}

.modal-body ol {
    padding-left: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px 20px;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* Stylowanie ekranu ukończenia przeniesione do main.css */

/* Animacje */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes celebration {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(5deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(102, 126, 234, 0.5); }
    50% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.8); }
    100% { box-shadow: 0 0 5px rgba(102, 126, 234, 0.5); }
}

.word-input.correct {
    animation: pulse 0.5s ease;
}

.word-input.incorrect {
    animation: shake 0.5s ease;
}

.snake-visualization.completed {
    animation: celebration 1s ease;
}

/* Animacja pełzania węża - efekt ciągłego ruchu w prawo */
.snake-visualization.crawling {
    overflow: visible;
    /* Kontener bez animacji - segmenty same się poruszają */
}

/* Animacje pełzania usunięte */

/* Opóźnienia animacji usunięte */

/* Keyframes usunięte */

/* Keyframes usunięte */


.word-image:hover {
    animation: glow 2s infinite;
}

/* Responsywność dla poziomu I */
@media screen and (max-width: 768px) {
    .level1-game {
        padding: 20px 15px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .game-stats {
        justify-content: center;
    }
    
    .game-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .snake-visualization-container {
        min-height: 300px;
    }
    
    .images-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .snake-sections {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .game-controls {
        flex-direction: column;
    }
    
    .submit-btn,
    .hint-btn,
    .restart-btn {
        width: 100%;
    }
}

/* Placeholder styles for missing images */
.placeholder-image {
    display: none;
    width: 100%;
    height: 200px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
    text-align: center;
    border-radius: 10px;
    margin: 10px 0;
}

.placeholder-word {
    display: none;
    width: 100%;
    height: 80px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    align-items: center;
    justify-content: center;
    color: #495057;
    font-size: 12px;
    flex-direction: column;
    border-radius: 8px;
    margin: 5px 0;
}

/* Zapewnij, że kontrolki gry są widoczne na poziomie 1 */
.level1-game .game-controls {
    display: flex !important;
}

.placeholder-image.show,
.placeholder-word.show {
    display: flex !important;
}
