/*
  软件名称：智能汉字笔画轨迹可视化辅助教学软件 V1.0
  文件名称：style.css
  描述：全局样式定义，包含CSS变量、响应式布局及组件样式
*/

:root {
    /* 全局配色方案 - 暖色调护眼设计 */
    --color-bg-body: #fff8f0;
    --color-bg-container: #fffaf5;
    --color-bg-board: #fff5e6;
    --color-text-main: #3a2610;
    --color-text-secondary: #7a5c3c;
    --color-accent: #8b4513;
    --color-border-main: #d4b483;
    --color-border-board: #c19a6b;
    --color-grid-line: rgba(139, 69, 19, 0.15);
    --color-active-bg: #f5e6d3;
    --color-grid-dot: rgba(139, 69, 19, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'SimSun', 'STSong', serif;
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    min-height: 100vh;
    touch-action: manipulation;
    /* 背景纹理 SVG (完整代码) */
    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%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d4b483' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    background-attachment: fixed;
}

/* 布局容器 */
.container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    gap: 15px;
    height: 100vh;
    padding: 15px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* 侧边栏样式 */
.sidebar {
    width: 240px;
    background-color: var(--color-bg-container);
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid var(--color-border-main);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar h2 {
    color: var(--color-accent);
    margin-bottom: 10px;
    font-size: 1.1rem;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border-main);
    text-align: center;
    font-weight: bold;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--color-bg-container);
    border-radius: 10px;
    border: 1px solid var(--color-border-main);
}

header {
    text-align: center;
    padding: 10px 0 5px 0;
    border-bottom: 2px solid var(--color-border-main);
    flex-shrink: 0;
}

h1 {
    color: var(--color-accent);
    font-size: 1.8rem;
    font-weight: bold;
    line-height: 1.2;
}

.title-translation {
    font-size: 0.9rem;
    color: var(--color-accent);
    font-style: italic;
    display: block;
    margin-top: 5px;
}

/* 说明区域样式 */
.instructions-section {
    width: 100%;
    max-width: 700px;
    margin: 0 auto 15px auto;
    background: rgba(245, 230, 211, 0.6);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--color-border-main);
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.board-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 15px 15px 15px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* 网格大框样式 */
.board {
    background-color: var(--color-bg-board);
    border: 10px solid var(--color-border-board);
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

/* 桌面端Grid布局 */
.desktop-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    margin: 0 auto;
    align-content: start;
}

.grid-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    background-color: var(--color-bg-container);
    border: 1px solid var(--color-border-main);
    border-radius: 4px;
}

.grid-container.grid-active {
    box-shadow: 0 0 0 3px var(--color-accent);
    border-color: var(--color-accent);
    z-index: 2;
}

/* 米字格背景层 */
.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.grid-background::before,
.grid-background::after,
.diagonal-1,
.diagonal-2 {
    content: '';
    position: absolute;
    background-color: var(--color-grid-line);
}

.grid-background::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: translateY(-50%);
}

.grid-background::after {
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
}

.diagonal-1 {
    width: 100%;
    height: 1px;
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(45deg);
}

.diagonal-2 {
    width: 100%;
    height: 1px;
    top: 50%;
    left: 0;
    transform: translateY(-50%) rotate(-45deg);
}

/* 装饰性圆点 */
.grid-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--color-grid-dot);
    border-radius: 50%;
}

.dot-tl { top: 10%; left: 10%; }
.dot-tr { top: 10%; right: 10%; }
.dot-bl { bottom: 10%; left: 10%; }
.dot-br { bottom: 10%; right: 10%; }

/* 绘图层 */
.grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: crosshair;
    touch-action: none !important;
}

.grid-number-label {
    position: absolute;
    bottom: 2px;
    right: 5px;
    font-size: 12px;
    color: var(--color-text-secondary);
    z-index: 5;
    pointer-events: none;
}

/* 信息面板与颜色指示器 */
.info-panel-item {
    background-color: var(--color-active-bg);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--color-border-main);
    text-align: center;
}

.info-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
    font-weight: bold;
}

