/* jCvC_modal_layers.js - Jeff Clayton's Modal Window-Like Layer toolkit */

html {
    /*font-size: 16px; /* Base font size for rem calculations */
}

body, html {
 /*   margin: 0;
    padding: 0;
    height: 100%;
    font-family: sans-serif;
 */
}

.jCvC_background_content {
    /*background: linear-gradient(to bottom, #222, #ddd);
    min-height: 100%; /* Change from height to min-height to allow content to expand 
    padding: 1.25rem;
    padding-top: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    box-sizing: border-box; */
}

@media (orientation: landscape) {
    .jCvC_background_content {
        /*padding-top: 5rem; /* More padding at top for landscape */
    }
    
    /* Make sure body allows scrolling */
    body {
        overflow-y: auto;
    }
}

.jCvC_control_panel {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1.25rem;
    border-radius: 0.625rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    margin-bottom: 1.25rem;
    max-width: 37.5rem;
    width: 80%;
}

.jCvC_button_group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
    justify-content: center;
    margin-top: 0.9375rem;
}

.jCvC_spawn_button {
    background-color: white;
    cursor: pointer;
    padding: 0.625rem 0.9375rem;
    border: 0.125rem solid #555;
    border-radius: 0.3125rem;
    box-shadow: 0.125rem 0.125rem 0.3125rem rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-weight: bold;
    font-size: 1rem;
}

.jCvC_spawn_button:hover {
    background-color: #eee;
    transform: translateY(-0.125rem);
    box-shadow: 0.125rem 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
}

.jCvC_spawn_button:active {
    transform: translateY(0.0625rem);
    box-shadow: 0.0625rem 0.0625rem 0.1875rem rgba(0, 0, 0, 0.3);
}

