/* Modal styles */
.modal {
    display: flex; /* Use flexbox for centering */
    justify-content: center;
    align-items: center;
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

.modal-content {
    background-color: #282c34; /* Dark background for the modal content */
    color: #f1f1f1; /* Light text color */
    margin: auto; /* Auto margins for centering */
    padding: 25px;
    border: 1px solid #555;
    border-radius: 8px;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 700px; /* Maximum width */
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    text-align: left;
}

.modal-content h2 {
    margin-top: 0;
    color: #61dafb; /* A light blue for the heading, similar to React logo */
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-content p {
    line-height: 1.6;
    margin-bottom: 15px;
}

.modal-content button {
    background-color: #61dafb; /* Light blue background */
    color: #282c34; /* Dark text for contrast */
    padding: 10px 20px;
    margin-top: 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: block; /* Make it a block to center it with margin auto */
    margin-left: auto;
    margin-right: auto;
}

.modal-content button:hover {
    background-color: #52c7e8;
}

/* Initially hide the modal if controlled by JS, or keep it visible if it should show on load */
/* For this request, it should be visible on load, so no display: none; here initially */


/* General body styling */
body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    color: #fff;
    font-family: sans-serif;
}

canvas {
    display: block;
}

.controls-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

/* General button styling */
.control-button {
    background-color: rgba(40, 40, 40, 0.8);
    color: #e0e0e0;
    border: 1px solid #555;
    padding: 10px 15px;
    margin: 5px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Noto Sans TC', sans-serif;
}

#volume-control-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 20px;
    z-index: 1001;
}

#volume-icon {
    font-size: 20px;
    cursor: pointer;
    margin-right: 8px;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 8px;
    background: #555;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    border-radius: 5px;
}

#volume-slider:hover {
    opacity: 1;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    background: #9d7a94;
    cursor: pointer;
    border-radius: 50%;
}

#volume-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: #9d7a94;
    cursor: pointer;
    border-radius: 50%;
}

.control-button:hover {
    background-color: #444;
}

.control-button.active {
    background-color: #555;
    border-color: #777;
}

.taiji-ui-button {
    padding: 5px; /* Adjust padding for the SVG */
    width: 60px; /* Fixed width for the button */
    height: 60px; /* Fixed height for the button */
    display: flex;
    align-items: center;
    justify-content: center;
}

.taiji-svg {
    width: 100%;
    height: 100%;
}

.taiji-ui-button.wuji-ui .taiji-svg circle[fill='black'],
.taiji-ui-button.wuji-ui .taiji-svg path[fill='black'] {
    fill: white; /* Change black parts to white */
}


@font-face {
    font-family: 'Taiwanlishu';
    src: url('Taiwanlishu.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'ZhuanshuFont';
    src: url('Taiwanshuowenjiezizhuanshu.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

.custom-view-button {
    position: absolute;
    top: 20px; /* Adjust as needed */
    left: 20px; /* Adjust as needed */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px; /* Initial padding, adjust for content and border */
    cursor: pointer;
    border-style: solid;
    border-width: 11px; /* Further reduced border thickness (70% of 15px) */
    border-image-source: url('longwen1.svg');
    border-image-slice: 30 fill; /* Slice value might need fine-tuning based on SVG */
    /* Ensure text is vertically centered if needed, or adjust padding */
    display: flex; /* Added to help with centering if direct children */
    flex-direction: column; /* Stack children vertically */
    align-items: center; /* Center children horizontally */
    justify-content: center; /* Center children vertically */
    border-image-repeat: stretch;
    min-height: 14px; /* Further reduced min-height (70% of 20px) */
    box-sizing: border-box;
    text-align: center;
    color: white;
    transition: transform 0.2s ease-out, filter 0.2s ease-out;
    z-index: 1000; /* Ensure it's above other elements like controls-container */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10 and IE 11 */
    user-select: none; /* Standard syntax */
}

.custom-view-button:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.9)); /* Brighter glow */
}

.custom-view-button .chinese-text {
    font-family: 'Taiwanlishu', sans-serif;
    font-size: 32px; /* Further increased font size */
    line-height: 1; /* Adjust line-height to help with vertical centering within its own box */
    padding-top: 2px; /* Reduced padding to move Chinese text up */
    margin-bottom: 0px; 
    color: #A159B7; 
}

.custom-view-button.zhuanshu-font .chinese-text {
    font-family: 'ZhuanshuFont', sans-serif !important;
}

.custom-view-button .english-text {
    font-family: sans-serif;
    font-size: 14px; /* Further increased font size */
    line-height: 1;
    color: #A159B7; /* Added color */
    margin-top: 2px; /* Reduced margin to move English text up */
}

/* Media Queries for Responsive Button Sizes */

/* Medium screens (e.g., tablets) */
@media (max-width: 768px) {
    .custom-view-button {
        top: 15px;
        left: 15px;
        padding: 6px 10px;
        border-width: 8px;
        min-height: 10px;
    }

    .custom-view-button .chinese-text {
        font-size: 24px; /* Reduced font size */
        padding-top: 1px;
    }

    .custom-view-button .english-text {
        font-size: 10px; /* Reduced font size */
        margin-top: 1px;
    }
}

