-# Game grid variablesb
-# Make sure these are reflected in the SASS.
- rows = 4;
- columns = 12;
- tilesPerSegment = 3;
- tilePerSegmentVertical = 7;
- hasIntro = true;
- hasLoader = true;

-# Game
.game
    -# Loader
    - if(hasLoader == true)
        .game_loader
            .game_loader__inner
                .logo
                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/mineLogo.gif'}
                .subtitle
                    %h1 A no JS Adventure game
                .bar
                    .bar_inner
                %span Loading checkboxes...
    -# Intro
    - if(hasIntro == true)
        .game_intro 
            %input#intro-1{:class => 'dialogue', :type => 'radio', :name => 'intro', :checked => 'checked'}
            .dialogue
                Ahhhhhhh!!
                %label{:for => 'intro-2'}
                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
            %input#intro-2{:class => 'dialogue', :type => 'radio', :name => 'intro'}
            .dialogue
                The floor just collapsed under me
                %label{:for => 'intro-3'}
                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
            %input#intro-3{:class => 'dialogue', :type => 'radio', :name => 'intro'}
            .dialogue
                Geez it sure is dark in here
                %label{:for => 'intro-4'}
                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
            %input#intro-4{:class => 'dialogue', :type => 'radio', :name => 'intro'}
            .dialogue
                Let me light my torch...
                %label{:for => 'intro-5'}
                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
            %input#intro-5{:class => 'dialogue', :type => 'radio', :name => 'intro'}
            .dialogue.end
                Better. Need to find a way out.
            %input#intro-6{:class => 'dialogue', :type => 'radio', :name => 'intro'}
            .overlay
    
    -# Padlock game
    %input#interactiveObject--lock{:type=> 'checkbox'}
    .padlock
        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/padlockBig.png'}
    -(1..3).each do |col|
        -(1..9).each do |i|
            - if(i == 9)
                %input{:type=> 'checkbox', 'value' => i, :id => "padlock#{col}-#{i}", :checked => 'checked'} 
                    %span{:id => "span-#{col}"} #{10 - i}
            - else
                %input{:type=> 'checkbox', 'value' => i, :id => "padlock#{col}-#{i}"} 
                    %span{:id => "span-#{col}"} #{10 - i}
    %label.check{:for => 'interactiveObject--lock'} check
    
    -# Game items

    %input#interactiveObject1{:type => 'radio', 'data-reference' => '1', 'data-debug' => "Empty box 1"}
    %input#interactiveObject2{:type => 'radio', 'data-reference' => '2', 'data-debug' => "Pickaxe"}
    %input#interactiveObject3{:type => 'checkbox', 'data-reference' => '3', 'data-debug' => "Boulder"}
    %input#interactiveObject4{:type => 'radio', 'data-reference' => '4', 'data-debug' => "Dynamite plunger"}
    %input#interactiveObject5{:type => 'checkbox', 'data-reference' => '5', 'data-debug' => "Dynamite door"}
    %input#interactiveObject6{:type => 'radio', 'data-reference' => '6', 'data-debug' => "Planks"}
    %input#interactiveObject7{:type => 'checkbox', 'data-reference' => '7', 'data-debug' => "Plank gap"}
    %input#interactiveObject8{:type => 'radio', 'data-reference' => '8', 'data-debug' => "Note 1"}
    %input#interactiveObject9{:type => 'radio', 'data-reference' => '9', 'data-debug' => "Note 2"}
    %input#interactiveObject10{:type => 'radio', 'data-reference' => '10', 'data-debug' => "Note 3"}
    %input#interactiveObject11{:type => 'radio', 'data-reference' => '11', 'data-debug' => "Lock door"}
    %input#interactiveObject12{:type => 'radio', 'data-reference' => '12', 'data-debug' => "Handle"}
    %input#interactiveObject13{:type => 'checkbox', 'data-reference' => '13', 'data-debug' => "Cog"}
    %input#interactiveObject14{:type => 'checkbox', 'data-reference' => '14', 'data-debug' => "Waterfall"}
    %input#interactiveObject15{:type => 'radio', 'data-reference' => '15', 'data-debug' => "Dynamite"}
    %input#interactiveObject16{:type => 'radio', 'data-reference' => '16', 'data-debug' => "Fuses"}
    %input#interactiveObject17{:type => 'checkbox', 'data-reference' => '17', 'data-debug' => "End door"}
    %input#interactiveObject18{:type => 'radio', 'data-reference' => '18', 'data-debug' => "Empty box 2"}
    %input#interactiveObject19{:type => 'radio', 'data-reference' => '19', 'data-debug' => "Empty box 3"}
    %input#interactiveObject20{:type => 'radio', 'data-reference' => '20', 'data-debug' => "Empty box 4"}
    %input#interactiveObject21{:type => 'radio', 'data-reference' => '21', 'data-debug' => "Empty box 5"}
    %input#interactiveObject22{:type => 'radio', 'data-reference' => '22', 'data-debug' => "Empty box 6"}
    
    -# Checkboxes for movement
    -(1..rows).each do |row|
        -(1..columns).each do |index|
            - if(row == 1 && index == 2)
                %input{:id => "indexRow#{row}-#{index}", :type => "radio", :name => "trigger", :checked => 'checked'}
            - else
                %input{:id => "indexRow#{row}-#{index}", :type => "radio", :name => "trigger"}
    
    -# Game character
    .game_character
           
    -# Game intermediates
    .game_key
    
    -# Game segments
    .viewport
        %img.level{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/tilemaps.png'}
        -(1..rows).each do |row|
            -(1..columns).each do |index|
                .game_segment
                    .drip_container
                        -(1..4).each do
                            .drip
                    .tiles
                        -(1..tilesPerSegment * tilePerSegmentVertical).each do |tile|
                            -if (row == 1 && index == 3 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject1', 'data-reference' => '1'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-24.png'}
                                        .response
                                            Nothing useful in here
                            -if (row == 1 && index == 12 && tile == 14)
                                .tile
                                    %label{:for => 'interactiveObject2', 'data-reference' => '2'}
                                        %img.object{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_035.png'}
                                        .response
                                            A pickaxe. This should come in handy
                            -if (row == 1 && index == 7 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject3', 'data-reference' => '3'}
                                        %img.forced{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_062.png'}
                                        .responseSuccess
                                            Ha! That got it
                                        .forcedResponse
                                            I need a tool to get past this
                                            %label{:for => 'interactiveObject3'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 1 && index == 8 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject4', 'data-reference' => '4'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_166.png'}
                                        .response
                                            That seemed to do something...
                            -if (row == 3 && index == 7 && tile == 13)
                                .tile.beam
                                    %label{:for => 'interactiveObject5', 'data-reference' => '5'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/beam.gif'}
                                        .responseSuccess
                                            door gone
                                        .forcedResponse
                                            Something must blow this up
                                            %label{:for => 'interactiveObject5'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 2 && index == 6 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject6', 'data-reference' => '6'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            A Plank of wood
                            -if (row == 3 && index == 5 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject7', 'data-reference' => '7'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_169.png'}
                                        .responseSuccess
                                            planks on
                                        .forcedResponse
                                            CSS won't let me jump this
                                            %label{:for => 'interactiveObject7'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 1 && index == 6 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject8', 'data-reference' => '8'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            A strange note
                            -if (row == 1 && index == 10 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject9', 'data-reference' => '9'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-24.png'}
                                        .response
                                            A strange note
                            -if (row == 3 && index == 5 && tile == 14)
                                .tile
                                    %label{:for => 'interactiveObject10', 'data-reference' => '10'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-24.png'}
                                        .response
                                            A strange note  
                            -if (row == 3 && index == 4 && tile == 13)
                                .tile.door
                                    %label{:for => 'interactiveObject--lock', 'data-reference' => '11'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/doorLocked.png'}
                                        .response
                                            A locked door
                            -if (row == 3 && index == 2 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject12', 'data-reference' => '12'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            Cog handle
                            -if (row == 4 && index == 10 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject13', 'data-reference' => '13'}
                                        %img.forced{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_148.png'}
                                        .responseSuccess
                                            That turned off the water
                                        .forcedResponse
                                            There's no handle
                                            %label{:for => 'interactiveObject13'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 4 && index == 11 && tile == 13)
                                .tile.water
                                    %label{:for => 'interactiveObject14', 'data-reference' => '14'}
                                        %img.forced{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/waterOn.gif'}
                                        .forcedResponse
                                            Cant get through here
                                            %label{:for => 'interactiveObject14'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 2 && index == 3 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject15', 'data-reference' => '15'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_161.png'}
                                        .response
                                            Dynamite sticks
                            -if (row == 4 && index == 12 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject16', 'data-reference' => '16'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            Box of fuses
                            -if (row == 2 && index == 12 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject17', 'data-reference' => '17'}
                                        %img.forced{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_168.png'}
                                        .forcedResponse
                                            If only i had some dynamite & fuses
                                            %label{:for => 'interactiveObject17'}
                                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (row == 2 && index == 7 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject18', 'data-reference' => '18'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-24.png'}
                                        .response
                                            Nothing useful in here
                            -if (row == 2 && index == 10 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject19', 'data-reference' => '19'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            Full of junk
                            -if (row == 3 && index == 9 && tile == 15)
                                .tile
                                    %label{:for => 'interactiveObject20', 'data-reference' => '20'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-24.png'}
                                        .response
                                            Just an empty box
                            -if (row == 1 && index == 12 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject21', 'data-reference' => '21'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-25.png'}
                                        .response
                                            Nothing i can use
                            -if (row == 4 && index == 8 && tile == 13)
                                .tile
                                    %label{:for => 'interactiveObject22', 'data-reference' => '22'}
                                        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_094.png'}
                                        .response
                                            Nope empty
                            .tile
                    %label{:for => "indexRow#{row}-#{index}"}
                        .game_segment__control
                            -if (index != 1)
                                .forward
                                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                            -if (index != columns)
                                .backward
                                    %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                    %label{:for => "indexRow#{row}-#{index}"}
                        .game_segment__control
                            .down
                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
                    %label{:for => "indexRow#{row - 1}-#{index}"}
                        .game_segment__control
                            .up
                                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/arrowMovement.png'}
    
    -# Game inventory
    .game_inventory
        %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyBackpack.png'}
        .game_inventory__item
            .item.pickaxe{'data-reference' => '0'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/apple.gif'}
                .details A healthy snack
                .name Apple
            .item.pickaxe{'data-reference' => '2'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/pickInventory.gif'}
                .details A sturdy looking pickaxe
                .name Pickaxe
            .item.pickaxe{'data-reference' => '6'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/plankInventory.gif'}
                .details A thick plank of wood
                .name Plank
            .item.pickaxe{'data-reference' => '8'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/note1.gif'}
                .details A mysterious note
                .name Note 1
            .item.pickaxe{'data-reference' => '9'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/note2.gif'}
                .details A mysterious note
                .name Note 2
            .item.pickaxe{'data-reference' => '10'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/note3.gif'}
                .details A mysterious note
                .name Note 3
            .item.pickaxe{'data-reference' => '12'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/handleInventory.gif'}
                .details Looks like its used to turn something
                .name Handle
            .item.pickaxe{'data-reference' => '15'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/dynamiteInventory.gif'}
                .details No good without any fuses
                .name Dynamite sticks
            .item.pickaxe{'data-reference' => '16'}
                %img{:src => 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/fusesInventory.gif'}
                .details Some fuses for dynamite
                .name Fuses
    -# Game conditional checks 
    .game_win
        .game_win__inner
            .character
            %p Thanks for playing
            %a{:href => 'https://www.codepen.io/jcoulterdesign', :target => '_blank'} Follow me on codepen
            %span for more shenanigans
        
View Compiled
$rows: 4 !global;
$columns: 12 !global;
$gameObjects: 22;
$tileSize: 48px;
$walkSpeed: 1s;
$tilesPerSegment: 3;
$tilesPerSegmentVertical: 7;
$segmentHeight: $tileSize * $tilesPerSegmentVertical;
$debug: false;

* {
    box-sizing: border-box;
}

@font-face {
    font-family: pixles;
    src: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/04B_03__.TTF);
}

/* ------------------------------------------------------------------------------------

Game styling

--------------------------------------------------------------------------------------- */

body {
    background: #141415;
    overflow: hidden;
    font-family: pixles;
    font-size: 15px;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    height: 100vh;
    margin: 0;

    & .game {
        width: $tileSize * $tilesPerSegment * $columns;
        position: absolute;
        left: calc(50% - 72px);
        right: 0;
        top: calc(50% - 212px);
        margin: auto;
        
        input {
            display: none;
        }
        
        // End screen styles
        
        &_win {
            position: fixed;
            left: 0;
            top: 0;
            background: #141415;
            z-index: 9;
            width: 100%;
            height: 100%;
            opacity: 0;
            pointer-events: none;
            transition: all 1s 0s;
            
            &__inner {
                position: absolute;
                left: 0;
                right: 0;
                margin: auto;
                width: 300px;
                top: 50%;
                transform: translateY(-50%);
                text-align: center;
                opacity: 0;
                transition: all 1s 2s;
                
                p {    
                    color: white;
                    margin-bottom: 30px;
                }
                
                span {
                    color: white;
                    opacity: 0.4;
                }
                
                a {
                    margin-bottom: 16px;
                    color: #78f148;
                    text-align: center;
                    width: 100%;
                    display: block;
                }
            }
            
            .character {
                width: 48px;
                height: 48px;
                position: relative;
                left: -60px;
                margin: auto;
                background: red;
                background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/corridorMainCharacter.gif');
                animation: walk-1 $walkSpeed infinite;
                z-index: 1;
                background-position: 0 0;
                transform: translateY(-50%) translateX($tileSize * ($tilesPerSegment / 2) - 8);
                transition: all $walkSpeed linear;
                z-index: 1;
                pointer-events: none;
            }
        }
        
        // Side inventory styles

        &_inventory {
            position: fixed;
            z-index: 9;
            left: 0;
            color: white;
            top: 50%;
            -webkit-transform: translateY(-50%);
            font-size: 11px;
            right: 0;
            margin: auto;
            left: -420px;
            width: 140px;
            padding-left: 15px;
            transform: translateY(-50%);
            height: 64px;
            cursor: pointer;
            transition: all .6s .3s;

            &:hover {
                height: 371px;
                transition: all .6s .2s;

                .item {
                    opacity: 1;
                    left: 0px;
                    transition: all 0.3s;
                    -webkit-filter: blur(0px);

                    &:first-child {
                        display: block;
                    }
                }
            }

            h1 {
                font-weight: normal;
                font-size: 12px;
            }

            img {
                transform: scale(3);
                image-rendering: pixelated;
                cursor: pointer;
                transform-origin: 0 0;

                &:hover {

                }
            }

            &__item {
                margin-top: 70px;
                text-align: center;
                position: relative;
                left: -24px;
                width: 100%;
                height: 100%;

                .item {
                    margin: 10px 0 30px 0;
                    display: none;
                    opacity: 0;
                    left: 0px;
                    position: relative;
                    transition: all 0s;
                    float: left;
                    margin-right: 10px;
                    width: 34%;

                    &:hover {
                        z-index: 15;
                        
                        .details {
                            opacity: 1;
                            top: -4px;
                        }
                    }
                    
                    .name {
                        position: relative;
                        top: 11px;
                    }
                    
                    .details {
                        padding: 7px;
                        opacity: 0;
                        border-radius: 4px;
                        position: absolute;
                        font-size: 13px;
                        text-align: center;
                        transition: all 0.2s .2s;
                        pointer-events: none;
                        background: white;
                        color: #141415;
                        width: 120px;
                        top: -4px;
                        left: 50px;
                        z-index: 20;
                    }

                    img {
                        transform: scale(2);
                        transform-origin: 50% 50%;
                    }
                }
            }
        }

        // Padlock stuff
        
        .padlock {
            display: none;    
            position: absolute;
            width: 280px;
            top: 71px;
            left: -70px;
            height: 280px;
            background: #301f41b8;
            z-index: 4;
            border-radius: 324px;
            border: 4px solid #ffb128;
            
            img {
                position: absolute;
                left: 80px;
                top: 35px;
            }
        }
        
        %o {
            display:block;
            position: absolute;
            left: 0;
            right: 0;
            top: 220px;
            margin: auto;
        }

        .check {
            display: none;
            width: 80px;
            cursor: pointer;
            height: 80px;
            position: absolute;
            z-index: 6;
            top: 303px;
            left: 30px;
            text-align: center;
            line-height: 77px;
            background: wheat;
            color: #615133;
            border-radius: 100px;
            border: 3px solid #ffb128;
            transition: all 0.3s;

            &:hover {
                background: #ffb128;
                color: white;
            }
        }
        
        input#interactiveObject--lock:not(:checked) {
            + span {
                display: none;
            }
        }
        
        input#interactiveObject--lock:checked {
            + .padlock {
                display: block;

                $y: '';
                $x: ' + span ';
                
                + input {
                    display: block;
                    @for $i from 1 through 26 {

                        $y: $y + ' + span + input';
                        $x: $x + ' + input + span ';
                            
                        #{$y} {
                            display: block;
                        }
                            #{$x} {
                            display: block;
                        }
                        #{$y} + span + label {
                            display: block;
                        }   
                    }
                }
            }
        }

        #padlock1-1,#padlock2-1,#padlock3-1 {
            &:after {
                display: block !important;
            }
        }

        #padlock1-9,#padlock2-9,#padlock3-9 {
            &:after {
                display: none !important;
            }
        }
        
        input[id*="padlock"] {
            @extend %o;

            z-index: 3;
            outline: none;
            display:none;
            -webkit-appearance: none;

            + span {
                @extend %o;

                background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/padlockBG.png);
                width: 10px;
                width: 22px;
                height: 36px;
                left: 0;
                display: none;
                line-height: 40px;
                text-align: center;
                position: fixed;
                color: #444444;
                top: 50%;
                transform: translateY(9px) translateX(-35px);
            }

            @for $i from 1 through 34 {
                &:nth-of-type(#{$i}) {
                    z-index: $i + 10;

                    &:checked {
                        z-index: 64 + $i;
                        
                        & + span {
                            z-index: 64 - $i;
                        }
                    }
                }
            }

            &:checked {
                z-index: 30;

                &:before {
                    display: none;
                } 

                & + span {
                    & + input {
                        &:after {
                            display: none;
                        }
                    }
                }
            }

            &:after {
                background: red;
                display: block;
                content: '';
                top: 48px;
                position: absolute;
                cursor: pointer;
                height: 23px;
                left: -7px;
                width: 22px;
                background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/padlockDown.png);
            }

            &:before {
                display: block;
                content: '';
                position: absolute;
                height: 23px;
                width: 22px;
                left: -7px;
                top: -30px;
                color: white;
                background: red;
                cursor: pointer;
                background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/padlockUp.png);
            }

            &[id*="padlock1"] {
                left: 19px;
                + span {
                  left: -27px;  
                }
            }
            
            &[id*="padlock2"] {
                left: 64px;
                + span {
                  left: 66px;  
                }
            }
            
            &[id*="padlock3"] {
                left: 106px;
                + span {
                  left: 149px;  
                }
            }
        }
        
        // Loading screen styles

        &_loader {
            position: fixed;
            z-index: 15;
            background: #141415;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            opacity: 1;
            animation: fadeOut 1.5s 7s forwards;

            &__inner {
                position: absolute;
                left: 0;
                right: 0;
                margin: auto;
                top: 50%;
                transform: translateY(-50%);
                font-size: 12px;
                width: 200px;
                text-align: center;

                h1 {
                    font-weight: normal;
                    font-size: 12px;
                }

                & .logo {
                    width: 200px;
                    height: 70px;
                    margin: auto;
                    margin-bottom: 10px;
                    transform: scale(0);
                    opacity: 0;
                    animation: logo 2s forwards;
                    
                    img {
                        width: 100%;
                    }
                }

                span {
                    color: rebeccapurple;
                    display: block;
                    opacity: 0;
                    margin-top: 8px;
                    animation: fadeIn 1.5s 3s forwards;
                }

                & .bar {
                    background: #3c3c3e;
                    position: relative;
                    height: 2px;
                    margin-top: 30px;
                    opacity: 0;
                    animation: fadeIn 1.5s 2.5s forwards;

                    &_inner {
                        width: 0px;
                        height: 100%;
                        background: white;
                        position: absolute;
                        top: 0;
                        animation: bar 3s 3s forwards;
                    }
                }

                & .subtitle {
                    color: #f49112;
                    margin: -18px 0px 40px 0;
                    opacity: 0;
                    animation: fadeIn 1.5s 1.5s forwards;
                }
            }
        }
        
        // Our little character

        &_character {
            width: 48px;
            height: 48px;
            background: red;
            background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/corridorMainCharacter.gif');
            position: absolute;
            top: 216px;
            left: -16px;
            z-index: 1;
            background-position: 0 0;
            transform: translateY(-50%) translateX($tileSize * ($tilesPerSegment / 2) - 8);
            transition: all $walkSpeed linear;
            z-index: 1;
            pointer-events: none;
            
            img {
                position: absolute;
                border: 512px solid #0c0c0d;
                transform: translateY(-685px) translateX(-670px);
                opacity: 1;
            }
        }

        // Intro dialogue
        
        &_intro {
            position: absolute;
            top: 38px;
            left: -33px;
            z-index: 14;

            input {
                display: none;
            }

            input[type="radio"]:checked + div {
                opacity: 1;
                top: 140px;
                transition: all 0.5s 0.8s;
                pointer-events: all;

                label {
                    opacity: 1;
                    bottom: -10px;
                }
            }
            
            input#intro-1[type="radio"]:checked + div {
                top: 140px;
                opacity: 0;
                transition: all 0.5s 0.8s;
                animation: dialogueIn .5s 9s forwards;
                pointer-events: all;
            }

            input#intro-1[type="radio"]:not(:checked) + div {
                opacity: 0;
                top: 160px;
                transition: all 0.5s 0.8s;
            }

            input[type="radio"]#intro-5:checked + div + input + div {
                opacity: 0;
                pointer-events: none !important;
            }
            
            input[type="radio"]#intro-5:checked + div {
                opacity: 0;
                animation: showResponse 2s 2s forwards;
            }

            & .overlay {
                position: fixed;
                top: 0 !important;
                width: 140%;
                left: 0;
                opacity: 1;
                height: 260%;
                background: #141415;
                z-index: -1;
                pointer-events: all;
                transition: all 4s .7s !important;
            }

            & .dialogue {
                position: absolute;
                top: 160px;
                opacity: 0;
                width: 170px;
                left: 20px;
                padding: 15px;
                border-radius: 4px;
                font-size: 13px;
                text-align: center;
                transition: all 0.2s .2s;
                pointer-events: none;
                background: white;
                color: #141415;
                
                &.end {
                    position: absolute;
                    width: 130px;
                    left: 0;
                    text-align: center;
                    right: 0;
                    pointer-events: none;
                    top: 100px !important;
                    margin: auto;
                    transform: translateY(140px) translateX(39px);
                    background: white;
                    color: #141415;
                    padding: 8px;
                    border-radius: 5px;
                }

                label {    
                    border-radius: 5px;
                    position: absolute;
                    right: -6px;
                    bottom: -20px;
                    z-index: 1;
                    opacity: 0;
                    cursor: pointer;
                    transition: all 0.4s 1s;

                    img {
                        transform: scale(2);
                        image-rendering: pixelated;
                    }

                    &:hover {
                        right: -13px;
                        background: #66bf60;
                    }
                }
            }
        }
        
        // Viewport

        .viewport {
            position: relative;
            z-index: 0;
            transition: all $walkSpeed linear;

            .level {
                position: absolute;
                left: 0;
                z-index: 1;
                transform: scale(3);
                transform-origin: 0 0;
                image-rendering: pixelated;
            }
        }

        &_segment {
            width: $tileSize * $tilesPerSegment;
            height: $segmentHeight;
            border: 0px solid white;
            float: left;
            z-index: 1;
            position: relative;
            color: white;

            .drip_container {
                position: relative;
                top: 80px;
                display: none;
                z-index: 10;

                & .drip {
                    width: 3px;
                    height: 20px;
                    background: #81eeef;
                    position: absolute;
                    height: 0;
                    top: 14px;
                    opacity: 1;

                    @for $i from 1 through 5 {
                        &:nth-of-type(#{$i}) {
                            left: random(144) + 0px;
                            animation: drip 1.25s random(52) / 10 + 0s linear infinite;
                        }
                    }
                }
            }

            @keyframes drip {
                0% {height: 0;}
                2% {height: 6px;}
                5% {height: 6px;top:14px}
                22% {top:158px; height:4px;opacity:1;}
                23%{opacity: 0;height:0px}
                100%{opacity: 0}
            }

            & .tiles {
                & .tile {
                    width: $tileSize;
                    height: $tileSize;
                    float: left;
                    image-rendering: pixelated;
                    
                    // Special tiles

                    &.door {
                        position: absolute;
                        top: 92px;
                        height: 144px;
                        left: -12px;
                        width: 60px;
                        
                        img {
                            position: relative;
                        }
                    }
                    
                    &.beam {
                        position: absolute;
                        top: 95px;
                        height: 108px;
                    }
                    

                    &.water {
                        position: absolute;
                        top: 107px;
                        height: 108px;
                    }

                    &:before {
                        display: none;
                        content: ' ';
                        position: absolute;
                        width: 4px;
                        height: 10px;
                        border-left: 4px solid #e69c69;
                        border-right: 4px solid #e69c69;
                        z-index: 1;
                        left: 67px;
                        top: 140px;
                        transition: all 1s linear;
                    }

                    &:after {
                        top: -48px;
                        transition: all 1s linear;
                        height: 40px !important;
                        display: block;
                        overflow: hidden;
                        pointer-events: none;

                        img {
                            position: relative;
                            top: -400px;
                        }
                    }

                    img {
                        width: 100%;
                        cursor: pointer;

                        &:hover {
                            -webkit-filter: drop-shadow(2px 0px white) drop-shadow(-2px 0px white) drop-shadow(0px -2px white);
                        }
                    }

                    label {
                        pointer-events: none;

                        .response, 
                        .forcedResponse, 
                        .responseSuccess {
                            display: none;
                            position: absolute;
                            width: 130px;
                            left: 0;
                            text-align: center;
                            right: 0;
                            pointer-events: none;
                            top: calc(50% - 46px);
                            margin: auto;
                            background: white;
                            color: #141415;
                            padding: 8px;
                            border-radius: 5px;
                        }

                        .forcedResponse {
                            pointer-events: all !important;

                            label {
                                border-radius: 5px;
                                position: absolute;
                                right: -6px;
                                cursor: pointer;
                                bottom: -14px;
                                transform: scale(2);
                                z-index: 3;
                                cursor: pointer;
                                transition: all 0.4s 1s;

                                &:hover {
                                    right: -2px;
                                }
                            }
                        }
                    }

                    &:after {
                        display: block;
                        width: $tileSize;
                        height: $tileSize;
                        transform: scale(3);
                        image-rendering: pixelated;
                        transform-origin: 0 0;
                    }
                }
            }
            
            // Game controls

            &__control {
                div {
                    position: absolute;
                    opacity: 0;
                    pointer-events: none;
                    border-radius: 4px;
                    top: 50%;
                    cursor: pointer;

                    img {
                        transform: scale(3);
                        image-rendering: pixelated;
                        position: relative;
                        left: 0;
                        top: 0;
                        transition: all 0.3s;
                    }
                }

                & .forward {
                    transform: translateY(50px) translateX(-$tileSize);
                    left: 66px;
                    transition: all 0.3s 0s;

                    &:hover {
                        img {
                            left: 4px;
                        }
                    }
                }

                & .backward {
                    transform: translateY(50px) translateX(47px);
                    right: 65px;
                    transition: all 0.3s .1s;

                    &:hover {
                        img {
                            left: -4px;
                        }
                    }

                    img {
                        transform: rotate(180deg) scale(3);
                    }
                }

                & .up {
                    top: 90px !important;
                    left: 50%;
                    transform: translateX(-50%) translateY(25px);
                    transition: all 0.3s .2s;

                    &:hover {
                        img {
                            top: -4px;
                        }
                    }

                    img {
                        transform: rotate(-90deg) scale(3);
                    }
                }

                & .down {
                    bottom: 350px !important;
                    left: 50%;
                    opacity: 0;
                    top: auto;
                    transform: translateX(-50%) translateY(10px);
                    transition: all 0.3s .2s;
                    
                    &:hover {
                        img {
                            top: 4px;
                        }
                    }

                    img {
                        transform: rotate(90deg) scale(3);
                    }
                }
            }
        }
    }
}

/* ------------------------------------------------------------------------------------

Calculate the way an animated sprite should be shown from its width and frame count
then animate the background image

--------------------------------------------------------------------------------------- */

@function walkCycle($frames, $width, $height, $row) {

    $t: 100 / $frames;
    $o: 0;
    $p: '';

    @for $i from 1 through $frames {
        $o: $o + $t;
        $p: $p + ($o - .1) + '%{background-position:-' + ($i - 1) * $width + 'px ' + $height * ($row - 1) + 'px;}';
        $p: $p + $o + '%{background-position:-' + $i * $width + 'px ' + $height * ($row - 1) + 'px;}';
        @if($o != 100) {
            $p: $p + ($o + .1) + '%{background-position:-' + $i * $width + 'px ' + $height * ($row - 1) + 'px;}';
        } @else {
            $o: 100;
        }
    }

    $v: '1%{background-position: 0px ' + $height * ($row - 1) + 'px;}' + $p;

    @return unquote($v);
}

/* ------------------------------------------------------------------------------------------------------

Name: Traverse through scenes
Description: Makes it incredibly easy to trigger scene changes using the checkbox *hack*
Instead of doing  input#index39:checked + input + div + div { props }

--------------------------------------------------------------------------------------------------------- */

@mixin traverse($n: 4) {
    $div: "" !global; // Empty div string
    $input: "" !global; // Empty input string
    $input2: "" !global;
    $input3: "" !global;
    $input4: "" !global;
    $label: "" !global; // Empty input string
    $label2: "" !global;
    $label3: "" !global;
    $label4: "" !global;
    $inputOffset: "+ input " !global;

    // This needs to be made dynamic

    @for $i from 1 through 47 {
        $input: $input + "+ input " !global;
        $inputOffset: $inputOffset + "+ input " !global;
    }

    @for $i from 1 through 35 {
        $input2: $input2 + "+ input " !global;
    }

    @for $i from 1 through 23 {
        $input3: $input3 + "+ input " !global;
    }

    @for $i from 1 through 11 {
        $input4: $input4 + "+ input " !global;
    }

    @for $i from 1 through $columns {
        @keyframes walk-#{$i} {
            animation: walkCycle(6, 48, 48, 1);
        }
    }

    @for $i from 1 through $n {
        $div: "+ div" !global;
        $position: $i !global; // Make this global so we can pass it in to our content
        $i: $i !global;
        $label: $label + "+ div " !global;

        @if ($i > 1) {
            $input: str_slice($input, 0, -9) !global; // Slice out the last input string
            $input2: str_slice($input2, 0, -9) !global; // Slice out the last input string
            $input3: str_slice($input3, 0, -9) !global; // Slice out the last input string
            $input4: str_slice($input4, 0, -9) !global; // Slice out the last input string
            $label2: $label2 + "+ div " !global;
        }

        @content;
    }
}

/* ------------------------------------------------------------------------------------

When in specified semgent, show the down arrow and the up arrow of the segment below

--------------------------------------------------------------------------------------- */

@mixin moveVerticleOnTile($row, $tile) {

    $totalInputs: $rows * $columns - ($row * $columns - ($columns - $tile));
    $totalDivs: $row * $columns - ($columns - $tile) + $columns + 2;
    $id: $row * $columns - ($columns - $tile);
    $tInput: '';
    $tDiv: '';
    $tInputDown: '';

    @for $i from 1 through $totalInputs {
        $tInput: $tInput + ' + input ';
    }

    @for $i from 1 through $totalDivs {
        $tDiv: $tDiv + ' + div ';
    }

    @for $i from 1 through $totalInputs - $columns {
        $tInputDown: $tInputDown + ' + input ';
    }

    .game_segment:nth-of-type(#{$id}) .tile:nth-of-type(14):after {
        content: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/corridorLift.png');
        position: relative;
        display: block;
    }

    .game_segment:nth-of-type(#{$id}) .tile:nth-of-type(14):before {
        display: block;
    }

    input#indexRow#{$row}-#{$tile}:checked #{$tInput} + div + div + .viewport > .game_segment:nth-of-type(#{$id + $columns})  {
        & .down {
            opacity: 1;
            pointer-events: all;
            transition: all 0.3s 1.1s;
            transform: translateX(-50%) translateY(0px);
        }
    }

    input#indexRow#{$row + 1}-#{$tile}:checked #{$tInputDown} + div + div + .viewport > .game_segment:nth-of-type(#{$id}) {
        .tile:nth-of-type(14):after {
            top :288px;
        }

        .tile:nth-of-type(14):before {
            height: 373px;
        }
    }

    input#indexRow#{$row + 1}-#{$tile}:checked #{$tInputDown} + div + div + .viewport > .game_segment:nth-of-type(#{$id + $columns}) {
        & .up {
            opacity: 1;
            pointer-events: all;
             transition: all 0.3s 1.1s;
            transform: translateX(-50%) translateY(15px);
        }
    }
}

/* ------------------------------------------------------------------------------------

Prevent movement labels showing on specified sement

--------------------------------------------------------------------------------------- */

@mixin makeWallAt($row, $tile) {

    $totalInputs: $rows * $columns - ($row * $columns - ($columns - $tile));
    $totalDivs: $row * $columns - ($columns - $tile) + $columns + 2;
    $id: $row * $columns - ($columns - $tile);
    $tInput: '';
    $tDiv: '';
    $tInputBack: '';
    $tInputDown: '';

    @for $i from 1 through $totalInputs + 1 {
        $tInput: $tInput + ' + input ';
    }

    @for $i from 1 through $totalInputs - 1 {
        $tInputBack: $tInputBack + ' + input ';
    }

    input#indexRow#{$row}-#{$tile - 1}:checked #{$tInput} + div + div + .viewport > .game_segment:nth-of-type(#{$id})  {
        & .forward {
            display: none !important;
        }
    }

    input#indexRow#{$row}-#{$tile + 1}:checked #{$tInputBack} + div + div + .viewport > .game_segment:nth-of-type(#{$id})  {
        & .backward {
            display: none !important;
        }
    }
}

/* ------------------------------------------------------------------------------------

Compare two inputs then do something

--------------------------------------------------------------------------------------- */

@mixin checkWinCondition($criteria, $criteria2, $result) {

    $totalInputs: 48 + ($gameObjects - $criteria - 2);
    $tInput: '';

    @for $i from 1 through $totalInputs {
        $tInput: $tInput + ' + input ';
    }
    
    input#interactiveObject#{$criteria}:checked + input:checked + input:checked #{$tInput} + div + div + div + div + div {
        opacity: 1;
        pointer-events: all;
        & .game_win__inner {
            opacity: 1;
        }
    }
    
    input#interactiveObject#{$criteria}:checked + input:checked + input:checked #{$tInput} + div + div + div + div {
        display: none;
    }
    
    input#interactiveObject#{$criteria}:checked + input:checked + input:checked #{$tInput} + div + div + div {
        animation: end 2s forwards;
        .forcedResponse {
            display: none !important;
        }
    }
}

/* ------------------------------------------------------------------------------------

Compare two inputs then do something

--------------------------------------------------------------------------------------- */

@mixin compare($input, $segment, $tile, $destroy, $waterfall, $plank) {

    $totalInputs: 48 + ($gameObjects - $input - 1);
    $tInput: '';

    @for $i from 1 through $totalInputs {
        $tInput: $tInput + ' + input ';
    }

    input#interactiveObject#{$input}:checked + input:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment - 1}) {
        .game_segment__control {
            display: block !important;

            .backward, .forward {
                display: block !important;
            }
        }
    }

    input#interactiveObject#{$input}:checked + input:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment + 3}) {
        .game_segment__control {
            display: block !important;

            .backward, .forward {
                display: block !important;
            }
        }
    }

    input#interactiveObject#{$input}:checked + input:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment + 1}) {
        .game_segment__control {
            display: block !important;

            .forward {
                display: block !important;
            }

            .backward {
                display: block !important;
            }
        }
    }
    
    @if($destroy) {
        input#interactiveObject#{$input}:checked + input #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment}) {
            .tile img {
                display: none;
            }
        }

        input#interactiveObject#{$input}:checked + input #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment - 1}) {
            .game_segment__control {
                .backward,.forward {
                    display: block !important;

                }
            }
        }
    }

    input#interactiveObject#{$input}:checked + input:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment}) {
        .game_segment__control {
            .backward {
                display: block !important;   
            }
        }

        @if($waterfall) {
            & + div .tiles .tile:nth-of-type(13) {
                content: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/waterOff.gif');
                
                img {
                    display: none;
                }
            }
        }

        @if($plank) {
            & + div .tiles .tile:nth-of-type(13) {
                content: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/creepyCorridor-_170.png');
                img {
                    display: none;
                }
            }
        }
    }

    input#interactiveObject#{$input}:checked + input:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment}) .tiles .tile:nth-of-type(#{$tile}) {
        img {
            display: none;
        }

        .forcedResponse {
            display: none;
        }

        .responseSuccess  {
            display: block;
            animation: showResponse 2s forwards;
        }
    }
}

