/* ====================================
   BASE STYLES
   ==================================== */

   body, button, a, input { 
    font-family: 'Architects Daughter', Times, serif; 
}

body {
    background-color: #f0f0f0;
    margin: 0;
    padding: 20px;
    overflow: hidden;
}

/* ====================================
   UTILITY CLASSES
   ==================================== */

.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.full-width {
    width: 100%;
}

.full-height {
    height: 100vh;
}

.font-black {
    font-weight: 900;
}

.text-pink {
    color: #ec4899;
}

.icon-image {
    width: 100%;
    height: 100%;
}

/* Body variants */
.index-body {
    background-color: #f3f4f6;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.draw-body {
    background-color: white;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Prevent scrolling on touch devices and small screens (draw page) */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    html, body.draw-page-container {
        height: 100vh;
        overflow: hidden;
        position: fixed;
        width: 100%;
        touch-action: none;
    }
}


/* ====================================
   LAYOUT COMPONENTS
   ==================================== */

/* Masonry Grid Container */
.masonry {
    column-count: 3;
    column-gap: 1em;
}

/* Masonry Grid Items */
.masonry-item {
    background-color: #fff;
    display: inline-block;
    margin: 0 0 1em;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    animation: moveVertical 10s infinite linear;
}

/* Masonry Item Images */
.masonry-item img {
    width: 100%;
    display: block;
}


/* ====================================
   ANIMATIONS
   ==================================== */

/* Vertical movement animation for masonry items */
@keyframes moveVertical {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(20px);
    }
    100% {
        transform: translateY(0);
    }
}


/* ====================================
   INDEX PAGE STYLES
   ==================================== */

.super-large-text {
    font-size: 10rem; /* 160px */
}

.drawna-title {
    -webkit-text-stroke: 2px #ec4899;
    text-shadow: 2px 2px 0px #ec4899, -2px -2px 0px #ec4899, 2px -2px 0px #ec4899, -2px 2px 0px #ec4899;
}

.gallery-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
    display: flex;
    gap: 1em;
    padding: 1em;
    box-sizing: border-box;
}

.masonry-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1em;
    height: 300vh;
}

/* Odd columns scroll up */
.masonry-column:nth-child(odd) {
    animation: scrollUp 90s linear infinite;
}

/* Even columns scroll down - start from bottom */
.masonry-column:nth-child(even) {
    animation: scrollDown 90s linear infinite;
    transform: translateY(-150vh); /* Start from above viewport */
}

.masonry-item-full {
    background-color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    border: 4px solid rgba(80, 80, 80, 0.5);
    flex-shrink: 0;
    min-height: 200px; /* Ensure consistent box size */
    display: flex;
    align-items: center;
    justify-content: center;
}

.masonry-item-full img {
    width: 100%;
    display: block;
    height: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.masonry-item-full img.loaded {
    opacity: 0.5;
}

.fade-top {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background: linear-gradient(to bottom, rgba(241, 245, 249, 1) 0%, rgba(241, 245, 249, 0) 100%);
    z-index: 5;
    pointer-events: none;
}

.fade-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background: linear-gradient(to top, rgba(241, 245, 249, 1) 0%, rgba(241, 245, 249, 0) 100%);
    z-index: 5;
    pointer-events: none;
}

.main-container {
    position: relative;
    z-index: 10;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.start-button {
    background: black;
    border: 0;
    color: white;
    font-size: 4rem;
    padding: 1rem 3rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-family: 'Architects Daughter', Times, serif;
}

.start-button:hover {
    background: #3b3b3b;
}

/* Sticky Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    color: black;
    text-align: center;
    padding: 10px 0;
    font-size: 1rem;
    z-index: 15;
}

/* ====================================
   DRAW PAGE STYLES
   ==================================== */

.toolbar-container {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.75rem;
    z-index: 20;
}

.drawing-area {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
}

.generated-image {
    max-height: 100%;
    max-width: 100%;
}

.error-message {
    padding: 1rem;
    background-color: #fef2f2;
    color: #b91c1c;
    margin-bottom: 1rem;
}

.error-text {
    font-size: 0.875rem;
    overflow-y: auto;
    max-height: 8rem;
    white-space: pre-wrap;
    word-break: break-words;
}

.prompt-input {
    width: 100%;
    border: 4px solid black;
    border-radius: 0;
    padding: 0.75rem;
    margin-bottom: 1rem;
    background-color: white;
    font-size: 1.125rem;
    font-family: 'Architects Daughter', Times, serif;
    box-sizing: border-box;
    outline: none;
}

.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 2rem;
    z-index: 10;
}

.main-content {
    padding-bottom: 140px; /* Space for sticky footer */
}

.icon-button {
    width: 68px;
    height: 68px;
    padding: 8px;
    background: white;
    border: 4px solid black;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background: #e0e0e0;
}

.icon-button:active {
    background: #e0e0e0;
}

.icon-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-button.disabled:hover {
    background: white;
    transform: none;
}

.draw-button {
    background: black;
    border: 0;
    color: white;
    font-size: 2rem;
    padding: 0.5rem;
    width: 100%;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-family: 'Architects Daughter', Times, serif;
}

.draw-button:hover {
    background: #3b3b3b;
}

.loader {
    width: 34px;
    height: 34px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #000000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ====================================
   ANIMATIONS
   ==================================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes scrollUp {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-150vh);
    }
}

@keyframes scrollDown {
    0% {
        transform: translateY(-150vh);
    }
    100% {
        transform: translateY(0);
    }
}

/* Vertical movement animation for masonry items */
@keyframes moveVertical {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(20px);
    }
    100% {
        transform: translateY(0);
    }
}

/* ====================================
   RESPONSIVE DESIGN
   ==================================== */

@media (max-width: 1200px) {
    .masonry-column:nth-child(n+6) {
        display: none;
    }
}

@media (max-width: 900px) {
    .masonry {
        column-count: 2;
    }
    
    .masonry-column:nth-child(n+4) {
        display: none;
    }
    .start-button {
        font-size: 3rem;
        padding: 1.5rem 3rem;
    }
}

@media (max-width: 768px) {
    .super-large-text {
        font-size: 6rem;
    }
    
    .footer {
        font-size: 0.8rem;
        padding: 8px 0;
    }
}

@media (max-width: 600px) {
    .masonry {
        column-count: 1;
    }
    
    .masonry-column:nth-child(n+3) {
        display: none;
    }
    .start-button {
        font-size: 2.5rem;
        padding: 1rem 2rem;
    }
}