@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;700&display=swap');

:root {
    --background-color: #000000;
    --text-color: #ffffff;
    --accent-color: #00B49B;
    --border-color: #555;
    --ui-dark-bg: #11111190;
    --transition-curve: cubic-bezier(0.68, -0.55, 0.27, 1.55);
    --file-item-height: 52px;
}

* {
    cursor: none;
    box-sizing: border-box; 
}

/* Scrollbar, Keyframes & Body */
::-webkit-scrollbar { width: 8px; background-color: transparent; }
::-webkit-scrollbar-thumb { background-color: #111111ab; border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
@keyframes moveGradients { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes line-reveal { from { clip-path: inset(50% 0 50% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes fade-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    overflow: hidden;
    background-image: 
        radial-gradient(at 15% 20%, hsl(280, 50%, 30%) 0px, transparent 50%),
        radial-gradient(at 80% 30%, hsl(170, 50%, 20%) 0px, transparent 50%),
        radial-gradient(at 70% 85%, hsl(310, 60%, 25%) 0px, transparent 50%);
    background-size: 250% 250%;
    animation: moveGradients 15s ease-in-out infinite;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 2rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    height: 50px;
    width: auto;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-text .name {
    font-size: 1.125rem;
    font-weight: 500;
}

.logo-text .title {
    font-size: .63rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: .3em;
}

.cta-button {
    padding: .8rem 1.5rem;
    border-radius: 50px;
    background-color: #11111190;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    text-decoration: none;
    font-weight: 700;
    font-size: .9rem;
    transition: all .4s var(--transition-curve);
}

.cta-button:hover {
    background-color: var(--accent-color);
    color: #121212;
    transform: scale(1.05);
}

.header-right-mobile {
    display: none; /* Hidden by default */
}

#custom-cursor {
    position: fixed;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--text-color);
    mix-blend-mode: difference;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: width .4s var(--transition-curve), height .4s var(--transition-curve);
    z-index: 9999;
}

#custom-cursor.hover {
    width: 60px;
    height: 60px;
}

#background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

#background-carousel {
    position: relative;
    display: flex;
    height: 100%;
}

.carousel-image {
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 2s ease-in-out;
}

.carousel-image.visible {
    opacity: .12;
}

.carousel-image.fading-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.main-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
}

.upload-wrapper {
    position: relative;
    width: 450px;
    height: 194px;
    margin-top: 2rem;
    transform-origin: bottom;
    transition: height .4s var(--transition-curve), transform .4s var(--transition-curve);
}

#upload-area {
    position: absolute;
    min-height: 150px;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem;
    border-radius: 32px;
    text-align: center;
    display: grid;
    place-items: center;
    transition: all .4s ease;
    z-index: 5;
    background-color: #12121220;
    border: 2px dashed var(--border-color);
}

#upload-area.dragover {
    border-color: var(--accent-color);
}

#upload-area.loaded { 
    border-color: transparent;
    align-items: flex-start;
}

#upload-area p { 
    pointer-events: none; 
    transition: opacity .3s ease;
    opacity: 1;
    grid-row: 1; /* Position in the same grid cell */
    grid-column: 1;
}

#upload-area p.hidden { opacity: 0; }

#file-list-container {
    width: calc(100% + 12px);
    height: 100%;
    border-radius: 26px; /* Inner radius */
    padding: 3.5rem 1rem 0rem 1rem; /* Space for buttons at top */
    padding-top: 2.5rem;
    padding-left: 0rem;
    padding-right: 0.7rem;
    padding-bottom: 0rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-sizing: border-box;
    z-index: 6; 
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
    overflow-y: auto;
    grid-row: 1; 
    grid-column: 1;
    margin-right: -12px; /* adjust for scrollbar width */
}

#file-list-container.visible { opacity: 1; pointer-events: all; }

/* Gradient mask only when scrolling */
#file-list-container.scrolling {
    -webkit-mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 90%,  rgba(0,0,0,0));
    mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 90%,  rgba(0,0,0,0));
}

#file-list-container.scrolling.no-bottom-fade {
    -webkit-mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 100%,  rgba(0,0,0,0));
    mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 100%,  rgba(0,0,0,0));
}

.file-item {
    position: relative;
    display: flex;
    align-items: center;
    background-color: #12121290;
    padding: 0.5rem;
    border-radius: 12px;
    height: var(--file-item-height);
    flex-shrink: 0; /* Prevent items from shrinking */
}

.file-item-preview-img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 1rem;
    flex-shrink: 0;
    background-color: #333; /* Placeholder color */
}

.file-item-name {
    color: #ffffff;
    text-align: left;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    padding-right: 1rem; /* Space for remove button */
    -webkit-mask-image: linear-gradient(to right, black 70%, transparent 100%);
    mask-image: linear-gradient(to right, black 70%, transparent 100%);
}

