/* ============================================================
   textbook.css — laoshi.kr 교재(Textbook) 페이지 스타일
   ============================================================ */

/* ===== CSS Variables ===== */
:root {
    --pri: #2563eb;
    --pri-light: #eef2ff;
    --pri-dark: #1d4ed8;
    --accent: #1a2634;
    --accent-light: #2c3e50;
    --text: #1d1d1f;
    --sub: #6e6e73;
    --sub-light: #8e8e93;
    --border: #e5e5ea;
    --border-light: #f0f0f2;
    --bg: #f8f8fa;
    --card: #ffffff;
    --sidebar-w: 290px;
    --font-size: 16px;
    --lh: 1.85;
    --content-max-w: 860px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --transition: .2s ease;
}

/* ===== Base ===== */
.tb-main {
    margin-left: var(--sidebar-w);
    padding: 120px 50px 100px;
    font-family: 'Noto Sans KR', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--font-size);
    line-height: var(--lh);
    color: var(--text);
    min-height: 100vh;
    background: var(--card);
}

/* Font size variable — controlled by JS font adjuster */
.tb-content {
    --fs: 16px;
    font-size: var(--fs);
}
.tb-content p,
.tb-content li,
.tb-content div:not(.tb-note):not(.tb-paywall):not(.tb-table-wrap),
.tb-content span,
.tb-content td,
.tb-content th,
.tb-content blockquote {
    font-size: var(--fs);
}

/* ===== Book Title ===== */

/* ============================================================
   CONTENT — Headings (계층 구조)
   ============================================================ */

/* h1: Major sections (动词, 补语, 综合练习题) */
.tb-content h1 {
    font-size: calc(var(--fs) * 1.625);
    font-weight: 800;
    color: var(--accent);
    margin: 50px 0 20px;
    padding: 0 0 12px 16px;
    border-left: 5px solid var(--pri);
    border-bottom: 2px solid var(--accent);
    line-height: 1.4;
    position: relative;
    scroll-margin-top: 130px;
}

/* h2: Chapter / subtopics (동사의 기능적 특징, 시량보어 등) */
.tb-content h2 {
    font-size: calc(var(--fs) * 1.375);
    font-weight: 700;
    color: var(--accent-light);
    margin: 38px 0 16px;
    padding: 0 0 8px 14px;
    border-left: 4px solid #3498db;
    border-bottom: 1.5px solid var(--border);
    line-height: 1.4;
    scroll-margin-top: 130px;
}

/* h3: Sub-chapter (1.1 自动词, 2.1 瞬间性动词) */
.tb-content h3 {
    font-size: calc(var(--fs) * 1.25);
    font-weight: 700;
    color: #333;
    margin: 28px 0 12px;
    padding-left: 14px;
    position: relative;
    line-height: 1.4;
    scroll-margin-top: 130px;
}
.tb-content h3::before {
    content: '◆';
    color: var(--pri);
    font-size: 10px;
    position: absolute;
    left: 0;
    top: 5px;
}

/* Anchor spans for TOC jump targets (offset for fixed navbar) */
.tb-content .anchor {
    scroll-margin-top: 130px;
}
/* 예시 heading — larger font for example headers */
.tb-ex-heading {
    display: inline-block;
    font-size: 19px;
    line-height: 1.6;
}
.tb-ex-heading strong {
    font-weight: 700;
}

/* ============================================================
   CONTENT — Text Elements
   ============================================================ */
.tb-content p,
.tb-content li,
.tb-content div:not(.tb-note):not(.tb-paywall):not(.tb-table-wrap) {
    margin: 10px 0;
    word-break: keep-all;
    line-height: 1.85;
}
.tb-content strong {
    color: var(--pri);
    font-weight: 700;
}
.tb-content em {
    font-style: italic;
    color: var(--accent-light);
}
.tb-content code {
    background: #f0eeeb;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.95em;
    font-family: 'Noto Sans SC', 'Microsoft YaHei', 'SimSun', monospace;
    color: #333;
    border: 1px solid #e0ddd8;
}
.tb-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border), transparent);
    margin: 32px 0;
}
.tb-content ul,
.tb-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.tb-content li {
    margin: 4px 0;
}

/* ============================================================
   TABLES — Responsive with horizontal scroll
   ============================================================ */
