/* ========================================
   브레인 플레이존 — 자료실 전용 스타일
   ======================================== */

:root {
    --sudoku-color: #4CAF50;
    --sudoku-bg: #E8F5E9;
    --game2048-color: #FF9800;
    --game2048-bg: #FFF3E0;
    --health-color: #2196F3;
    --health-bg: #E3F2FD;
    --download-color: #9C27B0;
    --download-bg: #F3E5F5;
}

/* ── 브레드크럼 ── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    font-size: 0.875rem;
    color: #888;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

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

.breadcrumb span { color: #555; }

/* ── 자료실 레이아웃 (글 + 사이드바) ── */
.library-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2.5rem;
    align-items: start;
}

/* ── 글 본문 ── */
.article-content {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.article-header { margin-bottom: 2rem; }

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.category-badge.sudoku { background: var(--sudoku-bg); color: var(--sudoku-color); }
.category-badge.game2048 { background: var(--game2048-bg); color: var(--game2048-color); }
.category-badge.health { background: var(--health-bg); color: var(--health-color); }
.category-badge.download { background: var(--download-bg); color: var(--download-color); }

.read-time { font-size: 0.85rem; color: #888; }

.article-content h1 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--dark);
    line-height: 1.3;
    margin-bottom: 1rem;
}

.article-summary {
    font-size: 1.05rem;
    color: #555;
    line-height: 1.7;
    padding: 1rem 1.25rem;
    background: var(--light);
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
}

/* ── 목차 ── */
.table-of-contents {
    background: #FAFAFA;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
}

.table-of-contents h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.75rem;
}

.table-of-contents ol {
    padding-left: 1.5rem;
    margin: 0;
}

.table-of-contents li { margin-bottom: 0.4rem; }

.table-of-contents a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.table-of-contents a:hover { text-decoration: underline; }

/* ── 본문 타이포그래피 ── */
.article-content h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
    margin: 2.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light);
}

.article-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin: 1.75rem 0 0.75rem;
}

.article-content p {
    font-size: 1rem;
    line-height: 1.85;
    color: #333;
    margin-bottom: 1.2rem;
}

.article-content ul,
.article-content ol {
    padding-left: 1.5rem;
    margin-bottom: 1.2rem;
}

.article-content li {
    font-size: 1rem;
    line-height: 1.75;
    color: #333;
    margin-bottom: 0.4rem;
}

.article-content strong { color: var(--dark); font-weight: 700; }

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.article-content th {
    background: var(--dark);
    color: white;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
}

.article-content td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #E0E0E0;
    color: #333;
}

.article-content tr:hover td { background: var(--light); }

