/* CSS Variables for easy color customization */
:root {
    --phosphor-green: #33ff33;
    --phosphor-dim: #0f4f0f;
    --bg-black: #000000;
    --glow-color: rgba(51, 255, 51, 0.5);
    --scanline-opacity: 0.15;
    --font-mono: 'Courier New', Courier, monospace;
    --screen-curve: 4px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-black);
    color: var(--phosphor-green);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 1px,
        rgba(0, 0, 0, var(--scanline-opacity)) 1px,
        rgba(0, 0, 0, var(--scanline-opacity)) 2px
    );
    animation: scanline-shift 8s linear infinite;
}

@keyframes scanline-shift {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* Terminal window shell */
#terminal-wrap {
    width: 980px;
    max-width: 94vw;
    height: 680px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at center, #0a0a0a 0%, #000000 100%);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.95), 
        inset 0 0 120px rgba(0, 0, 0, 0.8),
        0 0 60px rgba(51, 255, 51, 0.03);
    overflow: hidden;
    position: relative;
    animation: flicker 3s infinite, screen-breathe 4s ease-in-out infinite;
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Barrel distortion effect via pseudo-element */
#terminal-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
    background: radial-gradient(
        ellipse at center,
        rgba(51, 255, 51, 0.02) 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 10;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    10% { opacity: 0.96; }
    11% { opacity: 1; }
    20% { opacity: 0.98; }
    21% { opacity: 1; }
    50% { opacity: 0.97; }
    51% { opacity: 1; }
    80% { opacity: 0.99; }
    81% { opacity: 1; }
}

@keyframes text-flicker {
    0%, 100% { 
        opacity: 1;
        text-shadow: 
            0 0 3px var(--glow-color),
            0 0 6px var(--glow-color),
            0 0 9px rgba(51, 255, 51, 0.3);
    }
    25% { 
        opacity: 0.4;
        text-shadow: 
            0 0 1px var(--glow-color),
            0 0 2px var(--glow-color);
    }
    30% { 
        opacity: 1;
        text-shadow: 
            0 0 5px var(--glow-color),
            0 0 10px var(--glow-color),
            0 0 15px rgba(51, 255, 51, 0.5);
    }
    50% { 
        opacity: 0.6;
        text-shadow: 
            0 0 2px var(--glow-color);
    }
    55% { 
        opacity: 1;
        text-shadow: 
            0 0 4px var(--glow-color),
            0 0 8px var(--glow-color),
            0 0 12px rgba(51, 255, 51, 0.4);
    }
}

@keyframes screen-breathe {
    0%, 100% { 
        filter: brightness(1) contrast(1.05);
    }
    50% { 
        filter: brightness(1.02) contrast(1.08);
    }
}

@keyframes interference {
    0%, 100% {
        transform: translateX(0);
        filter: hue-rotate(0deg);
    }
    20% {
        transform: translateX(-3px) skewX(-2deg);
        filter: hue-rotate(5deg) brightness(1.2);
    }
    40% {
        transform: translateX(3px) skewX(2deg);
        filter: hue-rotate(-5deg) brightness(0.8);
    }
    60% {
        transform: translateX(-2px) skewX(-1deg);
        filter: hue-rotate(3deg) brightness(1.1);
    }
    80% {
        transform: translateX(2px) skewX(1deg);
        filter: hue-rotate(-3deg) brightness(0.9);
    }
}

/* Header / window chrome */
.terminal-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.02));
    z-index: 8;
    -webkit-user-select: none;
    user-select: none;
}

/* Title layout on the left */
.terminal-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--phosphor-green);
    font-size: 14px;
    letter-spacing: 0.6px;
}

.terminal-header .ascii-left {
    color: rgba(51, 255, 51, 0.25);
    font-family: var(--font-mono);
}

.terminal-header .muted {
    color: var(--phosphor-dim);
    font-size: 12px;
    margin-left: 6px;
}

/* Window control buttons (top-right) */
.window-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.wc {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(51, 255, 51, 0.4);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.6);
    cursor: default;
    padding: 0;
}

.wc-close {
    background: rgba(255, 70, 70, 0.4);
    border-color: rgba(255, 70, 70, 0.6);
}

.wc-min {
    background: rgba(255, 200, 70, 0.35);
    border-color: rgba(255, 200, 70, 0.6);
}

.wc-max {
    background: rgba(70, 255, 120, 0.35);
    border-color: rgba(70, 255, 120, 0.6);
}

/* Body / content area */
.terminal-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.terminal {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 28px;
    text-shadow: 
        0 0 3px var(--glow-color),
        0 0 6px var(--glow-color),
        0 0 9px rgba(51, 255, 51, 0.3);
    font-size: 15px;
    line-height: 1.45;
    word-wrap: break-word;
    scrollbar-width: thin;
    scrollbar-color: var(--phosphor-dim) var(--bg-black);
    box-sizing: border-box;
    filter: brightness(1.05);
    background-image: url('background.jpeg?v=18');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 60%;
    background-attachment: scroll;
}

