/* Global Styles and Variables - Breaking the Purple Paradigm */
:root {
    --primary: #00ff9f;
    --secondary: #ff6b35;
    --accent: #ffd23f;
    --danger: #ff006e;
    --success: #06ffa5;
    --bg-dark: #0a0e27;
    --bg-darker: #050814;
    --text: #e8f4f8;
    --text-dim: #8892b0;
    --terminal-green: #00ff9f;
    --glow: #00ff9f;
}

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

body {
    font-family: 'Courier New', monospace;
    background: var(--bg-darker);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Starfield Background */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.stars::before,
.stars::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow: 
        100px 200px white, 300px 100px white, 500px 300px white,
        700px 150px white, 200px 400px white, 600px 250px white,
        150px 350px white, 450px 450px white, 800px 400px white,
        250px 150px white, 550px 100px white, 350px 500px white,
        50px 100px var(--primary), 900px 200px var(--primary),
        400px 50px var(--secondary), 750px 500px var(--secondary);
    animation: twinkle 3s infinite;
}

.stars::after {
    animation-delay: 1.5s;
    opacity: 0.7;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Hero Section */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-darker) 0%, #1a1f3a 50%, var(--bg-darker) 100%);
    overflow: hidden;
    z-index: 1;
}

.drum-container {
    position: absolute;
    width: 300px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    z-index: 0;
}

.drum-memory {
    width: 100%;
    height: 100%;
    border: 3px solid var(--primary);
    border-radius: 50%;
    animation: rotate 10s linear infinite;
    box-shadow: 
        0 0 20px var(--glow),
        inset 0 0 20px var(--glow);
}

.drum-memory::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border: 2px solid var(--secondary);
    border-radius: 50%;
    opacity: 0.5;
}

.read-head {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--accent);
    animation: pulse 1s infinite;
}

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

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    50% { 
        opacity: 0.5;
        transform: translateX(-50%) scale(1.2);
    }
}

/* Glitch Title Effect */
.glitch {
    font-size: 4rem;
    font-weight: bold;
    text-align: center;
    position: relative;
    color: var(--primary);
    letter-spacing: 0.1em;
    text-shadow: 
        0 0 10px var(--glow),
        0 0 20px var(--glow),
        0 0 30px var(--glow);
    animation: glitch 3s infinite;
    z-index: 2;
    margin: 20px;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--danger);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--secondary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 4s infinite linear alternate-reverse;
}

@keyframes glitch {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
}

@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 31px, 0); }
    20% { clip: rect(85px, 9999px, 140px, 0); }
    40% { clip: rect(45px, 9999px, 98px, 0); }
    60% { clip: rect(120px, 9999px, 170px, 0); }
    80% { clip: rect(5px, 9999px, 55px, 0); }
    100% { clip: rect(70px, 9999px, 105px, 0); }
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-dim);
    text-align: center;
    z-index: 2;
}

.byline {
    font-size: 1rem;
    color: var(--text-dim);
    text-align: center;
    z-index: 2;
    margin-top: 0.5rem;
}

/* Hex Rain Effect */
.hex-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* Story Container - Main Scrolling Page */
.story-container {
    background: var(--bg-dark);
    position: relative;
    z-index: 2;
}

.story-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

/* Story Text Blocks */
.story-text-block {
    margin: 2rem 0;
    line-height: 1.9;
    font-size: 1.1rem;
}

.story-text-block p {
    margin: 0.8rem 0;
    color: var(--text);
    transition: all 0.3s ease;
}

.story-text-block:hover p {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(0, 255, 159, 0.3);
}

.story-text-block.indented {
    margin-left: 3rem;
    padding-left: 2rem;
    border-left: 3px solid var(--accent);
    color: var(--accent);
}

.quote-block {
    background: rgba(255, 107, 53, 0.1);
    border-left: 4px solid var(--secondary);
    padding: 1.5rem;
    padding-left: 2rem;
    margin: 2rem 0;
    font-style: italic;
    border-radius: 5px;
}

.quote-block p {
    color: var(--text-dim);
}

.section-title {
    font-size: 3rem;
    color: var(--primary);
    text-align: center;
    margin-bottom: 3rem;
    text-shadow: 0 0 20px var(--glow);
}

/* Terminal Window */
.terminal-window {
    background: #1e1e1e;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 255, 159, 0.3);
    margin: 2rem auto;
    max-width: 800px;
}

.terminal-header {
    background: #2d2d2d;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27c93f; }

.terminal-title {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.terminal-body {
    padding: 2rem;
    font-size: 1.1rem;
    line-height: 1.8;
}

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--terminal-green);
    white-space: nowrap;
    margin: 0.5rem 0;
    animation: typing 2s steps(40, end), blink-caret 0.75s step-end infinite;
}