/* ── 하이라이트 박스 ── */
.highlight-box {
    background: #FFF8E1;
    border: 1px solid #FFD54F;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.highlight-box.info { background: #E3F2FD; border-color: #90CAF9; }
.highlight-box.success { background: #E8F5E9; border-color: #A5D6A7; }
.highlight-box.warning { background: #FFF3E0; border-color: #FFCC80; }

.highlight-box p { margin: 0; font-size: 0.95rem; }

/* ── 스도쿠 그리드 예시 ── */
.sudoku-example {
    display: inline-grid;
    grid-template-columns: repeat(9, 36px);
    border: 3px solid #333;
    margin: 1.5rem auto;
    display: grid;
}

.sudoku-example .cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid #CCC;
    color: #333;
}

.sudoku-example .cell.given { color: var(--dark); background: #F5F5F5; }
.sudoku-example .cell.highlight { background: #FFF9C4; color: var(--primary); font-weight: 700; }
.sudoku-example .cell.border-right { border-right: 2px solid #333; }
.sudoku-example .cell.border-bottom { border-bottom: 2px solid #333; }

/* ── 인터랙티브 퀴즈 ── */
.interactive-quiz {
    background: linear-gradient(135deg, #F3E5F5, #EDE7F6);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
}

.interactive-quiz h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #6A1B9A;
}

.interactive-quiz p { color: #333; margin-bottom: 1rem; }

.quiz-reveal-btn {
    background: #9C27B0;
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.quiz-reveal-btn:hover { background: #7B1FA2; }

.quiz-answer {
    margin-top: 1rem;
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.quiz-answer p { margin: 0; color: #333; }

/* ── 관련 글 ── */
.related-articles {
    margin: 3rem 0 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--light);
}

.related-articles h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--dark);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.related-card {
    display: block;
    background: var(--light);
    border-radius: 10px;
    padding: 1.25rem;
    text-decoration: none;
    color: var(--dark);
    border: 1px solid #E0E0E0;
    transition: all 0.2s;
}

.related-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.related-category {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
}

.related-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.related-card p {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* ── 다음 단계 CTA ── */
.next-step-cta { margin: 2rem 0; }

.cta-box {
    background: var(--gradient-2);
    color: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
}

.cta-box h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }
.cta-box p { font-size: 0.95rem; opacity: 0.9; margin-bottom: 1.25rem; }

.cta-box .btn-primary {
    display: inline-block;
    background: white;
    color: var(--primary);
    padding: 0.65rem 1.5rem;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    margin: 0.25rem;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.cta-box .btn-secondary {
    display: inline-block;
    background: transparent;
    color: white;
    border: 2px solid rgba(255,255,255,0.7);
    padding: 0.65rem 1.5rem;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    margin: 0.25rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.cta-box .btn-secondary:hover { background: rgba(255,255,255,0.15); }

/* ── 사이드바 ── */
.sidebar { position: sticky; top: 100px; }

.sidebar-widget {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-widget h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light);
}

/* 카테고리 목록 */
.category-list { list-style: none; }

.category-list li { margin-bottom: 0.5rem; }

.category-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #444;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.category-list a:hover { background: var(--light); color: var(--primary); }

.category-list span {
    background: var(--light);
    color: #888;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}

/* 인기 글 목록 */
.popular-list { list-style: none; counter-reset: popular-counter; }

.popular-list li {
    counter-increment: popular-counter;
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--light);
}

.popular-list li:last-child { border-bottom: none; margin-bottom: 0; }

.popular-list a {
    color: #444;
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.4;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    transition: color 0.2s;
}

.popular-list a::before {
    content: counter(popular-counter);
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.popular-list a:hover { color: var(--primary); }

/* 사이드바 CTA */
.sidebar-cta .btn-play {
    display: block;
    text-align: center;
    background: var(--primary);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
}

.sidebar-cta .btn-play:hover { background: var(--primary-dark); }
.sidebar-cta .btn-2048 { background: #FF9800; }
.sidebar-cta .btn-2048:hover { background: #E65100; }

/* 사이드바 다운로드 */
.sidebar-download a {
    display: block;
    color: var(--download-color);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--light);
    transition: color 0.2s;
}

.sidebar-download a:hover { color: #6A1B9A; }
.sidebar-download a:last-child { border-bottom: none; }

/* ── 자료실 인덱스 카드 ── */
.library-index-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

.article-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.article-card {
    display: block;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--dark);
    box-shadow: var(--shadow-sm);
    border: 1px solid #E8E8E8;
    transition: all 0.25s;
}

.article-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.article-card .card-category {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.article-card h3 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.article-card p {
    font-size: 0.875rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.article-card .card-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #999;
}

/* ── 반응형 ── */
@media (max-width: 900px) {
    .library-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .sidebar-widget { margin-bottom: 0; }
}

@media (max-width: 600px) {
    .article-content {
        padding: 1.5rem 1.25rem;
    }

    .article-content h1 { font-size: 1.5rem; }
    .article-content h2 { font-size: 1.2rem; }

    .related-grid { grid-template-columns: 1fr; }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .library-layout { padding: 1rem 1rem 3rem; }
    .breadcrumb { padding: 0.5rem 1rem; }
}
