/* Story-based Interactive Maze Steganography Styles */

/* Base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0e27;
    color: #e2e8f0;
    line-height: 1.7;
    font-size: 18px;
    margin: 0;
    padding: 0;
}

/* Hero section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, #0a0e27 0%, #1a365d 100%);
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-content {
    text-align: center;
    z-index: 1;
    padding: 0 20px;
}

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #a0aec0;
    max-width: 600px;
    margin: 0 auto;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.7;
    animation: float 3s ease-in-out infinite;
}

.mouse {
    width: 30px;
    height: 50px;
    border: 2px solid #667eea;
    border-radius: 15px;
    position: relative;
}

.wheel {
    width: 4px;
    height: 10px;
    background: #667eea;
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    animation: scroll 2s ease-out infinite;
}

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

@keyframes scroll {
    0% { opacity: 1; top: 8px; }
    100% { opacity: 0; top: 20px; }
}

/* Main wrapper */
.main-wrapper {
    position: relative;
}

/* Main container layout */
.main-container {
    display: flex;
    min-height: 100vh;
}

/* Left side: Story content */
.story-content {
    flex: 1;
    padding: 0;
    background: #0a0e27;
}

/* Right side: Fixed maze */
.maze-container {
    position: sticky;
    top: 0;
    width: 500px;
    height: 100vh;
    background: rgba(26, 32, 44, 0.8);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.maze-canvas {
    background: white;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
    transition: box-shadow 0.3s;
}

.maze-canvas:hover {
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.4);
}

.maze-info {
    margin-top: 20px;
    text-align: center;
}

.maze-info p {
    color: #a0aec0;
    font-size: 0.9rem;
    font-style: italic;
}

/* Chapter sections */
.chapter {
    min-height: 100vh;
    padding: 80px 40px;
    display: flex;
    align-items: center;
    scroll-snap-align: start;
    position: relative;
}

.chapter:nth-child(even) {
    background: rgba(26, 32, 44, 0.3);
}

.chapter.active {
    background: rgba(102, 126, 234, 0.05);
}

.content {
    max-width: 600px;
    width: 100%;
}

.chapter h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: 1.5rem;
    color: #667eea;
    position: relative;
    padding-left: 30px;
}

.chapter h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.lead {
    font-size: 1.3rem;
    color: #cbd5e0;
    margin-bottom: 1.5rem;
    font-weight: 300;
}

/* Controls panel */
.controls-panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin: 30px 0;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.controls-panel .instruction {
    color: #a0aec0;
    font-style: italic;
    text-align: center;
    margin: 0 0 15px 0;
    padding: 10px 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 20px;
    display: inline-block;
    width: 100%;
}

.status {
    text-align: center;
    margin-top: 15px;
    font-size: 0.95rem;
    color: #cbd5e0;
    min-height: 24px;
}

/* Story buttons */
.story-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: inline-block;
    margin: 5px;
}

.story-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s;
}

.story-btn:hover::before {
    left: 100%;
}

.story-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.story-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.story-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.story-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Special elements */
.insight-box {
    background: rgba(102, 126, 234, 0.1);
    border-left: 4px solid #667eea;
    padding: 20px;
    border-radius: 10px;
    margin: 25px 0;
}

.insight-box h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.algorithm-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 25px 0;
}

.algo-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.algo-card.llc {
    border-color: rgba(66, 153, 225, 0.5);
}

.algo-card.eedge {
    border-color: rgba(56, 178, 172, 0.5);
}

.algo-card h4 {
    margin-bottom: 12px;
    color: #e2e8f0;
    font-size: 1.1rem;
}

.algo-card ul {
    list-style: none;
}

.algo-card li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 8px;
    color: #a0aec0;
    font-size: 0.95rem;
}

.algo-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: #667eea;
}

/* Message input */
.message-input {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 20px;
    border-radius: 30px;
    margin-bottom: 15px;
}

.message-input input {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    outline: none;
    flex: 1;
}

