/* ===========================================
   블로그 메인 스타일시트 - 정리된 버전
   =========================================== */

/* ===========================================
   기본 스타일 및 리셋
   =========================================== */
* {
    box-sizing: border-box;
}

header::after, nav::after, aside::after, div::after, section::after, li::after, select::after {
    content: "";
    display: table;
    clear: both;
    cursor: auto;
}

/* 최상위에서 가로 오버플로우 차단.
   ⚠️ body 에는 주지 않는다. `overflow-x: hidden` 은 그 요소를 **스크롤 컨테이너로** 만드는데,
      그러면 안쪽의 `position: sticky` 가 body 안에 갇혀 화면을 따라오지 못한다(주식 목록
      오른쪽 TOP 10 사이드바가 실제로 그랬다). html 하나로도 가로 스크롤은 막힌다 —
      html 의 overflow 는 뷰포트로 전파되므로 sticky 는 뷰포트 기준으로 정상 동작한다. */
html {
    overflow-x: hidden;
}

body {
    min-width: 400px;
    margin: 0;
    padding: 0;
    background: var(--bae-bg);   /* 페이지 배경 — 정본 #202020(2026-10-12, 전엔 #1C1C1C) */
    color: var(--bae-text-muted);
    font-family: "arial", sans-serif;
    box-sizing: border-box;
}

/* ===========================================
   레이아웃
   =========================================== */
#blog {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px;
    position: relative;
}

/* 헤더 */
header { 
    width: 100%; 
}

#topRight, #topWrite { 
    color: var(--bae-text-muted); 
    text-align: center; 
    cursor: pointer; 
    transition: var(--transition); 
    font-size: 2ex;
    font-weight: 400;
    border-radius: var(--border-radius-sm); 
    padding: 7px 10px;
    box-sizing: border-box;
    display: inline-block;
}

#topRight:hover, #topWrite:hover { 
    color: var(--bae-text-primary); 
    background: var(--bae-surface-hover); 
    transform: translateY(-1px); 
}

#topRight { 
    width: max-content;
    margin-right: 7%; 
    float: right; 
}

#topWrite { 
    width: max-content;
    float: right; 
}

#title { 
    width: 100%; 
    padding: 60px 0 40px; 
    text-align: center; 
    clear: both;
}

/* ⚠️ 로고는 **폭으로만** 크기를 정한다 — 높이는 이미지 비율이 따라 정한다. 그래서
   로고를 갈아끼울 때 비율이 달라지면 헤더 높이가 통째로 바뀐다. 지금 로고는 한 줄짜리
   워드마크라 7.6:1 로 납작하다(옛 로고는 3.76:1). 같은 600px 이면 높이가 79px 밖에 안 돼
   허전해서 폭을 900 까지 키운 것이다 — 로고 크기를 바꾸려면 이 두 숫자만 만지면 된다. */
#blogTitle {
    width: 70%;
    max-width: 900px;
    cursor: pointer;
}

body.stock-page #title,
body.admin-page #title {
    padding: 40px 0 40px;
}

body.stock-page #blogTitle,
body.admin-page #blogTitle {
    width: 35%;
    max-width: 520px;   /* 위와 같은 비율(900 × 350/600) */
    display: block;
    margin: 0 auto;
}

/* 메인 컨텐츠 영역 */
section { 
    padding: 10px; 
    border-radius: var(--border-radius-lg); 
    background: var(--bae-bg);
}

section.stock-page-section {
    padding: 0;
    background: transparent;
}

#side-panel {
    width: 220px; 
    float: right;
}

#content { 
    width: calc(100% - 220px); 
    float: left;
}

#content.stock-page-content {
    width: 100%;
    max-width: 100%;
    float: none;
    margin: 0;
}

/* ===========================================
   사이드바 컴포넌트
   =========================================== */
#profile, #category {
    margin: 10px 10px 20px 10px; 
    padding: 20px; 
    border-radius: var(--border-radius-lg); 
    background: var(--bae-surface); 
    display: block;
}

#category { 
    list-style: none; 
}

/* ⚠️ 이 규칙은 블로그 카테고리와 **관리자 메뉴가 함께** 쓴다(admin.css 에 따로 없다).
   한쪽만 보고 고치지 말 것.
   ⚠️ 단위가 `ex`(폰트 x-높이)였다 — 기기·폰트에 따라 실제 크기가 흔들려 px 로 바꿨다.
   여기 15px 은 옛 1.8ex 의 실측값이라 PC 화면은 그대로다. */
