/* Drifted Stories - Themeable CSS */
 
:root {
    /* Dark theme variables */
    --bg-primary: linear-gradient(135deg, #0a0a0a 0%, #111111 100%);
    --bg-secondary: linear-gradient(135deg, #141414 0%, #1a1a1a 100%);
    --bg-tertiary: linear-gradient(135deg, #222 0%, #2a2a2a 100%);
    --text-primary: #f1f1f1;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --accent-primary: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --accent-hover: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    --border-color: #2d2d2d;
    --border-secondary: #3a3a3a;
    --border-accent: #4a4a4a;
    
    /* Enhanced shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    
    /* Sentiment colors - slightly more vibrant */
    --sentiment-happiness: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    --sentiment-chaos: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --sentiment-sadness: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    --sentiment-wellbeing: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    --sentiment-temperature: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --sentiment-confidence: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    
    /* Status colors */
    --status-success: #10b981;
    --status-error: #f87171;
    --status-info: #3b82f6;
    
    /* Layout dimensions */
    --topbar-height: 60px;
    --bottombar-height: 90px;
    --sentiment-height: 36px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

/* Light theme override */
[data-theme="light"] {
    --bg-primary: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    --bg-secondary: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
    --bg-tertiary: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    --text-primary: #1f2937;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --accent-primary: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --accent-hover: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    --border-color: #e5e7eb;
    --border-secondary: #d1d5db;
    --border-accent: #9ca3af;
    
    /* Light theme shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fixed viewport container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
}

/* Top bar - fixed height */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    flex-shrink: 0;
}

.control-button {
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    min-height: 44px;
    min-width: 44px;
}

.control-button:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.control-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.control-button:hover {
    background: var(--accent-hover);
}

.control-select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    min-width: 100px;
}

/* Main content - flex-grow */
.main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Story card */
.story-card {
    height: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.story-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Header section */
.story-header {
    flex-shrink: 0;
    padding: 16px 16px 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.timestamp {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.ward-badge {
    background: var(--accent-primary);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 8px;
}

.story-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 70px;
    margin: 0;
}

.story-title a {
    color: inherit;
    text-decoration: none;
}

/* Thumbnail section */
.story-thumbnail {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    min-height: 200px;
    height: 200px;
    overflow: hidden;
}

.story-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Sentiment strip - fixed height */
.sentiment-strip {
    height: calc(var(--sentiment-height) + 12px);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-shrink: 0;
}

.sentiment-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    border-right: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.sentiment-item:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.3;
}

.sentiment-happiness:before { background: #22c55e; }
.sentiment-chaos:before { background: #ef4444; }
.sentiment-sadness:before { background: #6b7280; }
.sentiment-wellbeing:before { background: #06b6d4; }
.sentiment-temperature:before { background: #f97316; }
.sentiment-confidence:before { background: #8b5cf6; }

.sentiment-item:last-child {
    border-right: none;
}

.sentiment-item:hover {
    background: var(--bg-tertiary);
}

.sentiment-label {
    font-size: 12px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.sentiment-value {
    font-size: 16px;
    font-weight: 600;
}

/* Sentiment colors */
.sentiment-happiness .sentiment-value { color: var(--sentiment-happiness); }
.sentiment-chaos .sentiment-value { color: var(--sentiment-chaos); }
.sentiment-sadness .sentiment-value { color: var(--sentiment-sadness); }
.sentiment-wellbeing .sentiment-value { color: var(--sentiment-wellbeing); }
.sentiment-temperature .sentiment-value { color: var(--sentiment-temperature); }
.sentiment-confidence .sentiment-value { color: var(--sentiment-confidence); }

/* Story body - scrollable */
.story-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-secondary);
}

/* Bottom bar - fixed height */
.bottom-bar {
    height: var(--bottombar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    flex-shrink: 0;
}

.action-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 60px;
    min-width: 60px;
    box-shadow: var(--shadow-sm);
}

.action-btn:hover {
    background: var(--border-secondary);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.action-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-hover);
}

.score-display {
    background: var(--bg-primary);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    min-width: 110px;
    min-height: 60px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

/* Comments panel */
.comments-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    max-height: 60vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.comments-panel.active {
    transform: translateY(0);
}

.comments-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comments-list {
    max-height: 40vh;
    overflow-y: auto;
    padding: 16px;
}

.comment-form {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.comment-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
}

/* Status display */
.status-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.status-overlay.show {
    opacity: 1;
}

.status-overlay.success {
    border-color: var(--status-success);
    color: var(--status-success);
}

.status-overlay.error {
    border-color: var(--status-error);
    color: var(--status-error);
}

.status-overlay.info {
    border-color: var(--status-info);
    color: var(--status-info);
}

/* Loading indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: var(--text-muted);
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Theme switcher utility */
.theme-switcher {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 3000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
}

.theme-switcher button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.theme-switcher button:hover {
    background: var(--bg-tertiary);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .top-bar {
        justify-content: space-between;
        padding: 0 24px;
    }
    
    .story-header {
        padding: 24px 24px 12px 24px;
    }
    
    .story-body {
        padding: 24px;
        font-size: 16px;
    }
    
    .bottom-bar {
        justify-content: space-between;
        padding: 0 24px;
    }
}

@media (max-width: 480px) {
    .action-btn {
        padding: 6px 8px;
        font-size: 12px;
        min-height: 32px;
    }
    
    .bottom-bar {
        gap: 8px;
        padding: 0 12px;
    }
    
    .score-display {
        min-width: 60px;
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* Profile/Menu Overlays */
.profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.profile-overlay.active {
    display: flex;
}

.profile-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.profile-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.profile-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.profile-actions {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

/* Help Overlay */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.help-overlay.active {
    display: flex;
}

.help-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.help-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.help-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.help-list {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.help-item {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-item kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
    min-width: 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

/* Desktop enhancements */
@media (min-width: 1024px) {
    body {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 20px;
        background: var(--bg-tertiary);
    }
    
    .app-container {
        position: fixed;
        width: 100%;
        max-width: 800px;
        height: calc(100vh - 40px);
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--border-radius-lg);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        overflow: hidden;
        border: 1px solid var(--border-secondary);
        backdrop-filter: blur(10px);
    }
    
    [data-theme="light"] .app-container {
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    }
}