// Show the rain element on specific segment

@mixin makeRainAt($segment) {
    .viewport .game_segment:nth-of-type(#{$segment}) .drip_container {
        display: block;
    }
}

/* ------------------------------------------------------------------------------------

Create an interactive object

--------------------------------------------------------------------------------------- */

@mixin makeInteractiveObject($reference, $segment, $tile, $force, $animate, $plank) {

    $totalInputs: ($rows * $columns) + ($gameObjects - $reference);
    $tInput: '';

    @for $i from 1 through $totalInputs {
        $tInput: $tInput + ' + input ';
    }

    @if($force) {
        input#interactiveObject#{$reference}:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment + 1}),
        input#interactiveObject#{$reference}:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment - 1}){
            .game_segment__control {
                display: none;
            }
        }
    }

    input#interactiveObject#{$reference}:checked #{$tInput} + div + div + div + div .game_inventory__item .item[data-reference="#{$reference}"] {
        display: block;
    }

    @if($animate) {
        input#interactiveObject#{$reference}:checked #{$tInput} + div + div + div {
            animation: shake 1s forwards; 
        }
    }

    input#interactiveObject#{$reference}:checked #{$tInput} + div + div + div > .game_segment:nth-of-type(#{$segment}) .tiles .tile:nth-of-type(#{$tile}) {
        img {
            pointer-events: none;
    
            &.object {
                display: none;
            }
            
            &.forced {
                pointer-events: all;
            }
        }

        .response  {
            display: block;
            animation: showResponse 2s forwards;
        }

        .forcedResponse {
            display: block;
            animation: forcedResponse 2s forwards;
        }
    }
}

