/* Font definitions */
@font-face {
    font-family: 'Comic-Lemon';
    src: url('fonts/Comic-Lemon.woff2') format('woff2'),
         url('fonts/Comic-Lemon.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Cat-Comic';
    src: url('fonts/Cat-Comic.woff2') format('woff2'),
         url('fonts/Cat-Comic.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* General Styles */
body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: 'Cat-Comic', Arial, sans-serif;
    background-image: url('memegen-bg.png'); /* Background image */
    background-size: cover;
    background-position: center;
    color: white;
    text-align: center;
}

.home-button {
    position: absolute;
    top: 20px;
    left: 20px;
}

.home-button a {
    text-decoration: none;
    font-family: 'Comic-Lemon', Arial, sans-serif;
    font-size: 1.5em;
    color: #FFFFFF;
    background-color: rgba(210, 87, 130, 0.9); /* Canvas color with transparency */
    padding: 10px 20px;
    border-radius: 5px;
}

.container {
    text-align: center;
    background-color: rgba(210, 87, 130, 0.9); /* Canvas color with transparency */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    color: white;
}

.header {
    font-family: 'Comic-Lemon', Arial, sans-serif;
    font-size: 2.5em;
    color: #ffffff; /* Text color */
    margin-bottom: 20px;
    margin: 20px 0; /* Adjust margin to ensure it's not cropped */
    padding-top: 60px; /* Add padding if necessary */
}

.memeCanvas {
    position: relative;
    width: 500px;
    height: 500px;
    border: 2px solid #ffffff; /* Border color */
    margin-top: 20px;
    overflow: hidden; 
    background-color: #d25782; /* Canvas color */
    display: flex;
    justify-content: center;
    align-items: center;
    object-fit: contain;
    margin-left: auto;
    margin-right: auto;
}

.memeCanvas img {
    max-width: 100%;
    max-height: 100%;
}

#defaultText {
    position: absolute;
    color: white;
    font-size: 2em;
    text-align: center;
}

button, select, input {
    background-color: rgba(255, 255, 255, 0.8);
    border: none;
    padding: 10px;
    margin: 10px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 5px;
}

button:hover, select:hover, input:hover {
    background-color: rgba(255, 255, 255, 1);
}

.face, .text-box {
    position: absolute;
    cursor: move;
    border: 2px dashed transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none; /* Prevent touch scrolling */
}

.face.selected, .text-box.selected {
    border-color: #ffffff; /* Border color */
}

.face img {
    display: block;
    width: 100%;
    height: 100%;
}

.text-box {
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    overflow: hidden;
    resize: both;
    white-space: pre-wrap; /* To allow text wrapping */
    word-wrap: break-word;
    text-align: center; /* Center align text */
    vertical-align: middle; /* Vertically center text */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30pt; /* Default text size */
    position: absolute;
    cursor: move;
    border: 2px dashed transparent;
}

.text-box:empty:before {
    content: 'Enter text here';
    color: #a0a0a0;
    pointer-events: none;
}

.text-box.selected {
    outline: 2px dotted white;
    border-color: #ffffff; /* Highlight selected text box */
}

.face .remove, .text-box .remove {
    position: absolute;
    top: -10px;
    right: -10px;
    background: red;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: none;
}

.face.selected .remove, .text-box.selected .remove {
    display: block;
}

.text-box.selected {
    outline: 2px dotted white;
    padding: 10px;
    position: relative;
}

.face .resize-handle, .face .rotate-handle, .text-box .resize-handle, .text-box .rotate-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #000;
    cursor: pointer;
    display: none;
}

.face.selected .resize-handle, .face.selected .rotate-handle, .text-box.selected .resize-handle, .text-box.selected .rotate-handle {
    display: block;
}

.face .resize-handle.nw, .face .resize-handle.ne, .face .resize-handle.sw, .face .resize-handle.se,
.text-box .resize-handle.nw, .text-box .resize-handle.ne, .text-box .resize-handle.sw, .text-box .resize-handle.se {
    width: 10px;
    height: 10px;
    background: #000;
    position: absolute;
    z-index: 10;
}

.face .resize-handle.nw, .text-box .resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.face .resize-handle.ne, .text-box .resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.face .resize-handle.sw, .text-box .resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.face .resize-handle.se, .text-box .resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

.face .rotate-handle, .text-box .rotate-handle {
    top: -20px;
    left: calc(50% - 5px);
    cursor: grab;
    background: green;
}

#watermark {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: black;
    color: white;
    padding: 5px;
    font-size: 6pt;
    z-index: 10;
    pointer-events: none;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .memeCanvas {
        width: 100%;
        height: auto;
    }

    .container {
        padding: 10px;
    }

    .header {
        font-size: 1.5em;
    }
}
