/* ==============================================================
   TITAN COVER GENERATOR - STYLESHEET
   
   This file controls all visual styling for the app.
   Organized into logical blocks for easy understanding.
   ============================================================== */


/* ==============================================================
   BLOCK 1: CSS VARIABLES (Design Tokens)
   
   Variables store reusable values like colors and spacing.
   Change a variable here, and it updates everywhere.
   Think of these as the "settings" for our design.
   ============================================================== */
:root {
    /* Background colors - dark theme */
    --bg-primary: #0a0a0a;      /* Darkest - main background */
    --bg-secondary: #141414;     /* Slightly lighter */
    --bg-card: #1a1a1a;          /* Card backgrounds */
    --bg-input: #0f0f0f;         /* Input field backgrounds */
    
    /* Accent colors - TITAN red theme */
    --accent-primary: #e63946;   /* Main red */
    --accent-secondary: #ff6b6b; /* Lighter red for hover states */
    --accent-glow: rgba(230, 57, 70, 0.4); /* Red glow effect */
    
    /* Text colors */
    --text-primary: #ffffff;     /* White - main text */
    --text-secondary: #a0a0a0;   /* Gray - secondary text */
    --text-muted: #666666;       /* Dark gray - hints, placeholders */
    
    /* Border colors */
    --border-subtle: rgba(255, 255, 255, 0.08);  /* Barely visible */
    --border-accent: rgba(230, 57, 70, 0.3);     /* Red tinted */
    
    /* Spacing scale - consistent throughout the app */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 40px;
    --spacing-xl: 64px;
}


/* ==============================================================
   BLOCK 2: CSS RESET & BASE STYLES
   
   Removes default browser styling for consistency.
   Sets up fundamental styles for the entire page.
   ============================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;  /* Makes sizing more intuitive */
}

html {
    scroll-behavior: smooth;  /* Smooth scrolling when clicking links */
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;        /* At least full screen height */
    line-height: 1.6;         /* Comfortable reading spacing */
    overflow-x: hidden;       /* Prevent horizontal scroll */
}


/* ==============================================================
   BLOCK 3: BACKGROUND EFFECTS
   
   Creates the atmospheric visual effects behind content.
   Uses gradients and noise texture for depth.
   ============================================================== */

/* Gradient glow effects */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(230, 57, 70, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(230, 57, 70, 0.1) 0%, transparent 50%),
        var(--bg-primary);
    pointer-events: none;  /* Click through this layer */
    z-index: -1;           /* Behind everything */
}

/* Subtle noise/grain texture */
.bg-noise {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.03;
    /* SVG noise pattern encoded as data URL */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}


/* ==============================================================
   BLOCK 4: LAYOUT CONTAINER
   
   Centers content and provides consistent padding.
   ============================================================== */
.container {
    max-width: 1200px;         /* Maximum width of content */
    margin: 0 auto;            /* Center horizontally */
    padding: var(--spacing-md); /* Padding on sides */
}


/* ==============================================================
   BLOCK 5: HEADER STYLES
   
   Styles for the top section: logo and tagline.
   Includes entrance animation.
   ============================================================== */
.header {
    text-align: center;
    padding: var(--spacing-xl) 0 var(--spacing-lg);
    animation: fadeInDown 0.8s ease-out;  /* Entrance animation */
}

/* Logo - big bold TITAN text */
.logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(48px, 10vw, 72px);  /* Responsive size */
    letter-spacing: 8px;
    color: var(--accent-primary);
    text-shadow: 0 0 40px var(--accent-glow);  /* Red glow */
    margin-bottom: var(--spacing-xs);
}

/* Tagline - elegant italic text */
.tagline {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 18px;
    font-style: italic;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Entrance animation - slides down and fades in */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ==============================================================
   BLOCK 6: MAIN CONTENT LAYOUT (Two-Column Grid)
   
   Creates the side-by-side layout for form and result.
   Responsive: stacks on mobile.
   ============================================================== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;  /* Two equal columns */
    gap: var(--spacing-lg);          /* Space between columns */
    margin-top: var(--spacing-lg);
    animation: fadeIn 1s ease-out 0.3s both;  /* Delayed fade in */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive: stack columns on smaller screens */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;  /* Single column */
    }
}


/* ==============================================================
   BLOCK 7: FORM CARD STYLES
   
   The container for all input fields.
   Features decorative corner accent.
   ============================================================== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: var(--spacing-lg);
    position: relative;
    overflow: hidden;
}

/* Decorative corner accent (top-left red gradient) */
.form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, transparent 60%);
    opacity: 0.1;
    pointer-events: none;
}

/* Form title */
.form-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 28px;
    letter-spacing: 2px;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}


/* ==============================================================
   BLOCK 8: FORM ELEMENT STYLES
   
   Styles for labels, inputs, selects, and textareas.
   Includes focus states for accessibility.
   ============================================================== */