// Check padlock code. The math is floored in this and so its not currently dynamic TODO

@mixin checkCode($one, $two, $three, $segment, $tile) {

    $diff: 2;
    $diff2: 6; // 13
    $diff3: 13; // 2
    $diff4: 3; // 4

    $inputPadlock: '';
    $inputPadlock2: '';
    $inputPadlock3: '';
    $inputPadlock4: '';
    //7,9,4
    $totalInputs: 48 + ($gameObjects);
    $tInput: '';

    @for $i from 1 through $totalInputs {
        $tInput: $tInput + ' + input ';
    }

    @for $i from 1 through $diff {
        $inputPadlock: $inputPadlock + ' + input + span ';
    }

    @for $i from 1 through $diff2 {
        $inputPadlock2: $inputPadlock2 + ' + input + span ';
    }

    @for $i from 1 through $diff3 {
        $inputPadlock3: $inputPadlock3 + ' + input + span ';
    }

    @for $i from 1 through $diff4 {
        $inputPadlock4: $inputPadlock4 + ' + input + span ';
    }

    input#interactiveObject--lock:not(:checked) + div #{$inputPadlock} + input:checked + span #{$inputPadlock2} + input:checked + span #{$inputPadlock3} + input:checked + span #{$inputPadlock4} + label #{$tInput} + div + div + div .game_segment:nth-of-type(#{$segment}) .tiles .tile:nth-of-type(#{$tile}) {
        img {
            display:none;
        }
        content: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/doorUnlocked.png')
    }
    
    input#interactiveObject--lock:not(:checked) + div #{$inputPadlock} + input:checked + span #{$inputPadlock2} + input:checked + span #{$inputPadlock3} + input:checked + span #{$inputPadlock4} + label #{$tInput} + div + div + div .game_segment:nth-of-type(#{$segment}) {
        .forward,.backward {
            display: block !important;
        }
    }
    
     input#interactiveObject--lock:not(:checked) + div #{$inputPadlock} + input:checked + span #{$inputPadlock2} + input:checked + span #{$inputPadlock3} + input:checked + span #{$inputPadlock4} + label #{$tInput} + div + div + div .game_segment:nth-of-type(#{$segment - 1}) {
        .forward,.backward {
            display: block !important;
        }
    }
}

