/* CMS 뼈대 ↔ 참조 시안 뼈대 맞춤(cms/docs/contracts/reader-css.md §3). 참조 CSS(ref/css/*.css) 다음에 읽는다.
   참조: <body class="page-…"><header/><main class="container" id="main">섹션…</main><footer/>
   CMS : <body><div class="layout-container"><header id="header-section"><div class="layout-section-inner">블록…</div></header>
         <main class="layout-body"><div class="layout-main constrained" id="main"><div class="grid-masonry-layout">
         <div class="section-wrapper">블록</div>…</div></div></main><footer id="footer-section">…</footer></div></body> */

/* 머리·바닥 영역: CMS 24칸 격자 간격을 없애 참조처럼 블록이 바로 이어지게 한다(모든 화면). */
#header-section > .layout-section-inner, #footer-section > .layout-section-inner { max-width: none; padding: 0; }
#header-section .grid-masonry-layout, #footer-section .grid-masonry-layout { gap: 0; }

/* 옮긴 화면(csPage를 부른 화면)만: .layout-main = 참조 main.container#main */
body.cs-ref .layout-main.constrained { width: min(var(--content-width), calc(100% - 2 * var(--page-gutter))); max-width: none; margin-inline: auto; padding: 0; }
body.cs-ref .grid-masonry-layout { gap: 0; }
body.cs-ref .mobile-layout-wrapper .layout-main.constrained { padding: 0; }
body.cs-ref .desktop-layout-wrapper { min-width: 0; }

/* 사용자가 쓴 HTML(기사 본문 .cms-article-body, 커뮤니티 글·관리자 글 .cs-user-html): 참조 reset(ul,ol{list-style:none;padding:0})이
   목록 표시를 지우지 않게 되돌린다. 사용자 HTML을 넣는 상자에는 둘 중 하나의 클래스를 붙인다(reader-css.md §4). */
:is(.cms-article-body, .cs-user-html) ul { padding-left: 1.5em; list-style: disc; }
:is(.cms-article-body, .cs-user-html) ol { padding-left: 1.5em; list-style: decimal; }

/* 하단 고정 소식받기 띠: 참조는 메인에만 있다(main.css 330-342, 453-459). 우리는 모든 화면에 두므로 메인 밖에서도 같은 값을 쓴다. */
@media (min-width: 1025px) { body:not(.page-main).has-bottom-quick { padding-bottom: var(--bottom-quick-height, 100px); } }
body:not(.page-main) .bottom-quick { position: fixed; right: 0; bottom: 0; left: 0; z-index: 20; background: color-mix(in srgb, var(--accent-color) 95%, transparent); color: var(--color-bg); padding-bottom: env(safe-area-inset-bottom); }
body:not(.page-main) .bottom-quick[hidden] { display: none; }
body:not(.page-main) .bottom-quick-inner { position: relative; display: flex; align-items: center; gap: 28px; min-height: 110px; padding: 12px 0 12px 250px; }
body:not(.page-main) .bottom-quick-image { position: absolute; bottom: 0; left: 0; display: block; width: 206px; height: 140px; object-fit: contain; }
body:not(.page-main) .bottom-quick-copy { flex: 1; min-width: 0; }
body:not(.page-main) .bottom-quick-copy strong { display: block; font-size: 1.5rem; line-height: 1.5; }
body:not(.page-main) .bottom-quick-copy p { margin-top: 8px; font-size: var(--font-body); line-height: 1.5; }
body:not(.page-main) .bottom-quick-link { display: flex; align-items: center; justify-content: center; flex: 0 0 260px; min-height: 60px; padding: 12px 16px; background: var(--color-text); color: var(--color-bg); font-size: var(--font-body); font-weight: 700; text-align: center; }
body:not(.page-main) .bottom-quick-close { position: absolute; top: 10px; right: 24px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--color-text); font-size: 1.8rem; line-height: 1; }
@media (max-width: 1024px) {
  body:not(.page-main) .bottom-quick { display: none; }
}
/* 그림이 없으면 글을 왼쪽 끝에서 시작한다(참조는 그림이 늘 있다). */
body .bottom-quick .bottom-quick-inner:not(:has(.bottom-quick-image)) { padding-left: 0; }

/* 푸터 회사 정보: 참조는 고정 문구라 구분선(|)을 마크업에 넣는다. 우리는 값이 있는 항목만 그리므로 구분선을 CSS로 넣는다(.footer-separator와 같은 값). */
.footer-bottom .footer-info-row { display: block; }
.footer-bottom .cs-fi:not(:last-child)::after { content: "|"; margin-inline: 6px; opacity: 0.6; }
/* 회사 정보 한 항목은 통째로 줄을 바꾼다(사업자등록번호가 중간에서 끊기지 않게). 줄보다 긴 항목만 안에서 줄을 바꾼다. */
.footer-bottom .cs-fi { display: inline-block; max-width: 100%; vertical-align: top; }
/* 푸터 연결 목록(휴대폰·태블릿): 참조의 4칸 격자(common.css 402·404·516)를 그대로 쓴다. 첫 줄 메뉴 4개, 둘째 줄 이용약관 + 개인정보 수집·이용
   (둘째 칸부터 끝까지), 셋째 줄 첫 칸은 쿠키 설정 단추다. 연결은 참조 여섯 개뿐이다(대표 결정 2026-11-25: 퍼블리싱 우선, common-mobile.yaml). */
