/* Extracted Styles for the Customizable Paper-Cut Scene Editor */

.layer-control-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.drag-handle {
    cursor: grab;
    font-weight: bold;
    color: #aaa;
    user-select: none;
    /* Prevents text selection while dragging */
}

.upload-control-group.dragging {
    opacity: 0.5;
    background: #e0e0e0;
}

#share-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

#share-overlay.visible {
    display: flex;
}

#share-modal {
    background-color: white;
    padding: 25px 35px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

#close-share-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
}

#share-content textarea,
#share-content input {
    width: 100%;
    box-sizing: border-box;
}

.link-btn {
    color: #cbcbcb;
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    background-color: rgba(93, 105, 172, 1);
}

.layer-control-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.move-buttons {
    display: flex;
    flex-direction: row;
}

.move-layer-btn {
    background: #f0f3f5;
    border: 1px solid #dee2e6;
    color: #495057;
    cursor: pointer;
    width: 24px;
    height: 18px;
    font-size: 10px;
    line-height: 1;
}

.move-layer-btn.up {
    border-radius: 5px 5px 0 0;
}

.move-layer-btn.down {
    border-radius: 0 0 5px 5px;
    border-top: none;
}

.move-layer-btn:hover {
    background-color: #ced4da;
}

/* Shared button styles */
.action-btn {
    display: block;
    width: 100%;
    padding: 4px 8px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

/* --- Scene Carousel Navigation --- */
.scene-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    /* Above layers but below the controls panel */
    background-color: rgba(0, 0, 0, 0.25);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 22px;
    font-weight: bold;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.3s ease, background-color 0.3s ease, transform 0.3s ease;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.scene-nav-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.5);
    transform: translateY(-50%) scale(1.05);
}

#prev-scene-btn {
    left: 15px;
}

#next-scene-btn {
    right: 15px;
}

/* NEW STYLES FOR CONSOLIDATED CONTROLS */

#user-info {
    text-align: center;
    margin-bottom: 10px;
    color: #373737;
}

#controls {
    position: absolute;
    top: 10px;
    left: 10px;
    bottom: 30px;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 15px;
    padding-top: 60px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    border: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#controls h3 {
    margin: 15px 0 10px 0;
    font-size: 1rem;
    color: #373737;
    text-align: center;
    border-top: 1px solid #ddd;
    padding-top: 15px;
}

#controls h3:first-of-type {
    margin-top: .6rem;
    border-top: none;
    padding-top: 0;
    border-bottom: 1px solid #373737;
}

.control-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #373737;
    pointer-events: none;
}

.control-group {}

#controls input[type="range"] {
    touch-action: none;
    /* Prevents scrolling conflicts */
}

.upload-control-group {
    border: 1px solid #ddd;
    padding: 10px;
    margin-top: .6rem;
    margin-bottom: .6rem;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.2);
}

.collapsible-content>.collapsible-header {
    color: #e1e1e1;
    background-color: rgb(64 147 159);
    /*box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.6);*/
}

.collapsible-content {
    border: #ffffff solid 1px;
    background-color: rgb(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: .6rem;
    margin-bottom: 3px;
    max-height: 4000px;
    /* Large value for open state */
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out, margin 0.4s ease-in-out;
}

.layer-transform-controls {
    display: none;
    /* Hidden by default */
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

.layer-transform-controls.visible {
    display: block;
}

.layer-animation-controls {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

.micro-control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.micro-control-group label {
    margin-right: 10px;
    font-size: 0.9em;
    flex-basis: 40px;
    /* Give labels a consistent width */
    flex-shrink: 0;
}

.micro-controls {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.micro-controls input[type="range"] {
    flex-grow: 1;
}

.micro-controls input[type="number"] {
    width: 60px;
    margin-left: 8px;
}

.micro-controls input[type="range"] {
    flex-grow: 1;
    touch-action: none;
    /* Add this line */
}

#controls input[type="range"] {
    touch-action: none;
}

.controls-panel-transparent {
    opacity: .2;
    background-color: rgba(0, 0, 0, 0.2) !important;
}

/* Add this new rule to your CSS style block */
div.collapsible-content>div.control-group>input[type="range"] {
    touch-action: none;
}

/* --- Mobile Responsiveness for Text --- */
@media (max-width: 768px) {
    .title-container {
        /* Adjust container width and position to be safe on mobile */
        width: 90vw;
        top: clamp(40%, calc(15% + var(--text-top, 30%)), 85%) !important;
        /* Adjust vertical position for mobile */
    }

    .title-container h1 {
        /* Use viewport width (vw) for fluid scaling, with min/max clamps */
        /* This ensures the font size is responsive but never too small or too large */
        font-size: clamp(1.5rem, calc(var(--headline-size, 5rem) * 0.6), 3.5rem) !important;
        letter-spacing: -1px !important;
        /* Reduce spacing on mobile */
        line-height: 1.1 !important;
        /* Tighten line height */
        word-break: break-word;
        /* Prevent overflow from long words */
    }

    .title-container p {
        font-size: clamp(0.8rem, calc(var(--subtitle-size, 1.3rem) * 0.75), 1.3rem) !important;
        line-height: 1.3 !important;
        width: 95% !important;
        /* Ensure subtitle width is constrained */
        margin: 1em auto 0;
        /* Add some space and center the paragraph */
    }
}

/* Define base shadow properties. The JS will override these. */
.layer svg {
    filter: drop-shadow(var(--shadow-offset-x) var(--shadow-offset-y) var(--shadow-blur) var(--shadow-color));
    transition: filter 0.3s ease;
    /* Smooth transition for the shadow */
}

/* --- Smooth Theme Transitions --- */
#scene .layer svg path,
#scene .layer svg rect,
#scene .layer svg circle,
#scene .layer svg polygon,
#scene .layer svg ellipse {
    /* Smoothly animates the fill color change over 0.8 seconds */
    transition: fill 0.8s ease;
}

.title-container h1,
.title-container p {
    /* Also transition the text color for a cohesive effect */
    transition: color 0.8s ease;
}

/* --- SVG Library Footer Styles --- */
#svg-library-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 150;
    /* Below help overlay, above scene */
    background-color: #2c3e50;
    color: #ecf0f1;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
}

#toggle-library-btn {
    width: 100%;
    background-color: #34495e;
    color: #ecf0f1;
    border: none;
    padding: 10px;
    font-size: 1rem;
    cursor: pointer;
    border-top: 1px solid #4a627a;
}