.tb-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: var(--fs);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tb-content th {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: var(--fs);
    padding: 11px 16px;
    text-align: left;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.tb-content td {
    border-bottom: 1px solid var(--border);
    padding: 11px 16px;
    vertical-align: top;
    word-break: keep-all;
}
.tb-content tr:last-child td {
    border-bottom: none;
}
.tb-content tr:nth-child(even) td {
    background: #f8f8fa;
}
.tb-content tr:hover td {
    background: #f0f0f5;
    transition: background var(--transition);
}

/* Table wrapper for mobile scroll */
.tb-table-wrap {
    overflow-x: auto;
    margin: 16px -10px;
    padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: linear-gradient(135deg, #f7f9fc 0%, #fafbfe 100%);
    border-radius: var(--radius-md);
    border: 1px solid #eef0f4;
}

/* ============================================================
   CONTENT BLOCKS — Semantic styling
   ============================================================ */

/* Concept Box — Core definitions */
.tb-content .tb-concept {
    font-size: calc(var(--fs) * 1.25);
    font-weight: 700;
    color: var(--accent);
    margin: 36px 0 12px !important;
    padding: 14px 20px;
    background: linear-gradient(135deg, #eef4fb 0%, #f8faff 100%);
    border-left: 5px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    line-height: 1.6;
    word-break: keep-all;
    box-shadow: 0 1px 4px rgba(26,38,52,.06);
}

/* Sub-Concept Box */
.tb-content .tb-sub-concept {
    font-size: calc(var(--fs) * 1.0625);
    font-weight: 700;
    color: #2c3e50;
    margin: 26px 0 10px !important;
    padding: 8px 16px;
    background: #f2f6fc;
    border-left: 4px solid #3498db;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
    word-break: keep-all;
}

/* Note Box */
.tb-content .tb-note {
    background: linear-gradient(135deg, #fff8ee 0%, #fffcf5 100%);
    border: 1px solid #f0d9b5;
    border-left: 5px solid #f39c12;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 22px 0 !important;
    font-size: var(--fs);
    line-height: 2.4;
    color: #333;
    word-break: keep-all;
    box-shadow: 0 1px 4px rgba(243,156,18,.08);
}
.tb-content .tb-note p {
    margin: 16px 0;
}
.tb-content .tb-note strong {
    color: var(--pri);
}

/* Q&A Box */
.tb-content .tb-qa {
    background: linear-gradient(135deg, #eef4fb 0%, #f8faff 100%);
    border: 1px solid #c8d8e8;
    border-left: 5px solid #2980b9;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 22px 0 !important;
    font-size: var(--fs);
    line-height: 1.8;
    color: #333;
    word-break: keep-all;
    box-shadow: 0 1px 4px rgba(41,128,185,.08);
}

/* Question / Answer sub-blocks */
.tb-content .qa-q {
    font-weight: 700;
    color: #2c3e50;
    font-size: var(--fs);
    margin: 8px 0 6px !important;
    padding: 10px 16px;
    background: #eef2f7;
    border-radius: var(--radius-sm);
    border-left: 4px solid #3498db;
}
.tb-content .qa-a {
    font-weight: 600;
    color: #5c3d2e;
    font-size: var(--fs);
    margin: 8px 0 6px !important;
    padding: 10px 16px;
    background: #eafaf1;
    border-radius: var(--radius-sm);
    border-left: 4px solid #27ae60;
}

/* Definition Box */
.tb-content .tb-def-box {
    background: #f7f8fa;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin: 14px 0 !important;
    font-size: var(--fs);
    line-height: 1.8;
    color: #333;
    word-break: keep-all;
    box-shadow: var(--shadow-sm);
}

/* Example list */
.tb-content .tb-example-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}
.tb-content .tb-example-list li {
    padding: 6px 0 6px 22px;
    border-left: 3px solid var(--border);
    margin: 6px 0;
    word-break: keep-all;
    position: relative;
}
.tb-content .tb-example-list li::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 12px;
    width: 6px;
    height: 6px;
    background: var(--pri);
    border-radius: 50%;
}

/* ============================================================
   CHINESE EXAMPLE SENTENCES (核心设计)
   ============================================================ */

/* Chinese example text */
.tb-content .cn-example {
    font-size: calc(var(--fs) * 1.0625);
    font-weight: 500;
    color: #1a1a2e;
    font-family: 'Noto Sans SC', 'Microsoft YaHei', 'SimSun', sans-serif;
    letter-spacing: 0.5px;
    padding: 8px 16px 3px;
    margin: 6px 0 1px;
    background: linear-gradient(135deg, #faf8f5 0%, #fffdfa 100%);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-left: 4px solid var(--pri);
    line-height: 1.9;
    font-size-adjust: 0.5;
}

/* Korean translation under example */
.tb-content .kr-translation {
    font-size: var(--fs);
    color: #666;
    padding: 2px 16px 10px;
    margin: 0 0 10px;
    background: #faf8f5;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-left: 4px solid rgba(37,99,235,.25);
    border-bottom: 1px solid rgba(37,99,235,.1);
    line-height: 1.7;
}

/* Example heading label */
.tb-content .example-heading {
    font-size: var(--fs);
    font-weight: 700;
    color: var(--pri);
    margin: 24px 0 10px !important;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--pri-light), #fff);
    border-radius: var(--radius-md);
    display: inline-block;
    border: 1px solid rgba(37,99,235,.15);
    letter-spacing: 0.5px;
}

/* Analysis/explanation box */
.tb-content .analysis-box {
    background: #f7f8fa;
    border-left: 4px solid var(--accent);
    padding: 12px 18px;
    margin: 12px 0 !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: var(--fs);
    line-height: 1.8;
    color: #444;
}

/* Light horizontal rule */
.tb-content .tb-light-hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border), transparent);
    margin: 28px 0;
}