.jCvC_spawn_button.blue { border-color: #0066cc; color: #0066cc; }
.jCvC_spawn_button.green { border-color: #00cc66; color: #00cc66; }
.jCvC_spawn_button.purple { border-color: #6600cc; color: #6600cc; }
.jCvC_spawn_button.orange { border-color: #cc6600; color: #cc6600; }
.jCvC_spawn_button.teal { border-color: #00cccc; color: #00cccc; }

/* Add a visual indicator for active layer buttons */
.jCvC_spawn_button.active {
    background-color: rgba(0, 0, 0, 0.1);
    box-shadow: inset 0.0625rem 0.0625rem 0.1875rem rgba(0, 0, 0, 0.3);
    transform: translateY(0.0625rem);
}

.jCvC_flex_layer {
    position: absolute;
    background-color: rgba(0, 48, 143, 0.5);
    border: 0.125rem solid #ccc;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 12.5rem;
    min-height: 9.375rem;
    border-radius: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
    cursor: move;
    --layer-scale: 1; /* Default scale factor for font sizing */
}

.jCvC_type_files { background-color: rgba(0, 48, 143, 0.5); border-color: #0066cc; }
.jCvC_type_system { background-color: rgba(0, 143, 48, 0.5); border-color: #00cc66; }
.jCvC_type_media { background-color: rgba(98, 0, 143, 0.5); border-color: #6600cc; }
.jCvC_type_social { background-color: rgba(143, 78, 0, 0.5); border-color: #cc6600; }
.jCvC_type_dev { background-color: rgba(0, 130, 130, 0.5); border-color: #00cccc; }

.jCvC_layer_content {
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.3125rem;
    height: 100%;
    overflow: auto;
    box-sizing: border-box;
    padding-top: 2.5rem;
    cursor: default;
}

.jCvC_icon {
    background-color: white;
    border: 0.0625rem solid #ddd;
    padding: 0.625rem;
    margin: 0.3125rem 0;
    text-align: center;
    flex: 0 0 auto;
    width: calc(25% - 0.625rem);
    height: auto;
    aspect-ratio: 4 / 5;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
    font-size: 1rem;
}

.jCvC_icon:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
}

.jCvC_icon:active {
    transform: scale(0.95);
    box-shadow: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.3);
}

.jCvC_type_files .jCvC_icon { border-color: #0066cc; }
.jCvC_type_system .jCvC_icon { border-color: #00cc66; }
.jCvC_type_media .jCvC_icon { border-color: #6600cc; }
.jCvC_type_social .jCvC_icon { border-color: #cc6600; }
.jCvC_type_dev .jCvC_icon { border-color: #00cccc; }

/* Create a container for the window buttons */
.jCvC_window_buttons {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    display: flex;
    flex-direction: row-reverse; /* Positions items from right to left */
    gap: 0.25rem; /* Space between buttons */
    z-index: 10;
}

/* Style for all window control buttons */
.jCvC_window_button {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    color: white;
    text-align: center;
    line-height: 1.5rem;
    cursor: pointer;
    border: 0.125rem solid white;
    box-shadow: 0.0625rem 0.0625rem 0.125rem rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
    .jCvC_window_button {
        width: 2rem;
        height: 2rem;
        line-height: 2rem;
    }
}

/* Maximize button */
.jCvC_maximize_button {
    background-color: rgba(0, 200, 0, 0.7);
    font-size: 1.25rem;
}

.jCvC_maximize_button:hover {
    background-color: rgba(0, 200, 0, 0.9);
    transform: scale(1.1);
}

.jCvC_maximize_button:active {
    background-color: rgba(0, 200, 0, 1);
    transform: scale(0.9);
}

.jCvC_flex_layer.jCvC_maximized {
    width: calc(100vw - 2rem) !important;
    height: calc(100vh - 2rem) !important;
    left: 1rem !important;
    top: 1rem !important;
    z-index: 999 !important; /* Ensure it stays on top */
}

/* Close button */
.jCvC_close_button {
    background-color: rgba(255, 0, 0, 0.7);
    font-size: 1rem;
}

.jCvC_close_button:hover {
    background-color: rgba(255, 0, 0, 0.9);
    transform: scale(1.1);
}

.jCvC_close_button:active {
    background-color: rgba(255, 0, 0, 1);
    transform: scale(0.9);
}

/* Hide buttons when needed */
.jCvC_flex_layer.jCvC_no_min_max .jCvC_maximize_button {
    display: none;
}

.jCvC_flex_layer.jCvC_no_close_button .jCvC_close_button {
    display: none;
}

.jCvC_layer_title {
    position: absolute;
    top: 0.625rem;
    left: 0.625rem;
    font-size: 0.875rem;
    color: white;
    text-shadow: 0.0625rem 0.0625rem 0.125rem rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 6;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jCvC_size_indicator {
    position: absolute;
    bottom: 0.3125rem;
    left: 0.3125rem;
    font-size: 0.6875rem;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 0.125rem 0.3125rem;
    border-radius: 0.1875rem;
    pointer-events: none;
}

.jCvC_layer_counter {
    position: fixed;
    top: 0.625rem;
    right: 0.625rem;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 0.3125rem 0.625rem;
    border-radius: 0.3125rem;
    font-size: 0.875rem;
    z-index: 1000;
}

#jCvC_message_box {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.625rem 0.9375rem;
    border: 0.0625rem solid #ccc;
    border-radius: 0.3125rem;
    z-index: 1000;
    color: #333;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: none;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.2);
    max-width: 80%;
    font-size: 1rem;
}

#jCvC_message_box:hover {
    opacity: 0.7;
}

/* Resize handles */
.jCvC_resize_handle {
    position: absolute;
    background-color: transparent;
    z-index: 5;
}

.jCvC_resize_handle.top {
    top: 0;
    left: 0.5rem;
    right: 0.5rem;
    height: 0.5rem;
    cursor: n-resize;
}

.jCvC_resize_handle.right {
    top: 0.5rem;
    right: 0;
    bottom: 0.5rem;
    width: 0.5rem;
    cursor: e-resize;
}

.jCvC_resize_handle.bottom {
    bottom: 0;
    left: 0.5rem;
    right: 0.5rem;
    height: 0.5rem;
    cursor: s-resize;
}

.jCvC_resize_handle.left {
    top: 0.5rem;
    left: 0;
    bottom: 0.5rem;
    width: 0.5rem;
    cursor: w-resize;
}

.jCvC_resize_handle.top-left {
    top: 0;
    left: 0;
    width: 0.5rem;
    height: 0.5rem;
    cursor: nw-resize;
}

.jCvC_resize_handle.top-right {
    top: 0;
    right: 0;
    width: 0.5rem;
    height: 0.5rem;
    cursor: ne-resize;
}

.jCvC_resize_handle.bottom-right {
    bottom: 0;
    right: 0;
    width: 0.5rem;
    height: 0.5rem;
    cursor: se-resize;
}

.jCvC_resize_handle.bottom-left {
    bottom: 0;
    left: 0;
    width: 0.5rem;
    height: 0.5rem;
    cursor: sw-resize;
}

/* Add styles for non-draggable windows */
.jCvC_flex_layer.jCvC_non_draggable {
    cursor: default;
}

/* Add styles for non-resizable windows */
.jCvC_flex_layer.jCvC_non_resizable {
    border-style: dashed;
}

/* Combined states */
.jCvC_flex_layer.jCvC_non_draggable.jCvC_non_resizable {
    border-style: dotted;
    border-width: 0.1875rem;
}

/* Add a responsive font size that scales with viewport width */
@media (min-width: 75em) { /* 1200px / 16px = 75em */
    html {
        font-size: calc(100% + 0.3vw);
    }
}

@media (max-width: 48em) { /* 768px / 16px = 48em */
    html {
        font-size: calc(87.5% + 0.2vw); /* 14px / 16px = 87.5% */
    }
    
    .jCvC_control_panel {
        width: 90%;
        padding: 0.9375rem;
    }
    
    .jCvC_button_group {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 30em) { /* 480px / 16px = 30em */
    html {
        font-size: calc(75% + 0.2vw); /* 12px / 16px = 75% */
    }
    
    .jCvC_icon {
       width: calc(50% - 0.625rem);
    }
}

@media (max-width: 20em) { /* 320px / 16px = 20em */
    html {
        font-size: 75%; /* 12px / 16px = 75% */
    }
    
    .jCvC_icon {
        width: 100%;
    }
}

/* Volume Control Mini-Window (horizontal) */
.jCvC_volume_control {
    position: fixed;
    top: 0.625rem;
    left: 0.625rem;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 0.3125rem;
    box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 0.625rem;
    display: flex;
    flex-direction: row; /* Changed from column to row */
    align-items: center;
    width: auto; /* Allow it to size based on content */
}

.jCvC_volume_header {
    margin-right: 0.5rem; /* Add right margin instead of bottom margin */
    margin-bottom: 0; /* Remove bottom margin */
}

.jCvC_volume_title {
    font-size: 0.875rem;
    font-weight: bold;
}

.jCvC_volume_body {
    display: flex;
    align-items: center;
    gap: 0.3125rem;
}

.jCvC_volume_toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
}

.jCvC_volume_slider {
    width: 5rem;
}

#jCvC_system_ready_message {
    position: fixed;
    bottom: 5rem; /* Adjust as needed */
    left: 1.25rem;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.625rem 0.9375rem;
    border: 0.0625rem solid #ccc;
    border-radius: 0.3125rem;
    z-index: 1000;
    color: #333;
    opacity: 0.9; /* Slightly transparent */
}

/* Window descriptions panel */
.jCvC_window_descriptions {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1.25rem;
    border-radius: 0.625rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    margin-top: 1.25rem;
    max-width: 37.5rem;
    width: 80%;
}
        
.jCvC_window_description {
    display: flex;
    align-items: center;
    margin-bottom: 0.625rem;
}
        
.jCvC_window_color {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    margin-right: 0.625rem;
    border: 1px solid rgba(0, 0, 0, 0.3);
}
        
.jCvC_window_color.blue { background-color: #0066cc; }
.jCvC_window_color.green { background-color: #00cc66; }
.jCvC_window_color.purple { background-color: #6600cc; }
.jCvC_window_color.orange { background-color: #cc6600; }
.jCvC_window_color.teal { background-color: #00cccc; }

.jCvC_flex_layer.jCvC_type_social {
    width: calc(100vw - 2rem) !important; /* Full viewport width minus 2rem (1rem on each side) */
    height: calc(100vh - 2rem) !important; /* Full viewport height minus 2rem (1rem on each side) */
    left: 1rem !important; /* 1rem from left edge */
    top: 1rem !important; /* 1rem from top edge */
}

/* Make text more responsive at small sizes */
@media (max-width: 30em) {
    .jCvC_window_description {
        font-size: 0.875rem;
    }
}
