/* piano.css */


/* An example of how you could get a smaller fixed-width piano.
   You would use it like this on your page that includes the piano:

   <div class="tiny-piano-wrapper">
        <div id="pianocontainer" class="piano-container">
            <!-- Piano keys will be added here by JavaScript -->
        </div>
   </div>

 */
.tiny-piano-wrapper {
    transform: scale(0.6);
    transform-origin: top left; /* Adjust scaling reference point */
    width: fit-content; /* Prevents scaling from affecting surrounding layout */
}

/* Dropdown container for selecting keyboard layout */
.keyboard-layout-dropdown {
    position: absolute; /* Position the dropdown absolutely within the piano container */
    top: 10px; /* Distance from the top */
    right: 10px; /* Distance from the right */
    z-index: 2; /* Ensure it appears above the piano keys */
}

/* keyboard layout Dropdown styling */
.keyboard-layout-dropdown select {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: rgb(230, 230, 230);
    font-size: 14px;
    color: #333;
    cursor: pointer;
    outline: none; /* Remove the default focus outline */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

/* keyboard layout Dropdown hover effect */
.keyboard-layout-dropdown select:hover {
    border-color: #888;
}

/* keyboard layout Dropdown focus effect */
.keyboard-layout-dropdown select:focus {
    border-color: #555;
}

/* Hide keyboard layout dropdown on small screens with touch input.
 * These devices may not have a keyboard layout to select, and even if
 * they do, it's unlikely to be used for the piano.
 */
/*@media (max-width: 768px) and (pointer: coarse) {*/
@media (max-width: 768px) {
    .keyboard-layout-dropdown select {
        display: none;
    }
}

/* Styling for the piano container
 *
 * This is the main container for the piano keys, the piano'S frame if you want. Users need to provide a div with the id "pianocontainer"
 * and class "piano-container" to use the piano in their HTML. The piano keys will be added to this container by JavaScript.
 *
 * E.g., <div id="pianocontainer" class="piano-container"></div>
 */
.piano-container {
    display: inline-block;
    background-color: rgb(220, 220, 220);
    padding: 40px; /* Frame thickness */
    border-radius: 10px; /* Rounded corners for the frame */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Subtle shadow for depth */
    position: relative; /* Position relative for absolute children */
}


/* The piano consists of a list of piano keys. It is inside the piano-container, which can be seen as the frame of the piano. */
.piano {
    display: flex;
    margin-top: 20px;
}

/* White piano keys */
.key {
    width: 40px;
    height: 220px;
    border: 1px solid #000;
    background-color: white;
    cursor: pointer;
    border-radius: 0 0 8px 8px; /* Rounded corners at the bottom */
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); /* Add a subtle shadow */
    transition: background-color 0.1s ease; /* Smooth transition for highlighting */
    user-select: none; /* Prevent text selection */
    -webkit-user-drag: none; /* Disable dragging in WebKit browsers */
}

/* Black piano keys */
.key.black {
    width: 25px;
    height: 140px;
    background-color: black;
    margin-left: -15px;
    margin-right: -15px;
    z-index: 1;
    border: 1px solid #000;
    border-radius: 0 0 6px 6px; /* Rounded corners for black keys */
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); /* Darker shadow for black keys */
}

/* Active key. Active means it is currently pressed. */
.key.active {
    background-color: #ccc; /* Highlight color when key is pressed */
}

.key.black.active {
    background-color: #555; /* Darker highlight for black keys */
}

/* Highlighted key. Highlighting is used programatically to highlight keys, e.g., to show which key is currently to be pressed, or which keys are pressed when during playback of a song. */
.key.highlighted {
    background-color: #ff4444; /* Red highlight for white keys */
}

.key.black.highlighted {
    background-color: #cc0000; /* Darker red highlight for black keys */
}

/* Responsive styles for smaller screens
 * This media query adjusts the layout of the piano for smaller screens, such as tablets and mobile devices.
 * It is a responsive design that stacks the keys vertically and adjusts their size based on the screen width.
 */
@media (max-width: 768px) and (orientation: portrait) {
    /* Ensure html and body take up full height */

    /* Piano container */
    .piano-container {
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgb(220, 220, 220);
        position: absolute; /* Keep absolute positioning */
    }

    /* Piano keys (vertical layout) */
    .piano {
        display: flex;
        flex-direction: column; /* Stack keys vertically */
        align-items: flex-end;
    }

    /* White keys */
    .key {
        width: 80vw; /* Responsive width based on viewport width */
        height: 5vh; /* Adjust height based on number of keys */
        border: 1px solid #000;
        background-color: white;
        cursor: pointer;
        border-radius: 8px 0 0 8px; /* Rounded corners at the top */
        box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
        transition: background-color 0.1s ease;
        user-select: none;
        -webkit-user-drag: none;
    }

    /* Black keys */
    .key.black {
        width: 50vw; /* Slightly narrower than white keys */
        height: 4vh; /* Adjust height based on number of keys */
        background-color: black;
        margin-left: 0; /* Reset horizontal margin */
        margin-right: 0; /* Reset horizontal margin */
        margin-top: -2.1vh; /* Overlap with white keys */
        margin-bottom: -2.1vh; /* Overlap with white keys */
        z-index: 1;
        border: 1px solid rgb(160, 160, 160);
        border-radius: 6px 0 0 6px; /* Rounded corners at the top */
        box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
        user-select: none;
        -webkit-user-drag: none;
    }

    /* Active key */
    .key.active {
        background-color: #ccc; /* Highlight color when key is pressed */
    }

    .key.black.active {
        background-color: #555; /* Darker highlight for black keys */
    }

    /* Highlighted key */
    .key.highlighted {
        background-color: #ff4444; /* Red highlight for white keys */
    }

    .key.black.highlighted {
        background-color: #cc0000; /* Darker red highlight for black keys */
    }
}