/* ============================================================
   全局样式 - 移动端优先 (Mobile First)
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   顶部导航栏
   ============================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header h1 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* 返回按钮 - 详情页使用 */
.header .back-btn {
    position: absolute;
    left: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.2s;
}

.header .back-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   画作列表卡片
   ============================================================ */
.painting-list {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* 平板以上屏幕 - 3列 */
@media (min-width: 768px) {
    .painting-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 桌面大屏 - 4列 */
@media (min-width: 1024px) {
    .painting-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

.painting-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s, box-shadow 0.2s;
}

.painting-card:active {
    transform: scale(0.97);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
}

/* 图片容器 - 保持4:3比例 */
.painting-card .image-wrap {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 = 3/4 */
    background: #e8e8e8;
    overflow: hidden;
}

.painting-card .image-wrap img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 图片加载中占位 */
.painting-card .image-wrap::after {
    content: "加载中...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 12px;
}

.painting-card .image-wrap img.loaded {
    opacity: 1;
}

.painting-card .image-wrap img.loaded + span,
.painting-card .image-wrap img.loaded::after {
    display: none;
}

/* 卡片文字信息 */
.painting-card .info {
    padding: 10px 12px 12px;
}

.painting-card .name {
    font-size: 15px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.painting-card .author {
    font-size: 12px;
    color: #888;
}

.painting-card .award-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    color: #fff;
    font-size: 11px;
    border-radius: 10px;
}

/* ============================================================
   详情页样式
   ============================================================ */
.detail-container {
    padding-bottom: 80px; /* 为底部下载按钮留空间 */
}

/* 主图区域 */
.detail-main-image {
    width: 100%;
    background: #000;
    position: relative;
}

.detail-main-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* 信息面板 */
.detail-info {
    background: #fff;
    margin: -20px 12px 0;
    border-radius: 16px;
    padding: 20px;
    position: relative;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.detail-info .painting-name {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.detail-info .painting-author {
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
}

.detail-info .painting-year {
    font-size: 12px;
    color: #999;
    margin-bottom: 16px;
}

/* 获奖信息区域 */
.awards-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #eee;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.section-title::before {
    content: "";
    width: 3px;
    height: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 2px;
    margin-right: 8px;
}

.award-item {
    display: flex;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.award-item:last-child {
    border-bottom: none;
}

.award-item .award-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #f6d365, #fda085);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    margin-right: 10px;
}

.award-item .award-content {
    flex: 1;
}

.award-item .award-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.award-item .award-meta {
    font-size: 12px;
    color: #999;
}

.no-awards {
    font-size: 13px;
    color: #aaa;
    padding: 8px 0;
    text-align: center;
}

/* 作品描述 */
.description-section {
    margin-top: 16px;
}

.description-text {
    font-size: 14px;
    color: #666;
    line-height: 1.8;
    text-align: justify;
}

/* ============================================================
   底部下载按钮栏 - 固定定位
   ============================================================ */
.download-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* iPhone 安全区 */
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.btn-download {
    display: block;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn-download:active {
    opacity: 0.85;
}

/* ============================================================
   加载/空状态
   ============================================================ */
.loading, .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #eee;
    border-top-color: #667eea;
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   图片放大预览弹窗
   ============================================================ */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.image-preview.active {
    display: flex;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview .close-hint {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

.image-preview .download-hint {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 13px;
    border-radius: 20px;
}