li.category {
    margin: 4px;
    padding: 10px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer; 
    transition: var(--transition); 
    border-radius: var(--border-radius); 
}

li.category:hover { 
    color: var(--bae-text-primary); 
    background: var(--bae-surface-hover); 
    box-shadow: var(--shadow-sm); 
}

/* 선택된 카테고리 — accent 는 배경 tint 와 좌측 막대가 이미 낸다. 글자까지 accent 면
   대비가 떨어져 오히려 덜 읽힌다. 흰색으로 또렷하게. */
li.category-selected {
    background: var(--primary-bg-light);
    border-left: 3px solid var(--bae-accent-fg);
    color: var(--bae-text-primary);
    position: relative;
    font-weight: 600;
}

li.category-selected:hover {
    background: var(--primary-bg-emphasis);
    color: var(--bae-text-primary);
    border-left-color: var(--bae-accent-fg-hover);
}

li.category-selected::before {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: var(--bae-accent-fg);
    opacity: 0.8;
}

/* ===========================================
   검색 UI
   =========================================== */

#search_posting_text {
    flex: 1;
    padding: 6px 8px;
    border: none;
    background: transparent;
    color: var(--bae-text-primary);
    font-size: 11px;
    font-weight: 500;
    outline: none;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    min-width: 0;
}

#search_posting_text::placeholder {
    color: var(--bae-text-dim);
    font-weight: 400;
    font-size: 10px;
}

/* ===========================================
   게시글 목록
   =========================================== */
#postings { 
    width: 100%; 
    margin-top: 10px; 
}

#left { 
    width: 50%; 
    float: left; 
}

#right { 
    width: 50%; 
    float: right; 
}

.posting { 
    width: calc(100% - 15px); 
    margin: 0 10px 20px 10px; 
    padding: 20px; 
    display: inline-block; 
    border-radius: var(--border-radius-lg); 
    color: var(--bae-text-primary); 
    background: var(--bae-surface);
    transition: var(--transition);
    cursor: pointer;
}

.posting-disabled { 
    background: var(--bg-danger); 
    opacity: 0.8; 
}

.posting:hover {
    background: var(--bae-surface-alt);
    box-shadow: var(--shadow-sm);
}

.posting-disabled:hover {
    background: var(--bae-surface-hover);
    box-shadow: var(--shadow-sm);
}

.posting:hover .posting_title {
    text-decoration: underline;
}

.posting_title, .post-title { 
    padding: 15px 2% 0 2%; 
    font-size: 3ex; 
    font-weight: bold; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* hr 태그 여백 조정 */
.posting hr {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--bae-border);
}

.posting_content_wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 15px;
}

.posting_content_wrapper.no-thumbnail {
    gap: 0;
}

.posting_thumbnail_container {
    flex-shrink: 0;
    max-width: 30%;
}

.posting_thumbnail { 
    display: block;
    max-width: 100%; 
    max-height: 300px;
    border-radius: var(--border-radius);
}

.posting_summary {
    flex: 1;
    padding: 0 10px 0 0;
}

.post-thumbnail-container {
    text-align: center;
}

.post-thumbnail {
    width: auto;
    height: auto;
    max-width: 70%;
    display: block;
    margin: 0 auto;
}

.posting_summary { 
    font-size: 2ex; 
    line-height: 200%; 
    word-break: break-all; 
}

/* ===========================================
   포스트 내용 및 이미지
   =========================================== */
.post-content img {
    width: auto;
    height: auto;
    max-width: 45%;
    max-height: 60vh;
    display: block;
    margin: 20px auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    image-rendering: -webkit-optimize-contrast;
}

/* ===========================================
   알림
   =========================================== */
.alert { 
    padding: 1rem; 
    border-radius: var(--border-radius-md); 
    margin-bottom: 1rem; 
}

.alert-info { 
    background: var(--bg-info); 
    color: var(--bae-info); 
    border: 1px solid var(--bae-info); 
}

/* 인증 페이지 스타일은 home.css 로 옮겨뒀다가 그 파일째 걷어냈다 — 로그인·로그아웃은
   중앙 인증(`10.auth`)이 자기 화면으로 처리하므로 이 저장소에 인증 화면이 없다. */

/* ===========================================
   폼 스타일
   =========================================== */
.form-row { 
    margin-bottom: 16px; 
}

/* ===========================================
   푸터
   =========================================== */
footer { 
    margin: 40px; 
    font-size: 2ex; 
    color: var(--bae-text-dim); 
}

footer a { 
    color: var(--bae-text-dim); 
    text-decoration: none; 
}

