/* Modern Design System - Vad tänker jag på? */

/* CSS Custom Properties */
:root {
    /* Dark Theme (Default) - Modern Palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #131827;
    --bg-tertiary: #1e2537;
    --bg-card: #1a2030;
    --bg-elevated: #222b3d;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-dim: #475569;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #60a5fa;
    --accent-glow: rgba(59, 130, 246, 0.3);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-medium: rgba(148, 163, 184, 0.2);
    --border-strong: rgba(148, 163, 184, 0.3);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px var(--accent-glow);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme */
.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #60a5fa;
    --accent-glow: rgba(59, 130, 246, 0.2);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-medium: rgba(15, 23, 42, 0.12);
    --border-strong: rgba(15, 23, 42, 0.2);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow); }
}

/* Theme Toggle - Moved to header */
.theme-toggle {
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.theme-dark .sun-icon { display: block; }
.theme-dark .moon-icon { display: none; }
.theme-light .sun-icon { display: none; }
.theme-light .moon-icon { display: block; }

/* Header */
.header-section {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.5rem 2rem;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    animation: slideUp 0.6s ease-out;
    justify-self: start;
}

.logo:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: var(--shadow-lg);
}

.game-title {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    text-align: center;
    animation: slideUp 0.6s ease-out 0.1s;
    animation-fill-mode: both;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: end;
}

.history-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.history-toggle:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.history-toggle svg {
    width: 18px;
    height: 18px;
}

.hamburger-menu {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.625rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.hamburger-menu:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.hamburger-menu svg {
    width: 24px;
    height: 24px;
}

/* Main Container */
.main-container {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
}

.game-wrapper {
    flex: 1;
    max-width: 700px;
    animation: fadeIn 0.8s ease-out;
}

/* Game Container - Modern Card Design */
.game-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-slow);
}

.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-light));
    opacity: 0.8;
}

.game-container:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

/* Response Area */
.response-container {
    margin-bottom: 2rem;
}

.response-area {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    min-height: 200px;
    max-height: 350px;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: all var(--transition-base);
    position: relative;
}

.response-area::-webkit-scrollbar {
    width: 8px;
}

.response-area::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.response-area::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-sm);
    transition: background var(--transition-base);
}

.response-area::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.question-input {
    flex: 1;
    width: 100%;
    padding: 1.125rem 3.5rem 1.125rem 1.25rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-base);
    outline: none;
}

.question-input::placeholder {
    color: var(--text-dim);
}

.question-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.char-counter {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    pointer-events: none;
    transition: all var(--transition-base);
}

