/**
 * 技能详情页 - 优化样式
 * 包含复制功能和图片预览的增强样式
 * 
 * @author AI Assistant
 * @version 1.0.0
 */

/* ========================
   Toast 通知组件样式
   ======================== */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #22C55E;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    min-width: 200px;
}

.toast.error {
    background: #EF4444;
}

.toast.warning {
    background: #F59E0B;
}

.toast.info {
    background: #3B82F6;
}

/* ========================
   复制按钮增强样式
   ======================== */

.copy-btn {
    position: relative;
    overflow: hidden;
}

.copy-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.copy-btn.error {
    background: #EF4444 !important;
    border-color: #EF4444 !important;
    color: white !important;
}

/* 复制按钮脉冲动画 */
@keyframes copyPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.copy-btn.copied {
    animation: copyPulse 0.6s ease;
}

/* 复制菜单 */
#copy-format-menu {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================
   图片预览模态框增强样式
   ======================== */

.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

.image-modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.image-modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
}

.image-modal-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
}

.image-modal-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 导航按钮 */
.image-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.image-modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.image-modal-prev {
    left: 2rem;
}

.image-modal-next {
    right: 2rem;
}

/* 图片计数器 */
.image-modal-counter {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* ========================
   加载动画样式
   ======================== */

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

@keyframes ripple {
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* 加载占位符 */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================
   滚动条优化样式
   ======================== */

.prompt-content::-webkit-scrollbar {
    width: 8px;
}

.prompt-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.prompt-content::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 4px;
    transition: background 0.3s;
}

.prompt-content::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Firefox */
.prompt-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.3) transparent;
}

/* ========================
   响应式调整
   ======================== */

@media (max-width: 768px) {
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    .image-modal {
        padding: 1rem;
    }

    .image-modal-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .image-modal-nav {
        width: 40px;
        height: 40px;
    }

    .image-modal-prev {
        left: 1rem;
    }

    .image-modal-next {
        right: 1rem;
    }

    .image-modal-counter {
        bottom: 1rem;
        font-size: 12px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .image-modal-nav {
        display: none;
    }

    .image-modal-content {
        max-width: 95%;
        max-height: 70%;
    }
}

/* ========================
   减少动画偏好支持
   ======================== */

@media (prefers-reduced-motion: reduce) {
    .toast,
    .image-modal,
    .image-modal-content img,
    .copy-btn,
    .image-modal-close,
    .image-modal-nav {
        animation: none !important;
        transition: none !important;
    }

    .image-modal.active {
        opacity: 1;
    }
}

/* ========================
   页面隐藏状态（节省资源）
   ======================== */

.page-hidden .bg-circle,
.page-hidden .skill-card {
    animation-play-state: paused !important;
}

/* ========================
   提示词内容优化样式
   ======================== */

.prompt-step {
    position: relative;
}

.prompt-step::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.prompt-step:hover::before {
    opacity: 1;
}

/* 代码块样式（如果有） */
.step-instructions code {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
}

.step-instructions pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.step-instructions pre code {
    background: none;
    color: inherit;
    padding: 0;
}

/* 强调文本 */
.step-instructions strong {
    color: #1e293b;
    font-weight: 600;
}

.step-instructions em {
    color: #667eea;
    font-style: italic;
}

/* 列表样式 */
.step-instructions ul,
.step-instructions ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.step-instructions li {
    margin: 0.25rem 0;
}

/* ========================
   图片画廊优化
   ======================== */

.gallery-image-wrapper {
    position: relative;
    overflow: hidden;
}

.gallery-image-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.4) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-image-wrapper::after {
    opacity: 1;
}

/* 图片加载状态 */
.gallery-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-image.loaded,
.gallery-image[src]:not([src=""]) {
    opacity: 1;
}

/* ========================
   技能头部优化
   ======================== */

.skill-header-image {
    position: relative;
}

.skill-header-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(102, 126, 234, 0.1) 0%,
        transparent 50%
    );
    pointer-events: none;
    z-index: 1;
}

/* ========================
   背景动画优化
   ======================== */

.bg-circle {
    will-change: transform;
}

/* 性能优化：只在可见时动画 */
@media (prefers-reduced-motion: no-preference) {
    .bg-circle {
        animation-play-state: running;
    }
}

/* ========================
   焦点样式优化（无障碍）
   ======================== */

.copy-btn:focus-visible,
.back-link:focus-visible,
.gallery-item:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ========================
   打印样式优化
   ======================== */

@media print {
    .bg-decoration,
    .image-modal,
    #toast-container,
    .copy-btn {
        display: none !important;
    }

    .skill-detail-container {
        background: white !important;
        color: black !important;
    }

    .skill-header,
    .skill-section {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .prompt-content {
        max-height: none !important;
        overflow: visible !important;
    }
}
