/* --- COLORS & BASE --- */
:root {
    --dark-rose: #cc3366;
    --medium-rose: #d65d82;
    --light-rose: #e07a99;
    --rose-shadow: rgba(204, 51, 102, 0.5);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Comic Sans MS", "Marker Felt", cursive;
    font-weight: normal;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #ffccd9 0%, #ffefff 50%, #ffe6ee 100%);
    background-size: 400% 400%;
    color: var(--dark-rose);
    line-height: 1.8;
    animation: backgroundShimmer 15s ease infinite;
    overflow-y: auto;
}

/* --- MAIN LAYOUT --- */
main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
}

/* --- HEADER --- */
h1 {
    font-family: "Brush Script MT", cursive;
    font-size: 2.5em;
    color: #ff69b4;
    text-shadow: 3px 3px 6px rgba(255, 105, 180, 0.4), -2px -2px 4px rgba(255, 255, 255, 0.8);
    margin: 2rem auto 1rem auto;
    text-align: center;
    width: 100%;
    animation: pulse 2s ease-in-out infinite;
    position: relative;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- SECTION CONTAINERS --- */
/* Make all containers and text readable and spaced */
.intro-container,
.button-container,
.result-container,
.loading {
    width: 100%;
    max-width: 500px;
    margin: 1.5rem auto;
    padding: 1.2rem;
    box-sizing: border-box;
    border-radius: 25px;
    background: rgba(255,255,255,0.3);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    font-size: 1.1em;
    line-height: 1.7;
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 500px;
    margin: 1rem auto;
    padding: 1rem;
    box-sizing: border-box;
    border-radius: 25px;
    background: rgba(255,255,255,0.3);
    align-items: stretch;
}

/* Add spacing below the form so the random button is further down */
.button-container form {
    margin-bottom: 2rem;
}

.button-container .random-button {
    margin-top: 0;
    font-size: 1em;
}

/* --- FORM --- */
/* Ensure form fields and buttons are spaced and readable */
form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    align-items: stretch;
    justify-content: center;
    font-size: 1em;
}
input[type="file"] {
    position: relative;
    padding: 1rem 1.5rem;
    font-size: 0.9em;
    color: var(--dark-rose);
    background: linear-gradient(45deg, rgba(255,182,193,0.2), rgba(255,240,245,0.4));
    border: 3px solid var(--dark-rose);
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(255,192,203,0.3), 0 0 12px rgba(255,255,255,0.8);
    transition: all 0.3s ease;
}
input[type="file"]:hover {
    transform: translateY(-2px);
    border-color: #ff69b4;
    box-shadow: 0 12px 20px rgba(255,192,203,0.4), 0 0 15px rgba(255,255,255,0.9);
}
input[type="file"]::-webkit-file-upload-button,
input[type="file"]::file-selector-button {
    visibility: hidden;
    width: 0;
}

/* --- BUTTONS --- */
button, .random-button {
    background: linear-gradient(45deg, var(--dark-rose), var(--medium-rose), var(--light-rose));
    padding: 0.6rem 1.5rem;
    font-size: 0.9em;
    color: white;
    border: 3px solid var(--dark-rose);
    border-radius: 50px;
    box-shadow: 0 8px 16px rgba(255,192,203,0.4), 0 0 12px rgba(255,255,255,0.8);
    position: relative;
    transition: transform 0.2s;
    margin-bottom: 1rem;
    width: 100%;
}
button:hover, .random-button:hover {
    transform: translateY(-3px) rotate(1deg);
    box-shadow: 0 15px 30px rgba(255,192,203,0.6), 0 0 20px rgba(255,255,255,0.9);
}
button::before, .random-button::before {
    content: '🎀 💖';
    position: absolute;
    top: -12px;
    left: 8px;
    font-size: 1em;
    animation: float 3s ease-in-out infinite;
}
button::after, .random-button::after {
    content: '';
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    background: linear-gradient(45deg, #ff69b4, #ffd1dc, #ffb6c1, #ff1493);
    border-radius: 50px;
    z-index: -1;
}

/* --- RESULT & IMAGE --- */
.result-container {
    display: none;
    width: 100%;
    margin: 20px auto;
    padding: 2rem;
    background: linear-gradient(45deg, rgba(255,182,193,0.4), rgba(255,240,245,0.5), rgba(255,182,193,0.4));
    border: 4px solid transparent;
    border-image: linear-gradient(45deg, var(--dark-rose), var(--medium-rose), var(--light-rose), var(--dark-rose)) 1;
    border-radius: 35px;
    box-shadow: 0 15px 35px var(--rose-shadow), 0 0 20px rgba(255,255,255,0.8);
    transition: opacity 0.3s ease-in-out;
    position: relative;
    flex-direction: column;
}
.result-container.active {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
    align-items: stretch !important;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem;
    animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px);}
    to { opacity: 1; transform: translateY(0);}
}
.result-container::before,
.result-container::after {
    content: '🌸 💝 🎀';
    position: absolute;
    font-size: 1.2em;
}
.result-container::before { top: 10px; left: 10px; }
.result-container::after { bottom: 10px; right: 10px; }

