@charset "utf-8";

/* ==========================================================================
   1. CSS Variables & Theme (Fox Bookstore Identity)
   ========================================================================== */
:root {
    /* Brand Colors (로고 기반) */
    --fox-red: #c8102e;     /* 상단 FOX 텍스트 색상 */
    --fox-maroon: #7a0016;  /* 하단 책 모양 색상 */
    --fox-gradient: linear-gradient(135deg, var(--fox-red) 0%, var(--fox-maroon) 100%);
    
    /* Light Theme (Default) */
    --bg-color: #ffffff;
    --bg-alt: #f8f9fa;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --link-color: var(--fox-red);
    --link-hover: var(--fox-maroon);
    --header-bg: rgba(255, 255, 255, 0.95);
    --card-bg: #ffffff;
    --card-shadow: 0 4px 12px rgba(0,0,0,0.05);
    --code-bg: #f1f3f5;
    
    /* Layout */
    --max-width: 1200px;
    --sidebar-width: 320px;
    --gap-lg: 40px;
    --gap-md: 24px;
    --gap-sm: 16px;
    --radius: 12px;
}

/* Dark Theme overrides */
body.dark {
    --bg-color: #121212;
    --bg-alt: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #9e9e9e;
    --border-color: #333333;
    --link-color: #ff4d6d;
    --link-hover: #ff8fa3;
    --header-bg: rgba(18, 18, 18, 0.95);
    --card-bg: #1e1e1e;
    --card-shadow: 0 4px 12px rgba(0,0,0,0.3);
    --code-bg: #2d2d2d;
}

/* ==========================================================================
   2. Reset & Base Setup
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, blockquote, figure, fieldset, legend, textarea, pre, iframe, hr, hgroup { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }
img, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; border: none; background: none; }
button { cursor: pointer; }
.blind { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 16px;
    word-break: keep-all;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--fox-red); }

/* Accessibility Skip Nav */
.skip-nav { position: absolute; top: -50px; left: 0; width: 100%; background: var(--fox-red); color: #fff; text-align: center; padding: 10px; z-index: 9999; transition: top 0.2s; }
.skip-nav:focus { top: 0; }

/* ==========================================================================
   3. Layout Structure
   ========================================================================== */
#wrap { display: flex; flex-direction: column; min-height: 100vh; }
#container { flex: 1; max-width: var(--max-width); margin: 0 auto; padding: 120px 20px 60px; display: flex; gap: var(--gap-lg); width: 100%; }
#main-content { flex: 1; min-width: 0; } /* min-width:0 prevents flex item from overflowing */
#sidebar { width: var(--sidebar-width); flex-shrink: 0; }

@media (max-width: 992px) {
    #container { flex-direction: column; padding-top: 100px; }
    #sidebar { width: 100%; }
}

/* ==========================================================================
   4. Header & Navigation (Tistory Category Fix Applied)
   ========================================================================== */
#header { position: fixed; top: 0; left: 0; width: 100%; background: var(--header-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1000; border-bottom: 1px solid transparent; transition: all 0.3s ease; }
#header.scrolled { border-bottom-color: var(--border-color); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
#header .inner { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; height: 80px; display: flex; align-items: center; justify-content: space-between; }

/* Logo */
.logo a { display: flex; align-items: center; gap: 10px; }
.logo img { max-height: 50px; }
.logo-text { font-size: 1.2rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; background: var(--fox-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Global Navigation (GNB) - Tistory Native Category Structure Control */
#gnb .tt_category { margin: 0; padding: 0; list-style: none; display: flex; align-items: center; }
#gnb .tt_category > li > a.link_tit { display: none; } /* GNB에서 '분류 전체보기' 텍스트 숨김 */
#gnb .tt_category .category_list { display: flex; gap: 24px; margin: 0; padding: 0; list-style: none; }
#gnb .tt_category .category_list > li > a { font-weight: 600; font-size: 1.05rem; padding: 5px 0; color: var(--text-main); position: relative; transition: color 0.2s; display: inline-block; }
#gnb .tt_category .category_list > li > a:hover { color: var(--fox-red); }
#gnb .tt_category .category_list > li > a::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background: var(--fox-red); transition: width 0.3s ease; }
#gnb .tt_category .category_list > li > a:hover::after { width: 100%; }
#gnb .tt_category .category_list > li > ul { display: none; } /* 2차 하위 메뉴는 헤더의 심플함을 위해 숨김 처리 */

/* Search & Utils */
.header-util { display: flex; align-items: center; gap: 15px; order: 3; }
.header-util button { font-size: 1.5rem; color: var(--text-main); display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; transition: background 0.2s; }
.header-util button:hover { background: var(--bg-alt); color: var(--fox-red); }
#menu-toggle { display: none; }

.search-box { position: relative; order: 2; margin-left: auto; margin-right: 20px; }
.search-box input { background: var(--bg-alt); border: 1px solid var(--border-color); color: var(--text-main); padding: 10px 40px 10px 16px; border-radius: 20px; width: 200px; transition: all 0.3s; font-size: 0.9rem; }
.search-box input:focus { outline: none; border-color: var(--fox-red); width: 240px; background: var(--bg-color); }
.search-box button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--text-muted); }

@media (max-width: 768px) {
    #header .inner { height: 60px; }
    #menu-toggle { display: flex; }
    #gnb { display: none; position: absolute; top: 60px; left: 0; width: 100%; background: var(--bg-color); padding: 20px; border-bottom: 1px solid var(--border-color); box-shadow: 0 10px 10px rgba(0,0,0,0.05); z-index: 999; }
    #header.menu-open #gnb { display: block; }
    #gnb .tt_category { flex-direction: column; align-items: flex-start; }
    #gnb .tt_category .category_list { flex-direction: column; gap: 15px; width: 100%; }
    #gnb .tt_category .category_list > li > a { display: block; width: 100%; }
    .search-box { display: none; }
}

/* ==========================================================================
   5. Main Content - List/Grid View
   ========================================================================== */
.list-header { margin-bottom: 30px; padding-bottom: 15px; border-bottom: 2px solid var(--text-main); }
.list-header h2 { font-size: 1.5rem; font-weight: 700; }
.list-header span { color: var(--fox-red); font-weight: 800; font-size: 1.2rem; margin-left: 10px; }

.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap-md); }

