/* ========================================
   SCREEN-SPECIFIC STYLES
   ======================================== */

/* Stories Grid */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Welcome page featured stories - center aligned */
#welcome-stories-list.stories-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

#welcome-stories-list .story-card {
    width: 220px;
    flex-shrink: 0;
}

.story-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px var(--shadow);
}

.story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px var(--shadow);
    border-color: var(--primary-light);
}

.story-thumbnail {
    width: 100%;
    padding-top: 100%; /* Creates square - height equals width */
    background: linear-gradient(135deg, var(--surface-elevated), var(--primary-light));
    position: relative;
    overflow: hidden;
}

.story-thumbnail img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.story-thumbnail i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 64px;
    color: var(--text-secondary);
    opacity: 0.3;
}

.story-info {
    padding: 16px;
}

.story-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remix-attribution {
    font-size: 12px;
    color: var(--purple);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    font-style: italic;
}

.remix-attribution i {
    font-size: 10px;
}

.story-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.story-meta i {
    width: 14px;
}

/* Story Card Teaser - Blurred with Login Overlay */
.story-card-teaser {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.story-card-teaser:hover {
    transform: translateY(-2px); /* Less movement than regular cards */
}

.story-thumbnail-blur img {
    filter: blur(8px);
}

.story-thumbnail-blur i {
    filter: blur(8px);
}

.story-teaser-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.3s ease;
}

.story-card-teaser:hover .story-teaser-overlay {
    background: rgba(0, 0, 0, 0.85);
}

.teaser-content {
    text-align: center;
    color: white;
    padding: 20px;
}

.teaser-content i {
    display: block;
    color: var(--primary);
    animation: pulse 2s ease-in-out infinite;
}

.teaser-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: white;
}

.teaser-content p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.teaser-content .btn {
    pointer-events: none; /* Click goes to parent card */
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Character Grid */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.character-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.3s ease;
    animation: cardSlideIn 0.6s ease-out both;
}

.character-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px var(--shadow);
    border-color: var(--primary-light);
}

.character-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.character-summary {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Character Reference Image Upload */
.character-reference-upload {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.reference-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 2px dashed rgba(139, 92, 246, 0.4);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reference-upload-label:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.reference-upload-label i {
    font-size: 16px;
}

.reference-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
}

.reference-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary);
}

.remove-reference-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-reference-btn:hover {
    background: #ef4444;
    color: white;
}

.reference-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 6px 0 0 0;
    font-style: italic;
    opacity: 0.8;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.image-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
    animation: cardSlideIn 0.6s ease-out both;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px var(--shadow);
    border-color: var(--primary-light);
}

.image-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover img {
    transform: scale(1.05);
}

.image-caption {
    padding: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

/* Image Review Card */
.image-review-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.image-container {
    margin-bottom: 16px;
    text-align: center;
}

.page-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.image-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page-text label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-text textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--background);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.page-text textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.image-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
}

.prompt-section {
    flex: 1;
}

.prompt-section label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.prompt-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--background);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* PDF Section */
.pdf-section {
    text-align: center;
    margin-top: 40px;
}

.pdf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.pdf-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    animation: cardSlideIn 0.6s ease-out both;
}

.pdf-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px var(--shadow);
    border-color: var(--primary-light);
}

.pdf-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
}

.pdf-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.pdf-meta {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.pdf-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gradient-primary);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.pdf-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    text-decoration: none;
    color: white;
}

/* Generation Messages */
.generation-messages {
    text-align: center;
    margin-top: 20px;
}

.generation-message {
    display: none;
    font-size: 16px;
    color: var(--text-secondary);
    animation: fadeInOut 3s ease-in-out infinite;
}

.generation-message.active {
    display: block;
}

/* ========================================
   WELCOME SCREEN STYLES
   ======================================== */

.welcome-hero {
    text-align: center;
    padding: 60px 20px 40px;
    max-width: 900px;
    margin: 0 auto;
}

.welcome-logo {
    margin: 0 auto 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.welcome-logo-img {
    height: 120px;
    width: auto;
    max-width: 80%;
    object-fit: contain;
    filter: drop-shadow(0 8px 32px rgba(139, 92, 246, 0.3));
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.3);
}

.welcome-icon i {
    font-size: 40px;
    color: white;
}

.welcome-title {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.welcome-subtitle {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.welcome-hero-actions {
    margin: 32px 0 40px;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 32px;
    margin-top: 48px;
    padding: 0 20px;
}

.feature {
    text-align: center;
    padding: 24px;
}

.feature i {
    font-size: 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    display: block;
}

.feature h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.feature p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.welcome-stories-section {
    max-width: 1200px;
    margin: 60px auto 40px;
    padding: 0 20px;
    text-align: center;
}

.section-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.section-title i {
    color: var(--primary);
}

.welcome-cta {
    margin-top: 60px;
    padding: 48px 32px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border: 2px solid var(--primary-light);
    border-radius: var(--radius-xl);
    text-align: center;
}

.cta-content h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.cta-content h3 i {
    color: var(--primary);
}

.cta-content p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
}

/* Mobile responsiveness for welcome screen */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 36px;
    }
    
    .welcome-subtitle {
        font-size: 18px;
    }
    
    .welcome-features {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .feature {
        padding: 16px;
    }
    
    .section-title {
        font-size: 24px;
    }
    
    .welcome-cta {
        padding: 32px 20px;
    }
    
    .cta-content h3 {
        font-size: 20px;
        flex-wrap: wrap;
    }
    
    /* Featured community stories - full width on mobile */
    #welcome-stories-list.stories-grid {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 0 16px;
    }
    
    #welcome-stories-list .story-card {
        width: 100%;
        max-width: 100%;
        flex-shrink: 1;
    }
    
    /* Also make teaser full width */
    #welcome-stories-list .story-card-teaser {
        width: 100%;
        max-width: 100%;
    }
}

/* ========================================
   USER PROFILE STYLES
   ======================================== */

.user-profile-header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    width: 100%;
}

.user-profile-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 1 auto;
    min-width: 0;
}

.user-profile-header-row > .btn {
    margin-left: auto !important;
    flex-shrink: 0;
}

.user-profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.user-profile-avatar i {
    font-size: 32px;
    color: white;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-profile-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.profile-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-username {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.profile-separator {
    color: var(--text-tertiary);
    font-size: 14px;
}

.profile-stat-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

.profile-stat-inline i {
    color: var(--primary);
    font-size: 12px;
}

.profile-name {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive: Stack on mobile */
@media (max-width: 640px) {
    .user-profile-header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .user-profile-left {
        width: 100%;
    }
    
    .user-profile-header-row .btn {
        width: 100%;
    }
}

.clickable-username {
    cursor: pointer;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.clickable-username:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}
