/* Font Stack */
body {
    font-family: 'Inter', sans-serif;
    color: #1a1a1a; /* Deep charcoal */
    background: #fefefe; /* Warm white */
    transition: background 0.3s, color 0.3s;
}

h1, h2, h3 {
    font-family: 'Playfair Display', serif;
}

/* Dark mode */
body.dark {
    color: #fefefe;
    background: #0a0a0a; /* Rich dark */
}

/* Color Palette */
:root {
    --primary: #1a1a1a;
    --background: #fefefe;
    --accent: #ff6b6b; /* Soft coral */
    --muted-light: #ccc;
    --muted-medium: #999;
    --muted-dark: #666;
}

body.dark {
    --primary: #fefefe;
    --background: #0a0a0a;
    --accent: #ff6b6b;
    --muted-light: #666;
    --muted-medium: #999;
    --muted-dark: #ccc;
}

/* Layout & Spacing */
.narrative-canvas {
    min-height: 100vh;
    padding: 4rem;
    max-width: 96ch; /* Optimal line length */
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: row;
}

/* Main Content Area */
.main-content {
    flex: 1;
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0; /* Allow content to shrink */
}

/* Sidebar Layout */
.sidebar {
    position: fixed;
    top: 0;
    height: 100vh;
    width: 300px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
}

.sidebar-left {
    left: 0;
}

.sidebar-right {
    right: 0;
    transform: translateX(100%);
    border-right: none;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark .sidebar-right {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.open {
    transform: translateX(0);
}

body.dark .sidebar {
    background: rgba(10, 10, 10, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}



.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    position: sticky;
    top: 0;
    z-index: 10;
}

body.dark .sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 10, 10, 0.5);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary);
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

body.dark .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
    padding: 1rem;
}

/* Theme List Styles */
.themes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.theme-item {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-weight: 500;
    color: var(--primary);
    position: relative;
    overflow: hidden;
}

body.dark .theme-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-item:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark .theme-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.theme-item.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(255, 107, 107, 0.3);
}

.theme-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.theme-item:hover::before,
.theme-item.active::before {
    transform: scaleY(1);
}

/* Subtheme List Styles */
.subthemes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.subtheme-item {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
    color: var(--primary);
    position: relative;
    overflow: hidden;
}

body.dark .subtheme-item {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.subtheme-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

body.dark .subtheme-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.subtheme-item.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 1px 8px rgba(255, 107, 107, 0.3);
}

.subtheme-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.subtheme-item:hover::before,
.subtheme-item.active::before {
    transform: scaleY(1);
}

/* Main Content Area */
.main-content {
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Adjust main content when sidebars are open */
.sidebar-left.open + .main-content {
    margin-left: 300px;
}

.sidebar-right.open ~ .main-content {
    margin-right: 300px;
}

/* Theme Constellation */
.theme-constellation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    perspective: 1000px;
}

/* Clean, minimal theme tags */
.theme-tag {
    background: var(--theme-primary, #4a90e2);
    border-radius: 8px;
    padding: 12px 20px;
    margin: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: white;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: var(--theme-accent, #7bb3f0);
}

.theme-tag:nth-child(2n) {
    animation-delay: -1s;
}

.theme-tag:nth-child(3n) {
    animation-delay: -2s;
}

/* Story Viewport */
.story-viewport {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
    line-height: 1.8;
    font-size: 1.1rem;
    padding: 4rem 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.story-viewport.active {
    opacity: 1;
    transform: translateY(0);
}

/* Narrative Controls */
.narrative-controls {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    background: rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--primary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

body.dark .control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.speed-slider {
    width: 100px;
}

/* Progress Visualization */
.narrative-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 107, 107, 0.2);
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d);
    width: 0%;
    transition: width 0.3s ease;
}

/* Typewriter Cursor */
.typewriter-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    color: var(--primary);
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Quote Emphasis */
.quote {
    color: var(--accent);
    font-style: italic;
    position: relative;
    padding: 0 0.5rem;
}

.quote::before {
    content: '"';
    position: absolute;
    left: -0.5rem;
    top: -0.5rem;
    font-size: 1.5em;
    color: var(--primary);
    opacity: 0.3;
}

/* Emotional Highlights */
.emotional-highlight {
    opacity: 0;
    transition: opacity 0.5s ease;
    color: var(--accent);
    font-weight: 600;
}

.emotional-highlight.revealed {
    opacity: 1;
}

/* Branching Choices */
.branching-choices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    animation: fadeIn 1s ease-in;
}