.file-item-remove-btn {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.file-item-remove-btn::before, .file-item-remove-btn::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 2px;
    background-color: white;
    transition: background-color 0.2s ease;
}
.file-item-remove-btn:hover::before, .file-item-remove-btn:hover::after { background-color: var(--accent-color); }

.file-item-remove-btn::before { transform: rotate(45deg); }
.file-item-remove-btn::after { transform: rotate(-45deg); }

.modal {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    visibility: hidden;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 450px;
    height: 194px;
    transform: translate(-50%, -50%);
}

.modal.visible {
    visibility: visible;
}

.modal.opening {
    animation: line-reveal .5s var(--transition-curve) forwards;
}

.modal.closing {
    animation: fade-out .3s ease-in-out forwards;
}

#upload-area.hidden {
    visibility: hidden;
    opacity: 0;
}

.modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: 32px;
    background-color: var(--ui-dark-bg);
    background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.01) 2px, rgba(255, 255, 255, 0.01) 4px);
    z-index: 1;
    overflow: visible;
    position: relative;
}

.modal-header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: -3rem;
    left: 0;
}

.modal-header h2 {
    margin: 0;
    padding: 0;
    font-weight: 400;
    font-size: 1.375rem;
    text-align: center;
}

.modal-header .close-btn {
    position: absolute;
    top: 4rem; 
    right: 1rem;
}

.custom-slider {
    position: relative;
    width: 90%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--ui-dark-bg);
    border-radius: 18px;
}

.custom-slider::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: var(--slider-fill, 50%);
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 18px;
    z-index: 1;
}

.custom-slider span {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    color: var(--accent-color);
    font-weight: 700;
    font-size: .9rem;
    pointer-events: none;
}

.custom-slider span::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--background-color);
    z-index: 2;
    clip-path: inset(0 calc(100% - var(--slider-fill, 50%)) 0 0);
}

input[type="range"] {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    z-index: 10;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 0; 
    height: 36px;
    background: transparent;
}

input[type="range"]::-moz-range-thumb {
    width: 0; 
    height: 36px;
    border: 0;
    background: transparent;
}

.custom-select {
    position: relative;
    width: 90%;
    height: 36px;
}

.select-selected {
    background-color: var(--ui-dark-bg);
    color: var(--text-color);
    height: 100%;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .4s var(--transition-curve);
    font-size: .9rem;
    padding: 0 1rem;
}

.select-selected::after {
    position: absolute;
    content: '';
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-color);
}

.select-selected.select-arrow-active::after {
    border-bottom: 5px solid var(--text-color);
    border-top: 0;
}

.select-items {
    position: absolute;
    background-color: #121212;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    border-radius: 100px;
    z-index: 2;
    display: flex;
    align-items: center;
    padding: 8px 9px;
    gap: 8px;
}

.select-items div {
    position: relative;
    color: var(--text-color);
    padding: .5rem 0;
    text-align: center;
    transition: background-color .3s ease, color .3s ease;
    flex: 1;
    border-radius: 100px;
}

.select-items div.option-selected::after {
    content: '*';
    position: absolute;
    right: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-color);
    font-weight: 500;
    font-size: 180%;
}

.select-items div:hover {
    background-color: var(--accent-color);
    color: var(--background-color);
}

.select-hide {
    display: none;
}

#upload-area p strong {
    font-weight: 700;
}

.options-container {
    position: absolute;
    bottom: 100px;
    display: flex;
    justify-content: center;
    gap: 2.7rem;
    margin: 0;
    padding: 0.9rem 2.7rem;
    border-radius: 50px;
    background-color: var(--ui-dark-bg);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s var(--transition-curve), transform .5s var(--transition-curve);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.options-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.option-trigger {
    font-size: 0.95rem;
    font-weight: 300;
    position: relative;
}

.option-trigger.active::after {
    content: '*';
    position: absolute;
    top: -10px;
    right: -17px;
    color: var(--accent-color);
    font-weight: 500;
    font-size: 180%;
}

.action-buttons {
    position: absolute;
    bottom: 40px;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

#convert-btn {
    padding: 0.76rem 1.9rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all .5s var(--transition-curve);
    background-color: var(--accent-color);
    color: var(--background-color);
    border: 2px solid transparent;
    opacity: 0;
    transform: translateY(20px);
}

#convert-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

#reset-btn, #add-more-btn, .close-btn {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    width: 28px;
    height: 28px;
    background-color: #111111;
    border: none;
    border-radius: 50%;
    transition: all .4s var(--transition-curve);
    z-index: 12;
    flex-shrink: 0;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

#reset-btn:hover,
#add-more-btn:hover,
.close-btn:hover {
    transform: rotate(90deg);
}

#reset-btn, #add-more-btn {
    position: absolute;
    top: 1rem;
    opacity: 0;
    pointer-events: none;
}