.post-card { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-shadow); transition: transform 0.3s ease, box-shadow 0.3s ease; border: 1px solid var(--border-color); }
.post-card:hover { transform: translateY(-5px); box-shadow: 0 12px 24px rgba(0,0,0,0.1); border-color: var(--fox-red); }
.post-card a { display: flex; flex-direction: column; height: 100%; }

.post-card .thumbnail { width: 100%; padding-top: 60%; position: relative; background: var(--bg-alt); overflow: hidden; }
.post-card .thumbnail img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.post-card:hover .thumbnail img { transform: scale(1.05); }

.post-card .content { padding: 24px; display: flex; flex-direction: column; flex: 1; }
.post-card .category { display: inline-block; font-size: 0.8rem; font-weight: 700; color: var(--fox-red); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.post-card h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .summary { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.post-card .meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-muted); margin-top: auto; padding-top: 15px; border-top: 1px solid var(--border-color); }

/* Notice & Protected Cards */
.notice-card { background: var(--bg-alt); border-left: 4px solid var(--text-main); }
.notice-badge { background: var(--text-main); color: var(--bg-color); padding: 2px 8px; border-radius: 4px; }
.protected-card .content { justify-content: center; align-items: center; text-align: center; padding: 50px 24px; }
.protected-card h3 i { font-size: 2rem; display: block; margin-bottom: 10px; color: var(--fox-maroon); }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 50px; font-weight: 600; }
.pagination a { display: inline-flex; justify-content: center; align-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text-muted); transition: all 0.2s; }
.pagination a:hover, .pagination a.selected { background: var(--fox-red); color: #fff; }
.pagination .btn-prev, .pagination .btn-next { width: auto; padding: 0 15px; border-radius: 20px; border: 1px solid var(--border-color); }
.pagination .btn-prev:hover, .pagination .btn-next:hover { background: var(--bg-alt); color: var(--fox-red); border-color: var(--fox-red); }
.pagination .no-more-prev, .pagination .no-more-next { opacity: 0.3; pointer-events: none; }

/* ==========================================================================
   6. Article Detail (View)
   ========================================================================== */
.post-detail { background: var(--bg-color); position: relative; }
.post-header { margin-bottom: 40px; text-align: center; padding-bottom: 30px; border-bottom: 1px solid var(--border-color); }
.post-header .category { display: inline-block; font-weight: 700; color: var(--fox-red); margin-bottom: 15px; font-size: 1rem; }
.post-header .title { font-size: 2.5rem; font-weight: 800; line-height: 1.3; margin-bottom: 20px; letter-spacing: -0.02em; }
.post-header .meta { color: var(--text-muted); font-size: 0.95rem; display: flex; justify-content: center; gap: 15px; align-items: center; }
.post-header .meta span::after { content: '·'; margin-left: 15px; }
.post-header .meta span:last-child::after { content: none; }

/* Article Content Formatting (Tistory Specifics & Typography) */
.article-content { font-size: 1.125rem; line-height: 1.8; color: var(--text-main); }
/* ★ 핵심 수정: 티스토리 에디터의 이미지 float 속성으로 인한 레이아웃 붕괴 방지(Clearfix) */
.article-content::after { content: ""; display: table; clear: both; }

.article-content p { margin-bottom: 1.5em; }
.article-content h1, .article-content h2, .article-content h3, .article-content h4 { font-weight: 700; margin: 2em 0 1em; color: var(--text-main); line-height: 1.4; clear: both; }
.article-content h2 { font-size: 1.8rem; padding-bottom: 10px; border-bottom: 2px solid var(--bg-alt); }
.article-content h3 { font-size: 1.5rem; }
.article-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5em auto; display: block; }
.article-content a { color: var(--link-color); text-decoration: underline; text-underline-offset: 4px; font-weight: 500; }
.article-content a:hover { color: var(--link-hover); }
.article-content blockquote { border-left: 5px solid var(--fox-maroon); padding: 15px 20px; background: var(--bg-alt); margin: 2em 0; border-radius: 0 8px 8px 0; font-style: italic; color: var(--text-muted); clear: both; }
.article-content ul, .article-content ol { margin-bottom: 1.5em; padding-left: 20px; }
.article-content ul { list-style: disc; }
.article-content ol { list-style: decimal; }
.article-content li { margin-bottom: 0.5em; }
.article-content pre { background: var(--code-bg); padding: 20px; border-radius: 8px; overflow-x: auto; margin: 2em 0; font-family: 'Consolas', monospace; font-size: 0.95rem; }
.article-content code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-family: 'Consolas', monospace; color: var(--fox-red); font-size: 0.9em; }
.article-content table { width: 100%; margin: 2em 0; border-collapse: collapse; clear: both; }
.article-content th, .article-content td { padding: 12px 15px; border: 1px solid var(--border-color); text-align: left; }
.article-content th { background: var(--bg-alt); font-weight: 700; }