.typewriter.delay-1 { animation-delay: 2s; opacity: 0; animation-fill-mode: forwards; }
.typewriter.delay-2 { animation-delay: 4s; opacity: 0; animation-fill-mode: forwards; }
.typewriter.delay-3 { animation-delay: 6s; opacity: 0; animation-fill-mode: forwards; }
.typewriter.delay-4 { animation-delay: 8s; opacity: 0; animation-fill-mode: forwards; }
.typewriter.delay-5 { animation-delay: 10s; opacity: 0; animation-fill-mode: forwards; }

@keyframes typing {
    from { width: 0; opacity: 1; }
    to { width: 100%; opacity: 1; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--terminal-green); }
}

/* Highlights */
.highlight {
    color: var(--accent);
    font-weight: bold;
    text-shadow: 0 0 10px var(--accent);
}

.highlight-green {
    color: var(--primary);
    font-weight: bold;
    text-shadow: 0 0 10px var(--primary);
}

.highlight-red {
    color: var(--danger);
    font-weight: bold;
    text-shadow: 0 0 10px var(--danger);
}

/* Computer Display */
.computer-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    margin: 3rem 0;
}

.lgp30-computer {
    background: linear-gradient(145deg, #2a2d3a, #1a1d2a);
    border: 3px solid var(--primary);
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 10px 50px rgba(0, 255, 159, 0.3);
}

.computer-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.lights {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.light {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary);
    animation: blink-random 2s infinite;
}

.light:nth-child(2) { animation-delay: 0.3s; }
.light:nth-child(3) { animation-delay: 0.6s; }
.light:nth-child(4) { animation-delay: 0.9s; }
.light:nth-child(5) { animation-delay: 1.2s; }

@keyframes blink-random {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.2; }
}

.switches {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.switch {
    width: 40px;
    height: 60px;
    background: var(--text-dim);
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.switch::before {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    background: var(--secondary);
    border-radius: 3px;
    top: 5px;
    left: 5px;
    transition: all 0.3s;
}

.switch:hover::before {
    top: 25px;
    background: var(--primary);
}

.computer-label {
    text-align: center;
    margin-top: 1rem;
    font-size: 1.5rem;
    color: var(--primary);
    letter-spacing: 0.2em;
}

.story-text {
    font-size: 1.1rem;
    line-height: 1.8;
}

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

.company {
    color: var(--accent);
    font-weight: bold;
}

blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 2rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-dim);
}

blockquote footer {
    margin-top: 1rem;
    color: var(--primary);
}

.emphasis {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: bold;
    margin: 1.5rem 0;
}

/* Drum Visualization */
.drum-visualization {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 3rem 0;
}

#drumCanvas {
    border: 2px solid var(--primary);
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 255, 159, 0.5);
    background: var(--bg-darker);
}

.drum-controls {
    margin: 2rem 0;
}

.action-btn {
    padding: 1rem 2rem;
    background: linear-gradient(145deg, var(--primary), var(--success));
    color: var(--bg-dark);
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Courier New', monospace;
    box-shadow: 0 5px 20px rgba(0, 255, 159, 0.4);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 255, 159, 0.6);
}

/* Code Example */
.code-example {
    background: #1e1e1e;
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 2rem;
    margin: 2rem 0;
}

.code-label {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.hex-display {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.hex-byte {
    background: var(--bg-darker);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 1.3rem;
    font-weight: bold;
    border: 1px solid var(--primary);
    box-shadow: 0 0 10px rgba(0, 255, 159, 0.3);
    animation: hex-glow 2s infinite;
}

.hex-byte:nth-child(even) {
    animation-delay: 1s;
}

@keyframes hex-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 255, 159, 0.3); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 159, 0.7); }
}

.code-note {
    color: var(--text-dim);
    font-style: italic;
    margin-top: 1rem;
}

/* Blackjack Game */
.blackjack-game {
    max-width: 900px;
    margin: 0 auto;
}

.sense-switch-panel {
    background: linear-gradient(145deg, #2a2d3a, #1a1d2a);
    border: 3px solid var(--danger);
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.switch-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 1.3rem;
    color: var(--accent);
    cursor: pointer;
}

.switch-slider {
    position: relative;
    width: 80px;
    height: 40px;
    background: var(--text-dim);
    border-radius: 20px;
    transition: all 0.3s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    top: 4px;
    left: 4px;
    transition: all 0.3s;
}

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]:checked + .switch-slider {
    background: var(--danger);
    box-shadow: 0 0 20px var(--danger);
}

input[type="checkbox"]:checked + .switch-slider::before {
    transform: translateX(40px);
}

.switch-status {
    margin-top: 1rem;
    font-size: 1.2rem;
    color: var(--primary);
}