footer a:hover {
    text-decoration: underline;
    color: var(--bae-accent-fg-hover);
}

/* ===========================================
   포스트 상세 페이지
   =========================================== */
.post-wrapper { 
    margin: 10px 5px 20px 5px; 
    padding: 30px; 
    border-radius: var(--border-radius-lg); 
    background: var(--bae-surface); 
}

.post-wrapper-disabled { 
    background: var(--bg-danger); 
    opacity: 0.8; 
}

.post { 
    background: transparent; 
    border-radius: 0; 
    padding: 0; 
    color: var(--bae-text-primary); 
}

.post-header { 
    border: none; 
    padding: 0; 
    margin: 0 0 40px 0; 
    border-bottom: 2px solid var(--bae-surface-hover); 
    padding-bottom: 10px; 
}

.post-meta { 
    margin-top: 8px; 
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    color: var(--bae-text-muted);
    font-size: 0.95rem;
    text-align: right;
    margin-bottom: 8px;
    min-height: 30px;
}

.post-meta span { 
    display: inline-flex; 
    align-items: center; 
    gap: 6px;
    line-height: 1;
}

.post-content { 
    background: transparent; 
    border: none; 
    border-radius: 0; 
    padding: 25px 20px 20px 20px; 
    line-height: 1.8; 
    font-size: 2ex; 
    margin-bottom: 30px; 
    overflow-x: hidden; 
    word-wrap: break-word; 
}

.post-actions { 
    margin-top: 3rem; 
    padding-top: 2rem; 
    text-align: right; 
}

.post-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: var(--bae-text-primary);
    background: transparent;
    padding: 20px 30px;
}

.post-category { 
    padding: 2px 8px; 
    margin: 2px;
    border: 1px solid var(--bae-border-hover); 
    border-radius: var(--border-radius-pill); 
    background: var(--bae-surface-alt); 
    color: var(--bae-mint); 
    font-weight: 600;
    display: flex;
    align-items: center;
    line-height: 1;
}

.post-author {
    color: var(--bae-info);
    display: flex;
    align-items: center;
    line-height: 1;
}

/* 글 수만큼 반복되는 이름이라 평소엔 중립. 짚을 때만 accent 를 준다. */
.post-author:hover {
    color: var(--bae-accent-fg);
}

.post-date { 
    color: var(--bae-text-muted);
    display: flex;
    align-items: center;
    line-height: 1;
}

.post-updated { 
    color: var(--bae-text-muted); 
    font-style: italic;
    display: flex;
    align-items: center;
    line-height: 1;
}

.post-read-count { 
    padding-left: 8px; 
    margin-left: 6px; 
    border-left: 1px solid var(--bae-border); 
    color: var(--bae-warn);
    display: flex;
    align-items: center;
    line-height: 1;
}

/* ===========================================
   버튼 시스템 (전역 공통)
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    min-height: 40px;
    line-height: 1;
    transition: var(--transition);
    box-sizing: border-box;
    white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* 크기 변형 */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
    border-radius: var(--border-radius-sm);
}

/* 색상 변형 */
.btn-primary {
    background: var(--bae-accent);
    color: var(--bae-accent-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--bae-accent-hover);
}

.btn-secondary {
    background: var(--bae-border-hover);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bae-surface-hover);
    color: white;
    text-decoration: none;
}

.btn-danger {
    background: var(--bae-danger);
    color: var(--bae-accent-text);
}

.btn-danger:hover:not(:disabled) {
    background: var(--bae-danger-hover);
}

/* 블로그 포스트 전용 액션 버튼 */
.btn-edit {
    background: var(--btn-edit);
    color: var(--bae-text-primary);
}

.btn-edit:hover:not(:disabled) {
    background: var(--btn-edit-hover);
}

.btn-disable {
    background: var(--btn-disable);
    color: var(--bae-text-primary);
}

.btn-disable:hover:not(:disabled) {
    background: var(--btn-disable-hover);
}

.btn-enable {
    background: var(--btn-enable);
    color: var(--bae-text-primary);
}

.btn-enable:hover:not(:disabled) {
    background: var(--btn-enable-hover);
}

/* ===========================================
   게시글 작성 페이지
   =========================================== */
#post-writer {
    margin: 10px 10px 20px 10px;
    padding: 30px;
    border-radius: var(--border-radius-lg);
    background: var(--bae-surface);
}

.post-form {
    background: transparent;
    border-radius: 0;
    padding: 0;
    color: var(--bae-text-primary);
}

.form-group {
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    margin-bottom: 16px;
}

.form-row .form-group {
    margin-right: 16px;
}