@include checkCode(7, 3, 6, 28, 13);

/* ------------------------------------------------------------------------------------

Assign an image/gif at a specific tile

--------------------------------------------------------------------------------------- */

@mixin assignTileAt($segment, $tiles, $id) {
    @each $tile in $tiles {
        .game_segment:nth-of-type(#{$segment}) .tiles .tile:nth-of-type(#{$tile}) {
            content: url($id);
        }   
    }
}

/* ----------------------------------

Init the traverse

------------------------------------- */

$animationIndex: 1;


@include traverse($rows * $columns) {

    /* ----------------------------------

    Global scene transitions

    ------------------------------------- */

    $animationRow: floor($position / $columns);
    $animationIndex: $position - ($animationRow * $columns);
    $inputMap: $input, $input2, $input3, $input4;

    @for $m from 1 through 4 {
        input#indexRow#{$m}-#{$i}:checked #{nth($inputMap, $m)} #{$div} {
            animation: walk-#{$animationIndex} $walkSpeed forwards;
            //static-#{$animationIndex} 2s $walkSpeed infinite
            //background-position: 0 48px;

            & + div + div {
                @if($debug) {
                    left: (-$tileSize * $tilesPerSegment) * ($i - 1) / 2;
                        } @else {
                            left: (-$tileSize * $tilesPerSegment) * ($i - 1);   
                                }

                @if($debug != true) {
                    clip-path: circle(140px at ((215px - ($tileSize * $tilesPerSegment)) + (($i - 1) * ($tileSize * $tilesPerSegment))) 212px + $segmentHeight * ($m - 1));
                }

                @if($debug) {
                    top: -($segmentHeight *  ($m - 1)) / 2;
                } @else {
                    top: -$segmentHeight * ($m - 1);
                }

            }
    }

        input#indexRow#{$m}-#{$i}:checked #{nth($inputMap, $m)} #{$div} + div + .viewport > .game_segment:nth-of-type(#{$i + 1 + (($m - 1) * $columns)}) {
            & .forward {
                opacity: 1;
                pointer-events: all;
                transform: translateY(39px) translateX(-48px);
                transition: all 0.3s .9s;
            }
        }

        input#indexRow#{$m}-#{$i}:checked #{nth($inputMap, $m)} #{$div} + div + .viewport > .game_segment:nth-of-type(#{#{$i + (($m - 1) * $columns)}}) {
            label {
                pointer-events: all !important;
            }
        }

        input#indexRow#{$m}-#{$i}:checked #{nth($inputMap, $m)} #{$div} + div + .viewport > .game_segment:nth-of-type(#{$i - 1 + (($m - 1) * $columns)}) {
            & .backward {
                opacity: 1;
                pointer-events: all;
                transform: translateY(39px) translateX(47px);
                transition: all 0.3s 1s;
            }
        }
    }
}

