/* Fallback styles and root styles */
:root {
    background-color: black;
    font-family: Arial, Helvetica, sans-serif;
}

/* Center the body content */
body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 15vh;

}

body.adv-open {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: 35vh;

}

/* Logo styles */
.logo {
    color: white;
    text-align: center;
    font-family: 'Libre Franklin', sans-serif;
}

/* GitHub button (top-left) */
#githubBtn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    color: #fff; /* makes inline SVG fill via currentColor */
    text-decoration: none;
    border: none;
    border-radius: 6px;
    z-index: 1000;
    cursor: pointer;
}

#githubBtn svg {
    display: block;
    width: 20px;
    height: 20px;
}

#githubBtn:hover {
    background: rgba(255,255,255,0.04);
}

#githubBtn:focus {
    outline: 2px solid rgba(255,255,255,0.12);
    outline-offset: 2px;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    justify-content: center;
    width: 45vw; /* Match canvas width */
    max-width: 1200px;
}

.mode-btn {
    background: black;
    border: 2px solid white;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    flex: 1; /* Equal width */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    height: 50px; /* Fixed height for consistency */
}

.mode-btn svg {
    height: 2rem;
    width: 2rem;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* container for the canvas */
#canvasHolder {
    position: relative; /* Needed for absolute positioning of hint */
    display: block;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    box-shadow: 0 0 10px white;
    border-radius: 1%;
    width: 45vw;
    height: auto;
    overflow: hidden;
    margin-top: 0%;
    cursor: pointer;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

#canvasHolder.drag-hover {
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.8);
    border-color: rgba(0, 255, 0, 0.9);
}

/* canvas element styles */
#memeEditor {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    overflow: inherit;
}

/* controls container */
.controls {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);

    width: 45vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;

    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    border-radius: 5%;
    z-index: 99999;
    --controls-h: calc(100%);
}

/* Text input styles */
.textInput {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 5px;
    background-color: black;
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    box-sizing: border-box;
    text-align: center;
}

#exportBtn {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 5px;
    background-color: black;
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    cursor: pointer;
}

.horizGroupImpact {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

#advBtn {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 5px;
    background-color: black;
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    cursor: pointer;
}

button {
    transition: transform 0.15s ease, background 0.15s ease;
}

button:active {
    transform: scale(0.97);
}

#advancedSettingsHandler {
    /* hidden state */
    max-height: 0;
    opacity: 0;
    transform: translateY(10px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: max-height 0.5s ease-in-out, opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
    pointer-events: none;
}

#advancedSettingsHandler.visible {
    /* visible state */
    max-height: 400px;
    /* large enough to fit contents — adjust if needed */
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.advGroup {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.advLabel {
    color: white;
    font-family: 'Libre Franklin', sans-serif;
}

.advInput {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 5px;
    background-color: black;
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    cursor: pointer;
}

/* Pill control styles */
.pill-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 2px solid white;
    border-radius: 25px;
    background-color: black;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.pill-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 5px 20px;
    cursor: pointer;
    transition: background 0.2s;
    width: auto;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pill-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.pill-input {
    background: none;
    border: none;
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    font-size: 1rem;
    text-align: center;
    width: 100%;
    -moz-appearance: textfield;
    appearance: textfield;
}

.pill-input::-webkit-outer-spin-button,
.pill-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#mobilePlaceholder {
    color: white;
    text-align: center;
    padding: 2rem;
    font-family: sans-serif;
}

.hidden {
    display: none;
}

.version-indicator {
    position: fixed;
    top: 1rem;
    right: 1rem;
    color: #444;
    font-family: 'Libre Franklin', sans-serif;
    font-size: 1rem;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
}

/* Modal Overlay */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalContentScale {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: modalFadeIn 0.3s ease-out forwards;
}

