/* ============================================================
   七年级古诗词 - 主样式表
   中国古典美学 · 移动优先 · 响应式
   ============================================================ */

:root {
    --bg: #F7F3ED;
    --bg-card: #FFFDF9;
    --bg-warm: #FDF5EB;
    --primary: #8B4513;
    --primary-light: #C4956A;
    --accent: #B22222;
    --accent-light: #D4745C;
    --text: #3C2A1E;
    --text-secondary: #7A6B5D;
    --text-muted: #B0A498;
    --border: #E5DDD3;
    --divider: #D4C8BA;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(60,42,30,0.06);
    --shadow-md: 0 4px 16px rgba(60,42,30,0.08);

    --font: "PingFang SC", "Noto Serif SC", "STSong", "Hiragino Mincho Pro", "Songti SC", serif;
    --font-sans: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;

    --touch-min: 44px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

button { border: none; background: none; cursor: pointer; font-family: inherit; }
button:active { transform: scale(0.96); }

/* ------------------ 页面切换 ------------------ */
.page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    animation: fadeSlideIn var(--duration-normal) var(--ease-out);
}
.page.active { display: flex; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==================== 列表页 ==================== */

.btn-home {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.15s;
    text-decoration: none;
}

.btn-home:active { background: rgba(255,255,255,0.35); }

.header {
    position: relative;
    background: linear-gradient(165deg, #8B4513 0%, #A0522D 40%, #C4956A 100%);
    padding: 28px 20px 55px;
    color: #fff;
    text-align: center;
    overflow: hidden;
}

.header-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 70%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 25%, rgba(255,255,255,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.header-content { position: relative; z-index: 1; }

.header-icon {
    font-size: 44px;
    display: block;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.header-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: 13px;
    opacity: 0.78;
    font-weight: 400;
    letter-spacing: 1px;
}

.header-wave {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 45px;
    pointer-events: none;
}

/* --- 列表 --- */
.list-container {
    flex: 1;
    padding: 16px 14px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
}

/* --- 分组标题 --- */
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    padding: 8px 4px 4px;
    margin-top: 6px;
    letter-spacing: 1px;
    font-family: var(--font-sans);
    border-left: 3px solid var(--primary-light);
    padding-left: 10px;
}

.section-title:first-child { margin-top: 0; }

/* --- 卡片 --- */
.card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}

.card:active {
    transform: scale(0.985);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.card-index {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-warm);
    color: var(--primary);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font-sans);
}

.card-body { flex: 1; min-width: 0; }

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.card-author {
    font-size: 13px;
    color: var(--text-secondary);
}

.card-preview {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

.card-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.35;
}

.bottom-safe-area {
    height: env(safe-area-inset-bottom, 0px);
}

/* ==================== 详情页 ==================== */

.detail-nav {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    gap: 8px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: background var(--duration-fast);
    flex-shrink: 0;
}

.btn-icon:active { background: var(--bg-warm); }
.btn-home-link { text-decoration: none; }

.detail-nav-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 1px;
}

.detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* --- 诗词卡片 --- */
.poem-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    text-align: center;
}

.poem-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.poem-author {
    font-size: 14px;
    color: var(--text-secondary);
}

.poem-divider {
    width: 40px;
    height: 2px;
    background: var(--divider);
    margin: 20px auto;
    border-radius: 1px;
}

.poem-text {
    font-size: 18px;
    line-height: 2.2;
    letter-spacing: 1.5px;
    color: var(--text);
    text-align: center;
}

/* 移动端逗号处换行 */
.br-mo { font-style: normal; }
@media (max-width: 480px) {
    .br-mo::after { content: '\A'; white-space: pre; }
}

/* --- 注释卡片 --- */
.notes-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.notes-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.notes-text {
    font-size: 15px;
    line-height: 1.9;
    color: var(--text-secondary);
}

.notes-text p {
    margin-bottom: 6px;
}

.notes-text strong {
    color: var(--text);
}

/* --- 播放控制 --- */
.player-area {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.progress-row { width: 100%; }

.progress-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.tts-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s linear;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.btn-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--duration-fast);
}

.btn-ctrl:active { transform: scale(0.9); }

.btn-ctrl-sm {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg);
}

.btn-ctrl-play {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(178,34,34,0.3);
}

.btn-ctrl-play:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(178,34,34,0.2);
}

.tts-status {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--font-sans);
}

/* --- 上下首导航 --- */
.poem-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.btn-poem-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg-warm);
    border: 1px solid var(--border);
    font-family: var(--font-sans);
    transition: all var(--duration-fast);
}

.btn-poem-nav:active { background: var(--border); }
.btn-poem-nav:disabled { opacity: 0.35; pointer-events: none; }

.poem-index {
    font-size: 14px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    min-width: 50px;
    text-align: center;
}

/* ==================== 响应式 ==================== */
@media (min-width: 768px) {
    .header { padding: 40px 24px 65px; }
    .header-title { font-size: 30px; }
    .header-icon { font-size: 52px; }

    .card-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .section-title { grid-column: 1 / -1; }

    .poem-text { font-size: 20px; line-height: 2.4; }
    .poem-title { font-size: 24px; }
    .notes-text { font-size: 16px; }
}