/* ============================================================
   IMAGES — Responsive
   ============================================================ */
.tb-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 20px auto;
    display: block;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   PAYWALL
   ============================================================ */
.tb-paywall {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    margin: 40px 0;
    box-shadow: 0 4px 24px rgba(0,0,0,.04);
}
.tb-paywall h2 {
    font-size: 22px;
    color: var(--accent);
    margin: 0 0 12px;
    border: none;
}
.tb-paywall p {
    font-size: 15px;
    color: var(--sub);
    margin: 6px 0;
}
.tb-paywall .btn-buy {
    display: inline-block;
    background: var(--pri);
    color: #fff;
    padding: 14px 44px;
    border-radius: 30px;
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
    margin-top: 20px;
    transition: background var(--transition), transform var(--transition);
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.tb-paywall .btn-buy:hover {
    background: var(--pri-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37,99,235,.35);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.tb-sidebar {
    position: fixed;
    top: 105px;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    background: var(--accent);
    overflow-y: auto;
    z-index: 999;
    padding: 0 0 40px;
    scrollbar-width: thin;
}
.tb-sidebar::-webkit-scrollbar {
    width: 5px;
}
.tb-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.2);
    border-radius: 3px;
}
.tb-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* Sidebar: Search */
.tb-sidebar-search {
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 8px;
}
.tb-sidebar-search input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: rgba(255,255,255,.1);
    color: #fff;
    box-sizing: border-box;
    transition: background var(--transition), border-color var(--transition);
}
.tb-sidebar-search input::placeholder {
    color: rgba(255,255,255,.45);
}
.tb-sidebar-search input:focus {
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.4);
}
.tb-sidebar-search .no-result {
    padding: 12px;
    text-align: center;
    color: rgba(255,255,255,.4);
    font-size: 12px;
    display: none;
}

/* Sidebar: Nav buttons (prev/next) */
.tb-sidebar-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
}
.tb-sidebar-nav span {
    color: rgba(255,255,255,.5);
    font-size: 12px;
    line-height: 24px;
}
.tb-sidebar-nav button {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 11px;
    color: rgba(255,255,255,.7);
    transition: background var(--transition);
}
.tb-sidebar-nav button:hover {
    background: rgba(255,255,255,.2);
}