// Assign all our animated tiles
@include assignTileAt(2, 10, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/spookyEyes.gif');
@include assignTileAt(19, 10, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/spookyEyes.gif');
@include assignTileAt(23, 11, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/spookyEyes.gif');
@include assignTileAt(7, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/spookyEyes.gif');
@include assignTileAt(5, 17, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/spookyEyes.gif');
@include assignTileAt(3, 7, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(3, 7, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(6, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(8, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(15, 7, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(18, 7, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(10, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(30, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(27, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(21, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(24, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(44, 8, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');
@include assignTileAt(12, 7, 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/swingingLantern.gif');

// Create objects
@include makeInteractiveObject(1, 3, 15, false, false, false); // Empy crate
@include makeInteractiveObject(2, 12, 15, false, false, false); // Pickaxe
@include makeInteractiveObject(3, 7, 15, true, false, false); // Rock
@include makeInteractiveObject(4, 8, 15, false, true, false); // Dynamite plunger
@include makeInteractiveObject(5, 31, 13, true, false, false); // Dynamite door
@include makeInteractiveObject(6, 18, 15, false, false, false); // Planks
@include makeInteractiveObject(7, 29, 13, true, false, true); // Plank gap
@include makeInteractiveObject(8, 6, 13, false, false, false); // Note 1
@include makeInteractiveObject(9, 10, 13, false, false, false); // Note 2
@include makeInteractiveObject(10, 29, 15, false, false, false); // Note 3
@include makeInteractiveObject(11, 27, 13, false, false, false); // Lock door
@include makeInteractiveObject(12, 26, 13, false, false, false); // Handle
@include makeInteractiveObject(13, 46, 13, false, false, false); // Cog
@include makeInteractiveObject(14, 47, 13, false, false, false); // Waterfall
@include makeInteractiveObject(15, 15, 15, false, false, false); // Dynamite
@include makeInteractiveObject(16, 48, 15, false, false, false); // Fuses
@include makeInteractiveObject(17, 24, 15, false, false, false); // End door
@include makeInteractiveObject(18, 19, 15, false, false, false); // Empty box 1
@include makeInteractiveObject(19, 22, 15, false, false, false); // Empty box 2
@include makeInteractiveObject(20, 33, 15, false, false, false); // Empty box 3
@include makeInteractiveObject(21, 12, 13, false, false, false); // Empty box 4
@include makeInteractiveObject(22, 44, 13, false, false, false); // Empty box 5

// Compare game logic
@include compare(2, 7, 15, false,false, false); // Compare pick to rock
@include compare(4, 31, 13, true,false, false); // Compare plunger to door
@include compare(6, 29, 13, false,false, true); // Compare planks to gap
@include compare(12, 46, 13, false,true, false);

// Check win condition
@include checkWinCondition(15, 16, 17);

// Create vertical tiles
@include moveVerticleOnTile(1,5); //e.g make elevator between row 1 segment 5 and the tile below it
@include moveVerticleOnTile(1,11); 
@include moveVerticleOnTile(2,2);
@include moveVerticleOnTile(2,8);
@include moveVerticleOnTile(3,9);

// Create walls
@include makeWallAt(1,1);
@include makeWallAt(1,8); // Blocking dynamite plunger
@include makeWallAt(1,9);
@include makeWallAt(1,13);
@include makeWallAt(2,13);
@include makeWallAt(2,4);
@include makeWallAt(2,1);
@include makeWallAt(3,1);
@include makeWallAt(3,3);
@include makeWallAt(3,4);
@include makeWallAt(3,6); // door
@include makeWallAt(3,10);
@include makeWallAt(4,7);
@include makeWallAt(4,13);
@include makeWallAt(4,11);

// Effects
@include makeRainAt(3);
@include makeRainAt(7);
@include makeRainAt(15);
@include makeRainAt(29);
@include makeRainAt(22);
@include makeRainAt(31);
@include makeRainAt(47);
@include makeRainAt(18);

// Animations
@keyframes showResponse {
    0% {opacity:1; top: calc(50% - 36px);}
    70% {opacity: 1;top: calc(50% - 46px);}
    100% {opacity:0; top: calc(50% - 46px);}
}

@keyframes forcedResponse {
    0% {opacity:1; top: calc(50% - 36px);}
    70% {opacity: 1;top: calc(50% - 46px);}
    100% {opacity:1; top: calc(50% - 46px);}
}

@keyframes logo {
    0%{opacity: 0; transform: scale(0)}
    100%{opacity: 1; transform: scale(1)}
}

@keyframes fadeIn {
    0%{opacity: 0;}
    100%{opacity: 1;}
}

@keyframes fadeOut {
    0%{opacity: 1;}
    100%{opacity: 0;}
}

@keyframes bar {
    0%{width: 0%;}
    100%{width: 100%;}
}

@keyframes dialogueIn {
    0%{opacity: 0;left: 20px;}
    10%{left: 20px;}
    20%{left: 0px;}
    30%{left: 20px;}
    40%{left: 4px;}
    50%{left: 18px;}
    60%{left: 8px;}
    70%{left: 20px;}
    80%{left: 5px;}
    90%{left: 16px;}
    100%{opacity: 1;left: 20px;}
}

@keyframes shake {
    0%{transform: translateX(0px)}
    10%{transform: translateX(6px)}
    20%{transform: translateX(-6px)}
    30%{transform: translateX(6px)}
    40%{transform: translateX(-6px)}
    50%{transform: translateX(6px)}
    60%{transform: translateX(-6px)}
    70%{transform: translateX(6px)}
    80%{transform: translateX(-6px)}
    90%{transform: translateX(6px)}
    100%{transform: translateX(0px)}
}

@keyframes end {
    0%{transform: translateX(0px);opacity:1}
    10%{transform: translateX(6px)}
    20%{transform: translateX(-6px)}
    30%{transform: translateX(6px)}
    40%{transform: translateX(-6px)}
    50%{transform: translateX(6px)}
    60%{transform: translateX(-6px)}
    70%{transform: translateX(6px)}
    80%{transform: translateX(-6px)}
    90%{transform: translateX(6px)}
    100%{transform: translateX(0px);opacity:0;}
}

@keyframes shake-debug {
    0%{transform: translateX(0px) scale(0.5)}
    10%{transform: translateX(10px) scale(0.5)}
    20%{transform: translateX(-0px) scale(0.5)}
    30%{transform: translateX(10px) scale(0.5)}
    40%{transform: translateX(-10px) scale(0.5)}
    50%{transform: translateX(10px) scale(0.5)}
    60%{transform: translateX(-10px) scale(0.5)}
    70%{transform: translateX(10px) scale(0.5)}
    80%{transform: translateX(-10px) scale(0.5)}
    90%{transform: translateX(10px) scale(0.5)}
    100%{transform: translateX(0px) scale(0.5)}
}


// Trailer
// Labels are out
View Compiled
// Nope, nothing here. Just a big long list of checkboxes and radio buttons.... You see, what happens is, let's say you click on the boulder, the input for the boulder is checked but the input for the pickaxe isn't. So CSS check to see if the checkbox is checked and the other checkbox is checked to check if the rule should apply. If the checkbox of the pickaxe is not checked then the check shows that the checkbox checked state of the previous checkbox isnt checked and thus the current checked box doesnt apply the checked checkbox state. Got that? Great. Me neither.
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js