.game-area {
    background: #0f4c3a;
    border: 3px solid var(--accent);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.dealer-area,
.player-area {
    margin: 2rem 0;
}

.dealer-area h3,
.player-area h3 {
    color: var(--accent);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.card-container {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 120px;
    margin: 1rem 0;
}

.card {
    width: 80px;
    height: 120px;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: deal-card 0.3s ease-out;
}

@keyframes deal-card {
    from {
        transform: translateY(-100px) rotateY(180deg);
        opacity: 0;
    }
    to {
        transform: translateY(0) rotateY(0);
        opacity: 1;
    }
}

.card.red {
    color: #d00;
}

.card.black {
    color: #000;
}

.card-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.card-suit {
    font-size: 2rem;
    text-align: center;
}

.score {
    font-size: 1.3rem;
    color: var(--primary);
    margin: 1rem 0;
}

.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

.game-btn {
    padding: 1rem 2rem;
    background: var(--text-dim);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Courier New', monospace;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

.game-btn.primary {
    background: linear-gradient(145deg, var(--primary), var(--success));
    color: var(--bg-dark);
}

.game-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.game-message {
    text-align: center;
    font-size: 1.5rem;
    color: var(--accent);
    min-height: 2rem;
    margin: 1rem 0;
    font-weight: bold;
}

.story-note {
    background: rgba(255, 0, 110, 0.1);
    border: 2px solid var(--danger);
    border-radius: 10px;
    padding: 2rem;
    margin-top: 2rem;
}

.story-note p {
    margin-bottom: 1rem;
}

/* Memory Diagram */
.memory-diagram {
    margin: 3rem 0;
}

/* Drum Animation Container */
.drum-animation-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 3rem auto;
    max-width: 500px;
}

#drum-animation-canvas {
    display: block;
    margin: 0 auto;
    background: rgba(10, 14, 39, 0.5);
    border-radius: 10px;
    border: 2px solid var(--primary);
    box-shadow: 0 0 30px rgba(0, 255, 159, 0.2);
}

.drum-animation-label {
    font-size: 1.3rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary);
    margin-top: 1.5rem;
    font-weight: bold;
    letter-spacing: 0.2em;
}

.memory-grid {
    background: #1e1e1e;
    border: 2px solid var(--primary);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.memory-row {
    display: grid;
    grid-template-columns: 150px 1fr 1fr;
    padding: 1rem;
    border-bottom: 1px solid var(--text-dim);
    transition: all 0.3s;
}

.memory-row.header {
    background: var(--bg-darker);
    color: var(--accent);
    font-weight: bold;
}

.memory-row:not(.header):hover {
    background: rgba(0, 255, 159, 0.1);
}

.memory-row.overflow {
    background: rgba(255, 0, 110, 0.2);
    border: 2px solid var(--danger);
}

.addr {
    color: var(--secondary);
    font-weight: bold;
}

.instr {
    color: var(--primary);
}

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

.revelation {
    background: linear-gradient(145deg, #2a2d3a, #1a1d2a);
    border: 3px solid var(--success);
    border-radius: 10px;
    padding: 2rem;
}

.revelation p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Legacy Section */
.legacy-content {
    max-width: 900px;
    margin: 0 auto;
}

.final-quote {
    background: linear-gradient(145deg, #2a2d3a, #1a1d2a);
    border-left: 5px solid var(--primary);
    padding: 3rem;
    margin: 3rem 0;
    font-size: 1.3rem;
    line-height: 2;
    border-radius: 10px;
}

.final-quote p {
    margin-bottom: 0.5rem;
}

.tribute {
    text-align: center;
    margin: 3rem 0;
    font-size: 1.2rem;
}

.tribute p {
    margin-bottom: 1rem;
}

.tech-specs {
    margin: 4rem 0;
}

.tech-specs h3 {
    font-size: 2rem;
    color: var(--accent);
    text-align: center;
    margin-bottom: 2rem;
}

.spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.spec-card {
    background: linear-gradient(145deg, #2a2d3a, #1a1d2a);
    border: 2px solid var(--primary);
    border-radius: 10px;
    padding: 2rem;
    transition: all 0.3s;
}

.spec-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 255, 159, 0.3);
}

.spec-card h4 {
    color: var(--accent);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

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

.spec-card li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.spec-card li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* Footer */
.footer {
    background: var(--bg-darker);
    border-top: 2px solid var(--primary);
    padding: 3rem 2rem;
    text-align: center;
}

.footer p {
    margin: 0.5rem 0;
}

.footer .small {
    font-size: 0.9rem;
    color: var(--text-dim);
}

/* Scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Ripple effect for buttons */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Enhanced animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-section.active .container > * {
    animation: fadeInUp 0.6s ease-out;
}

/* Card hover effects */
.card {
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px) rotate(2deg);
}

/* Enhanced button effects */
.game-btn,
.action-btn {
    position: relative;
    overflow: hidden;
}

.game-btn::before,
.action-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.game-btn:active::before,
.action-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .glitch {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.2rem;
    }
    
    .story-nav {
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .computer-display,
    .spec-grid {
        grid-template-columns: 1fr;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    #drumCanvas {
        width: 100%;
        max-width: 400px;
        height: auto;
    }
}