/* Sidebar: TOC */
.tb-sidebar .toc-title {
    color: rgba(255,255,255,.45);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    padding: 0 22px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 10px;
}
.tb-sidebar a {
    display: block;
    padding: 6px 22px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    transition: background .15s, border-color .15s;
    border-left: 3px solid transparent;
    font-size: 14px;
    line-height: 1.4;
}
.tb-sidebar a:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}
.tb-sidebar a.active {
    color: #fff;
    border-left-color: var(--pri);
    background: rgba(255,255,255,.12);
}
.tb-sidebar .lvl1 {
    padding-left: 22px;
    font-weight: 700;
    font-size: 14.5px;
}
.tb-sidebar .lvl2 {
    padding-left: 38px;
    font-weight: 600;
    font-size: 14px;
}
.tb-sidebar .lvl3 {
    padding-left: 54px;
    font-weight: 400;
    font-size: 13.5px;
    color: rgba(255,255,255,.55);
}

/* ============================================================
   MOBILE UI
   ============================================================ */

/* Mobile search bar */
.tb-mobile-search {
    display: none;
    position: fixed;
    top: 75px;
    left: 0;
    right: 0;
    z-index: 10000;
    background: #fffef5;
    padding: 8px 15px;
    border-bottom: 1px solid #e0d8c0;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.tb-mobile-search input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0d8c0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    background: #fff;
    transition: border-color var(--transition);
}
.tb-mobile-search input:focus {
    border-color: var(--pri);
}
.tb-mobile-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    padding-bottom: 2px;
}
.tb-mobile-nav span {
    font-size: 13px;
    color: var(--sub);
    line-height: 26px;
}
.tb-mobile-nav button {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
}

/* Mobile TOC */
.tb-mob-toc {
    display: none;
    margin-top: 6px;
}
.tb-mob-toc details {
    margin-top: 4px;
}
.tb-mob-toc details[open] {
    max-height: 60vh;
    overflow-y: auto;
}
.tb-mob-toc summary {
    padding: 6px 12px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}
.tb-mob-toc a {
    display: block;
    padding: 5px 12px;
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    border-left: 2px solid transparent;
    line-height: 1.3;
    transition: background .15s;
}
.tb-mob-toc a:hover {
    background: var(--bg);
}
.tb-mob-toc .lvl1 {
    padding-left: 8px;
    font-weight: 700;
    font-size: 12.5px;
}
.tb-mob-toc .lvl2 {
    padding-left: 22px;
    font-weight: 600;
}
.tb-mob-toc .lvl3 {
    padding-left: 36px;
}

/* ============================================================
   SEARCH HIGHLIGHT
   ============================================================ */
.tb-highlight {
    background: #fcf8a9;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: 768–1200px */
@media (max-width: 1200px) {
    .tb-sidebar {
        width: 240px;
    }
    .tb-main {
        margin-left: 240px;
        padding: 115px 30px 80px;
    }
    .tb-book-title {
        font-size: 28px;
    }
}

/* Mobile: < 768px */
@media (max-width: 768px) {
    .tb-sidebar {
        display: none;
    }
    .tb-mobile-search {
        display: block;
    }
    .tb-mob-toc {
        display: block;
    }
    .tb-main {
        margin-left: 0;
        padding: 140px 16px 130px;
    }
    .tb-book-title {
        font-size: 24px;
    }
    .tb-content h1 {
        margin: 40px 0 16px;
        padding-left: 12px;
    }
    .tb-content h2 {
        margin: 30px 0 12px;
        padding-left: 10px;
    }
    .tb-content h3 {
        margin: 22px 0 10px;
    }
    .tb-content .cn-example {
        padding: 6px 12px 2px;
    }
    .tb-content .kr-translation {
        padding: 2px 12px 8px;
    }
    .tb-content .tb-concept {
        padding: 12px 16px;
    }
    .tb-content th,
    .tb-content td {
        padding: 8px 10px;
    }
    .tb-paywall {
        padding: 32px 20px;
    }
    .tb-paywall .btn-buy {
        padding: 12px 32px;
        font-size: 15px;
    }
    .tb-content img {
        margin: 16px -6px;
        border-radius: var(--radius-sm);
    }
}

/* Small mobile: < 400px */
@media (max-width: 400px) {
    .tb-main {
        padding: 130px 12px 130px;
    }
    .tb-content th,
    .tb-content td {
        padding: 6px 8px;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .tb-sidebar,
    .tb-mobile-search,

    .tb-paywall {
        display: none !important;
    }
    .tb-main {
        margin-left: 0;
        padding: 20px;
    }
    .tb-content img {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