/* Form group - wrapper for label + input pairs */
.form-group {
    margin-bottom: var(--spacing-md);
}

/* Labels */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

/* Text inputs, selects, and textareas - shared styles */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    transition: all 0.3s ease;  /* Smooth state changes */
}

/* Focus state - red border and glow */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Placeholder text color */
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

/* Select dropdown - custom arrow */
.form-select {
    cursor: pointer;
    appearance: none;  /* Remove default arrow */
    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Dropdown options */
.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Textarea */
.form-textarea {
    min-height: 80px;
    resize: vertical;  /* Allow vertical resize only */
}


/* ==============================================================
   BLOCK 9: API KEY SECTION
   
   Special highlighted section for the API key input.
   Uses accent colors to draw attention.
   ============================================================== */
.api-key-section {
    background: rgba(230, 57, 70, 0.05);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.api-key-section .form-group {
    margin-bottom: 0;
}

.api-key-section .form-label {
    color: var(--accent-secondary);
}

/* Help text below API key input */
.api-key-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.api-key-note a {
    color: var(--accent-primary);
    text-decoration: none;
}

.api-key-note a:hover {
    text-decoration: underline;
}


/* ==============================================================
   BLOCK 10: PHOTO UPLOAD STYLES
   
   Custom file upload area with drag-and-drop support.
   Shows preview after image selection.
   ============================================================== */
.photo-upload {
    position: relative;
    border: 2px dashed var(--border-subtle);
    border-radius: 12px;
    padding: var(--spacing-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-input);
}

/* Hover state */
.photo-upload:hover {
    border-color: var(--accent-primary);
    background: rgba(230, 57, 70, 0.05);
}

/* State when image is selected */
.photo-upload.has-image {
    padding: var(--spacing-sm);
}

/* Hidden file input (covers entire area) */
.photo-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Upload icon */
.photo-upload-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
    opacity: 0.5;
}

/* Upload instructions text */
.photo-upload-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.photo-upload-text strong {
    color: var(--accent-primary);
}

/* Image preview */
.photo-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: none;  /* Hidden until image selected */
    margin: 0 auto;
}

/* Show preview, hide placeholder when image selected */
.photo-upload.has-image .photo-preview {
    display: block;
}

.photo-upload.has-image .photo-upload-placeholder {
    display: none;
}


/* ==============================================================
   BLOCK 11: SUBMIT BUTTON STYLES
   
   Primary action button with gradient, hover effects,
   and loading spinner animation.
   ============================================================== */
.submit-btn {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #c1121f 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-top: var(--spacing-sm);
}

/* Hover state - lift up with shadow */
.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--accent-glow);
}

/* Click state */
.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Disabled state */
.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading state - hide text */
.submit-btn.loading {
    color: transparent;
}

/* Loading spinner */
.submit-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ==============================================================
   BLOCK 12: ERROR MESSAGE STYLES
   
   Red highlighted box for showing errors.
   Includes shake animation for attention.
   ============================================================== */
.error-message {
    display: none;
    padding: var(--spacing-sm);
    background: rgba(230, 57, 70, 0.1);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    color: var(--accent-secondary);
    font-size: 14px;
    margin-top: var(--spacing-sm);
    text-align: center;
}

/* Visible state */
.error-message.visible {
    display: block;
    animation: shake 0.5s ease-out;
}

/* Shake animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}


/* ==============================================================
   BLOCK 13: RESULT CARD STYLES
   
   Right panel displaying the generated cover.
   Shows placeholder before generation, image after.
   ============================================================== */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

/* Placeholder (before generation) */
.result-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.result-placeholder-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-sm);
    opacity: 0.3;
}

.result-placeholder-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 18px;
    font-style: italic;
}

/* Generated cover image */
.result-image {
    max-width: 100%;
    max-height: 600px;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: none;  /* Hidden until generated */
    animation: scaleIn 0.5s ease-out;
}

/* Scale-in animation for result */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Show image, hide placeholder when result exists */
.result-card.has-result .result-image {
    display: block;
}

.result-card.has-result .result-placeholder {
    display: none;
}

/* Download button */
.download-btn {
    display: none;  /* Hidden until result exists */
    margin-top: var(--spacing-md);
    padding: 12px 32px;
    background: transparent;
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    color: var(--accent-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: var(--accent-primary);
    color: white;
}

/* Show download button when result exists */
.result-card.has-result .download-btn {
    display: inline-block;
}


/* ==============================================================
   BLOCK 14: FOOTER STYLES
   
   Bottom section with credits and links.
   ============================================================== */
.footer {
    text-align: center;
    padding: var(--spacing-xl) 0 var(--spacing-lg);
    color: var(--text-muted);
    font-size: 13px;
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}
