/* Python代码动画样式 - 为AI学姐博客创建一个充满科技感的动画 */

/* 主题变量设置 */
:root {
    --terminal-bg: #1e1e2e;
    --terminal-header-bg: #313244;
    --terminal-text: #cdd6f4;
    --terminal-keyword: #f38ba8;
    --terminal-function: #89b4fa;
    --terminal-string: #a6e3a1;
    --terminal-comment: #6c7086;
    --terminal-number: #fab387;
    --terminal-class: #f9e2af;
    --terminal-result-bg: rgba(30, 30, 46, 0.8);
    --terminal-result-border: #89b4fa;
    --terminal-border: #7f849c;
    --terminal-glow: rgba(137, 180, 250, 0.5);
    --matrix-color: rgba(137, 220, 235, 0.7);
}

/* 浅色模式变量 */
body:not(.dark-mode) {
    --terminal-bg: #232634;
    --terminal-header-bg: #292c3c;
    --terminal-text: #c6d0f5;
    --terminal-border: #8caaee;
    --terminal-glow: rgba(140, 170, 238, 0.5);
    --terminal-result-border: #8caaee;
}

/* 黑暗模式变量 - 为终端使用更深的颜色 */
body.dark-mode {
    --terminal-bg: #11111b;
    --terminal-header-bg: #181825;
    --terminal-text: #f8f8f2;
    --terminal-border: #89b4fa;
    --terminal-glow: rgba(137, 180, 250, 0.5);
    --terminal-result-border: #89b4fa;
    --terminal-keyword: #ff79c6;
    --terminal-function: #50fa7b;
    --terminal-string: #f1fa8c;
    --terminal-comment: #6272a4;
}

/* 代码终端基础样式 */
.code-terminal {
    max-width: 700px;
    margin: 0 auto;
    position: relative;
    background-color: var(--terminal-bg);
    border-radius: 8px;
    box-shadow: 0 4px 25px var(--terminal-glow), 0 0 10px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    transition: all 0.3s ease, transform 0.5s ease, box-shadow 0.5s ease;
    z-index: 10;
    border: 1px solid var(--terminal-border);
}

.code-terminal:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px var(--terminal-glow), 0 0 15px rgba(0, 0, 0, 0.3);
}

/* 终端头部样式 */
.terminal-header {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    background: var(--terminal-header-bg);
    position: relative;
    overflow: hidden;
}

/* 终端窗口按钮样式 */
.terminal-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 15px;
}

.terminal-button {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.button-close {
    background-color: #ff5f56;
}

.button-minimize {
    background-color: #ffbd2e;
}

.button-maximize {
    background-color: #27c93f;
}

.button-close:hover, .button-minimize:hover, .button-maximize:hover {
    filter: brightness(1.1);
    transform: scale(1.1);
}

/* 终端标题样式 */
.terminal-title {
    color: var(--terminal-text);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 0 2px var(--terminal-glow);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    position: relative;
}

/* 代码区域样式 - 隐藏滚动条 */
.code-area {
    position: relative;
    padding: 15px;
    overflow: auto;
    max-height: 500px;
    background-color: var(--terminal-bg);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.code-area::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

/* 代码行样式 */
.code-line {
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: var(--terminal-text);
    margin: 4px 0;
    padding: 4px 4px 4px 8px;
    white-space: pre;
    display: block;
    position: relative;
    border-radius: 4px;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.code-line::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.code-line:hover {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.code-line.typing::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    height: 16px;
    width: 2px;
    background-color: #fff;
    transform: translateY(-50%);
    animation: cursor 1s infinite;
}

/* 代码高亮样式 */
.keyword {
    color: var(--terminal-keyword);
}

.function {
    color: var(--terminal-function);
}

.string {
    color: var(--terminal-string);
}

.number {
    color: var(--terminal-number);
}

.comment {
    color: var(--terminal-comment);
    font-style: italic;
}

.class {
    color: var(--terminal-class);
}

/* 缩进样式修复 */
.indent {
    padding-left: 20px;
    position: relative;
    display: block;
}

.indent.indent {
    padding-left: 40px;
    display: block;
}

/* 装饰元素样式 */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

.particle:nth-child(1) {
    width: 10px;
    height: 10px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    width: 15px;
    height: 15px;
    top: 20%;
    left: 80%;
    animation-delay: 2s;
}

.particle:nth-child(3) {
    width: 8px;
    height: 8px;
    top: 60%;
    left: 30%;
    animation-delay: 5s;
}

.particle:nth-child(4) {
    width: 12px;
    height: 12px;
    top: 80%;
    left: 60%;
    animation-delay: 7s;
}

.particle:nth-child(5) {
    width: 6px;
    height: 6px;
    top: 30%;
    left: 50%;
    animation-delay: 9s;
}

.particle:nth-child(6) {
    width: 9px;
    height: 9px;
    top: 70%;
    left: 20%;
    animation-delay: 11s;
}

.particle:nth-child(7) {
    width: 7px;
    height: 7px;
    top: 40%;
    left: 70%;
    animation-delay: 13s;
}

.particle:nth-child(8) {
    width: 11px;
    height: 11px;
    top: 50%;
    left: 40%;
    animation-delay: 15s;
}

/* 数据流线效果 */
.data-stream {
    position: absolute;
    top: 0;
    left: 30%;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--terminal-function), transparent);
    opacity: 0.3;
    z-index: 1;
    animation: dataStream 8s infinite linear;
}

.data-stream:nth-child(2) {
    left: 60%;
    animation-delay: 2s;
}

.data-stream:nth-child(3) {
    left: 90%;
    animation-delay: 4s;
}

/* 矩阵雨效果 */
.matrix-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.matrix-column {
    position: absolute;
    top: -100px;
    color: var(--matrix-color);
    font-family: monospace;
    font-size: 14px;
    text-align: center;
    width: 20px;
    animation: matrixRain 15s infinite linear;
    opacity: 0.5;
}

/* 执行结果区域 */
.result-area {
    margin-top: 15px;
    padding: 10px;
    background-color: var(--terminal-result-bg);
    border-radius: 4px;
    border-left: 3px solid var(--terminal-result-border);
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    color: var(--terminal-text);
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
    animation: fadeIn 1s forwards;
    animation-delay: 2s;
}

.result-line {
    line-height: 1.5;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s forwards;
    animation-delay: calc(2s + var(--i, 0) * 0.5s);
}

.result-line:nth-child(1) {
    --i: 1;
}

.result-line:nth-child(2) {
    --i: 2;
}

/* 交互元素 */
.interactive-element {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(137, 180, 250, 0.1);
    border: 1px solid rgba(137, 180, 250, 0.3);
    cursor: pointer;
    z-index: 5;
    transition: all 0.3s ease;
}

.interactive-element:first-of-type {
    bottom: 20%;
    right: 20%;
}

.interactive-element:last-of-type {
    top: 30%;
    left: 15%;
}

.interactive-element:hover {
    transform: scale(1.2);
    background-color: rgba(137, 180, 250, 0.2);
    border-color: rgba(137, 180, 250, 0.5);
    box-shadow: 0 0 15px rgba(137, 180, 250, 0.3);
}

/* 代码闪光效果 */
.code-highlight {
    position: absolute;
    top: 20%;
    left: 10%;
    width: 80%;
    height: 5px;
    background: linear-gradient(90deg, transparent, rgba(137, 180, 250, 0.2), transparent);
    z-index: 2;
    opacity: 0;
    animation: codeHighlight 8s infinite;
}

/* 动画关键帧 */
@keyframes cursor {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(10px, 10px);
    }
    50% {
        transform: translate(0, 20px);
    }
    75% {
        transform: translate(-10px, 10px);
    }
    100% {
        transform: translate(0, 0);
    }
}