/* New Button Menu Styles */
#interactive-area {
    position: absolute;
    top: 20px; /* Adjust as needed, same as .custom-view-button */
    left: 0; /* Align to the left edge */
    z-index: 1000; /* Ensure it's above other elements */
    /* Temporary debug styles */
    width: 200px; /* Adjust as needed, can be auto if children define width */
    min-height: 520px; /* Further adjusted min-height to fully cover button and expanded menu */
    /* background-color: rgba(255, 0, 0, 0.2); */ /* Light red transparent background - DEBUG REMOVED */
    /* border: 1px solid red; */ /* DEBUG REMOVED */
}

#button-menu-container {
    position: absolute;
    /* "Earth View" button bottom is ~108px (20px top + ~88px height). 
       Adjusting top to align closer to the Earth View button. */
    top: 108px; 
    left: 0;
    min-width: 150px; /* DEBUG: Ensure it has some width based on content */
    max-height: 400px; /* DEBUG: Increased max-height to ensure space for 5+ buttons */
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(-82%); /* Partially hide, leaving 18% visible */
    /* visibility: hidden; */ /* Removed for no fade-out */
    /* opacity: 0; */ /* Removed for no fade-out */
    transition: transform 0.5s ease-in-out; /* Only transform transition */
    padding-left: 5px; 
    /* background-color: rgba(0,0,255,0.3); */ /* DEBUG: Slightly less opaque blue background - DEBUG REMOVED */
    /* border: 1px solid blue; */ /* DEBUG: Blue border - DEBUG REMOVED */
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
    z-index: 1001; 
    direction: rtl; /* Move scrollbar to the left */
}

#interactive-area:hover #button-menu-container,
#interactive-area.touch-active #button-menu-container {
    transform: translateX(0);
    /* visibility: visible; */ /* Removed for no fade-out */
    /* opacity: 1; */ /* Removed for no fade-out */
    transition: transform 0.5s ease-in-out; /* Only transform transition */
}

.button-list {
    display: flex;
    flex-direction: column;
    /* padding-top: 60px; */ /* Removed as container is now positioned lower */
    direction: ltr; /* Ensure content within list items is LTR */
}

.menu-item {
    position: relative; /* Override position: absolute from .custom-view-button */
    top: auto; /* Reset positioning */
    left: auto; /* Reset positioning */
    right: auto; /* Reset positioning */
    bottom: auto; /* Reset positioning */
    margin-bottom: 5px; /* Uniform 5px space between menu items */
    padding: 2px 12px; /* Override inherited padding to make items shorter */
    /* Most other visual styles (border, text, etc.) will be inherited from .custom-view-button */
    /* Ensure hover effects from .custom-view-button apply, or define specific ones if needed */
    /* Opacity and visibility are handled by #button-menu-container's transition */
}

/* 
  Since .menu-item now also has .custom-view-button, 
  the .custom-view-button:hover styles will apply automatically.
  If specific hover behavior is needed for menu items that differs from the main button, 
  it can be defined here, e.g., .menu-item:hover { ... }
*/

/* 
  Similarly, .chinese-text and .english-text styles within .menu-item 
  will inherit from the general .custom-view-button .chinese-text and .english-text rules.
  If overrides are needed specifically for menu items, they can be defined here.
  For now, we assume the inherited styles are desired.
*/

/* Style for the scrollbar */
#button-menu-container::-webkit-scrollbar {
    width: 8px;
}

#button-menu-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#button-menu-container::-webkit-scrollbar-thumb {
    background: rgba(161, 89, 183, 0.7); /* Purple color from button text */
    border-radius: 4px;
}

#button-menu-container::-webkit-scrollbar-thumb:hover {
    background: rgba(161, 89, 183, 1);
}

/* Fade out effect for top/bottom items when scrolling */
#button-menu-container .button-list .menu-item:first-child {
    /* Placeholder for potential top fade-out if implemented via JS or more complex CSS */
}

/* #button-menu-container .button-list .menu-item:last-child {
    opacity: 0.5; 
} */

/* Ensure the main viewToggleButton is positioned correctly within the interactive area */
#interactive-area > #viewToggleButton {
    /* position: relative; */ /* Not strictly necessary if #interactive-area is not flex/grid and #viewToggleButton is block */
    /* top: 0; */
    /* left: 0; */
    /* transform: translateX(0); */
}

/* Small screens (e.g., mobile phones) */
@media (max-width: 480px) {
    .custom-view-button {
        top: 10px;
        left: 10px;
        padding: 4px 8px;
        border-width: 6px;
        min-height: 8px;
    }

    .custom-view-button .chinese-text {
        font-size: 18px; /* Further reduced font size */
        padding-top: 0px;
    }

    .custom-view-button .english-text {
        font-size: 8px; /* Further reduced font size */
        margin-top: 0px;
    }
}