.terminal::-webkit-scrollbar {
    width: 8px;
}

.terminal::-webkit-scrollbar-track {
    background: var(--bg-black);
}

.terminal::-webkit-scrollbar-thumb {
    background: var(--phosphor-dim);
    border-radius: 4px;
}

.terminal::-webkit-scrollbar-thumb:hover {
    background: var(--phosphor-green);
}

.terminal-line {
    margin: 4px 0;
}

/* Hope line styling - clean, no effects */
.terminal-line.hope {
    color: rgba(220, 255, 220, 0.95);
    text-shadow: none;
    filter: none;
}

.terminal-line.hope-dim {
    color: rgba(150, 200, 150, 0.7);
    text-shadow: none;
    filter: none;
}

.glitch {
    position: relative;
    display: inline-block;
}

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

.glitch::before {
    animation: glitch-1 0.3s infinite;
    color: #ff0055;
    text-shadow: 2px 0 3px #ff0055;
    z-index: -1;
    opacity: 0.85;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.glitch::after {
    animation: glitch-2 0.3s infinite;
    color: #00ffff;
    text-shadow: -2px 0 3px #00ffff;
    z-index: -2;
    opacity: 0.85;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
    0%, 100% {
        transform: translate(0);
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    }
    20% {
        transform: translate(-3px, 2px);
        clip-path: polygon(0 15%, 100% 15%, 100% 65%, 0 65%);
    }
    40% {
        transform: translate(3px, -2px);
        clip-path: polygon(0 30%, 100% 30%, 100% 80%, 0 80%);
    }
    60% {
        transform: translate(-2px, 1px);
        clip-path: polygon(0 10%, 100% 10%, 100% 50%, 0 50%);
    }
    80% {
        transform: translate(2px, -3px);
        clip-path: polygon(0 40%, 100% 40%, 100% 90%, 0 90%);
    }
}

@keyframes glitch-2 {
    0%, 100% {
        transform: translate(0);
        clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    }
    25% {
        transform: translate(3px, -1px);
        clip-path: polygon(0 25%, 100% 25%, 100% 75%, 0 75%);
    }
    45% {
        transform: translate(-3px, 2px);
        clip-path: polygon(0 60%, 100% 60%, 100% 95%, 0 95%);
    }
    65% {
        transform: translate(2px, -2px);
        clip-path: polygon(0 35%, 100% 35%, 100% 85%, 0 85%);
    }
    85% {
        transform: translate(-2px, 3px);
        clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
    }
}

@keyframes horizontal-shift {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(5px) skewX(2deg);
    }
    50% {
        transform: translateX(-5px) skewX(-2deg);
    }
    75% {
        transform: translateX(3px) skewX(1deg);
    }
}

.glitch.active {
    animation: horizontal-shift 0.15s ease-in-out;
}

.input-container {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.35));
    position: sticky;
    bottom: 0;
}

.prompt {
    color: var(--phosphor-green);
    margin-right: 8px;
    text-shadow: 0 0 5px var(--glow-color);
}

.command-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--phosphor-green);
    font-family: var(--font-mono);
    font-size: 14px;
    text-shadow: 0 0 5px var(--glow-color);
    caret-color: var(--phosphor-green);
}

.command-input::selection {
    background: var(--phosphor-dim);
    color: var(--phosphor-green);
}

/* Start button - hidden */
.start-button {
    display: none;
}

.dim {
    color: var(--phosphor-dim);
}

.bright {
    color: var(--phosphor-green);
    text-shadow: 0 0 8px var(--glow-color);
}

.flicker-prompt {
    animation: text-flicker 0.8s infinite !important;
}

/* Audio controls - redesigned */
.audio-controls {
    position: fixed;
    bottom: 20px;
    right: 10px;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    gap: 0;
    z-index: 200;
}

.audio-btn {
    background: rgba(0, 255, 0, 0.03);
    border: 1px solid rgba(51, 255, 51, 0.4);
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(51, 255, 51, 0.7);
    transition: all 0.2s ease;
    box-shadow: 0 0 2px rgba(51, 255, 51, 0.3);
    position: relative;
    z-index: 2;
    text-shadow: none;
}

.audio-btn:hover {
    border-color: var(--phosphor-green);
    box-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
    background: rgba(0, 255, 0, 0.08);
    color: var(--phosphor-green);
}

.volume-slider-container {
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid var(--phosphor-green);
    border-radius: 20px;
    padding: 8px 15px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    margin-right: 35px;
}

