/**
 * A1 单字网页专用样式
 * 三栏布局、HanziWriter 样式、移动端适配
 */

/* ===== 三栏表格样式 ===== */
.character-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    border: 1px solid #bbbddd;
    background: #fff;
}

.character-table thead {
    display: none; /* 移动端默认隐藏表头 */
}

.character-table th,
.character-table td {
    border: 1px solid #bbbddd;
    padding: 20px 15px;
    text-align: center;
    vertical-align: top;
}

.character-table th {
    background: #f5f5f5;
    font-weight: bold;
    color: #333;
}

/* 桌面端显示表头 */
@media (min-width: 769px) {
    .character-table thead {
        display: table-header-group;
    }
}

/* ===== 汉字展示区 (第一栏) ===== */
.char-display {
    width: 25%;
}

#char-viewer {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 220px;
}

/* HanziWriter 容器样式 */
.hanzi-viewer-container,
.hanzi-writer-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===== 汉字练习区 (第二栏) ===== */
.char-practice {
    width: 35%;
}

#char-writer {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 220px;
}

.writer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.writer-btn {
    padding: 10px 20px;
    background: #cc0000;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    min-width: 80px;
}

.writer-btn:hover {
    background: #aa0000;
}

.writer-btn:active {
    background: #880000;
}

.writer-btn:focus {
    outline: 2px solid #cc0000;
    outline-offset: 2px;
}

/* ===== 读音和解释区 (第三栏) ===== */
.char-info {
    width: 40%;
    text-align: left !important;
    font-size: 15px;
    line-height: 1.8;
}

/* 为直接格式的读音和按钮添加样式 */
.char-info span {
    font-weight: bold;
    color: #cc0000;
    margin-right: 8px;
}

.char-info .play-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    margin: 0 4px;
    padding: 0;
    background: #0055aa;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    vertical-align: middle;
    transition: background 0.2s;
}

.char-info .play-btn:hover {
    background: #003377;
}

.pronunciation-entry {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px dotted #eee;
}

.pronunciation-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pronunciation-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

/* 确保读音和按钮在同一行 */
.pronunciation-header .pinyin {
    flex-shrink: 0;
}

.pronunciation-header .play-btn {
    flex-shrink: 0;
}

.pronunciation-entry .pinyin {
    font-weight: bold;
    color: #cc0000;
    font-size: 1.1em;
}

.pronunciation-entry .play-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #0055aa;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s;
}

.pronunciation-entry .play-btn:hover {
    background: #003377;
}

.pronunciation-entry .play-btn:focus {
    outline: 2px solid #0055aa;
    outline-offset: 2px;
}

.pronunciation-entry .meaning {
    margin-top: 8px;
    color: #555;
    line-height: 1.8;
    padding-left: 4px;
}

/* ===== 面包屑导航 ===== */
.breadcrumb {
    margin: 10px 0 15px;
    font-size: 0.9rem;
    color: #666;
}

.breadcrumb a {
    color: #0055aa;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ===== 笔画说明区域 ===== */
.stroke-info {
    margin: 25px 0;
    padding: 18px;
    background: #f9f9f9;
    border-left: 4px solid #cc0000;
    border-radius: 4px;
}

.stroke-info h3 {
    margin-bottom: 10px;
    color: #cc0000;
}

.stroke-info p {
    color: #555;
    line-height: 1.6;
}

/* ===== More 文章链接区域 ===== */
#ad1 {
    margin: 30px 0;
}

#ad2 {
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

#ad2 b {
    display: block;
    margin-bottom: 15px;
    color: #333;
}

/* 所有 ul - 去掉红点 */
#ad2 ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* 去掉所有 li 的前置红点伪元素 */
#ad2 ul li::before {
    content: none;
}

/* 汉字链接 - 横向排列，无红点，无方框 */
#ad2 ul.character-links {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

#ad2 ul.character-links li {
    margin: 0;
    position: static; /* 覆盖主样式中的 absolute 定位 */
}

#ad2 ul.character-links li a {
    color: #0055aa;
    text-decoration: none;
    font-size: 18px; /* 汉字字体更大 */
}

#ad2 ul.character-links li a:hover {
    text-decoration: underline;
}

/* 其他文章链接 - 纵向列表 */
#ad2 ul:not(.character-links) li {
    margin-bottom: 10px;
    position: static; /* 覆盖主样式中的 absolute 定位 */
    padding-left: 0; /* 去掉左侧内边距 */
}

#ad2 ul:not(.character-links) li a {
    color: #0055aa;
    text-decoration: none;
}

#ad2 ul:not(.character-links) li a:hover {
    text-decoration: underline;
}

/* 其他文章链接 - 保持原有纵向样式 */
#ad2 > ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#ad2 > ul > li {
    margin-bottom: 10px;
}

#ad2 > ul > li a {
    color: #0055aa;
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .character-table thead {
        display: none;
    }

    .character-table tbody tr {
        display: flex;
        flex-direction: column;
    }

    .character-table td {
        width: 100% !important;
        display: block;
        border: none;
        border-bottom: 1px solid #bbbddd;
        padding: 20px 10px;
    }

    .character-table td:last-child {
        border-bottom: none;
    }

    #char-viewer,
    #char-writer {
        min-height: 180px;
    }

    .writer-controls {
        gap: 8px;
    }

    .writer-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 70px;
    }

    .pronunciation-header {
        flex-wrap: wrap;
    }

    #ad2 ul {
        gap: 6px;
    }

    #ad2 a {
        font-size: 14px;
        padding: 6px 12px;
        min-width: 45px;
    }
}

/* 小屏幕移动端进一步优化 */
@media (max-width: 480px) {
    .character-table td {
        padding: 15px 8px;
    }

    #char-viewer,
    #char-writer {
        min-height: 150px;
    }

    .writer-btn {
        flex: 1;
        min-width: 60px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .stroke-info {
        padding: 15px;
    }

    #ad2 {
        padding: 15px;
    }
}

/* ===== HanziWriter SVG 调整 ===== */
.hanzi-viewer-container svg,
.hanzi-writer-container svg {
    max-width: 100%;
    height: auto;
}

/* ===== 加载状态 ===== */
.loading-message {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* ===== 播放按钮动画 ===== */
.play-btn.playing {
    animation: pulse 1s infinite;
    background: #00aa55;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ===== 无障碍增强 ===== */
.writer-btn[aria-label],
.play-btn[aria-label] {
    position: relative;
}

/* 跳过链接（屏幕阅读器） */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== 打印样式 ===== */
@media print {
    .writer-controls,
    .play-btn {
        display: none;
    }

    .character-table {
        page-break-inside: avoid;
    }
}