.form-row .form-group:last-child {
    margin-right: 0;
}

.form-group-title {
    flex: 3;
    margin-bottom: 0;
}

.form-group-category {
    flex: 1;
    margin-bottom: 0;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bae-text-primary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--bae-border);
    border-radius: var(--border-radius);
    background: var(--bae-surface-alt);
    color: var(--bae-text-primary);
    font-size: 16px;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--bae-accent-fg);
    box-shadow: var(--shadow-focus);
    background: var(--bae-surface-alt);
}

.form-control::placeholder {
    color: var(--bae-text-dim);
    font-weight: 400;
}

.form-control.error {
    border-color: var(--bae-danger);
    box-shadow: var(--shadow-focus-danger);
}

.field-error[hidden] { display: none; }

.field-error {
    margin-top: 6px;
    font-size: 0.9rem;
    color: var(--bae-danger);
    font-weight: 500;
}

.form-actions {
    margin-top: 32px;
    padding-top: 0;
    text-align: right;
}

/* ===========================================
   반응형 디자인
   =========================================== */

/* 모바일 크기 (1024px 미만) — layout.html 의 사이드바 접기 판정(innerWidth < 1024)과 짝 */
@media (max-width: 1023.98px) {
    /* 최상위 폭을 화면에 맞게 제한 */
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* 작은 화면에서 강제 최소폭 제거 */
    body {
        min-width: 0;
    }

    /* 헤더 좌/우 버튼 마진을 픽셀로 조정 */
    #topRight, #topWrite {
        margin-left: 0;
        margin-right: 0;
    }
    
    
    #topRight {
        margin-right: 3px;
    }
    #blog {
        padding: 20px 5px;
        padding-top: 10px;
    }
    
    section { 
        padding: 5px; 
        display: flex;
        flex-direction: column;
    }
    
    #side-panel { 
        width: 100%; 
        float: none; 
        order: 1;
        margin-bottom: 20px;
        border-bottom: 1px solid var(--bae-surface-hover);
        padding-bottom: 20px;
    }
    
    #content { 
        width: 100%; 
        float: none; 
        order: 2;
    }
    
    /* 사이드 패널 토글 버튼 */
    .sidebar-toggle {
        display: block;
        width: calc(100% - 20px);
        align-items: center;
        margin: 10px;
        padding: 12px 16px;
        background: var(--bae-surface-alt);
        border: 1px solid var(--bae-border);
        border-radius: var(--border-radius);
        color: var(--bae-text-primary);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        text-align: center;
        transition: var(--transition);
        position: relative;
    }
    
    .sidebar-toggle:hover {
        background: var(--bae-surface-hover);
        border-color: var(--bae-accent-fg);
    }
    
    .sidebar-toggle::after {
        content: "▼";
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 12px;
        transition: transform 0.2s ease;
    }
    
    .sidebar-toggle.collapsed::after {
        transform: translateY(-50%) rotate(-90deg);
    }
    
    /* 사이드 패널 콘텐츠 */
    .sidebar-content {
        transition: max-height 0.3s ease, opacity 0.2s ease;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
    }
    
    .sidebar-content.expanded {
        max-height: 1000px;
        opacity: 1;
    }
    
    /* 사이드바 컴포넌트 최적화 */
    #profile, #category {
        margin: 8px 5px 12px 5px;
        padding: 15px;
        border-radius: var(--border-radius-md);
    }
    
    /* ⚠️ 여기서 글자를 **줄이고 있었다**(1.4ex ≈ 11.8px). 손가락으로 누르는 화면이라
       방향이 거꾸로였다 — 키우고 높이도 44px 이상으로 잡는다(터치 타깃 권장치). */
    li.category {
        padding: 12px 14px;
        font-size: 16px;
        line-height: 1.4;
        margin-bottom: 4px;
        border-radius: var(--border-radius-sm);
    }

    /* 선택 항목은 좌측 막대 2px 만큼 안쪽 여백을 빼서 글자 시작점을 나머지와 맞춘다. */
    li.category-selected {
        border-left-width: 2px;
        padding-left: 12px;
    }
    
    li.category-selected::before {
        left: 4px;
        font-size: 0.6em;
        opacity: 0.8;
    }
    
    /* 포스팅 제목 및 본문 글자 크기 조정 */
    .post-title {
        font-size: 1.8rem;
        padding: 15px 10px;
    }
    
    .post-content {
        font-size: 1.8ex;
        line-height: 1.7;
        padding: 20px 10px 15px 10px;
    }
    
    /* 포스트 상세 페이지 여백 줄이기 */
    .post-wrapper {
        margin: 5px 3px;
        padding: 20px 12px;
    }
    
    /* 포스트 목록 제목 크기 조정 */
    .posting_title {
        font-size: 2.5ex;
        padding: 12px 1% 0 1%;
    }
    
    /* 포스팅 카드 본문/메타 글자 크기 조정 */
    .posting_summary {
        font-size: 1.7ex;
        line-height: 180%;
    }
    
    .posting .post-meta {
        font-size: 0.85rem;
    }
    
    /* 포스팅 카드 여백 줄이기 */
    .posting {
        width: calc(100% - 10px);
        margin: 0 5px 15px 5px;
        padding: 15px;
    }
    
    .posting_thumbnail_container {
        max-width: 25%;
    }
    
    
    /* 검색 UI 모바일 최적화 */
    #search_posting_text {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    
    
    /* 프로필 정보 컴팩트 */
    #profile {
        font-size: 1.2ex;
        text-align: center;
    }
    
    
    
    
    
    /* 포스트 내용 이미지 최적화 */
    .post-content img {
        max-width: 50%;
        max-height: 55vh;
        margin: 15px auto;
        border-radius: var(--border-radius-sm);
    }
    
    .post-content {
        padding: 0px 10px 20px 10px;
    }
    
    /* 폼 최적화 */
    #post-writer {
        margin: 5px;
        padding: 20px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group-title,
    .form-group-category {
        margin-bottom: 24px;
    }
    
    .form-control {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    
    .form-actions {
        text-align: center;
    }
    
}

