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

:root {
    /* Color Variables - Updated dynamically by JavaScript */
    --text-color: #ecf0f1;
    --background-color: #34495e;
    --accent-color: #e74c3c;
    --overlay-color: rgba(52, 73, 94, 0.7);
    
    /* Animation Variables */
    --breathing-duration: 15s;
    --transition-duration: 1.5s;
    
    /* Layout Variables */
    --quote-panel-width: 25%;
    --image-panel-width: 75%;
}

body {
    font-family: 'Georgia', serif;
    background: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
    transition: background-color var(--transition-duration) ease;
}

/* App Container */
.app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--background-color);
}

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

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

.hidden {
    display: none !important;
}

/* Desktop Layout */
.desktop-layout {
    display: flex;
    height: 100vh;
}

/* Quote Panel (25% left) */
.quote-panel {
    width: var(--quote-panel-width);
    background: var(--background-color);
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-duration) ease,
                color var(--transition-duration) ease;
    position: relative;
    overflow-y: auto;
}

.quote-content {
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.quote-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.quote-text {
    font-size: 1.8rem;
    line-height: 1.4;
    margin-bottom: 1.5rem;
    font-style: italic;
    color: var(--text-color);
    transition: color var(--transition-duration) ease;
}

/* Enhanced quote formatting for structured content */
.quote-text.formatted-content {
    font-style: normal; /* Remove italic for structured content */
}

.quote-text.formatted-content p {
    margin: 0 0 1rem 0;
}

.quote-text.formatted-content p:first-child {
    font-size: 1.4rem;  /* Larger for first paragraph */
    line-height: 1.3;
}

.quote-text.formatted-content p:nth-child(2) {
    font-size: 1.2rem;  /* Medium for second paragraph */
    line-height: 1.4;
}

.quote-text.formatted-content p:nth-child(n+3) {
    font-size: 1.1rem;  /* Smaller for subsequent paragraphs */
    line-height: 1.4;
}

.quote-text.formatted-content strong {
    font-weight: bold;
    font-size: 1.1em;  /* Slightly larger than surrounding text */
}

.quote-author {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-color);
    display: block;
    margin-bottom: 1rem;
    transition: color var(--transition-duration) ease;
}

.quote-author::before {
    content: "— ";
}

.quote-context {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-top: auto;
    padding-top: 2rem;
    opacity: 0.75;
    font-style: italic;
    color: var(--text-color);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    transition: color var(--transition-duration) ease;
}

/* Context formatting for progressive typography */
.quote-context .context-primary {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.8rem;
}

.quote-context .context-secondary {
    font-size: 0.85rem;
    line-height: 1.4;
    opacity: 0.8;
    font-style: italic;
}

/* Image Panel (75% right) */
.image-panel {
    width: var(--image-panel-width);
    position: relative;
    overflow: hidden;
}

.image-container {
    width: 100%;
    height: 100vh;
    position: relative;
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity var(--transition-duration) ease,
                transform var(--breathing-duration) ease-in-out;
    animation: breathe-image var(--breathing-duration) ease-in-out infinite;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
                var(--overlay-color) 0%,
                transparent 30%,
                transparent 70%,
                var(--overlay-color) 100%);
    opacity: 0.1;
    transition: opacity var(--transition-duration) ease;
}

/* Mobile Layout */
.mobile-layout {
    display: none;
    flex-direction: column;
    height: 100vh;
}

.mobile-image-section {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.mobile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    animation: breathe-image var(--breathing-duration) ease-in-out infinite;
}

.mobile-quote-section {
    background: var(--background-color);
    padding: 2rem 1.5rem;
    transition: background-color var(--transition-duration) ease;
}

.mobile-quote-content {
    /* No breathing animation for text content */
}

.mobile-quote-text {
    font-size: 1.4rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    font-style: italic;
    color: var(--text-color);
}

/* Enhanced mobile quote formatting for structured content */
.mobile-quote-text.formatted-content {
    font-style: normal; /* Remove italic for structured content */
}

.mobile-quote-text.formatted-content p {
    margin: 0 0 0.8rem 0;
}