.color-sequence {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.color-dot.current {
    transform: scale(1.3);
    border-color: var(--color-accent);
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.color-dot.next {
    border: 1px dashed var(--color-accent);
    opacity: 0.8;
}

.color-dot:not(.current):not(.next) {
    opacity: 0.3;
    transform: scale(0.9);
}

.color-display-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 5px;
}

.color-box-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.small-color-box {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 2px solid var(--color-border-main);
}

/* 按钮样式组件 */
.button {
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 8px;
    color: #fff5e6;
    transition: transform 0.1s;
    font-size: 0.9rem;
    line-height: 1.2;
}

.button span {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: normal;
    margin-top: 2px;
}

.button:active {
    transform: translateY(2px);
}

.button-primary { background-color: var(--color-accent); }
.button-utility { background-color: #a0522d; }
.button-secondary { background-color: #b22222; }
.button-clear-all { background-color: #cd853f; }
.button-success { background-color: #2e8b57; }

/* 导出模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: none;
    z-index: 500;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--color-bg-container);
    padding: 20px;
    border-radius: 10px;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid var(--color-border-main);
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-accent);
}

.add-grid-control {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    justify-content: center;
    align-items: center;
}

.add-grid-control input {
    width: 50px;
    text-align: center;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid var(--color-border-main);
    font-size: 1rem;
}

/* 移动端响应式布局 */
.mobile-layout {
    display: none;
}

/* 屏幕适配：小于1100px切换为移动模式 */
@media (max-width: 1100px) {
    .sidebar, .board {
        display: none !important;
    }
    
    .container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 10px;
        overflow-y: auto;
    }
    
    .mobile-layout {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    
    .mobile-add-grid-section {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 20px;
        margin-bottom: 15px;
        padding: 10px;
        background-color: var(--color-active-bg);
        border-radius: 8px;
        border: 1px solid var(--color-border-main);
        flex-wrap: nowrap;
    }
    
    .mobile-add-grid-section .add-grid-control { margin-bottom: 0; gap: 5px; }
    .mobile-add-grid-section .add-grid-control span { font-size: 0.9rem; white-space: nowrap; }
    .mobile-add-grid-section .total-info { font-size: 0.9rem; color: var(--color-text-secondary); white-space: nowrap; }
    
    .mobile-function-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin: 0 15px 15px 15px;
    }
    
    .mobile-color-section {
        margin: 0 15px 15px;
        background-color: var(--color-active-bg);
        border: 1px solid var(--color-border-main);
        border-radius: 8px;
        padding: 10px;
    }
    
    .mobile-board-area {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .mobile-current-grid {
        width: 280px;
        height: 280px;
        position: relative;
        border: 4px solid var(--color-border-board);
        background: var(--color-bg-board);
        margin: 0 auto 15px auto;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }
    
    .mobile-nav {
        display: flex;
        justify-content: space-between;
        width: 280px;
        margin: 0 auto 20px auto;
    }
    
    /* 移动端预览条 */
    .mobile-preview-bar {
        margin: 0 15px;
        background: var(--color-active-bg);
        border: 1px solid var(--color-border-main);
        border-radius: 8px;
        padding: 10px;
        overflow-x: auto;
        white-space: nowrap;
        display: flex;
        gap: 10px;
    }
    
    .mobile-preview-item {
        display: inline-block;
        width: 60px;
        height: 60px;
        border: 1px solid var(--color-border-main);
        background: var(--color-bg-board);
        flex-shrink: 0;
        position: relative;
        border-radius: 4px;
    }
    
    .mobile-preview-item.active {
        border-color: var(--color-accent);
        box-shadow: 0 0 0 2px var(--color-accent);
    }
    
    .mobile-preview-item canvas {
        width: 100%;
        height: 100%;
        position: absolute;
        z-index: 2;
        top: 0;
        left: 0;
    }
}

/* 导出区域样式 */
#exportResultArea {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    margin-top: 20px;
}

.export-page-wrapper {
    width: 100%;
    max-width: 500px;
}

.export-img-item {
    width: 100%;
    border: 1px solid var(--color-border-main);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}