.branching-choices:not(:first-child) .choice-btn {
    animation-delay: 0.5s;
}

.branching-choices .choice-btn {
    animation: fadeIn 0.5s ease-in forwards;
}

@media (max-width: 768px) {
    /* Hide sidebars on mobile */
    .sidebar {
        display: none !important;
    }
    
    /* Hide sidebar toggle buttons on mobile */
    #themes-sidebar-btn,
    #subthemes-sidebar-btn {
        display: none !important;
    }
    
    /* Reset layout on mobile */
    .narrative-canvas {
        flex-direction: column;
        padding: 2rem;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100%;
    }
    
    .theme-constellation {
        padding: 2rem 1rem;
    }
    
    .theme-tag {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .story-viewport {
        padding: 2rem 1rem;
        font-size: 1rem;
    }
    
    .narrative-controls {
        bottom: 1rem;
        padding: 0.3rem 0.8rem;
    }
    
    .control-btn {
        font-size: 1rem;
    }
    
    .speed-slider {
        width: 80px;
    }
}

@media (max-width: 768px) {
    .branching-choices {
        flex-direction: column;
        align-items: center;
    }
    
    .theme-constellation {
        gap: 0.5rem;
    }
    
    #text-content {
        font-size: 0.95rem;
    }
}

/* Clean choice button styling */
.choice-btn {
    background: var(--theme-primary, #4a90e2);
    border-radius: 8px;
    padding: 12px 20px;
    margin: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: var(--theme-accent, #7bb3f0);
}

.choice-btn:active {
    transform: translateY(0);
}

.choice-btn:focus {
    outline: 2px solid var(--theme-accent, #7bb3f0);
    outline-offset: 2px;
}

/* Dark mode adjustments */
body.dark .theme-tag,
body.dark .choice-btn {
    color: white;
    text-shadow: none;
    font-weight: 500;
}

body.dark .choice-btn:focus,
body.dark .theme-tag:focus {
    outline: 2px solid white;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .theme-tag, .choice-btn {
        animation: none;
        transition: none;
    }
}

.answer {
    margin-top: 2em;
    font-weight: 600;
}

.question {
    font-style: italic;
}

.reaction {
    color: var(--muted-dark);
    line-height: 1.5;
    margin-top: 2em;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    font-style: italic;
}

/* Introductory Screen Styles */
.intro-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--background);
    position: relative;
    transition: background 0.3s ease;
}

.intro-content {
    text-align: left;
    max-width: 600px;
    padding: 4rem 2rem;
    position: relative;
    z-index: 2;
}

.intro-title {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--primary);
    font-weight: 700;
    line-height: 1.2;
}

.intro-text {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--primary);
    margin-bottom: 3rem;
    opacity: 0.8;
}

.intro-text p {
    margin-bottom: 1rem;
}

.start-btn {
    background: var(--primary);
    color: var(--background);
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.start-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.start-btn:active {
    transform: translateY(0);
}

/* Responsive design for intro screen */
@media (max-width: 768px) {
    .intro-content {
        padding: 2rem 1rem;
    }
    
    .intro-title {
        font-size: 2.5rem;
    }
    
    .intro-text {
        font-size: 1rem;
    }
    
    .start-btn {
        padding: 1rem 2.5rem;
        font-size: 1.1rem;
    }
}
.bottom-links {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--background);
    padding: 1rem;
    text-align: center;
}
.bottom-links a {
    color: var(--primary);
    text-decoration: none;
}
.bottom-links a:hover {
    text-decoration: underline;
}