@keyframes dataStream {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(100%);
    }
}

@keyframes matrixRain {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(1000%);
    }
}

@keyframes codeHighlight {
    0%, 100% {
        opacity: 0;
        top: 20%;
    }
    25% {
        opacity: 0.8;
        top: 30%;
    }
    50% {
        opacity: 0;
        top: 50%;
    }
    75% {
        opacity: 0.8;
        top: 70%;
    }
}

/* 响应式样式优化 */
@media (max-width: 768px) {
    .code-terminal {
        max-width: 100%;
        margin: 0 10px;
    }
    
    .code-line {
        font-size: 12px;
    }
    
    .terminal-title {
        font-size: 12px;
    }
    
    .particle, .data-stream {
        display: none;
    }
    
    .matrix-column {
        opacity: 0.3;
    }
    
    .matrix-column:nth-child(n+4) {
        display: none;
    }
}

@media (max-width: 576px) {
    .code-line::before {
        display: none;
    }
    
    .code-line {
        padding-left: 5px;
    }
    
    .indent {
        padding-left: 10px;
    }
    
    .indent.indent {
        padding-left: 20px;
    }
    
    .matrix-column:nth-child(n+3) {
        display: none;
    }
}

/* 矩阵雨效果在暗色模式下的增强 */
body.dark-mode .matrix-column {
    color: rgba(80, 250, 123, 0.7); /* 暗色模式下更亮的矩阵效果 */
    opacity: 0.7;
}

/* 交互元素在暗色模式下的样式 */
body.dark-mode .interactive-element {
    background-color: rgba(80, 250, 123, 0.1);
    border-color: rgba(80, 250, 123, 0.3);
}

body.dark-mode .interactive-element:hover {
    background-color: rgba(80, 250, 123, 0.2);
    border-color: rgba(80, 250, 123, 0.5);
    box-shadow: 0 0 15px rgba(80, 250, 123, 0.3);
}

/* 增强暗色模式下终端窗口按钮的可见性 */
body.dark-mode .terminal-button {
    opacity: 0.9;
}

/* 终端结果区域在暗色模式下的优化 */
body.dark-mode .result-area {
    background-color: rgba(17, 17, 27, 0.8);
    border-left-color: #50fa7b;
}

/* 代码行高亮效果在暗色模式下的增强 */
body.dark-mode .code-line.typing::before {
    background-color: #50fa7b;
}

/* 调整代码终端在深色背景下的外观 */
body.dark-mode .code-terminal {
    box-shadow: 0 4px 25px rgba(80, 250, 123, 0.2), 0 0 10px rgba(0, 0, 0, 0.4);
    border-color: rgba(80, 250, 123, 0.3);
}

body.dark-mode .code-terminal:hover {
    box-shadow: 0 8px 30px rgba(80, 250, 123, 0.3), 0 0 15px rgba(0, 0, 0, 0.5);
}

/* 提高暗色模式下代码高亮的可见性 */
body.dark-mode .keyword {
    color: #ff79c6;
    font-weight: 600;
}

body.dark-mode .function {
    color: #50fa7b;
    font-weight: 600;
}

body.dark-mode .string {
    color: #f1fa8c;
}

body.dark-mode .number {
    color: #bd93f9;
}

body.dark-mode .comment {
    color: #6272a4;
}

body.dark-mode .class {
    color: #8be9fd;
    font-weight: 600;
}