#reset-btn {
    right: 1rem;
}

#add-more-btn {
    left: 1rem;
}

#upload-area.loaded #reset-btn, #upload-area.loaded #add-more-btn {
    opacity: .7;
    pointer-events: all;
}

#reset-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 2px;
    background-color: #e1e1e1;
    transform: translate(-50%, -50%);
    transition: background-color .3s ease;
}

#reset-btn:hover::before {
    background-color: var(--accent-color);
}

#add-more-btn::before, #add-more-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    background-color: #e1e1e1;
    transition: background-color .3s ease;
}

#add-more-btn::before {
    width: 12px;
    height: 2px;
    margin-left: -6px;
    margin-top: -1px;
}

#add-more-btn::after {
    width: 2px;
    height: 12px;
    margin-left: -1px;
    margin-top: -6px;
}

#add-more-btn:hover::before, #add-more-btn:hover::after {
    background-color: var(--accent-color);
}

.close-btn:hover::before, .close-btn:hover::after {
    background-color: var(--accent-color);
}

.sub-options {
    width: 90%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    transition: opacity .3s ease, transform .3s ease, max-height .4s ease;
    max-height: 100px;
    transform: translateY(0);
    overflow: hidden;
}

.sub-options.hidden {
    max-height: 0;
    opacity: 0;
    transform: translateY(-10px);
    margin: 0 !important;
    padding: 0;
    gap: 0;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
}

.checkbox-wrapper label {
    font-size: .9rem;
    font-weight: 500;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    position: relative;
    transition: all .2s ease;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '';
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    transition: opacity .3s ease .1s, max-width .4s ease;
    max-width: 150px;
    opacity: 1;
    overflow: hidden;
    white-space: nowrap;
}

.color-input-wrapper.hidden {
    max-width: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    border: none;
    transition: opacity .2s ease, max-width .3s ease;
}

.color-picker-container {
    display: flex;
    align-items: center;
    border: 0px solid var(--border-color);
    border-radius: 25px 12px 12px 25px;
    background-color: #11111190;
    padding: .4rem;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 25px;
}

#webp-bg-color-hex {
    background: transparent;
    border: none;
    color: var(--text-color);
    width: 80px;
    text-align: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: .9rem;
    caret-color: var(--accent-color);
    text-shadow: 0 0 0 var(--text-color);
}

#webp-bg-color-hex:focus {
    outline: none;
    box-shadow: none;
}

/* Credits Popup */
.credits-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s .3s, opacity .3s ease;
}

.credits-popup.visible {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.credits-popup::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.01) 2px, rgba(255, 255, 255, 0.01) 4px);
    pointer-events: none;
    z-index: -1;
}

#close-credits-popup {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 36px;
    height: 36px;
    background-color: var(--ui-dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    z-index: 1010;
}

#close-credits-popup::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    background-color: var(--text-color);
    transform: translate(-50%, -50%);
}

.credits-popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.credits-popup-content .logo {
    transform: scale(1.5);
}

.credits-popup-content .logo-text {
    display: flex; /* Ensure it's visible inside the popup */
    text-align: center;
}

.credits-popup-content .cta-button {
    margin-top: 40px;
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 0 1.5rem 1.5rem; /* Adjust padding to bring button to the edge */
    }

    .header-left {
        flex-grow: 1;
    }

    .logo-text {
        display: none; /* Hide name/title on mobile */
    }

    .header-right {
        display: none; /* Hide desktop CTA */
    }

    .header-right-mobile {
        display: block;
    }

    .credits-button-mobile {
        padding: calc(.8rem - 3px) 1.5rem; /* Adjust padding */
        background-color: #13131390;
        color: var(--accent-color);
        text-decoration: none;
        font-weight: 700;
        font-size: .9rem;
        border-radius: 50px 0 0 50px;
        border: none;
    }

    .upload-wrapper {
        width: 90%;
        min-height: 160px;
        margin-top: 0;
        transform: translateY(-20%)!important; /* Visually center on mobile */
    }

    .modal {
        width: 90%;
        transform: translate(-50%, -50%) scale(0.9);
    }

    .options-container {
        width: 70%;
        transform: scale(0.85);
        gap: 0;
        justify-content: space-evenly; /* Use space-evenly for padding effect */
        padding: 1rem 12px;
        bottom: 110px;
    }

    .action-buttons {
        bottom: 50px;
    }
    
    #close-credits-popup {
        top: 2rem;
        right: 2rem;
        bottom: auto;
        transform: none;
    }
    #file-list-container.scrolling.no-bottom-fade {
        -webkit-mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 100%,  rgba(0,0,0,0));
        mask-image: linear-gradient(to bottom,  rgba(0,0,0,0), black 10%, black 100%,  rgba(0,0,0,0));
    }
}
