/* ========================================
   408 Knowledge Archives CSS
   拟物化办公桌风格样式表
   ======================================== */

/* Wood/Desk Grain Effect using pure CSS patterns */
.wood-texture {
    background-color: #f0f4f8;
    background-image:
        radial-gradient(at 0% 0%, rgba(255, 255, 255, 0.8) 0px, transparent 50%),
        repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.02) 0px, rgba(0, 0, 0, 0.02) 2px, transparent 2px, transparent 8px);
}

/* Glass Effect for Ruler */
.glass-ruler {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Paper Texture */
.paper-texture {
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
}

/* Tape Effect */
.tape {
    background-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    transform: rotate(-2deg);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Hide scrollbar for clean look */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tab Transitions */
.tab-transition {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #fdfbf7;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Action Buttons (Edit & Delete) */
.action-buttons {
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.25s ease;
}

.group:hover .action-buttons {
    opacity: 1;
    transform: translateY(0);
}

/* Fade Out Animation */
@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

/* Form Input Styles */
.form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Patrick Hand', cursive;
    font-size: 18px;
    transition: border-color 0.2s;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: #94a3b8;
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Patrick Hand', cursive;
    font-size: 18px;
    background: white;
    cursor: pointer;
}

.form-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Patrick Hand', cursive;
    font-size: 16px;
    resize: vertical;
    min-height: 80px;
    background: white;
}

.form-textarea:focus {
    outline: none;
    border-color: #94a3b8;
}

/* Lightbox Styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    animation: zoomIn 0.3s ease;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover {
    background: white;
    transform: scale(1.1);
}

.lightbox-title {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-family: 'Patrick Hand', cursive;
    font-size: 24px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   移动端响应式适配
   ======================================== */

/* 平板设备 (768px 及以下) */
@media (max-width: 768px) {

    /* 头部区域调整 */
    header.glass-ruler {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 0.75rem;
    }

    header .flex.items-center.gap-3 h1 {
        font-size: 1.5rem;
    }

    /* 搜索框和按钮容器 */
    header .flex.items-center.gap-6 {
        width: 100%;
        justify-content: space-between;
    }

    /* 搜索框全宽 */
    header .flex.items-center.gap-6 .relative.group {
        flex: 1;
    }

    header .flex.items-center.gap-6 .relative.group input {
        width: 100%;
    }

    /* 卡片网格 - 平板双列 */
    #cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        margin-left: 0;
    }

    /* 内容板减少内边距 */
    #content-board {
        padding: 2rem 1.5rem;
        min-height: 400px;
    }

    /* 标签页横向滚动 */
    #tabs-container {
        overflow-x: auto;
        padding-left: 1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #tabs-container::-webkit-scrollbar {
        display: none;
    }

    /* 模态框适配 */
    .modal-content {
        width: 95%;
        max-width: 500px;
    }
}

/* 手机设备 (640px 及以下) */
@media (max-width: 640px) {

    /* 主容器减少内边距 */
    body>div {
        padding: 1rem 0.5rem;
    }

    /* 头部进一步简化 */
    header.glass-ruler {
        padding: 0.75rem;
    }

    header .flex.items-center.gap-3 .w-10 {
        width: 2rem;
        height: 2rem;
    }

    header .flex.items-center.gap-3 h1 {
        font-size: 1.25rem;
    }

    /* 隐藏装饰性标尺刻度 */
    header .absolute.bottom-0 {
        display: none;
    }

    /* 搜索框调整 */
    header input {
        font-size: 16px !important;
        /* 防止iOS自动放大 */
    }

    /* 标签页优化 */
    #tabs-container button {
        font-size: 1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        min-width: 80px;
        white-space: nowrap;
    }

    /* 卡片网格 - 手机单列 */
    #cards-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-left: 0;
    }

    /* 卡片优化 */
    #cards-grid>div {
        margin: 0 auto;
        max-width: 400px;
        width: 100%;
    }

    /* 操作按钮在移动端始终显示（无hover状态） */
    .action-buttons {
        opacity: 1;
        transform: translateY(0);
    }

    /* 内容板 */
    #content-board {
        padding: 1.5rem 1rem;
        border-radius: 0.5rem;
    }

    /* 隐藏装饰性活页孔 */
    #content-board>.absolute.left-4 {
        display: none;
    }

    /* 模态框全屏化 */
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal-content form {
        padding: 1.25rem;
    }

    /* 表单输入优化 */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        /* 防止iOS自动放大 */
    }

    /* 按钮触摸优化 */
    button {
        min-height: 44px;
        /* iOS推荐最小触摸区域 */
        min-width: 44px;
    }

    /* Lightbox 移动端优化 */
    .lightbox-content {
        max-width: 100vw;
        max-height: 100vh;
        padding: 1rem;
    }

    .lightbox-image {
        max-width: 100%;
        max-height: 100vh;
        width: auto;
        height: auto;
        object-fit: contain;
        /* 提升图片清晰度 */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }

    /* Lightbox 关闭按钮优化 */
    .lightbox-close {
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        background: rgba(255, 255, 255, 0.95);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        z-index: 210;
    }

    /* Lightbox 标题位置调整 */
    .lightbox-title {
        position: fixed;
        bottom: 2rem;
        left: 1rem;
        right: 1rem;
        font-size: 1.25rem;
        padding: 0.75rem;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 0.5rem;
        backdrop-filter: blur(10px);
    }
}

/* 超小屏幕设备 (400px 及以下) */
@media (max-width: 400px) {
    header .flex.items-center.gap-3 h1 {
        font-size: 1.125rem;
    }

    #tabs-container button {
        font-size: 0.875rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        min-width: 70px;
    }

    .lightbox-title {
        font-size: 1rem;
        bottom: 1rem;
    }
}

/* 触摸设备通用优化 */
@media (hover: none) and (pointer: coarse) {

    /* 移除hover效果，改为active效果 */
    button:active {
        transform: scale(0.95);
    }

    /* 操作按钮在触摸设备上始终显示 */
    .action-buttons {
        opacity: 1;
        transform: translateY(0);
    }

    /* 禁用某些元素的长按选择 */
    button,
    .lightbox-image {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
}

/* 图片加载动画 */
@keyframes imageLoading {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: 200px 0;
    }
}

.image-loading {
    background: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
    background-size: 200px 100%;
    animation: imageLoading 1.5s infinite;
}