.modal.show .modal-content {
    animation: modalContentScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.modal-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

/* Modal Content Box */
.modal-content {
    background-color: #1a1a1a;
    color: #eee;
    padding: 30px;
    border: 1px solid #333;
    border-radius: 15px;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    font-family: sans-serif;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
    font-weight: normal;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

.modal-content ul {
    padding-left: 20px;
    line-height: 1.6;
    font-size: 1rem;
    color: #ccc;
}

.modal-content li {
    margin-bottom: 10px;
}

/* Close Button */
.close-btn {
    color: #666;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #fff;
}

/* Navigation Controls */
.nav-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    user-select: none;
    min-width: 80px;
}

.nav-group.hidden {
    opacity: 0;
    pointer-events: none;
}

.nav-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: transparent;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.nav-group:hover .nav-btn {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.nav-label {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Upload Hint Overlay */
.upload-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none; /* Let clicks pass through to canvas/container */
    opacity: 0.7;
    transition: opacity 0.2s;
}

.upload-hint span {
    color: white;
    font-family: 'Libre Franklin', sans-serif;
    font-size: 1.2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-align: center;
}

.upload-hint.hidden {
    display: none;
}

/* Export Modal Styles */
.export-options-content {
    max-width: 700px;
    text-align: center;
    background: #000;
    border: 1px solid #333;
}

.modal-title {
    margin-bottom: 2rem;
    font-family: 'Libre Franklin', sans-serif;
}

.export-choices {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.export-choice-btn {
    flex: 1;
    min-width: 250px;
    background: transparent;
    border: 2px solid #fff;
    border-radius: 8px;
    padding: 2rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.export-choice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.export-choice-btn h3 {
    font-size: 1.5rem;
    margin: 0;
    font-family: 'Libre Franklin', sans-serif;
}

.export-choice-btn p {
    font-size: 1rem;
    opacity: 0.8;
    line-height: 1.4;
    margin: 0;
    font-family: 'Libre Franklin', sans-serif;
}

@media (max-width: 600px) {
    .export-choices {
        flex-direction: column;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-group {
        flex-direction: row;
        gap: 15px;
    }
    
    .modal-content {
        order: 2;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .nav-group.left {
        order: 1;
    }
    
    .nav-group.right {
        order: 3;
    }
}

@media (max-width: 600px) {

    /* Center the body content */
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding-bottom: 30vh;

    }

    body.adv-open {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding-bottom: 55vh;
    }

    /* Mobile layout: show canvas and controls, hide the placeholder */

    #canvasHolder {
        display: block;
        width: 95vw;
        max-width: 1200px;
        margin: 0.5rem auto;
        border-radius: 8px;
        border: 1px solid white;
        box-shadow: 0 0 10px white;
        cursor: pointer;
    }

    .mode-selector {
        width: 95vw;
        max-width: 1200px;
    }

    /* Make canvas scale to container width while keeping aspect ratio */
    #memeEditor {
        width: 100%;
        height: auto;
        touch-action: manipulation;
        /* improve touch responsiveness */
    }

    .controls {
        display: flex;
        width: 95vw;
        max-width: 1200px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 0.5rem;
        padding: 0.75rem;
        gap: 0.5rem;
        border-radius: 10px;
    }

    .horizGroupImpact {
        flex-direction: column;
        gap: 0.5rem;
    }

    .textInput {
        width: 100%;
        padding: 0.85rem 0.75rem;
        font-size: 1.05rem;
        border-radius: 8px;
    }

    button,
    .advInput {
        width: 100%;
        padding: 0.8rem;
        font-size: 1.05rem;
        border-radius: 8px;
    }

    .pill-btn {
        width: auto;
        border-radius: 0;
        padding: 5px 20px;
    }

    #mobilePlaceholder {
        display: none;
    }

    /* Keyboard open state */
    body.keyboard-open {
        justify-content: flex-start;
        padding-bottom: 80px;
        padding-top: 10px;
    }

    body.keyboard-open #exportBtn,
    body.keyboard-open #advBtn,
    body.keyboard-open #advancedSettingsHandler {
        display: none !important;
    }

    body.keyboard-open .controls {
        position: fixed;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
        bottom: 0;
        height: auto;
        padding: 10px;
        z-index: 999999;
        left: 0;
        width: 100%;
        transform: none;
        border-radius: 0;
        box-sizing: border-box;
    }

    body.keyboard-open .textInput {
        display: none;
    }

    body.keyboard-open .textInput.active-input {
        display: block;
        width: 100%;
        border: 2px solid white;
        background: black;
    }
}

/* Error Modal Styles */
.error-content {
    max-width: 500px;
    text-align: center;
    background: #000;
    border: 1px solid #333;
    min-height: auto;
    padding-bottom: 40px;
}

.error-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    font-family: 'Libre Franklin', sans-serif;
    font-size: 1.1rem;
    line-height: 1.5;
    color: #ccc;
}

#errorOkBtn {
    background: transparent;
    border: 2px solid #fff;
    border-radius: 8px;
    padding: 12px 40px;
    color: white;
    cursor: pointer;
    font-family: 'Libre Franklin', sans-serif;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    min-width: 150px;
    margin-top: 10px;
}

#errorOkBtn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}
