/* ===================================
   Omoide Art - Style Sheet
   =================================== */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for consistent theming */
:root {
    --bg-primary: #FDFBF7;      /* Warm, creamy off-white like washi paper */
    --text-primary: #3D3D3D;    /* Soft charcoal black */
    --accent-color: #BC4749;    /* Deep muted red like hanko seal */
    --text-light: #757575;      /* Light gray for secondary text */
    --border-color: #E0E0E0;    /* Subtle border color */
    --hover-bg: #FFF8F0;        /* Slightly warmer hover state */
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Typography base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    font-weight: 400;
}

/* Header Styles */
.header {
    text-align: center;
    padding: 80px 20px 60px;
    max-width: 800px;
    margin: 0 auto;
}

.header h1 {
    font-family: 'Noto Serif JP', serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.kanji {
    font-size: 0.8em;
    opacity: 0.7;
    margin-left: 8px;
}

.tagline {
    font-size: 1.125rem;
    color: var(--text-light);
    font-weight: 300;
    letter-spacing: 0.01em;
}

/* Main Content Container */
.main-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

/* Form Styling */
.memory-form {
    margin-bottom: 80px;
}

/* Form Acts (Sections) */
.form-act {
    margin-bottom: 60px;
    padding-bottom: 60px;
    border-bottom: 1px solid var(--border-color);
}

.form-act:last-of-type {
    border-bottom: none;
}

.act-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 32px;
    color: var(--text-primary);
    opacity: 0.9;
}

/* Form Groups */
.form-group {
    margin-bottom: 32px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Labels */
label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

/* Text Inputs */
input[type="text"],
textarea {
    width: 100%;
    padding: 16px 20px;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(188, 71, 73, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Placeholder styling */
::placeholder {
    color: #B0B0B0;
    opacity: 1;
}

/* Button Groups */
.button-group,
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Style Buttons (Atmosphere) */
.style-button {
    flex: 1 1 150px;
    padding: 14px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.style-button:hover {
    background-color: var(--hover-bg);
    border-color: var(--accent-color);
}

.style-button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Tag Buttons (Feelings) */
.tag-button {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.tag-button:hover {
    background-color: var(--hover-bg);
    border-color: var(--accent-color);
}

.tag-button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Season Selector */
.season-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.season-choice {
    padding: 16px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.season-choice:hover {
    background-color: var(--hover-bg);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.season-choice.selected {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.season-choice span {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Submit Button */
.form-submit {
    margin-top: 60px;
    text-align: center;
}

.submit-button {
    padding: 18px 48px;
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 500;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 32px;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px var(--shadow-light);
}

.submit-button:hover {
    background-color: #A43739;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.submit-button:active {
    transform: translateY(0);
}

/* Canvas Container */
.canvas-container {
    width: 512px;
    height: 512px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background-color: white;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.canvas-placeholder {
    color: var(--text-light);
    font-size: 1rem;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* When image is loaded */
.canvas-container.has-image {
    border: none;
    box-shadow: 0 8px 32px var(--shadow-medium);
}

.canvas-container.has-image .canvas-placeholder {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 60px 20px 40px;
    }
    
    .form-act {
        margin-bottom: 40px;
        padding-bottom: 40px;
    }
    
    .act-title {
        font-size: 1.25rem;
        margin-bottom: 24px;
    }
    
    .button-group {
        gap: 8px;
    }
    
    .style-button {
        flex: 1 1 calc(50% - 4px);
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .tag-button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .season-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .season-choice {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
    
    .submit-button {
        padding: 16px 40px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.75rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .style-button {
        flex: 1 1 100%;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.canvas-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: fadeIn 0.5s ease-out;
}

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.loading-subtext {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0;
    font-style: italic;
}

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

/* Image Overlay */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.7) 100%
    );
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: var(--transition);
}

.canvas-container:hover .image-overlay {
    opacity: 1;
}

.download-button {
    padding: 12px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.download-button:hover {
    background-color: #A43739;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Disabled submit button */
.submit-button:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px var(--shadow-light);
}

.submit-button:disabled:hover {
    background-color: var(--text-light);
    transform: none;
    box-shadow: 0 2px 8px var(--shadow-light);
}

/* Canvas Choice (Aspect Ratio Selector) */
.canvas-choice {
    margin-top: 40px;
    text-align: center;
}

.canvas-choice h4 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-family: 'Noto Serif JP', serif;
}

.aspect-ratio-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.ar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.ar-btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--accent-color);
}

.ar-btn.selected {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Preview Boxes */
.preview-box {
    background-color: currentColor;
    border-radius: 3px;
    opacity: 0.8;
    transition: var(--transition);
}

/* Square preview box */
.preview-box.square {
    width: 18px;
    height: 18px;
}

/* Portrait preview box */
.preview-box.portrait {
    width: 16px;
    height: 20px;
}

/* Landscape preview box */
.preview-box.landscape {
    width: 20px;
    height: 16px;
}

/* Dynamic Canvas Container Sizing */
.canvas-container {
    transition: aspect-ratio 0.3s ease, width 0.3s ease, height 0.3s ease;
}

/* Aspect ratio classes for dynamic sizing */
.canvas-container.square {
    aspect-ratio: 1 / 1;
}

.canvas-container.portrait {
    aspect-ratio: 3 / 4;
    max-width: 512px;
    width: 512px;
    height: auto;
}

.canvas-container.landscape {
    aspect-ratio: 4 / 3;
    max-width: 512px;
    width: 512px;
    height: auto;
}

/* Mobile responsiveness for aspect ratio buttons */
@media (max-width: 480px) {
    .aspect-ratio-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .ar-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
}

/* Artist's Quad Gallery */
.gallery-section {
    margin-top: 60px;
    text-align: center;
}

.gallery-section h3 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 32px;
    font-family: 'Noto Serif JP', serif;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--background-light);
    border: 2px solid var(--border-color);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px var(--shadow-medium);
    border-color: var(--accent-color);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: var(--transition);
}

.gallery-item img:hover {
    transform: scale(1.05);
}

/* Loading states */
.gallery-item.loading {
    cursor: default;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.show {
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 32px;
    color: white;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

#lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.lightbox-actions {
    padding: 20px;
    text-align: center;
    background: white;
}

.lightbox-download {
    padding: 12px 24px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.lightbox-download:hover {
    background-color: #A43739;
    transform: translateY(-2px);
}

/* Mobile responsiveness for gallery */
@media (max-width: 768px) {
    .gallery-grid {
        max-width: 400px;
        gap: 16px;
    }
    
    .lightbox-content {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .gallery-section h3 {
        font-size: 1.25rem;
        margin-bottom: 24px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }
}