#toggle-library-btn:hover {
    background-color: #4a627a;
}

#svg-library-content {
    padding: 15px;
    max-height: 40vh;
    /* Limit the height */
    overflow-y: auto;
    /* Allow scrolling if content overflows */
}

.library-actions {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #4a627a;
    display: flex;
    gap: 10px;
}

.svg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.svg-thumbnail {
    width: 100%;
    height: 100px;
    border: 2px solid #7f8c8d;
    border-radius: 5px;
    background-color: #ecf0f1;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
    padding: 5px;
    box-sizing: border-box;
    /* Ensure padding is included in the size */
}

.svg-thumbnail:hover {
    transform: scale(1.05);
    border-color: #3498db;
}

.svg-thumbnail svg {
    width: 100%;
    height: 100%;
    fill: #34495e;
    /* Default fill for library SVGs */
}

/* --- Mobile Responsiveness for Control Panel --- */
@media (max-width: 768px) {
    #controls {
        /* Make the panel take up most of the screen, not a fixed pixel value */
        width: 85vw;
        max-width: 340px;
        /* Add a max-width for smaller tablets */
        font-size: 14px;
        /* Slightly reduce font size for readability */
    }

    /* Adjust padding to create more space inside the panel */
    #controls .collapsible-content {
        padding: 10px;
    }

    /* Make form elements and buttons take up the full available width */
    #controls input[type="text"],
    #controls input[type="password"],
    #controls select,
    #controls .action-btn {
        width: 100%;
        box-sizing: border-box;
        /* Important for consistent sizing */
    }

    /* Allow the buttons for each layer to wrap onto a new line on narrow screens */
    .layer-control-buttons {
        flex-wrap: wrap;
        gap: 5px;
    }

    .layer-control-buttons .svg-upload {
        flex-basis: 100%;
        /* Make the file input take its own line */
    }
}

/* New class for solo mode */
.solo-mode-hidden {
    display: none !important;
}

.svg-thumbnail {
    position: relative;
    /* This is required to position the delete button */
}

.delete-svg-btn {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    background-color: #c0392b;
    /* A subtle red */
    color: white;
    border: 1px solid white;
    border-radius: 50%;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    /* Hide the button by default */
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: scale(0.8);
}

.svg-thumbnail:hover .delete-svg-btn {
    opacity: 1;
    /* Show the button on hover */
    transform: scale(1);
}

.delete-svg-btn:hover {
    background-color: #e74c3c;
    /* Brighter red on hover */
}

/* NEW styling for the footer toggle as a tab */
#toggle-footer-btn {
    position: absolute;
    bottom: 100%;
    /* Sits directly on top of the footer content */
    right: 0px;
    padding: 10px 25px;
    border: none;
    background: #954a0a;
    /* Matches the footer */
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-weight: bold;
    font-size: .9rem;
    cursor: pointer;
    /* Creates the tab shape */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

/* Reveal/Hide Title Text Tab */
.text-toggle-tab {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    color: #333;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.text-toggle-tab:hover {
    background: rgba(255, 255, 255, 0.95);
    padding-top: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* Title container background & dropdown animations */
.title-container {
    background-color: rgba(0, 0, 0, 0.4);
    border: 2px solid #ffffff;
    padding: 20px;
    width: 90%;
    border-radius: 10px;
    box-sizing: border-box;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.6s ease, visibility 0.6s, background-color 0.3s ease, border-color 0.3s ease, padding 0.3s ease, width 0.3s ease, border-radius 0.3s ease;
    
    /* Standardization fixes for containment and overflow */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-height: 80vh;
    overflow-y: auto;
}

.title-container.hidden-text {
    transform: translate(-50%, calc(-50% - var(--text-top-vh, 30vh) - 100%)) !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

