/* 定义全局CSS变量，便于统一管理颜色和效果 */
:root {
    --main-pink: #FFA1C9;      /* 主粉色 - 用于主题强调和渐变 */
    --sky-blue: #87CEEB;       /* 天蓝色 - 用于主题渐变 */
    --mint-green: #98FB98;     /* 薄荷绿 - 预留颜色变量 */
    --deep-purple: #9370DB;    /* 深紫色 - 用于按钮和强调 */
    --bg-blur: blur(12px);     /* 背景模糊效果 - 用于半透明元素 */
}

/* 全局样式设置 */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(145deg, var(--sky-blue) 0%, var(--main-pink) 100%);
    min-height: 100vh;         /* 确保页面至少占满整个视口高度 */
    padding: 10px;
    position: relative;
    overflow-x: hidden;        /* 隐藏水平滚动条 */
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击元素时的高亮效果 */
}

/* 视差背景效果 - 增强页面深度感 */
.parallax-bg {
    position: fixed;           /* 固定定位，不随页面滚动 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;               /* 置于底层，不遮挡内容 */
    background: linear-gradient(145deg, var(--sky-blue) 0%, var(--main-pink) 100%);
    transform: translateZ(-1px) scale(2); /* 3D变换，创建视差效果 */
    transition: transform 0.1s ease-out; /* 平滑过渡效果 */
}

/* 点击波纹效果 - 增强交互反馈 */
.ripple {
    position: relative;
    overflow: hidden;          /* 隐藏超出元素范围的波纹 */
}

/* 波纹效果的实现 */
.ripple:after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;      /* 不影响元素的点击事件 */
    background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;  /* 波纹从中心扩散 */
    transform: scale(10, 10);  /* 初始缩放状态 */
    opacity: 0;                /* 初始透明 */
    transition: transform .5s, opacity 1s; /* 波纹动画过渡 */
}

/* 点击时的波纹效果 */
.ripple:active:after {
    transform: scale(0, 0);    /* 缩放到消失 */
    opacity: .3;               /* 短暂显示不透明 */
    transition: 0s;            /* 立即执行结束状态 */
}

/* 状态动画定义 */
@keyframes successPulse {
    /* 成功状态动画 - 缩放并淡入 */
    0% { transform: scale(0.8); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes errorShake {
    /* 错误状态动画 - 左右摇晃 */
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* 应用成功动画的类 */
.success-animation {
    animation: successPulse 0.6s ease-out forwards;
}

/* 应用错误动画的类 */
.error-animation {
    animation: errorShake 0.5s ease-in-out forwards;
}

/* 右上角工具组件容器 */
.widgets-container {
    position: fixed;           /* 固定在右上角 */
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;                 /* 组件之间的间距 */
    z-index: 1000;             /* 确保在其他内容上方 */
}

/* 工具组件卡片样式 */
.widget-card {
    background: rgba(255, 255, 255, 0.95); /* 半透明白色背景 */
    backdrop-filter: var(--bg-blur);       /* 背景模糊效果 */
    padding: 8px 15px;
    border-radius: 20px;                   /* 圆角设计 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* 轻微阴影 */
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: transform 0.3s ease, box-shadow 0.3s ease; /* 悬停过渡效果 */
}

/* 工具卡片悬停效果 */
.widget-card:hover {
    transform: translateY(-3px); /* 上移效果 */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); /* 增强阴影 */
}

/* 主内容容器 */
.main-container {
    position: relative;
    max-width: 800px;          /* 限制最大宽度 */
    margin: 10px auto;         /* 居中显示 */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: var(--bg-blur);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3); /* 半透明边框 */
}

/* 输入框容器 */
.input-box {
    position: relative;        /* 用于内部元素的绝对定位 */
    margin: 20px 0;
    background: #fff;
    border-radius: 40px;       /* 大圆角设计 */
    box-shadow: 0 3px 12px rgba(255, 161, 201, 0.2); /* 粉色系阴影 */
    overflow: hidden;
}

/* URL输入框样式 */
#urlInput {
    width: 100%;
    padding: 14px 110px 14px 45px; /* 右侧预留按钮空间，左侧预留图标空间 */
    border: none;              /* 移除默认边框 */
    background: transparent;   /* 透明背景，继承容器背景 */
    font-size: 15px;
    color: #6A5ACD;            /* 紫色文本 */
    outline: none;             /* 移除聚焦时的默认轮廓 */
    box-sizing: border-box;    /* 确保padding不影响总宽度 */
}