.audio-controls:hover .volume-slider-container {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.volume-slider-container.hidden {
    opacity: 0;
    transform: translateX(10px);
}

.volume-slider {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(51, 255, 51, 0.2);
    outline: none;
    border-radius: 2px;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--phosphor-green);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 5px var(--glow-color);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--phosphor-green);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0 5px var(--glow-color);
}

/* Keyword glitch effects - intense and chaotic */
.keyword-glitch {
    position: relative;
    display: inline-block;
    z-index: 1;
}

.keyword-glitch.active {
    animation: keyword-glitch-intense 0.4s steps(4) infinite;
    z-index: 10;
}

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

.keyword-glitch.active::before {
    animation: keyword-glitch-before 0.4s steps(3) infinite;
    color: #ff0055;
    z-index: 1;
    mix-blend-mode: screen;
}

.keyword-glitch.active::after {
    animation: keyword-glitch-after 0.4s steps(3) infinite;
    color: #00ffff;
    z-index: 2;
    mix-blend-mode: screen;
}

@keyframes keyword-glitch-intense {
    0% {
        transform: translateX(0);
        text-shadow: 
            3px 0 0 rgba(255, 0, 85, 0.8),
            -3px 0 0 rgba(0, 255, 255, 0.8),
            0 2px 0 rgba(0, 255, 0, 0.6);
        clip-path: inset(0);
        opacity: 1;
    }
    20% {
        transform: translateX(-3px);
        text-shadow: 
            -4px 0 0 rgba(255, 0, 85, 0.9),
            4px 0 0 rgba(0, 255, 255, 0.9),
            0 -2px 0 rgba(0, 255, 0, 0.7);
        clip-path: inset(40% 0 0 0);
        opacity: 0.8;
    }
    40% {
        transform: translateX(3px);
        text-shadow: 
            2px 0 0 rgba(255, 0, 85, 1),
            -2px 0 0 rgba(0, 255, 255, 1),
            0 3px 0 rgba(0, 255, 0, 0.8);
        clip-path: inset(0 0 60% 0);
        opacity: 0.9;
    }
    60% {
        transform: translateX(-2px);
        text-shadow: 
            -3px 0 0 rgba(255, 0, 85, 0.85),
            3px 0 0 rgba(0, 255, 255, 0.85),
            0 -3px 0 rgba(0, 255, 0, 0.5);
        clip-path: inset(20% 0 0 0);
        opacity: 0.75;
    }
    80% {
        transform: translateX(2px);
        text-shadow: 
            4px 0 0 rgba(255, 0, 85, 0.95),
            -4px 0 0 rgba(0, 255, 255, 0.95),
            0 2px 0 rgba(0, 255, 0, 0.6);
        clip-path: inset(0 0 40% 0);
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        text-shadow: 
            3px 0 0 rgba(255, 0, 85, 0.8),
            -3px 0 0 rgba(0, 255, 255, 0.8),
            0 2px 0 rgba(0, 255, 0, 0.6);
        clip-path: inset(0);
        opacity: 1;
    }
}

@keyframes keyword-glitch-before {
    0%, 100% {
        transform: translateX(-2px);
        clip-path: inset(0 0 50% 0);
    }
    33% {
        transform: translateX(3px);
        clip-path: inset(30% 0 0 0);
    }
    66% {
        transform: translateX(-3px);
        clip-path: inset(0 0 70% 0);
    }
}

@keyframes keyword-glitch-after {
    0%, 100% {
        transform: translateX(2px);
        clip-path: inset(50% 0 0 0);
    }
    33% {
        transform: translateX(-2px);
        clip-path: inset(0 0 60% 0);
    }
    66% {
        transform: translateX(3px);
        clip-path: inset(40% 0 0 0);
    }
}

/* Full terminal glitch effect */
.full-glitch {
    animation: full-terminal-glitch 1s ease-out;
}

@keyframes full-terminal-glitch {
    0%, 100% {
        opacity: 1;
        transform: translate(0, 0);
        filter: none;
    }
    10% {
        opacity: 0.8;
        transform: translate(-3px, 2px) skewX(2deg);
        text-shadow: 
            3px 0 0 rgba(255, 0, 85, 0.8),
            -3px 0 0 rgba(0, 255, 255, 0.8);
    }
    20% {
        opacity: 1;
        transform: translate(3px, -2px) skewX(-2deg);
        text-shadow: 
            -3px 0 0 rgba(255, 0, 85, 0.8),
            3px 0 0 rgba(0, 255, 255, 0.8);
        filter: blur(1px);
    }
    30% {
        opacity: 0.9;
        transform: translate(-2px, 3px);
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 40%);
    }
    40% {
        opacity: 1;
        transform: translate(2px, -1px);
        clip-path: polygon(0 50%, 100% 55%, 100% 100%, 0 100%);
    }
    50% {
        opacity: 0.85;
        transform: translate(-3px, 1px) skewX(1deg);
        text-shadow: 
            4px 0 0 rgba(255, 0, 85, 0.9),
            -4px 0 0 rgba(0, 255, 255, 0.9);
        filter: blur(0.5px);
    }
    60% {
        opacity: 1;
        transform: translate(1px, -2px);
        clip-path: none;
    }
    70% {
        opacity: 0.95;
        transform: translate(-1px, 2px);
        text-shadow: 
            2px 0 0 rgba(255, 0, 85, 0.6),
            -2px 0 0 rgba(0, 255, 255, 0.6);
    }
    80% {
        opacity: 1;
        transform: translate(0, 0);
        filter: none;
    }
}

