/* ===================================
   VLAK SVEZNALICA - Main Stylesheet
   =================================== */

/* Base Styles */
body {
    margin: 0;
    overflow: hidden;
    background-color: #f4e4bc;
    font-family: 'Patrick Hand', cursive;
    user-select: none;
}

/* UI Overlay */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    box-sizing: border-box;
}

/* HUD (dinamička pozicija i font iz config) */
.hud-panel {
    display: flex;
    justify-content: space-between;
    color: #333;
    position: relative;
}

.controls-hint {
    text-align: right;
    font-size: 18px;
    opacity: 0.7;
}

/* ================
   THROTTLE BAR
   ================ */
.throttle-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 150px;
    border: 3px solid #333;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    z-index: 500;
}

.throttle-fill {
    width: 100%;
    height: 0%;
    background: #333;
    transition: height 0.3s ease-out, background 0.2s;
}

.throttle-fill.accelerating {
    background: linear-gradient(180deg, #333 0%, #000 100%);
}

.throttle-fill.braking {
    background: linear-gradient(180deg, #ff3333 0%, #cc0000 100%);
}

.throttle-label {
    position: absolute;
    bottom: 180px;
    right: 20px;
    font-weight: bold;
    color: #333;
}

/* ================
   TEMPERATURE BAR
   ================ */
.temperature-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 40px;
    height: 150px;
    border: 3px solid #333;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    z-index: 500;
    pointer-events: all;
}

.temperature-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, #ff3333 0%, #ffaa00 50%, #4CAF50 100%);
    transition: height 0.1s, background 0.3s;
}

.temperature-label {
    position: absolute;
    bottom: 180px;
    left: 20px;
    font-weight: bold;
    color: #333;
    font-family: 'Patrick Hand', cursive;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 5px;
    border: 2px solid #333;
    pointer-events: none;
    user-select: none;
}

/* ================
   PROGRESS BARS
   ================ */
.station-progress {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 20px;
    border: 3px solid #333;
    border-radius: 10px;
    background: white;
}

.progress-fill {
    height: 100%;
    background: repeating-linear-gradient(45deg,
            #333,
            #333 10px,
            #666 10px,
            #666 20px);
    width: 0%;
    transition: width 0.1s;
}

/* Global Progress Bar */
.global-progress-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    background: rgba(255, 255, 255, 0.9);
    border: 4px solid #333;
    border-radius: 20px;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.global-progress-track {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.station-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}

.station-marker-dot {
    width: 20px;
    height: 20px;
    background: #ff6b6b;
    border: 3px solid #333;
    border-radius: 50%;
    margin-bottom: 5px;
}

.station-marker.completed .station-marker-dot {
    background: #4CAF50;
}

.station-marker-label {
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 4px;
    border: 2px solid #333;
    white-space: nowrap;
    font-family: 'Patrick Hand', cursive;
}

.train-position-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 2px;
    z-index: 3;
    transition: left 0.3s ease;
}

.mini-train-icon {
    width: 30px;
    height: 22px;
    background: url('assets/train.png') center/contain no-repeat;
    filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.3));
}

.mini-wagon-icon {
    width: 24px;
    height: 18px;
    background: url('assets/wagon.png') center/contain no-repeat;
    filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.3));
}

/* ================
   PUZZLE SCREEN
   ================ */
#puzzle-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(244, 228, 188, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    z-index: 10;
    padding: 10px;
    box-sizing: border-box;
}

#puzzle-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    height: 100%;
    justify-content: center;
}

#puzzle-top-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#puzzle-word-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#target-word-display {
    font-size: clamp(24px, 5vw, 40px);
    letter-spacing: clamp(3px, 1vw, 8px);
    margin-bottom: 10px;
    min-height: clamp(35px, 6vw, 50px);
    border-bottom: 3px dashed #333;
    padding: 5px 10px;
}

#letters-container {
    width: 95%;
    flex: 1;
    max-height: 50vh;
    min-height: 200px;
    position: relative;
    border: 2px solid #333;
    border-radius: 20px;
    background: white;
}

/* Mobile adjustments for puzzle */
@media (max-width: 768px) {
    #puzzle-top-section {
        flex-direction: column;
        gap: 10px;
    }
    
    #word-image {
        font-size: clamp(50px, 12vw, 80px);
        min-height: 80px;
    }
    
    #target-word-display {
        font-size: clamp(20px, 6vw, 32px);
        letter-spacing: clamp(2px, 1.5vw, 6px);
    }
    
    #letters-container {
        max-height: 45vh;
        min-height: 250px;
    }
    
    .letter-bubble {
        width: clamp(45px, 12vw, 65px);
        height: clamp(45px, 12vw, 65px);
        font-size: clamp(20px, 6vw, 32px);
    }
    
    .station-name-header {
        font-size: clamp(14px, 4vw, 20px);
        padding: 4px 10px;
    }
    
    .skip-station-btn {
        font-size: clamp(16px, 4vw, 20px);
        padding: 10px 20px;
    }
}

.letter-bubble {
    position: absolute;
    width: clamp(50px, 10vw, 70px);
    height: clamp(50px, 10vw, 70px);
    border-radius: 50%;
    border: 3px solid #333;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(24px, 5vw, 36px);
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 3px 3px 0px #333;
    transform: translate(-50%, -50%);
    transition: transform 0.1s;
    user-select: none;
}