/* Tistory Native Image Gallery/Grid Fixes */
.tt_article_useless_p_margin p { margin-bottom: 0; }
figure.imageblock { margin: 1.5em 0; text-align: center; clear: both; }
figcaption { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; text-align: center; }

/* Tags */
.post-tags { margin-top: 50px; padding-top: 20px; border-top: 1px dashed var(--border-color); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; clear: both; }
.post-tags i { color: var(--fox-red); font-size: 1.2rem; }
.post-tags a { background: var(--bg-alt); color: var(--text-muted); padding: 6px 12px; border-radius: 20px; font-size: 0.9rem; transition: all 0.2s; }
.post-tags a:hover { background: var(--fox-red); color: #fff; }

/* Protected Post Input */
.protected-post { text-align: center; padding: 60px 20px; background: var(--bg-alt); border-radius: var(--radius); margin: 40px 0; border: 1px solid var(--border-color); }
.protected-post i { font-size: 3rem; color: var(--fox-maroon); margin-bottom: 20px; display: block; }
.protected-post h2 { font-size: 1.5rem; margin-bottom: 10px; }
.protected-post p { color: var(--text-muted); margin-bottom: 20px; }
.protected-post .input-wrap { display: flex; justify-content: center; gap: 10px; }
.protected-post input { padding: 12px 20px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-color); color: var(--text-main); font-size: 1rem; width: 250px; }
.protected-post input:focus { border-color: var(--fox-red); outline: none; }
.protected-post .btn { padding: 12px 24px; background: var(--fox-red); color: #fff; border-radius: 8px; font-weight: 700; transition: background 0.2s; }
.protected-post .btn:hover { background: var(--fox-maroon); }

/* ==========================================================================
   7. Comments (Layout Overlap Fix Applied)
   ========================================================================== */
/* ★ 핵심 수정: 댓글 영역이 무조건 본문 아래쪽에 배치되도록 강제 속성 추가 */
.comment-section { margin-top: 60px; padding-top: 30px; border-top: 2px solid var(--text-main); clear: both; display: block; width: 100%; position: relative; z-index: 10; }
.comment-list h3 { font-size: 1.3rem; margin-bottom: 20px; font-weight: 700; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.comment-list h3 span { color: var(--fox-red); }

.comment-item { padding: 20px 0; border-bottom: 1px solid var(--border-color); }
.comment-item .author-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.comment-item .avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.comment-item .name { font-weight: 700; font-size: 1.05rem; }
.comment-item .date { color: var(--text-muted); font-size: 0.85rem; }
.comment-item .comment-desc { font-size: 1rem; line-height: 1.6; margin-bottom: 15px; word-break: break-all; }
.comment-item .comment-control a { font-size: 0.85rem; color: var(--text-muted); margin-right: 15px; display: inline-flex; align-items: center; gap: 5px; }
.comment-item .comment-control a:hover { color: var(--fox-red); }

.reply-list { margin-left: 40px; padding-left: 20px; border-left: 2px solid var(--bg-alt); }
.reply-list .comment-item { padding: 15px 0; border-bottom: 1px dashed var(--border-color); }

.comment-form { margin-top: 40px; background: var(--bg-alt); padding: 30px; border-radius: var(--radius); }
.guest-inputs { display: flex; gap: 10px; margin-bottom: 15px; }
.guest-inputs input { flex: 1; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-color); color: var(--text-main); }
.textarea-wrap textarea { width: 100%; padding: 15px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-color); color: var(--text-main); resize: vertical; margin-bottom: 15px; font-size: 1rem; }
.textarea-wrap textarea:focus, .guest-inputs input:focus { border-color: var(--fox-red); outline: none; }
.submit-wrap { display: flex; justify-content: space-between; align-items: center; }
.secret-check { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.secret-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--fox-red); }
.submit-wrap button { background: var(--text-main); color: var(--bg-color); padding: 12px 30px; border-radius: 6px; font-weight: 700; transition: background 0.2s; }
.submit-wrap button:hover { background: var(--fox-red); color: #fff; }

/* ==========================================================================
   8. Sidebar (Tistory Category Structure Fix Applied)
   ========================================================================== */
#sidebar { position: sticky; top: 100px; height: fit-content; }
.sidebar-module { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 25px; margin-bottom: var(--gap-md); box-shadow: var(--card-shadow); }
.sidebar-module h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 8px; }
.sidebar-module h3 i { color: var(--fox-red); font-size: 1.3rem; }