.mobile-quote-text.formatted-content p:first-child {
    font-size: 1.2rem;  /* Larger for first paragraph */
    line-height: 1.3;
}

.mobile-quote-text.formatted-content p:nth-child(2) {
    font-size: 1.0rem;  /* Medium for second paragraph */
    line-height: 1.4;
}

.mobile-quote-text.formatted-content p:nth-child(n+3) {
    font-size: 0.95rem;  /* Smaller for subsequent paragraphs */
    line-height: 1.4;
}

.mobile-quote-text.formatted-content strong {
    font-weight: bold;
    font-size: 1.1em;  /* Slightly larger than surrounding text */
}

.mobile-quote-author {
    font-size: 1rem;
    font-weight: bold;
    color: var(--accent-color);
    display: block;
    margin-bottom: 0.8rem;
}

.mobile-quote-author::before {
    content: "— ";
}

.mobile-quote-context {
    font-size: 0.85rem;
    line-height: 1.4;
    opacity: 0.8;
    color: var(--text-color);
}

/* Mobile context formatting for progressive typography */
.mobile-quote-context .context-primary {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.6rem;
}

.mobile-quote-context .context-secondary {
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0.8;
    font-style: italic;
}

/* Footer Bar */
.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.8rem 1.5rem;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    color: #ffffff;
    position: relative;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    justify-content: flex-start;
}

.source-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.source-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.separator {
    opacity: 0.5;
}

.new-inspiration-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-inspiration-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.footer-center {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    opacity: 0.7;
}

.footer-center-text {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.85rem;
    opacity: 0.7;
    flex: 1;
    justify-content: flex-end;
}

.breathing-indicator {
    animation: pulse 2s ease-in-out infinite;
    color: var(--accent-color);
}