.text-static {
    animation: text-static-glitch 1s ease-out;
}

@keyframes text-static-glitch {
    0%, 100% { 
        opacity: 1;
        filter: none;
    }
    5% {
        opacity: 0.8;
        transform: translate(-2px, 1px);
        filter: blur(0.5px);
    }
    10% {
        opacity: 1;
        transform: translate(2px, -1px);
    }
    15% {
        opacity: 0.7;
        transform: translate(-1px, 2px);
        filter: blur(1px);
    }
    20% {
        opacity: 1;
        transform: translate(1px, -2px);
    }
    25% {
        opacity: 0.9;
        transform: translate(-2px, -1px);
        filter: blur(0.3px);
    }
    30% {
        opacity: 1;
        transform: translate(0, 0);
        filter: none;
    }
}

.error {
    color: #ff3333;
    text-shadow: 0 0 5px rgba(255, 51, 51, 0.5);
}

.warning {
    color: #ffaa33;
    text-shadow: 0 0 5px rgba(255, 170, 51, 0.5);
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    #terminal-wrap {
        width: 96vw;
        height: 78vh;
        border-radius: 8px;
    }
    
    .terminal-header {
        height: 48px;
        padding: 8px 10px;
    }
    
    .terminal-header .title {
        font-size: 12px;
    }
    
    .terminal-header .muted {
        display: none;
    }
    
    .terminal {
        font-size: 12px;
        padding: 12px 16px;
    }
    
    .command-input {
        font-size: 12px;
    }
    
    .start-button {
        right: 10px;
        bottom: 10px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .terminal-header .ascii-left {
        display: none;
    }
}

@media (max-height: 600px) {
    #terminal-wrap {
        height: 88vh;
    }
    
    .terminal {
        font-size: 12px;
    }
}

/* ========================================
   SOCIAL LINKS
   ======================================== */

#social-links {
    position: fixed;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 100;
}

.social-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(51, 255, 51, 0.4);
    color: var(--phosphor-green);
    transition: all 0.2s;
    box-shadow: 0 0 5px rgba(51, 255, 51, 0.3);
}

.social-icon:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 10px var(--glow-color);
    transform: translateY(-2px);
    border-color: var(--phosphor-green);
}

.social-icon svg {
    stroke: var(--phosphor-green);
    fill: var(--phosphor-green);
}

@media (max-width: 768px) {
    #social-links {
        bottom: 35px;
        gap: 15px;
    }
    
    .social-icon {
        width: 30px;
        height: 30px;
    }
    
    .social-icon svg {
        width: 18px;
        height: 18px;
    }
}

/* ========================================
   DOOM FOOTER
   ======================================== */

#doom-footer {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(0, 255, 0, 0.3);
    filter: blur(0.5px);
    z-index: 50;
    pointer-events: none;
    animation: footer-color-cycle 9s ease-in-out infinite, footer-glitch 3s steps(2) infinite;
    text-shadow: 
        1px 0 0 rgba(255, 0, 0, 0.2),
        -1px 0 0 rgba(0, 255, 255, 0.2);
}

@keyframes footer-color-cycle {
    0%, 100% {
        color: rgba(0, 255, 0, 0.3);
    }
    33% {
        color: rgba(255, 0, 0, 0.5);
    }
    66% {
        color: rgba(255, 255, 255, 0.4);
    }
}

@keyframes footer-glitch {
    0%, 90% {
        text-shadow: 
            1px 0 0 rgba(255, 0, 0, 0.2),
            -1px 0 0 rgba(0, 255, 255, 0.2);
    }
    92% {
        text-shadow: 
            3px 0 0 rgba(255, 0, 0, 0.6),
            -3px 0 0 rgba(0, 255, 255, 0.6);
        transform: translateX(-50%) translateY(1px);
    }
    94% {
        text-shadow: 
            -2px 0 0 rgba(255, 0, 0, 0.5),
            2px 0 0 rgba(0, 255, 255, 0.5);
        transform: translateX(-50%) translateY(-1px);
    }
    96%, 100% {
        text-shadow: 
            1px 0 0 rgba(255, 0, 0, 0.2),
            -1px 0 0 rgba(0, 255, 255, 0.2);
        transform: translateX(-50%) translateY(0);
    }
}