/* Profile */
.profile-module { text-align: center; }
.profile-img { width: 100px; height: 100px; border-radius: 50%; margin: 0 auto 15px; object-fit: cover; border: 3px solid var(--bg-alt); }
.profile-info strong { display: block; font-size: 1.2rem; font-weight: 800; margin-bottom: 5px; color: var(--text-main); }
.profile-info p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }

/* Categories - Tistory Native Structure Refinement */
.category-module .tt_category { margin: 0; padding: 0; list-style: none; }
.category-module .tt_category .link_tit { font-weight: 800; font-size: 1.05rem; color: var(--text-main); display: block; margin-bottom: 15px; }
.category-module .tt_category .category_list { padding-left: 0; list-style: none; }
.category-module .tt_category .category_list > li { margin-bottom: 10px; }
.category-module .tt_category .category_list > li > a { display: block; color: var(--text-main); font-size: 0.95rem; transition: color 0.2s; }
.category-module .tt_category .category_list > li > a:hover { color: var(--fox-red); font-weight: 600; }
.category-module .tt_category .category_list li ul { padding-left: 15px; margin-top: 8px; border-left: 2px solid var(--border-color); list-style: none; }
.category-module .tt_category .category_list li ul li { margin-bottom: 6px; }
.category-module .tt_category .category_list li ul li a { font-size: 0.85rem; color: var(--text-muted); }

/* Lists (Recent Posts) */
.list-module ul li { margin-bottom: 12px; line-height: 1.4; }
.list-module a { display: flex; justify-content: space-between; font-size: 0.95rem; color: var(--text-main); transition: color 0.2s; }
.list-module a:hover { color: var(--fox-red); }
.list-module .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; padding-right: 10px; }
.list-module .cnt { color: var(--fox-red); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }

/* Tags Cloud */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.tags-wrap a { background: var(--bg-alt); color: var(--text-muted); padding: 4px 10px; border-radius: 4px; font-size: 0.85rem; transition: all 0.2s; }
.tags-wrap a:hover { background: var(--fox-red); color: #fff; }

/* ==========================================================================
   9. Footer
   ========================================================================== */
#footer { background: var(--bg-alt); padding: 60px 20px; margin-top: 60px; border-top: 1px solid var(--border-color); }
#footer .inner { max-width: var(--max-width); margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 20px; }
.footer-info strong { font-size: 1.5rem; font-weight: 800; background: var(--fox-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: block; margin-bottom: 10px; }
.footer-info p { color: var(--text-muted); font-size: 0.9rem; }
.footer-links { display: flex; gap: 20px; font-size: 0.95rem; font-weight: 600; }
.footer-links a:hover { color: var(--fox-red); }
.copyright { color: var(--text-muted); font-size: 0.85rem; }

/* ==========================================================================
   10. Media Queries (Mobile & Tablet specific adjustments)
   ========================================================================== */
@media (max-width: 768px) {
    .post-header .title { font-size: 2rem; }
    .article-content { font-size: 1rem; }
    .comment-form { padding: 20px; }
    .guest-inputs { flex-direction: column; }
    .post-grid { grid-template-columns: 1fr; }
}