@media (max-width: 1024px) {
  /* 회사 정보 구분선: 참조 휴대폰 값(common.css 408 .footer-separator)과 같게 */
  body .site-footer .footer-bottom .cs-fi:not(:last-child)::after { margin-inline: 2px; opacity: 1; }
}
/* 모바일 푸터 회사 정보(common-mobile.yaml p.cs-fi-flow): 참조(html/layout.html 249-255)는 회사 정보를 글자로 이어 쓴다. 항목을 통째로
   줄 바꾸면(위 inline-block) 줄 끝에 「|」이 남아서, 모바일은 항목을 참조 글처럼 인라인으로 두고(낱말 사이에서 줄을 바꾼다)
   구분선을 다음 항목 앞(::before)에 둔다. 구분선 앞뒤의 U+2060(낱말 잇기)이 앞 항목 끝 글자·다음 항목 첫 글자와 붙여 「|」이
   줄 끝·줄 머리에 혼자 남지 않는다. 글자 크기·색·줄 높이는 참조 CSS(.footer-bottom p, .footer-info-row) 그대로다. */
.footer-bottom .cs-fi-flow .cs-fi { display: inline; vertical-align: baseline; }
.footer-bottom .cs-fi-flow .cs-fi:not(:last-child)::after { content: none; }
.footer-bottom .cs-fi-flow .cs-fi + .cs-fi::before { content: "\2060|\2060"; margin-inline: 6px; opacity: 0.6; }
@media (max-width: 1024px) {
  body .site-footer .footer-bottom .cs-fi-flow .cs-fi + .cs-fi::before { margin-inline: 2px; opacity: 1; }
}
body footer.site-footer .footer-links .tcb-open { text-align: left; text-decoration: none; white-space: nowrap; }
/* 메인 투표: 참조는 「총 N표 누적」을 질문 줄 오른쪽 위에 띄워 긴 질문과 겹친다. 질문 옆 칸으로 두어 질문이 줄을 바꾸게 한다. */
body .main-feed .mf-poll-question .mf-poll-total { position: static; flex: 0 0 auto; align-self: flex-start; line-height: 28px; white-space: nowrap; }

/* 참조 body > main 여백(common.css 395): CMS는 main이 body 바로 아래가 아니다. */
body.cs-ref main.layout-body { padding-bottom: var(--footer-gap); }

/* 모바일 고정 헤더: 참조 .site-header{position:sticky;top:-48px}는 body가 부모다. CMS는 블록 래퍼가 부모라 붙지 않으므로
   머리 영역 전체를 같은 값으로 붙인다(위 48px 신문 로고 줄은 스크롤되어 사라진다). */
@media (max-width: 767px) {
  #header-section { position: sticky; top: -48px; z-index: 20; }
}
/* 태블릿 폭(768~1024px, 옮긴 화면): 참조 .site-header{position:sticky;top:0}(common.css 493~)를 머리 영역에 같은 값으로. */
@media (min-width: 768px) and (max-width: 1024px) {
  body.cs-ref #header-section { position: sticky; top: 0; z-index: 20; }
}
/* 떠 있는 카카오 채널 풍선: 휴대폰에서 100px이면 투표 단추·목록 왼쪽을 넓게 가린다. 72px로 줄이고, 바닥글이 보이는 동안에는
   간행본 풍선과 함께 숨긴다(common-mobile.yaml의 is-footer-near). 간행본 풍선은 줄어든 만큼 내려 붙인다. */
@media (max-width: 767px) {
  body:is(body, .page-main[data-stage]) .mobile-quick .mobile-quick-notice.mobile-quick-notice { width: 72px; height: 72px; }
  body:is(body, .page-main[data-stage]) .mobile-quick .mobile-quick-book-wrap.mobile-quick-book-wrap { bottom: calc(100% + 96px); }
  body:is(body, .page-main[data-stage]) .mobile-quick:has(.mobile-quick-notice[hidden]) .mobile-quick-book-wrap.mobile-quick-book-wrap { bottom: calc(100% + 12px); }
}
body .mobile-quick :is(.mobile-quick-notice, .mobile-quick-book-wrap) { transition: opacity .2s ease, visibility .2s ease; }
body .mobile-quick.is-footer-near :is(.mobile-quick-notice, .mobile-quick-book-wrap) { opacity: 0; visibility: hidden; pointer-events: none; }
/* 본문 글자색(휴대폰·태블릿): 레이아웃 래퍼(.layout-container)의 인라인 color(#292d30)가 상속을 끊어 참조 CSS가 body에 준 화면별 글자색
   (기본 #1e1e1f, 회원 #202020, 계산기 #181c25)이 내려오지 않았다. 래퍼가 body 색을 그대로 물려받게 한다. */