/* 중간 화면 (640px ~ 767px) */
@media (min-width: 640px) and (max-width: 767.98px) {
    .post-content img {
        max-width: 80%;
        max-height: 50vh;
    }
}

/* 매우 작은 화면 (640px 미만) */
@media (max-width: 639.98px) {
    /* 헤더 버튼 마진 조정 */
    #topLeft, #topRight, #topWrite {
        margin-left: 0;
        margin-right: 0;
    }
    
    #topLeft {
        margin-left: 3px;
    }
    
    
    #topRight {
        margin-right: 2px;
    }
    
    #blog {
        padding: 15px 3px;
        padding-top: 8px;
    }
    
    section {
        padding: 3px;
    }
    
    #side-panel {
        margin-bottom: 15px;
        padding-bottom: 15px;
    }
    
    #profile, #category {
        margin: 6px 3px 10px 3px;
        padding: 12px;
        border-radius: 10px;
    }
    
    /* ⚠️ 여기가 제일 작았다(1.2ex ≈ 10.1px, 높이 27px). 화면이 좁을수록 손가락은 그대로라
       크기를 더 줄일 이유가 없다 — 위 1024px 규칙의 값을 그대로 물려받게 두고 간격만 줄인다. */
    li.category {
        margin-bottom: 3px;
    }
    
    /* 검색 UI 초소형 최적화 */
    #search_posting_text {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    
    
    /* 포스트 내용 이미지 최적화 */
    .post-content img {
        max-width: 100%;
        max-height: 50vh;
        margin: 10px auto;
        border-radius: var(--border-radius-xs);
    }
    
    .post-content {
        padding: 15px 5px 12px 5px;
        font-size: 1.6ex;
        line-height: 1.65;
    }
    
    .post-title {
        font-size: 1.5rem;
        padding: 12px 5px;
    }
    
    /* 포스트 목록 제목 크기 조정 */
    .posting_title {
        font-size: 2.2ex;
        padding: 10px 1% 0 1%;
    }
    
    /* 포스팅 카드 본문/메타 글자 크기 조정 */
    .posting_summary {
        font-size: 1.4ex;
        line-height: 170%;
    }
    
    .posting .post-meta {
        font-size: 0.8rem;
    }
    
    /* 포스팅 카드 여백 더 줄이기 */
    .posting {
        width: calc(100% - 6px);
        margin: 0 3px 12px 3px;
        padding: 12px;
    }
    
    .posting_thumbnail_container {
        max-width: 30%;
    }
    
    .post-wrapper {
        margin: 3px 2px;
        padding: 12px 8px;
    }
    
    /* 에디터 최적화 */
    #post-writer {
        margin: 3px;
        padding: 12px;
    }
    
    .form-label {
        font-size: 0.9rem;
    }
    
    .form-control {
        padding: 6px 8px;
        font-size: 13px;
    }
    
    
}

/* 데스크톱에서는 토글 버튼 숨김 */
@media (min-width: 1024px) {
    .sidebar-toggle {
        display: none;
    }
}