.capacity-display {
    color: #a0aec0;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Algorithm toggle */
.algorithm-toggle {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px;
    border-radius: 25px;
    justify-content: center;
    margin-bottom: 15px;
}

.algorithm-toggle label {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.algorithm-toggle input {
    display: none;
}

.algorithm-toggle input:checked + span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
}

/* Encoding rules */
.encoding-rules {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.encoding-rules h4 {
    color: #e2e8f0;
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

.encoding-rules ul {
    list-style: none;
    display: flex;
    gap: 30px;
    justify-content: center;
    margin: 0;
}

.encoding-rules li {
    padding: 8px 16px;
    font-size: 0.95rem;
}

/* Binary text */
.binary {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Extracted message display */
.extracted-message {
    background: rgba(102, 126, 234, 0.1);
    padding: 15px 25px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.extracted-message .label {
    color: #a0aec0;
}

/* Conclusion section */
.conclusion {
    min-height: auto;
    padding-bottom: 100px;
}

.key-takeaways {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: 15px;
    margin: 25px 0;
}

.key-takeaways h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.key-takeaways ul {
    list-style: none;
}

.key-takeaways li {
    margin-bottom: 12px;
    padding-left: 25px;
    position: relative;
}

.key-takeaways li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

.try-yourself {
    background: rgba(102, 126, 234, 0.1);
    padding: 25px;
    border-radius: 15px;
    margin: 25px 0;
}

.credits {
    margin-top: 40px;
    padding-top: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: #718096;
    font-size: 0.9rem;
}

.credits a {
    color: #667eea;
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}

/* Acknowledgments section for credits */
.acknowledgment {
    margin-top: 30px;
    font-style: italic;
    color: #a0aec0;
    text-align: center;
}

/* Maze visibility transitions */
.maze-container {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.maze-container.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    display: none;
}

.maze-container.minimized {
    opacity: 0.3;
    transform: scale(0.8);
}

/* On mobile, handle maze visibility differently */
@media (max-width: 768px) {
    .maze-container.hidden {
        display: none;
    }
}

/* Touch-friendly controls on mobile */
@media (hover: none) and (pointer: coarse) {
    .story-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .algorithm-toggle label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .message-input input {
        min-height: 44px;
    }
}

/* Algorithm sections */
.algorithm-section {
    margin-bottom: 30px;
}

.algorithm-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.algorithm-section p {
    margin-bottom: 20px;
}

.status-display {
    text-align: center;
    margin: 20px 0;
}

.scroll-hint {
    text-align: center;
    font-style: italic;
    color: #a0aec0;
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
}

.visualization-container {
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.comparison-display {
    background: rgba(102, 126, 234, 0.1);
    padding: 20px;
    border-radius: 15px;
    margin-top: 30px;
    text-align: center;
}

.comparison-display h4 {
    color: #667eea;
    margin-bottom: 15px;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .story-content {
        flex: 1;
        width: 100%;
    }
    
    .maze-container {
        width: 100%;
        height: 400px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 20px;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .chapter {
        padding: 60px 30px;
        min-height: auto;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    .hero h1 {
        font-size: clamp(2rem, 6vw, 3.5rem);
    }
    
    .subtitle {
        font-size: clamp(1rem, 2.5vw, 1.5rem);
    }
    
    .chapter {
        padding: 40px 20px;
        min-height: auto;
    }
    
    .chapter h2 {
        font-size: clamp(1.5rem, 3.5vw, 2rem);
        padding-left: 20px;
    }
    
    .lead {
        font-size: 1.1rem;
    }
    
    .algorithm-comparison {
        grid-template-columns: 1fr;
    }
    
    .encoding-rules ul {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls-panel {
        padding: 15px;
    }
    
    .story-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        margin: 3px;
    }
    
    .maze-container {
        height: 320px;
        padding: 15px;
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(26, 32, 44, 0.98);
        border-bottom: 2px solid rgba(102, 126, 234, 0.3);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    /* Add padding to first chapter to account for fixed maze */
    .chapter:first-of-type {
        padding-top: 340px;
    }
    
    .maze-canvas {
        max-width: 260px;
        max-height: 260px;
        width: auto;
        height: auto;
    }
    
    .maze-info {
        display: none;
    }
    
    .comparison-table {
        overflow-x: auto;
    }
    
    .comparison-table table {
        min-width: 400px;
    }
    
    .message-input {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 15px;
    }
    
    .algorithm-toggle {
        flex-wrap: wrap;
    }
    
    .insight-box, .quote-box {
        padding: 15px;
        margin: 20px 0;
    }
    
    .resources, .reflection-prompts, .next-steps {
        padding: 20px;
    }
    
    .scroll-indicator {
        bottom: 20px;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .chapter {
        padding: 30px 15px;
    }
    
    .chapter h2 {
        font-size: 1.5rem;
    }
    
    .maze-container {
        height: 250px;
    }
    
    .maze-canvas {
        max-width: 220px;
        max-height: 220px;
    }
    
    .controls-panel .instruction {
        font-size: 0.85rem;
        padding: 8px 15px;
    }
    
    .encoding-rules h4,
    .algo-card h4 {
        font-size: 1rem;
    }
    
    .encoding-rules li,
    .algo-card li {
        font-size: 0.85rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 10px;
        font-size: 0.85rem;
    }
}

/* New styles for additional chapters */
.quote-box {
    margin: 30px 0;
    padding: 20px 25px;
    background: rgba(102, 126, 234, 0.1);
    border-left: 4px solid #667eea;
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.comparison-table {
    margin: 40px 0;
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(45, 55, 72, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table th {
    background: rgba(102, 126, 234, 0.2);
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
}

.comparison-table td {
    padding: 15px;
    border-bottom: 1px solid rgba(45, 55, 72, 0.5);
}

.comparison-table tr:last-child td {
    border-bottom: none;
}

.reflection-prompts {
    margin: 40px 0;
    padding: 30px;
    background: rgba(45, 55, 72, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.reflection-prompts p {
    margin-bottom: 15px;
    color: #a0aec0;
}

.reflection-prompts ul {
    list-style: none;
    padding: 0;
}

.reflection-prompts li {
    padding: 10px 0;
    padding-left: 25px;
    position: relative;
}

.reflection-prompts li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #667eea;
}

.resources {
    margin-top: 50px;
    padding: 30px;
    background: rgba(26, 54, 93, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.resources h4 {
    margin-bottom: 20px;
    color: #e2e8f0;
}

.resources ul {
    list-style: none;
    padding: 0;
}

.resources li {
    padding: 8px 0;
}

.resources a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.resources a:hover {
    color: #805ad5;
    text-decoration: underline;
}

/* Chapter 8 transition styles */
.next-steps {
    margin: 40px 0;
    padding: 30px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.next-steps h3 {
    margin-bottom: 15px;
    color: #e2e8f0;
}

.next-steps ul {
    list-style: none;
    padding: 0;
    margin-top: 10px;
}

.next-steps li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.next-steps li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

p.transition {
    margin-top: 40px;
    font-style: italic;
    color: #a0aec0;
    text-align: center;
    font-size: 1.1em;
}

/* Deep dive details styling */
details.deep-dive {
    background: rgba(26, 32, 46, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 0;
    margin: 20px 0;
}

details.deep-dive summary {
    padding: 15px 20px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    position: relative;
    color: #667eea;
    transition: all 0.2s ease;
}

details.deep-dive summary::-webkit-details-marker {
    display: none;
}

details.deep-dive summary:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #805ad5;
}

details.deep-dive summary::before {
    content: '▶';
    position: absolute;
    left: 20px;
    transition: transform 0.2s;
}

details.deep-dive[open] summary::before {
    transform: rotate(90deg);
}

details.deep-dive[open] summary {
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
}

details.deep-dive pre {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

details.deep-dive table {
    border-collapse: collapse;
    width: 100%;
}

details.deep-dive table th,
details.deep-dive table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

details.deep-dive table th {
    background: rgba(102, 126, 234, 0.1);
    font-weight: 600;
    color: #e2e8f0;
}

details.deep-dive table tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

/* Tooltip styles for technical terms */
.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted #667eea;
    cursor: help;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 250px;
    background-color: #1a365d;
    color: #e2e8f0;
    text-align: left;
    border-radius: 6px;
    padding: 10px 15px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 10px; /* Start from left edge of the word */
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    white-space: normal;
}

/* If tooltip would go off right edge, align to right instead */
.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Check if we're in the right half of the content */
.chapter:nth-child(n+4) .tooltip .tooltip-text {
    left: auto;
    right: 10px;
}

/* Adjust tooltip position on smaller screens */
@media (max-width: 768px) {
    .tooltip .tooltip-text {
        width: 200px;
        left: 0;
        right: auto;
    }
}

.tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 30px;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1a365d transparent transparent transparent;
}

/* Arrow for right-aligned tooltips */
.chapter:nth-child(n+4) .tooltip .tooltip-text::after {
    left: auto;
    right: 25px;
}