#image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}
#image-container img {
    width: 100%;
    max-width: 250px;
    height: auto;
    border-radius: 30px;
    border: 5px solid var(--dark-rose);
    box-shadow: 0 10px 25px rgba(255,192,203,0.4), 0 0 15px rgba(255,255,255,0.8);
    object-fit: cover;
}

/* --- QUOTE --- */
/* Make quote and attribution readable */
.quote-wrapper {
    width: 100%;
    padding: 1rem;
    background: rgba(255,255,255,0.3);
    border-radius: 25px;
    text-align: center;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.quote-container {
    background-color: rgba(255,192,203,0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.random-quote {
    background-color: rgba(147,197,253,0.1);
}
.quote {
    font-family: "Comic Sans MS", cursive;
    font-size: 1.2em;
    line-height: 1.5;
    color: #ff69b4;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5em 0.8em;
    position: relative;
    width: 100%;
    word-break: break-word;
}
.attribution {
    font-family: "Comic Sans MS", cursive;
    font-size: 1em;
    color: #ff69b4;
    font-style: italic;
    text-align: right;
    margin-top: 1em;
    text-shadow: 1px 1px 3px rgba(255,105,180,0.3);
    position: relative;
    word-break: break-word;
}
.attribution::after {
    content: '💝';
    position: absolute;
    right: -45px;
    top: 0;
    font-size: 1.2em;
    animation: twinkle 2s ease-in-out infinite;
}
@keyframes twinkle {
    0%,100%{opacity:1;}
    50%{opacity:0.5;}
}

/* --- LOADING --- */
.loading {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    padding: 2rem 3rem;
    border-radius: 25px;
    border: 3px solid var(--dark-rose);
    box-shadow: 0 10px 30px rgba(255,192,203,0.6), 0 0 20px rgba(255,255,255,0.9);
    text-align: center;
    z-index: 1000;
    animation: floatLoading 2s ease-in-out infinite;
    backdrop-filter: blur(5px);
    background: rgba(255,255,255,0.2);
}
.loading.active { display: block; }
.loading::before {
    content: '✨ 🌟 💫';
    font-size: 2em;
    display: block;
    margin-bottom: 1rem;
    animation: spin 2s linear infinite;
}
.loading-text {
    font-size: 1.5em;
    color: var(--dark-rose);
    margin: 0;
    position: relative;
    display: inline-block;
}
.loading-text::after {
    content: '...';
    position: absolute;
    right: -20px;
    animation: ellipsis 1.5s steps(4) infinite;
}
@keyframes spin { 0%{transform:rotate(0deg);}100%{transform:rotate(360deg);} }
@keyframes floatLoading { 0%,100%{transform:translate(-50%,-50%);}50%{transform:translate(-50%,-60%);} }
@keyframes ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* --- DECORATIONS --- */
body::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background-image: url('https://hbk-bs.github.io/text-the-universal-interface-finepung/rosen.png');
    background-repeat: repeat-x;
    background-position: bottom center;
    background-size: contain;
    z-index: -1;
    opacity: 0.8;
    pointer-events: none;
}
main::before {
    content: '✨ 🌟 ⭐️ ✨ 🌟 ⭐️ ✨ 🌟 ⭐️';
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 1.2em;
    letter-spacing: 0.5em;
    animation: twinkle 2s ease-in-out infinite;
    pointer-events: none;
}

/* --- BACKLINK BUTTON --- */
@import url('https://fonts.googleapis.com/css2?family=Canterbury&display=swap');

#backlink-blog {
  --color-accent: var(--dark-rose);
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px dashed var(--dark-rose);
  background-color: var(--medium-rose);
  padding: 8px;
  cursor: pointer;
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  transition: all 0.3s ease;
  transform: rotate(-2deg) scale(0.9);
  box-shadow: 0 0 10px 0 var(--rose-shadow);
  font-family: 'Canterbury', cursive;
  z-index: 10;
}
#backlink-blog:hover {
  transform: rotate(2deg) scale(1);
  background-color: var(--light-rose);
}
#backlink-blog a {
  text-decoration: none;
  color: inherit;
  background-image: linear-gradient(to right,
                      var(--color-accent) 0%,
                      var(--color-accent) 100%);
  background-size: 0% 100%;
  background-position: left center;
  background-repeat: no-repeat;
  transition: background-size 0.2s ease-in-out;
  padding: 0.5rem;
  display: inline-block;
}
#backlink-blog a:hover {
  background-size: 100% 100%;
  color: white;
}

/* --- RESPONSIVE --- */
@media (max-width: 600px) {
    main,
    .intro-container,
    .button-container,
    .result-container,
    .loading,
    .quote-wrapper,
    form {
        max-width: 100vw;
        padding: 0.7rem;
        font-size: 1.08em;
    }
    h1 { font-size: 1.5em; } /* Bigger than before, but still fits mobile */
    h1::before, h1::after {
        width: 28px;
        height: 28px;
    }
    .quote { font-size: 1.08em; }
    .attribution { font-size: 0.98em; }
    #image-container img { max-width: 90vw; }
}