/**
 * Word Train - Game-specific styles
 * Chain Reaction style word association game
 */

/* Word Container Layout */
.wt-word-container {
    margin: 0;
    text-align: center;
    position: relative;
}

.wt-middle-container {
    padding: 2px 0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

/* Connector arrows between rows */
.wt-connector {
    font-size: 1.1em;
    color: #333;
    font-weight: 900;
    margin: 0;
    line-height: 1;
    height: 18px;
    text-shadow: 0 0 1px #333;
}

/* Labels for START/END */
.wt-word-label {
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 2px 0;
}

.wt-given-label {
    color: #FF9800;
}

/* Hidden connector for START word alignment */
.wt-connector-hidden {
    visibility: hidden;
}

/* Given words (top and bottom) */
.wt-given-row .puzzle-tile {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    border-color: #E65100;
    color: white;
    font-weight: bold;
}

.wt-given {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%) !important;
    border-color: #E65100 !important;
    color: white !important;
}

/* Locked rows (not yet accessible) */
.wt-locked {
    opacity: 0.4;
    pointer-events: none;
}

.wt-locked .puzzle-tile {
    background: #e0e0e0;
    border-color: #bdbdbd;
    cursor: not-allowed;
}

.wt-locked .wt-connector {
    color: #666;
    text-shadow: 0 0 1px #666;
}

/* Unlocked rows (accessible) */
.wt-unlocked {
    opacity: 1;
}

.wt-unlocked .puzzle-tile {
    cursor: pointer;
    background: #fff;
    border-color: #ccc;
    transition: all 0.2s ease;
}

.wt-unlocked .puzzle-tile:hover {
    border-color: #FF9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.2);
}

/* Active row highlight */
.wt-active {
    background: rgba(255, 152, 0, 0.08);
    border-radius: 8px;
}

.wt-active .wt-connector {
    color: #FF9800;
}

/* Completed rows */
.wt-completed .puzzle-tile,
.wt-correct .puzzle-tile {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%) !important;
    border-color: #2E7D32 !important;
    color: white !important;
    font-weight: bold;
}

.wt-completed .wt-connector,
.wt-correct .wt-connector {
    color: #4CAF50;
}

/* Revealed hint tiles */
.wt-revealed {
    background: #f5f5f5 !important;
    color: #666 !important;
    font-style: italic;
}

.wt-unlocked .wt-revealed,
.wt-active .wt-revealed {
    border-color: #FF9800 !important;
    background: #fff3e0 !important;
    color: #e65100 !important;
}

/* Loading hint animation */
.wt-hint-loading {
    animation: wt-pulse 0.8s ease-in-out infinite;
    color: #999 !important;
}

@keyframes wt-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Active tile cursor (override for Word Train) */
.wt-unlocked .puzzle-tile-active,
.wt-active .puzzle-tile-active {
    border-color: #FF9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
}

/* Filled tiles */
.wt-unlocked .puzzle-tile-filled,
.wt-active .puzzle-tile-filled {
    border-color: #666;
    background: #fafafa;
}

/* Hint confirmation popup - positioned near tile */
#wt-hint-confirm {
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 2px solid #FF9800;
    border-radius: 10px;
    padding: 12px 18px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    white-space: nowrap;
}

#wt-hint-confirm .hint-title {
    font-size: 1.05em;
    color: #e65100;
    font-weight: bold;
    margin-bottom: 5px;
}

#wt-hint-confirm .hint-remaining {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 10px;
}

#wt-hint-confirm .hint-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#wt-hint-confirm .hint-buttons button {
    padding: 6px 18px !important;
    font-size: 0.9em !important;
    margin: 0 !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Hint counter styles */
#wt-hint-counter {
    transition: all 0.3s ease;
}

/* Shake animation for incorrect answers */
.wt-middle-container .puzzle-tile-shake {
    animation: wtShake 0.5s ease;
}

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

/* Pop animation for correct answers */
.wt-correct .puzzle-tile {
    animation: wtPop 0.3s ease;
}

@keyframes wtPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .wt-word-container {
        margin: 0;
    }
    
    .wt-connector {
        font-size: 0.85em;
        height: 14px;
    }
    
    .wt-word-label {
        font-size: 0.65em;
    }
    
    #wt-hint-counter {
        font-size: 0.85em;
        padding: 5px 10px;
        margin-bottom: 8px;
    }
}

/* Compact mode for zoomed/narrow viewports - arrows on left */
@media (max-width: 340px) {
    /* Make container a horizontal flex row */
    .wt-word-container {
        display: flex;
        align-items: center;
        gap: 3px;
        margin: 0;
        justify-content: center;
    }
    
    .wt-middle-container {
        padding: 1px 0;
    }
    
    /* Arrow becomes inline on the left */
    .wt-connector {
        font-size: 0.8em;
        order: -1;
        min-width: 14px;
        width: 14px;
        height: auto;
        text-align: right;
        margin: 0;
    }
    
    /* Hide START/END labels in compact mode */
    .wt-word-label {
        display: none;
    }
    
    /* Tile row stays centered */
    .wt-word-container .puzzle-tile-row {
        flex: 0 0 auto;
    }
    
    /* Add balancing spacer on the right */
    .wt-word-container::after {
        content: '';
        min-width: 14px;
        width: 14px;
    }
    
    #wt-hint-counter {
        font-size: 0.75em;
        padding: 4px 8px;
        margin-bottom: 5px;
    }
    
    /* Reduce message spacing */
    #wt-message {
        margin: 5px 0 !important;
        min-height: 18px !important;
        font-size: 0.85em !important;
    }
    
    /* Tighten keyboard spacing */
    #wt-keyboard {
        margin: 8px auto !important;
    }
}

/* Game tile size adjustments for variable word lengths */
.wt-word-container .puzzle-tile {
    width: 44px;
    height: 44px;
    font-size: 1.4em;
    margin: 2px;
}

@media (max-width: 400px) {
    .wt-word-container .puzzle-tile {
        width: 38px;
        height: 38px;
        font-size: 1.2em;
        margin: 1px;
    }
}

@media (max-width: 340px) {
    .wt-word-container .puzzle-tile {
        width: 30px;
        height: 30px;
        font-size: 0.95em;
        margin: 1px;
    }
}

/* Ensure 6-letter words fit */
.wt-word-container[data-word-length="6"] .puzzle-tile {
    width: 40px;
    height: 40px;
    font-size: 1.3em;
}

@media (max-width: 400px) {
    .wt-word-container[data-word-length="6"] .puzzle-tile {
        width: 34px;
        height: 34px;
        font-size: 1.1em;
    }
}

@media (max-width: 340px) {
    .wt-word-container[data-word-length="6"] .puzzle-tile {
        width: 26px;
        height: 26px;
        font-size: 0.85em;
    }
}