@media (max-width: 1024px) {
  body.cs-ref .layout-container { color: inherit !important; }
}
@media (min-width: 1025px) {
  .page-community .community-board .community-table tr:has(.best) td:first-child { color: var(--color-muted); }
  .page-community-post .post-comments-section > form.comment-composer { padding: 18px; }
}

/* Empty thumbnails share the watermark selected in the publisher's brand settings. */
body.page-main :is(.lead-story .ratio-main, .mf-top-visual, .discussion-title + .mini-list .image-slot) > .ph {
  display: block;
  width: 100%;
  height: 100%;
}
body.page-main .mf-lead-list .mf-news-row > .ph {
  flex: 0 0 26.715686%;
  aspect-ratio: 109 / 77;
  border-radius: var(--mf-radius-sm);
}
html body .ph:empty,
html body .ready:has(> img[src$="/chungyak-symbol.png"] + em) {
  background: #f2f2f2 url("/api/v2/public/brand/watermark") center / min(50%, 160px) auto no-repeat !important;
}
html body .ph:empty::before,
html body .ph:empty::after {
  content: none !important;
}
html body .ready:has(> img[src$="/chungyak-symbol.png"] + em) > :is(img, em) {
  visibility: hidden;
}

body.page-community-post #main .post-vote .vote-symbol > img {
  display: block;
  width: 24px;
  height: 25px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  object-fit: contain;
}

html body.page-main #main .hero-grid .lead-story > p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
}

html body.page-main #main .community-grid .poll-heading + .poll-question {
  padding-left: 0;
}
html body.page-main #main .community-grid .poll-heading + .poll-question > span:first-child {
  display: none;
}

/* Keep the brand watermark centered on overview cards without a thumbnail. */
body.page-stories .stories-overview-card:has(> h3:first-child)::before {
  content: "";
  display: block;
  aspect-ratio: 16 / 9;
  background: #f2f2f2 url("/api/v2/public/brand/watermark") center / min(46%, 140px) auto no-repeat;
}
/* Mobile community guest photo preview */
@media (max-width: 1024px) {
  body.page-community-post:not([data-member-preview]) .neighbor-post .imgs,
  body.page-community-post:not([data-member-preview]) .neighbor-post .post-body img {
    display: none !important;
  }
}
@media (max-width: 1024px) {
  html:root body.mobile-layout-wrapper.page-news-post > button.floating-chat,
  html:root body.mobile-layout-wrapper.page-community-post > button.floating-chat { display: none !important; }
}
/* Mobile overview card captions */
@media (max-width: 1024px) {
  .mf-overview .mf-overview-card { min-width: 0; }
  .mf-overview .mf-overview-card > small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

@media (max-width: 1024px) {
  .cs-mh .site-header:has(.brand.cs-site) .mobile-masthead {
    display: contents;
  }
  .cs-mh .site-header:has(.brand.cs-site) .mobile-masthead .mobile-channel {
    display: none;
  }
  .cs-mh .site-header:has(.brand.cs-site) .mobile-paper-brand.cs-mast {
    position: absolute;
    z-index: 2;
    top: 4px;
    left: 16px;
    width: calc(100% - 116px);
    height: 14px;
    padding: 0;
    gap: 5px;
    align-items: center;
    font-size: 10px;
    line-height: 14px;
  }
  .cs-mh .site-header:has(.brand.cs-site) .cs-mast img { width: auto; height: 12px; }
  .cs-mh .site-header:has(.brand.cs-site) .cs-mast i { width: 12px; margin: 0; }
  .cs-mh .site-header:has(.mobile-masthead .cs-mast) .brand.cs-site .mobile-brand-text::before {
    content: "";
    display: block;
    height: 12px;
    visibility: hidden;
  }
  body[class] .cs-mh .site-header:has(.brand.cs-site) .mobile-paper-brand.cs-mast,
  body[class] .cs-mh .site-header:has(.mobile-masthead) .brand.cs-site .mobile-brand-text::before {
    display: none;
  }
  body[class] .cs-mh .site-header .brand.cs-site .mobile-brand-text {
    white-space: nowrap;
  }
}

.news-magazine:not(:has(.news-magazine-visual img)) { display: none; }

@media (max-width: 1024px) {
  .stories-quick-grid a[data-overview-shortcut] { display: grid; grid-template-rows: 48px auto 1fr; align-content: start; justify-items: center; text-align: center; }
  .stories-quick-grid a[data-overview-shortcut] small { position: static; white-space: normal; }
}

/* Article list thumbnails keep their crop when the shared image detector marks a portrait. */
body.page-news.news-landing :is(.news-row, .news-edition-row) img.cs-contain {
  object-fit: cover !important;
  object-position: center;
  outline: none;
}