.char-counter.text-red-500 {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Buttons - Modern Design */
.submit-button,
.play-again-button {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 1.125rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.submit-button::before,
.play-again-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.submit-button:hover::before,
.play-again-button:hover::before {
    left: 100%;
}

.submit-button:hover:not(:disabled),
.play-again-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.submit-button:active:not(:disabled),
.play-again-button:active:not(:disabled) {
    transform: translateY(0);
}

.submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.button-loader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* History Sidebar - Modern Design */
.history-sidebar {
    position: fixed;
    top: 120px;
    right: -380px;
    width: 360px;
    height: calc(100vh - 140px);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    transition: right var(--transition-slow);
    z-index: 50;
    overflow: hidden;
}

.history-sidebar.expanded {
    right: 0;
}

.history-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-history {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.close-history:hover {
    background: var(--danger);
    border-color: var(--danger);
    transform: rotate(90deg);
}

.close-history svg {
    width: 18px;
    height: 18px;
}

.history-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.history-content p {
    margin-bottom: 1rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
    font-size: 0.875rem;
    line-height: 1.6;
    transition: all var(--transition-base);
    animation: slideUp 0.3s ease-out;
}

.history-content p:hover {
    background: var(--bg-elevated);
    transform: translateX(4px);
}

.highlight {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Mobile History */
.mobile-history {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-card);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.mobile-history.show {
    transform: translateX(0);
}

.mobile-history-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mobile-history-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.mobile-header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mobile-theme-toggle {
    display: none;
}

.close-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: 0.625rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.close-button:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.close-button svg {
    width: 20px;
    height: 20px;
}

.mobile-history-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.mobile-history-area p {
    margin-bottom: 1rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Celebration & Failure Overlays */
.celebration-overlay,
.failure-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

.celebration-content,
.failure-content {
    text-align: center;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.trophy,
.sad-face {
    font-size: 6rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease-in-out infinite;
}

.celebration-text,
.failure-text {
    font-size: 3rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--success), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.failure-text {
    background: linear-gradient(135deg, var(--danger), var(--warning));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Footer */
.app-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
    padding: 2rem 1.5rem 1.5rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-link {
    color: var(--accent-primary);
    text-decoration: none;
    transition: all var(--transition-base);
    position: relative;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: width var(--transition-base);
}

.footer-link:hover::after {
    width: 100%;
}

.footer-text {
    color: var(--text-dim);
}

/* Legal Pages */
.legal-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2rem;
    animation: fadeIn 0.6s ease-out;
}

.legal-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-subtle);
}

.legal-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.legal-date {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.legal-content {
    line-height: 1.8;
}

.legal-section {
    margin-bottom: 2.5rem;
    animation: slideUp 0.5s ease-out;
    animation-fill-mode: both;
}

.legal-section:nth-child(1) { animation-delay: 0.1s; }
.legal-section:nth-child(2) { animation-delay: 0.2s; }
.legal-section:nth-child(3) { animation-delay: 0.3s; }

.legal-section h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.legal-section h3 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.legal-section p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.legal-section ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.legal-section li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.legal-section li strong {
    color: var(--text-primary);
}

.legal-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-subtle);
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.back-link:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateX(-4px);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .history-sidebar {
        width: 320px;
        right: -340px;
    }
}

@media (max-width: 768px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
    
    .header-section {
        padding: 1rem 1rem;
    }
    
    .header-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 1rem;
        justify-items: center;
    }
    
    .logo {
        width: 40px;
        height: 40px;
        grid-row: 1;
        grid-column: 1;
        justify-self: center;
        margin-right: auto;
        margin-left: 1rem;
    }
    
    .game-title {
        font-size: 1.25rem;
        white-space: nowrap;
        grid-row: 1;
        grid-column: 1;
        justify-self: center;
    }
    
    .header-controls {
        grid-row: 2;
        grid-column: 1;
        justify-self: center;
        gap: 1rem;
    }
    
    /* Hide desktop theme toggle on mobile */
    .header-controls .theme-toggle {
        display: none;
    }
    
    /* Show mobile theme toggle in history panel */
    .mobile-theme-toggle {
        display: flex !important;
    }
    
    .history-toggle {
        display: none;
    }
    
    .hamburger-menu {
        display: flex;
    }
    
    .history-sidebar {
        display: none;
    }
    
    .main-container {
        padding: 2rem 1rem;
    }
    
    .game-container {
        padding: 1.75rem;
    }
    
    .response-area {
        min-height: 160px;
        max-height: 280px;
        padding: 1.25rem;
        font-size: 0.9375rem;
    }
    
    .question-input {
        padding: 1rem 3rem 1rem 1rem;
        font-size: 1rem;
    }
    
    .submit-button,
    .play-again-button {
        padding: 1rem 1.5rem;
    }
    
    .celebration-text,
    .failure-text {
        font-size: 2rem;
    }
    
    .trophy,
    .sad-face {
        font-size: 4rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .legal-header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }
    
    .response-area {
        min-height: 140px;
        padding: 1rem;
    }
    
    .question-input {
        padding: 0.875rem 2.5rem 0.875rem 1rem;
    }
    
    .char-counter {
        right: 1rem;
        font-size: 0.625rem;
    }
}

/* Utility Classes */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.5s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}

::-moz-selection {
    background: var(--accent-primary);
    color: white;
}
