/* ============================================================
   初中英语语法重构 · 全局主样式 main.css
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --accent: #f1c40f;
    --accent-hover: #e6b800;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --bg-page: #f0f2f5;
    --bg-card: #ffffff;
    --border-color: #e8e8e8;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 6px 18px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 统一顶部导航 */
.top-bar, .lesson-topbar, .wb-topbar {
    background: var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.top-bar-inner, .topbar-inner, .wb-topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
}

.brand-icon {
    width: 38px; height: 38px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.brand-text h1, .brand-text .brand-name { font-size: 16px; font-weight: 900; color: #fff; line-height: 1.3; }
.brand-text p  { font-size: 12px; color: #95a5a6; margin-top: 1px; }

.topbar-back {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.topbar-back:hover { opacity: 0.8; }
.topbar-sep { color: #4a6278; font-size: 16px; flex-shrink: 0; }

.topbar-lesson-info { flex: 1; min-width: 0; }
.topbar-lesson-info .tl-tag {
    font-size: 11px;
    color: #95a5a6;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-lesson-info .tl-title {
    font-size: 15px;
    font-weight: 900;
    color: #ecf0f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-print {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 20px;
    padding: 6px 15px;
    font-size: 13px;
    font-weight: bold;
    color: rgba(255,255,255,0.95);
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}
.topbar-print:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }

/* 页面内容容器 */
.main, .lesson-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.book-container {
    background: var(--bg-card);
    padding: 44px 50px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0,0,0,0.06);
    border: 1px solid #e8e8e8;
}

p {
    font-size: 16px;
    line-height: 1.85;
    color: #2c3e50;
    margin: 12px 0;
}

img, svg { max-width: 100%; }
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

.site-legal-links {
    margin-top: 10px !important;
    font-size: 12px !important;
    color: #71808d !important;
}
.site-legal-links a { color: inherit; text-underline-offset: 3px; }

@media screen and (max-width: 768px) {
    .book-container table,
    .wb-main table,
    .lesson-main table,
    .all-lessons-wrapper table,
    .all-workbooks-wrapper table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media print {
    table { display: table !important; overflow: visible !important; }
    .site-legal-links { display: none !important; }
}

/* 章节封面 */
.chapter-cover {
    background: linear-gradient(135deg, #1a252f 0%, #2c3e50 55%, #2980b9 100%);
    border-radius: var(--radius-md);
    padding: 38px 36px 32px;
    margin-bottom: 35px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.chapter-cover::before {
    content: attr(data-num);
    position: absolute;
    right: 25px; top: 5px;
    font-size: 120px; font-weight: 900;
    color: rgba(255,255,255,0.05);
    line-height: 1; letter-spacing: -5px;
    pointer-events: none;
}
.lesson-tag {
    background: var(--accent); color: var(--primary);
    font-weight: 900; font-size: 13px;
    padding: 5px 15px; border-radius: 20px;
    display: inline-block; margin-bottom: 14px; letter-spacing: 0.05em;
}
.chapter-cover h1 { font-size: 28px; font-weight: 900; line-height: 1.35; margin-bottom: 10px; }
.chapter-cover h1 span { color: var(--accent); }
.chapter-cover .subtitle { font-size: 15.5px; color: rgba(255,255,255,0.85); line-height: 1.75; margin-top: 6px; }
.meta-row { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.meta-chip {
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.22);
    border-radius: 20px; padding: 5px 14px; font-size: 13px; color: rgba(255,255,255,0.92);
    display: flex; align-items: center; gap: 5px;
}

/* 学习目标 */
.goal-box {
    background: #fffde7; border: 2px solid #ffe082;
    border-radius: var(--radius-md); padding: 22px 26px;
    margin-bottom: 35px; display: flex; gap: 16px; align-items: flex-start;
}
.goal-icon { font-size: 28px; flex-shrink: 0; line-height: 1.2; }
.goal-box h3 { font-size: 16.5px; color: #e65100; margin-bottom: 8px; font-weight: 900; }
.goal-box p  { font-size: 15px; color: #5d4037; line-height: 1.8; margin: 0; }

/* 模块通用卡片 */
.module-card {
    margin: 36px 0;
    padding: 32px 30px 26px;
    border-radius: var(--radius-md);
    position: relative;
    line-height: 1.85;
    font-size: 16px;
    background: #fff;
    border: 2px solid var(--border-color);
}
.module-badge, .badge {
    display: inline-block;
    font-weight: 900;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 16.5px;
    margin-bottom: 18px;
    margin-top: -50px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.section-divider { display: flex; align-items: center; gap: 12px; margin: 38px 0 28px; }
.section-divider hr { flex: 1; border: none; border-top: 2px dashed #e0e0e0; }
.section-divider span { font-size: 13px; color: #aaa; white-space: nowrap; font-weight: bold; }

/* 极简通透 Callout 组件 (减少框套框视觉负担) */
.note-callout, .tip-callout, .warn-callout {
    background: #f8fafc;
    border-left: 4px solid var(--accent);
    padding: 13px 18px;
    border-radius: 0 10px 10px 0;
    margin: 18px 0;
    font-size: 14.5px;
    color: #334155;
    line-height: 1.75;
}
.tip-callout {
    background: #f0fdf4;
    border-left-color: #22c55e;
    color: #166534;
}
.warn-callout {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #991b1b;
}

/* 呼吸感清单与表格斑马纹 */
.memory-list {
    list-style: none;
    padding: 0;
    margin: 14px 0;
}
.memory-list li {
    padding: 9px 14px;
    margin-bottom: 7px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    font-size: 14.5px;
    line-height: 1.65;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.memory-list li::before {
    content: "•";
    color: var(--accent-hover);
    font-weight: 900;
    font-size: 16px;
}

/* 提示框 */
.warn-box {
    background: #fff5f5; border: 1.5px solid #ffcccc; border-left: 5px solid #e74c3c;
    border-radius: var(--radius-sm); padding: 18px 22px; margin: 18px 0;
}
.warn-box .warn-title { font-weight: 900; color: #c0392b; font-size: 15.5px; margin-bottom: 6px; }
.warn-box p { font-size: 15px; color: #444; line-height: 1.75; margin: 0; }

.tip-box {
    background: #f4fbf4; border: 1.5px solid #c3e6c3; border-left: 5px solid #27ae60;
    border-radius: var(--radius-sm); padding: 16px 20px; margin: 18px 0;
    font-size: 15px; color: #1e8449; line-height: 1.75;
}
.tip-box strong { color: #145a32; }

.brain-box {
    background: #fffdf5; border: 2px dashed #f39c12; border-radius: var(--radius-sm);
    padding: 18px 22px; margin: 18px 0;
}
.brain-box p { margin: 6px 0; font-size: 15px; line-height: 1.8; }

/* 底部导航 */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 32px 0 20px;
    flex-wrap: wrap;
}
.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 18px;
    text-decoration: none;
    color: var(--primary);
    font-size: 14px;
    transition: all 0.15s;
    flex: 1;
    min-width: 160px;
    max-width: 280px;
}
.nav-btn:hover {
    border-color: #2980b9;
    box-shadow: 0 4px 12px rgba(41,128,185,0.15);
    transform: translateY(-1px);
}
.nav-btn.prev { justify-content: flex-start; }
.nav-btn.next { justify-content: flex-end; margin-left: auto; }
.nav-btn .nb-arrow { font-size: 18px; color: #aaa; flex-shrink: 0; }
.nav-btn:hover .nb-arrow { color: #2980b9; }
.nav-btn .nb-text { min-width: 0; }
.nav-btn .nb-label { font-size: 11px; color: #aaa; display: block; }
.nav-btn .nb-title { font-size: 14px; font-weight: bold; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-btn-home {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    border-radius: 10px;
    padding: 12px 18px;
    text-decoration: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.nav-btn-home:hover { opacity: 0.85; }

/* 页脚 */
.footer, .lesson-footer {
    background: var(--primary);
    color: #95a5a6;
    text-align: center;
    padding: 24px 20px;
    font-size: 13px;
    line-height: 1.8;
}
.footer strong, .lesson-footer strong { color: var(--accent); }

/* ============================================================
   移动端响应式优化 (Mobile & Tablet Optimization)
   ============================================================ */
@media (max-width: 768px) {
    .main, .lesson-main { padding: 14px 10px 40px; }
    .book-container { padding: 22px 14px; border-radius: 12px; }
    
    .topbar-inner, .top-bar-inner, .wb-topbar-inner { padding: 10px 14px; }
    .topbar-print { display: none; }
    
    .chapter-cover { padding: 20px 16px 18px; margin-bottom: 22px; border-radius: 12px; }
    .chapter-cover h1 { font-size: 21px; line-height: 1.3; margin-bottom: 8px; }
    .chapter-cover h1 span { font-size: 15px; margin-top: 2px; }
    .chapter-cover .subtitle { font-size: 13.5px; line-height: 1.6; }
    .chapter-cover::before { font-size: 56px; right: 8px; top: -5px; }
    
    .goal-box { padding: 14px 16px; gap: 10px; margin-bottom: 24px; border-radius: 10px; }
    .goal-icon { font-size: 22px; }
    .goal-box h3 { font-size: 14.5px; }
    .goal-box p { font-size: 13.5px; line-height: 1.65; }
    
    .module-card { padding: 24px 14px 18px; margin: 26px 0; }
    .module-badge, .badge { font-size: 13.5px; padding: 5px 12px; margin-top: -38px; }
    
    p { font-size: 14.5px; line-height: 1.75; margin: 10px 0; }
}

@media (max-width: 640px) {
    .lesson-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .nav-btn {
        max-width: 100%;
        width: 100%;
        min-width: 0;
        padding: 10px 14px;
    }
    .nav-btn.next { margin-left: 0; }
    .nav-btn-home {
        justify-content: center;
        order: -1;
        width: 100%;
        padding: 10px 14px;
    }
    
    .meta-row { gap: 6px; margin-top: 14px; }
    .meta-chip { font-size: 11.5px; padding: 3px 9px; }
}

/* 浮动返回顶部与目录气泡 */
.floating-actions {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 99;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s ease;
}
.floating-actions.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.float-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--accent);
    border: 1.5px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, background 0.15s;
}
.float-btn:hover {
    transform: scale(1.08);
    background: var(--primary-dark);
}
@media (max-width: 768px) {
    .floating-actions { right: 14px; bottom: 18px; }
    .float-btn { width: 40px; height: 40px; font-size: 16px; }
}
