/* BBS Style Poetry Screensaver CSS */

/* 主容器 - 透明背景，文字直接浮現在頁面上 */
#poetry-screensaver-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    
    /* 完全透明背景，讓頁面內容透過 */
    background: transparent !important;
}

/* 螢幕保護程式啟動時 */
#poetry-screensaver-container.active {
    opacity: 1;
    visibility: visible;
}

/* 移除所有掃描線和 CRT 效果 */
#poetry-screensaver-container::after,
#poetry-screensaver-container::before {
    display: none !important;
}

/* 背景遮罩 - 更深的黑色 */
#poetry-screensaver-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    pointer-events: none;
}

/* 背景遮罩啟動時 */
#poetry-screensaver-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    cursor: pointer;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.7) 70%,
        rgba(0, 0, 0, 0.9) 100%
    );
}

/* BBS 風格詩句 */
.bbs-poetry-line {
    position: absolute !important;
    
    /* 經典等寬字體 */
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace !important;
    
    /* 基本文字屬性 */
    font-size: 1.2rem !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    letter-spacing: 0.05em !important;
    
    /* 終端綠色為預設 */
    color: #34d9cb !important;
    
    /* 經典 CRT 字體光暈效果 - 調整為較柔和的光暈 */
    text-shadow: 
        0 0 2px currentColor,
        0 0 4px currentColor,
        0 0 6px rgba(255, 255, 255, 0.3) !important;
    
    /* 位置和層級 */
    z-index: 10002 !important;
    white-space: nowrap !important;
    
    /* 移除任何變形 */
    transform: none !important;
    
    /* 文字渲染優化 */
    text-rendering: optimizeSpeed !important;
    -webkit-font-smoothing: auto !important;
    -moz-osx-font-smoothing: auto !important;
    
    /* 避免選取 */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
}

/* 中文字體特殊處理 */
.bbs-poetry-line.lang-zh {
    font-family: 'Monaco', 'Menlo', 'Microsoft YaHei Mono', 'Consolas', 'SimHei', monospace !important;
    letter-spacing: 0.1em !important;
    font-size: 1.1rem !important;
}

/* 不同螢幕尺寸的字體調整 */
@media (max-width: 480px) {
    .bbs-poetry-line {
        font-size: 0.9rem !important;
        letter-spacing: 0.02em !important;
    }
    
    .bbs-poetry-line.lang-zh {
        font-size: 0.85rem !important;
        letter-spacing: 0.05em !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .bbs-poetry-line {
        font-size: 1rem !important;
    }
    
    .bbs-poetry-line.lang-zh {
        font-size: 0.95rem !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .bbs-poetry-line {
        font-size: 1.1rem !important;
    }
    
    .bbs-poetry-line.lang-zh {
        font-size: 1.05rem !important;
    }
}

@media (min-width: 1025px) and (max-width: 1440px) {
    .bbs-poetry-line {
        font-size: 1.2rem !important;
    }
    
    .bbs-poetry-line.lang-zh {
        font-size: 1.15rem !important;
    }
}

@media (min-width: 1441px) {
    .bbs-poetry-line {
        font-size: 1.4rem !important;
    }
    
    .bbs-poetry-line.lang-zh {
        font-size: 1.3rem !important;
    }
}

/* 經典終端顏色變化 - 調整為更柔和的光暈動畫 */
.bbs-poetry-line {
    animation: terminalGlow 2s ease-in-out infinite alternate;
}

@keyframes terminalGlow {
    0% {
        text-shadow: 
            0 0 2px currentColor,
            0 0 4px currentColor,
            0 0 6px rgba(255, 255, 255, 0.3);
    }
    100% {
        text-shadow: 
            0 0 1px currentColor,
            0 0 3px currentColor,
            0 0 5px rgba(255, 255, 255, 0.2);
    }
}

/* 打字光標效果 */
.bbs-poetry-line::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 1em;
    border-right: 2px solid currentColor;
    animation: blink 1s infinite;
    margin-left: 2px;
    vertical-align: text-bottom;
}

/* 光標閃爍動畫 */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 終端風格掃描線效果 */
#poetry-screensaver-container.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.01) 2px,
        rgba(0, 255, 0, 0.01) 4px
    );
    animation: scanlineMove 0.1s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scanlineMove {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* 移除所有 CRT 螢幕效果，讓文字直接浮現在頁面上 */
#poetry-screensaver-container.active {
    /* 移除所有背景和濾鏡效果 */
    background: transparent !important;
    filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* CRT 螢幕邊緣暗化 */
#poetry-screensaver-container.active::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(0, 0, 0, 0.1) 70%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
    z-index: 10000;
}

/* 高對比度模式下的調整 - 更柔和的光暈 */
@media (prefers-contrast: high) {
    .bbs-poetry-line {
        text-shadow: 
            0 0 1px currentColor,
            0 0 2px currentColor !important;
    }
    
    #poetry-screensaver-container.active {
        filter: contrast(1.3) brightness(1.1);
    }
}

/* 減少動畫偏好時的處理 - 調整靜態光暈 */
@media (prefers-reduced-motion: reduce) {
    .bbs-poetry-line {
        animation: none !important;
        text-shadow: 
            0 0 2px currentColor,
            0 0 4px currentColor !important;
    }
    
    #poetry-screensaver-container::after,
    #poetry-screensaver-container::before {
        animation: none !important;
    }
    
    @keyframes scanlines,
    @keyframes scanlineMove,
    @keyframes blink,
    @keyframes terminalGlow {
        0%, 100% { 
            /* 靜態狀態 */
        }
    }
}

/* 螢幕保護程式模式時保持 body 原狀，不改變背景 */
body.poetry-screensaver-active {
    overflow: hidden !important;
    /* 移除背景顏色變化，保持頁面原有背景 */
}

/* 確保在所有裝置上都能正確顯示 */
#poetry-screensaver-container .bbs-poetry-line {
    pointer-events: none !important;
    backface-visibility: hidden !important;
    perspective: 1000px !important;
}

/* 移除終端視窗和邊緣效果，讓容器完全透明 */
#poetry-screensaver-container.active {
    /* 完全透明，讓頁面內容透過 */
    background: transparent !important;
    filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* 經典 BBS 系統訊息樣式（用於暫停等狀態） */
.bbs-system-message {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    font-family: 'Monaco', 'Consolas', monospace !important;
    font-size: 0.8rem !important;
    color: #ffff00 !important;
    background: rgba(0, 0, 0, 0.8) !important;
    padding: 5px 10px !important;
    border: 1px solid #ffff00 !important;
    z-index: 10003 !important;
    text-shadow: 0 0 5px #ffff00 !important;
}