/* Lottie Gradient Editor - Styles */

* { box-sizing: border-box; }

/* ===== 响应式缩放 - 根据屏幕 CSS 宽度自动调整 ===== */

/* 基础设置（笔记本/小屏幕） */
html {
    font-size: 14px;
}

/* 大屏幕笔记本 / 外接显示器 */
@media (min-width: 1440px) {
    html { font-size: 15px; }
}

/* 1080p 显示器 */
@media (min-width: 1920px) {
    html { font-size: 16px; }
}

/* 4K 显示器（Windows 150% 缩放，CSS 宽度约 2560px） */
@media (min-width: 2400px) {
    html { font-size: 20px; }
}

/* 4K 显示器（100% 缩放，CSS 宽度约 3840px） */
@media (min-width: 3200px) {
    html { font-size: 26px; }
}

/* 5K+ 超高分显示器 */
@media (min-width: 4800px) {
    html { font-size: 32px; }
}

/* ===== 减少动画偏好 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== 页面入场动画 ===== */

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

@keyframes enterSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes enterScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.animate-enter-fade {
    opacity: 0;
    animation: enterFade 0.5s ease-out forwards;
}

.animate-enter-header {
    opacity: 0;
    animation: enterSlideDown 0.5s cubic-bezier(0.16, 0.74, 0.3, 1) forwards;
}

.animate-enter-card {
    opacity: 0;
    animation: enterSlideUp 0.6s cubic-bezier(0.16, 0.74, 0.3, 1) forwards;
}

.animate-enter-btn {
    opacity: 0;
    animation: enterSlideRight 0.35s cubic-bezier(0.16, 0.74, 0.3, 1) forwards;
}

.animate-enter-logo {
    opacity: 0;
    animation: enterScale 0.5s cubic-bezier(0.16, 0.74, 0.3, 1) forwards;
}

.enter-d1 { animation-delay: 0s; }
.enter-d2 { animation-delay: 0s; }
.enter-d3 { animation-delay: 0s; }
.enter-d4 { animation-delay: 0s; }
.enter-d5 { animation-delay: 0s; }

/* ===== 安全区域支持 ===== */
.app-wrapper {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ===== 桌面双列布局：锁定为单屏应用式布局 =====
   高度自上而下分配（视口 → main → 卡片 → 预览容器），
   页面不产生滚动，渐变列表/编辑器在面板内部滚动；
   1:1 预览容器由 max-height + aspect-ratio 自动缩放适配。
   窗口过矮时由 min-height 兜底，此时允许页面滚动。 */
@media (min-width: 1024px) {
    .app-wrapper {
        height: 100vh;
        min-height: 600px;
    }
}

header {
    padding-top: env(safe-area-inset-top);
}

/* ===== 弹窗滚动控制 ===== */
.modal-content {
    overscroll-behavior: contain;
}

/* ===== 文本截断工具类 ===== */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 颜色选择器焦点状态 ===== */
input[type=color]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* ===== 可随字体缩放的布局尺寸 ===== */

/* 内容区域最大宽度（替代固定 1600px）
   width: 100% 必不可少：main 是 flex 子项且左右 margin 为 auto，
   缺少显式宽度时会收缩到内容宽度导致整页变窄 */
.content-max-w {
    width: 100%;
    max-width: 110rem;
    margin-left: auto;
    margin-right: auto;
}

/* 卡片高度 - 按比例分配右侧列高度 */
.gradient-list-panel { flex: 2; min-height: 0; }
.editor-panel { flex: 3; min-height: 0; }

/* 滚动容器高度 - 填满父卡片剩余空间 */
.gradient-list-content { flex: 1; min-height: 0; }
.editor-content { flex: 1; min-height: 0; }

/* Lottie 动画容器 - 固定 1:1 宽高比，在 flex 容器中自适应
   窄屏（堆叠布局）：宽度驱动，宽度撑满、高度按比例 */
.lottie-1x1 {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
}

/* 桌面锁高布局：高度驱动，高度撑满、宽度按比例，
   保证正方形且始终完整落在一屏内 */
@media (min-width: 1024px) {
    .lottie-1x1 {
        width: auto;
        height: 100%;
    }
}

/* 防止 flex 容器被动画内容撑大 */
#drop-zone {
    min-width: 0;
    min-height: 0;
}

/* 强制 Lottie 渲染的 SVG 填满容器，不受动画原始尺寸影响 */
.lottie-1x1 svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 应用包装器 */
.app-wrapper {
    width: 100%;
    max-width: 100vw;
}

::-webkit-scrollbar { width: 8px; height: 8px; }

::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.alpha-checkered {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.gradient-preview-bar {
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
}

input[type=range] {
    -webkit-appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type=color] {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }

input[type=color]::-webkit-color-swatch { border: none; border-radius: 0; }

.glass {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
}

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

.animate-fade-in { animation: fadeIn 0.3s ease-out; }

.gradient-item { 
    transition: transform 0.2s ease, background 0.2s ease;
    cursor: pointer;
}

.gradient-item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px #3b82f6;
    border-radius: 0.5rem;
}

.gradient-item:hover { transform: translateX(4px); }

.gradient-item.selected {
    background: linear-gradient(90deg, rgba(59,130,246,0.1) 0%, rgba(59,130,246,0.05) 100%);
    border-left: 3px solid #3b82f6;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #3b82f6;
}

.btn-secondary {
    background: #f1f5f9;
    transition: background 0.2s;
}

.btn-secondary:hover { background: #e2e8f0; }

.btn-secondary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #94a3b8;
}

.card { transition: transform 0.3s, box-shadow 0.3s; }

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.1);
}

input[type=number] { -moz-appearance: textfield; }

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.drop-zone {
    transition: border-color 0.3s, background 0.3s;
    border: 2px dashed transparent;
}

.drop-zone.drag-over {
    border-color: #3b82f6;
    background: rgba(59,130,246,0.05);
}

/* 空状态下点击预览区可打开文件选择 */
.drop-zone.empty {
    cursor: pointer;
}

/* ===== Toast 提示 ===== */
#toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 16px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    max-width: min(90vw, 480px);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #fff;
    background: #334155;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success { background: #059669; }

.toast-error { background: #dc2626; }