/* Controls Hint */
.controls-hint {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.controls-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Breathing Animations */
@keyframes breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

@keyframes breathe-image {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Ken Burns Effects */
@keyframes ken-burns-in {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

@keyframes ken-burns-out {
    0% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes ken-burns-pan-left {
    0% { transform: scale(1.03) translateX(2%); }
    100% { transform: scale(1.03) translateX(-2%); }
}

@keyframes ken-burns-pan-right {
    0% { transform: scale(1.03) translateX(-2%); }
    100% { transform: scale(1.03) translateX(2%); }
}

.ken-burns-in {
    animation: ken-burns-in 5s ease-out forwards;
}

.ken-burns-out {
    animation: ken-burns-out 5s ease-out forwards;
}

.ken-burns-pan-left {
    animation: ken-burns-pan-left 5s ease-out forwards;
}

.ken-burns-pan-right {
    animation: ken-burns-pan-right 5s ease-out forwards;
}

/* Carousel Image Transition */
.carousel-image-transition {
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade Transitions */
.fade-out {
    opacity: 0 !important;
    transform: translateY(10px) !important;
}

.fade-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Attribution Elements */
.model-badge {
    color: #ffffff;
    opacity: 0.6;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.content-info {
    color: #ffffff;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s ease;
    position: relative;
    z-index: 10;
}

.content-info:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Generation Tooltip (Desktop Hover) */
.generation-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.generation-tooltip:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.tooltip-content {
    background: rgba(0, 0, 0, 0.95);
    color: #ffffff;
    padding: 1rem 1.2rem;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 350px;
    min-width: 250px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.tooltip-content p {
    margin: 0.3rem 0;
}

.tooltip-content strong {
    color: var(--accent-color);
    margin-right: 0.5rem;
}

.tooltip-prompt {
    white-space: normal;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 3px;
    margin-top: 0.5rem;
    border-left: 3px solid var(--accent-color);
}

/* Arrow pointing down */
.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.95);
}

/* Hide tooltip on mobile/touch devices */
@media (max-width: 768px) {
    .generation-tooltip {
        display: none !important;
    }
}

/* Generation Details Modal */
.generation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.generation-modal.hidden {
    display: none;
}

.modal-content {
    background: var(--background-color);
    color: var(--text-color);
    padding: 2rem;
    border-radius: 8px;
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body h3 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: var(--accent-color);
}

.generation-details p {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.generation-details strong {
    color: var(--accent-color);
    margin-right: 0.5rem;
}

.prompt-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.prompt-text {
    margin-top: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .desktop-layout {
        display: none;
    }

    .mobile-layout {
        display: flex;
    }

    .controls-hint {
        top: 1rem;
        right: 1rem;
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
    }

    .footer-bar {
        padding: 0.6rem 1rem;
    }

    .footer-content {
        font-size: 0.8rem;
        flex-wrap: wrap;
        gap: 0.5rem 0;
    }

    .footer-left {
        gap: 0.6rem;
        flex: 1;
        order: 1;
        min-width: 0;
    }

    .footer-right {
        flex: 1;
        order: 2;
        min-width: 0;
        justify-content: flex-end;
    }

    .footer-center {
        position: static;
        transform: none;
        flex: 1 1 100%;
        order: 3;
        justify-content: center;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .mobile-quote-section {
        padding: 1.5rem 1rem;
    }
    
    .mobile-quote-text {
        font-size: 1.2rem;
    }
    
    .controls-hint {
        display: none; /* Hide on very small screens */
    }
    
    .modal-content {
        max-width: 95%;
        width: 95%;
        padding: 1.5rem;
    }
    
    .prompt-text {
        font-size: 0.7rem;
        padding: 0.8rem;
        max-height: 300px;
    }
}

/* Carousel Indicators */
.carousel-indicators {
    position: absolute;
    bottom: 60px; /* Moved up to clear footer bar */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1100; /* Higher than footer bar (1000) */
    opacity: 1;
    transition: opacity 0.3s ease;
}

.carousel-indicators.hidden {
    opacity: 0;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    padding: 0;
}

.carousel-dot:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.carousel-dot.active {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Mobile carousel indicators */
.mobile-indicators {
    bottom: 20px;
}

.mobile-indicators .carousel-dot {
    width: 12px;
    height: 12px;
}

/* Quote-to-Quote Fade Through Black */
.fade-to-black {
    opacity: 0 !important;
    background: #000000 !important;
    transition: opacity 0.75s ease-out, background-color 0.75s ease-out !important;
}

.fade-from-black {
    opacity: 1 !important;
    background: transparent !important;
    transition: opacity 0.75s ease-in, background-color 0.75s ease-in !important;
}

/* Ensure carousel indicators remain visible during fade transitions */
.fade-out .carousel-indicators {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.fade-out .carousel-indicators.hidden {
    opacity: 0 !important;
}

/* Smooth Carousel Transitions - Dual Layer System */
.carousel-image-stack {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.carousel-image-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity; /* Performance optimization */
}

.carousel-image-layer.active {
    opacity: 1;
}

/* Extended Ken Burns animations for smoother flow */
.ken-burns-in { 
    animation: ken-burns-in 10s ease-out forwards; 
}
.ken-burns-out { 
    animation: ken-burns-out 10s ease-out forwards; 
}
.ken-burns-pan-left { 
    animation: ken-burns-pan-left 10s ease-out forwards; 
}
.ken-burns-pan-right { 
    animation: ken-burns-pan-right 10s ease-out forwards; 
}

/* Enhanced Ken Burns keyframes for overlap period */
@keyframes ken-burns-in {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); } /* Slightly increased for overlap period */
}

@keyframes ken-burns-out {
    0% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes ken-burns-pan-left {
    0% { transform: scale(1.05) translateX(2%); }
    100% { transform: scale(1.05) translateX(-2%); }
}

@keyframes ken-burns-pan-right {
    0% { transform: scale(1.05) translateX(-2%); }
    100% { transform: scale(1.05) translateX(2%); }
}

/* Ensure smooth animation during reduced motion */
@media (prefers-reduced-motion: reduce) {
    .carousel-image-layer {
        transition: opacity 0.5s ease;
    }
    
    .ken-burns-in,
    .ken-burns-out,
    .ken-burns-pan-left,
    .ken-burns-pan-right {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .footer-bar,
    .controls-hint,
    .carousel-indicators {
        display: none;
    }
    
    .image-panel,
    .mobile-image-section {
        display: none;
    }
    
    .quote-panel {
        width: 100% !important;
        background: white !important;
        color: black !important;
    }
}