:root {
    --bg-color: #f4f1ea; /* 宣纸色 */
    --ink-color: #2c2c2c;
    --accent-red: #c93737; /* 印泥红 */
    --text-color: #333;
    --paper-texture: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"/></svg>');
}

body {
    font-family: "Noto Serif SC", "KaiTi", "楷体", serif;
    background-color: var(--bg-color);
    /* 使用用户提供的背景图 */
    background-image: url('assets/background.jpeg'), var(--paper-texture);
    background-size: cover, auto;
    background-attachment: fixed;
    background-position: center;
    background-blend-mode: multiply;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* 图片展示优化 */
.image-container {
    width: 100%;
    height: 220px; /* 固定高度，形成横幅效果 */
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid var(--ink-color);
    background: #fff;
    cursor: zoom-in;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img {
    transition: transform 0.5s;
}

/* 修正倒置的图片：旋转并填充 */
.sideways-img {
    transform: rotate(90deg);
    /* 旋转后宽高互换，为了填满容器，需要放大 */
    min-width: 150%; 
    min-height: 150%;
    object-fit: cover;
}

.image-container:hover .sideways-img {
    transform: rotate(90deg) scale(1.1);
}

/* Lightbox (大图查看器) */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    border: 5px solid white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    object-fit: contain;
    transition: transform 0.3s;
}

/* Lightbox 中也需要旋转 */
.lightbox-content.rotate-90 {
    transform: rotate(90deg);
    /* 旋转后可能超出屏幕，限制最大尺寸 */
    max-width: 60vh; 
    max-height: 80vw;
}

.lightbox-caption {
    color: white;
    margin-top: 15px;
    font-size: 1.2em;
    font-family: "KaiTi", serif;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.3s;
}

.lightbox-close:hover {
    color: var(--accent-red);
}
.hero-section {
    position: relative;
    height: 400px;
    /* 背景透明，让body背景透过来 */
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 5px solid var(--ink-color);
}

.hero-content {
    z-index: 2;
    padding: 40px;
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid var(--ink-color);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.main-title {
    font-family: "Ma Shan Zheng", "Zhi Mang Xing", cursive;
    font-size: 5em;
    margin: 0;
    color: var(--ink-color);
    text-shadow: 3px 3px 0px rgba(0,0,0,0.1);
}

.sub-title {
    font-size: 1.2em;
    margin-top: 10px;
    color: var(--accent-red);
    font-weight: bold;
    letter-spacing: 2px;
}

/* 主体容器 */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* 书法家板块 */
.calligrapher-section {
    position: relative;
    margin-bottom: 60px;
    padding: 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    overflow: hidden;
}

.paper-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--paper-texture);
    opacity: 0.5;
    pointer-events: none;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 40px;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.avatar-container {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid var(--ink-color);
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.intro-text {
    flex: 1;
}

.intro-text h2 {
    font-family: "Ma Shan Zheng", cursive;
    font-size: 2.5em;
    margin: 0 0 15px 0;
    color: var(--ink-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.honor-title {
    background-color: var(--accent-red);
    color: white;
    font-size: 0.4em;
    padding: 5px 10px;
    border-radius: 4px;
    vertical-align: middle;
    font-family: "Noto Serif SC", serif;
}

.bio {
    font-size: 1.1em;
    line-height: 1.8;
    color: #555;
    background: #f9f9f9;
    padding: 15px;
    border-left: 4px solid var(--accent-red);
    border-radius: 0 10px 10px 0;
}

.align-right {
    text-align: right;
}

.align-right .bio {
    border-left: none;
    border-right: 4px solid var(--accent-red);
    border-radius: 10px 0 0 10px;
}

.align-right h2 {
    justify-content: flex-end;
}

/* 内容网格 */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    position: relative;
    z-index: 1;
}

.card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: transform 0.3s ease;
}

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

.card h3 {
    margin-top: 0;
    border-bottom: 2px dashed #ccc;
    padding-bottom: 10px;
    color: var(--ink-color);
}

/* 视频占位符 */
.video-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    overflow: hidden;
}

.placeholder-content p {
    margin: 5px 0;
    font-size: 0.9em;
    color: #aaa;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 作品图片 */
.image-container {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 或者 contain，取决于图片比例 */
    transition: transform 0.5s;
}

.image-container:hover img {
    transform: scale(1.1);
}

.appreciation {
    background: #fff8e1;
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9em;
}

.appreciation h4 {
    margin: 0 0 5px 0;
    color: var(--accent-red);
}

/* 分割线 */
.divider {
    height: 2px;
    background: linear-gradient(to right, transparent, var(--ink-color), transparent);
    margin: 40px 0;
    opacity: 0.3;
}

/* 练字板块 */
.practice-section {
    text-align: center;
    background: rgba(255, 255, 255, 0.95); /* 增加不透明度 */
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    border: 1px solid #dcdcdc;
}

.section-title {
    font-family: "Ma Shan Zheng", cursive;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.instruction {
    color: #666;
    margin-bottom: 30px;
}

.practice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.style-selector {
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.style-btn {
    padding: 10px 25px;
    border: 2px solid var(--ink-color);
    background: transparent;
    font-size: 1.2em;
    font-family: "KaiTi", serif;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s;
}

.style-btn.active {
    background: var(--ink-color);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.tools-panel {
    display: flex;
    gap: 10px;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 50px;
    align-items: center;
}

.tool-btn {
    padding: 8px 20px;
    border: none;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-family: "KaiTi", serif;
    font-size: 1.1em;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tool-btn.active {
    background: var(--accent-red); /* 选中字帖用红色 */
    color: white;
}

.separator {
    width: 1px;
    height: 20px;
    background: #ccc;
    margin: 0 10px;
}

.action-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    color: white;
}

.action-btn.clear {
    background: #666;
}

.action-btn.save {
    background: var(--accent-red);
}

.canvas-wrapper {
    position: relative;
    width: 320px;
    height: 320px;
    border: 4px solid var(--accent-red); /* 米字格红框 */
    background: #fff;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    /* 真正的米字格样式 */
    background-image: 
        linear-gradient(var(--accent-red) 1px, transparent 1px), /* 横线 */
        linear-gradient(90deg, var(--accent-red) 1px, transparent 1px), /* 竖线 */
        linear-gradient(45deg, transparent 49.5%, var(--accent-red) 49.5%, var(--accent-red) 50.5%, transparent 50.5%), /* 斜线1 */
        linear-gradient(-45deg, transparent 49.5%, var(--accent-red) 49.5%, var(--accent-red) 50.5%, transparent 50.5%); /* 斜线2 */
    background-size: 100% 100%;
    background-position: center;
}

/* 优化米字格线条：虚线效果用伪元素模拟会更好，这里简化处理，用透明度区分 */
.canvas-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(var(--accent-red) 1px, transparent 1px),
        linear-gradient(90deg, var(--accent-red) 1px, transparent 1px);
    background-size: 50% 50%; /* 田字格 */
    opacity: 0.3;
    pointer-events: none;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7.127 22.562l-7.127 1.438 1.438-7.128 5.689 5.69zm1.414-1.414l11.228-11.225-5.69-5.692-11.227 11.227 5.689 5.69zm9.768-21.148l-2.816 2.817 5.691 5.691 2.816-2.819-5.691-5.689z" fill="black"/></svg>') 0 24, auto; /* 毛笔光标 */
}

.template-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 240px;
    color: rgba(0, 0, 0, 0.1); /* 极淡的灰色 */
    z-index: 1;
    pointer-events: none;
    user-select: none;
    /* 默认字体 */
    font-family: "KaiTi", serif;
}

/* 字体风格类 */
.font-wang {
    font-family: "Zhi Mang Xing", cursive !important; /* 行书风格 */
}

.font-yan {
    font-family: "Noto Serif SC", serif !important; /* 楷书风格，加粗 */
    font-weight: 900;
}

footer {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 0.9em;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        text-align: center;
    }
    
    .intro-text.align-right {
        text-align: center;
    }
    
    .align-right h2 {
        justify-content: center;
    }
    
    .bio, .align-right .bio {
        border: none;
        border-top: 4px solid var(--accent-red);
        border-radius: 0 0 10px 10px;
    }
}