/* 输入框占位符样式 */
#urlInput::placeholder {
    color: #C8A2C8;            /* 浅紫色占位符 */
    font-size: 14px;
}

/* 输入框底部高亮线 - 聚焦时显示 */
.input-highlight {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, var(--deep-purple), var(--main-pink));
    transform: scaleX(0);      /* 初始隐藏 */
    transition: transform 0.3s ease; /* 平滑显示动画 */
}

/* 输入框聚焦时显示高亮线 */
#urlInput:focus + .input-highlight {
    transform: scaleX(1);      /* 显示高亮线 */
}

/* 输入框内的图标 */
.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%); /* 垂直居中 */
    color: #C8A2C8;
    font-size: 18px;
}

/* 解析按钮样式 */
.parse-btn {
    position: absolute;
    right: 4px;
    top: 4px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--deep-purple), var(--main-pink));
    color: white;
    border: none;
    border-radius: 35px;       /* 圆角按钮 */
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;                  /* 图标与文字间距 */
    font-size: 14px;
    touch-action: manipulation; /* 优化触摸设备体验 */
    transition: all 0.2s ease; /* 过渡效果 */
}

/* 按钮悬停效果 */
.parse-btn:hover {
    opacity: 0.95;             /* 略微透明 */
    transform: translateY(-1px); /* 轻微上移 */
}

/* 媒体卡片容器 */
.media-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 媒体卡片悬停效果 */
.media-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* 视频容器 - 保持16:9比例 */
.video-container {
    position: relative;
    padding-top: 56.25%;       /* 16:9比例 (9/16 = 0.5625) */
    border-radius: 12px;
    overflow: hidden;
}

/* 视频元素样式 */
video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;         /* 保持比例并覆盖容器 */
}

/* 加载动画容器 */
.bouncing-loader {
    display: flex;
    justify-content: center;   /* 水平居中 */
    margin: 15px 0;
}

/* 加载动画的小球 */
.bouncing-loader div {
    width: 10px;
    height: 10px;
    margin: 3px;
    background: var(--deep-purple);
    border-radius: 50%;        /* 圆形 */
    animation: bouncing 0.6s infinite alternate; /* 弹跳动画 */
    animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.335);
}

/* 为每个小球设置不同的动画延迟，创建错落有致的效果 */
.bouncing-loader div:nth-child(2) {
    animation-delay: 0.2s;
}

.bouncing-loader div:nth-child(3) {
    animation-delay: 0.4s;
}

/* 弹跳动画定义 */
@keyframes bouncing {
    to {
        transform: translateY(-10px); /* 向上弹跳 */
    }
}

/* 调试信息样式 */
.debug-info {
    position: fixed;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7); /* 半透明黑色背景 */
    color: white;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 9999;             /* 确保在最上层 */
    max-width: 90%;            /* 限制最大宽度 */
}

/* 图片画廊项目样式 */
.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease; /* 缩放过渡 */
}

/* 画廊项目悬停效果 */
.gallery-item:hover {
    transform: scale(1.03);    /* 轻微放大 */
}

/* 图片索引标记 */
.image-index {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;        /* 圆形标记 */
    display: flex;
    align-items: center;
    justify-content: center;   /* 文字居中 */
}

/* 下载按钮基础样式 */
.download-all-btn, .download-btn {
    transition: all 0.2s ease; /* 过渡效果 */
}

/* 下载按钮悬停效果 */
.download-all-btn:hover, .download-btn:hover {
    transform: translateY(-2px); /* 上移效果 */
    box-shadow: 0 4px 12px rgba(255, 161, 201, 0.3); /* 增强阴影 */
}

/* 响应式设计 - 平板及以上设备 */
@media (min-width: 768px) {
    .main-container {
        padding: 30px;         /* 更大的内边距 */
        margin: 20px auto;
    }

    #urlInput {
        font-size: 16px;       /* 更大的字体 */
        padding: 16px 130px 16px 50px; /* 调整内边距 */
    }

    .parse-btn {
        padding: 12px 25px;    /* 更大的按钮 */
        font-size: 15px;
    }
}