.letter-bubble:active {
    transform: translate(-50%, -50%) translate(2px, 2px);
    box-shadow: 1px 1px 0px #333;
}

.skip-station-btn {
    margin-top: 10px;
    padding: 8px 16px;
    font-size: clamp(14px, 3vw, 18px);
    font-family: 'Patrick Hand', cursive;
    background: #e74c3c;
    color: white;
    border: 3px solid #c0392b;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.skip-station-btn:hover {
    background: #c0392b;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #333;
    padding: 15px;
    font-size: clamp(20px, 5vw, 30px);
    display: none;
    box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.2);
    max-width: 90%;
    text-align: center;
}

#word-image {
    font-size: clamp(40px, 8vw, 60px);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 100px;
    max-width: 512px;
    max-height: 512px;
}

#word-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.station-name-header {
    margin: 0 0 10px 0;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 15px;
    border-radius: 10px;
    border: 3px solid #333;
    font-size: clamp(16px, 3vw, 24px);
}

.puzzle-instruction {
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: clamp(14px, 3vw, 18px);
}

/* ================
   ANIMATIONS
   ================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translate(-50%, -50%) translateX(0) rotate(0deg) scale(1);
    }
    10% {
        transform: translate(-50%, -50%) translateX(-2px) rotate(-2deg) scale(1.03);
    }
    20% {
        transform: translate(-50%, -50%) translateX(2px) rotate(2deg) scale(0.97);
    }
    30% {
        transform: translate(-50%, -50%) translateX(-2px) rotate(-3deg) scale(1.05);
    }
    40% {
        transform: translate(-50%, -50%) translateX(2px) rotate(3deg) scale(0.95);
    }
    50% {
        transform: translate(-50%, -50%) translateX(-2px) rotate(-2deg) scale(1.03);
    }
    60% {
        transform: translate(-50%, -50%) translateX(2px) rotate(2deg) scale(0.97);
    }
    70% {
        transform: translate(-50%, -50%) translateX(-2px) rotate(-3deg) scale(1.05);
    }
    80% {
        transform: translate(-50%, -50%) translateX(2px) rotate(3deg) scale(0.95);
    }
    90% {
        transform: translate(-50%, -50%) translateX(-2px) rotate(-2deg) scale(1.02);
    }
}

.letter-bubble.hint {
    animation: shake 2s ease-in-out infinite;
    border-color: #FFD700 !important;
    box-shadow: 0 0 15px #FFD700 !important;
}

/* ================
   BUTTONS
   ================ */
.station-label {
    color: #333;
    font-family: 'Patrick Hand', cursive;
    font-size: 24px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border: 3px solid #333;
    border-radius: 10px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
    pointer-events: none;
    user-select: none;
}

.menu-button {
    position: absolute;
    padding: 12px 25px;
    font-family: 'Patrick Hand', cursive;
    font-weight: bold;
    background: #3498db;
    color: white;
    border: 3px solid #2980b9;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    z-index: 500;
    transition: all 0.2s;
    pointer-events: auto;
}

.menu-button:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3);
}

/* Settings Button */
.settings-button {
    position: absolute;
    top: 20px;
    right: 80px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
    z-index: 1000;
    user-select: none;
    transition: transform 0.1s;
    pointer-events: all;
}

.settings-button:hover {
    transform: scale(1.1);
}

.settings-button:active {
    transform: scale(0.95);
}

/* Help Button */
.help-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
    z-index: 1000;
    user-select: none;
    transition: transform 0.1s;
    pointer-events: all;
}

.help-button:hover {
    transform: scale(1.1);
}

.help-button:active {
    transform: scale(0.95);
}

/* ================
   MOBILE CONTROLS
   ================ */
.mobile-controls-container {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 150px;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    box-sizing: border-box;
    z-index: 1000;
}

.control-group {
    display: flex;
    gap: 20px;
    pointer-events: auto;
    align-items: flex-end;
}

.control-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    user-select: none;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
    background-size: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
}

.control-btn:active {
    transform: scale(0.95);
    filter: brightness(0.8);
}

.btn-brake {
    background-color: #ff4444;
    background-image: url('assets/btn_brake.png');
}

.btn-horn {
    width: 80px;
    height: 80px;
    background-color: #ffeb3b;
    background-image: url('assets/btn_horn.png');
    margin-bottom: 10px;
}

.btn-forward {
    background-color: #4CAF50;
    background-image: url('assets/btn_forward.png');
}

.btn-turbo {
    width: 80px;
    height: 80px;
    background-color: #2196F3;
    background-image: url('assets/btn_turbo.png');
    margin-bottom: 10px;
}

/* ================
   TOGGLE SWITCH
   ================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Old Switch Styles (compatibility) */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border: 2px solid #333;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border: 2px solid #333;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ================
   ORIENTATION WARNING
   ================ */
#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #333;
    color: white;
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

@media screen and (orientation: portrait) {
    #orientation-warning {
        display: flex;
    }
}

/* ================
   MOBILE RESPONSIVE
   ================ */
@media (max-width: 768px) {
    .settings-button {
        top: 10px;
        right: 70px;
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .help-button {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
    
    .temperature-container {
        bottom: 10px;
        left: 10px;
        width: 35px;
        height: 120px;
    }
    
    .temperature-label {
        bottom: 140px;
        left: 10px;
        font-size: 14px;
        padding: 3px 6px;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .temperature-container {
        height: 100px;
    }
    
    .temperature-label {
        bottom: 110px;
        font-size: 12px;
    }
}
