/* single-post-news — .tpl-single-post-news 아래로 작성 */

/* 시안 .nd — 고정 헤더 높이만큼 내린다. 폭(1236px)은 에디터 main 레이아웃의 콘텐츠 폭, 좌우 여백(gutter)은 에디터 패딩.
   아래 여백은 시안 .nd-foot(위 · 아래 패딩을 합친 값) */
.tpl-single-post-news {
  max-width: none;
  margin: 0;
  padding-top: calc(var(--thesmc-header-height, 72px) + clamp(26px, calc(20.252px + 1.533 * var(--wp--custom--vwc)), 49.68px));
  padding-bottom: clamp(104px, calc(89.92px + 3.754 * var(--wp--custom--vwc)), 162px);
}

/* ---------- 뒤로가기 — 시안 .nd-top. 글 카테고리 블록(.nd-back)에 접두어 「All 」 → 「← ALL IR」(그 카테고리 목록 링크, inc/blocks.php).
   글자 · 색은 블록 설정, 화살표 · hover는 Works 상세 뒤로가기(.wd-back)와 같다 ---------- */
.tpl-single-post-news .nd-back {
  margin-block: 0;
  padding-bottom: clamp(18px, calc(15.03px + 0.792 * var(--wp--custom--vwc)), 30.24px);
}

.tpl-single-post-news .nd-back a {
  transition: color var(--thesmc-dur) var(--thesmc-ease);
}

.tpl-single-post-news .nd-back a::before {
  content: "←";
  content: "←" / "";
  display: inline-block;
  margin-right: 7px;
  transition: transform var(--thesmc-dur) var(--thesmc-ease);
}

.tpl-single-post-news .nd-back a:hover::before {
  transform: translateX(-3px);
}

/* ---------- HERO — 시안 .nd-hero. 상단 배너 + 왼쪽 아래에 붙는 아이보리 카테고리 블록(.nd-cat) ----------
   배너는 모든 뉴스가 같은 브랜드 배너라 템플릿의 이미지 블록(.nd-banner, 테마 assets/images/news-banner.jpg)에 고정했다(글마다 넣는 상단 이미지 필드는 뉴스에서 뺐다).
   카테고리는 하위 카테고리만 · 링크 없이(inc/blocks.php) */
.tpl-single-post-news .nd-hero {
  position: relative;
  margin-bottom: clamp(30px, calc(4.7 * var(--wp--custom--vwc)), 80px);
}

/* 배너(2095×646)는 가로로 긴 비율이라 좁은 화면에서 그대로 줄이면 너무 낮아진다 —
   900px까지는 시안처럼 16:9로 잘라(가운데 기준) 높이를 확보하고, 그보다 넓으면 배너 비율 그대로.
   900px은 시안 .nd-thumb의 구간(사이트 구간 규칙 768 · 1024의 예외). 비율을 상자에 정해 두어 이미지가 늦게 와도 자리가 흔들리지 않는다 */
.tpl-single-post-news .nd-hero .nd-banner {
  margin: 0;
  overflow: hidden;
  aspect-ratio: var(--wp--preset--aspect-ratio--16-9);
}

.tpl-single-post-news .nd-hero .nd-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 901px) {
  .tpl-single-post-news .nd-hero .nd-banner {
    aspect-ratio: 2095 / 646;
  }
}

/* 들어올 때 배너가 위에서 아래로 펼쳐진다(시안 .nd-thumb의 clip-path). 배너와 카테고리 블록을 함께 잘라
   배너는 제자리에 있고 가림막만 걷히며, 왼쪽 아래 카테고리 블록은 마지막에 드러난다 — 시안은 블록이 이미지 상자 안에 있어 같이 잘린다.
   시작(.is-in)은 single-post-news.js가 배너를 그릴 준비가 된 뒤에 붙인다 — 애니메이션을 CSS만으로 걸면 페이지가 화면에
   그려지기 전에 시작돼 첫 화면에 이미 반쯤 펼쳐진 채 나타난다.
   시작 전 숨김은 첫 화면부터 걸려야 해서(JS가 붙이면 다 보인 배너가 한 번 깜빡인다) CSS로 — JS가 꺼져 있거나 움직임 줄이기 ·
   에디터(.is-root-container)에서는 숨기지 않는다 */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .wp-site-blocks:not(.is-root-container) .tpl-single-post-news .nd-hero {
    clip-path: inset(0 0 100% 0);
  }
}

.tpl-single-post-news .nd-hero.is-in {
  animation: nd-hero-reveal 0.9s var(--thesmc-ease) both;
}

@keyframes nd-hero-reveal {
  from {
    clip-path: inset(0 0 100% 0);
  }
  /* 아래만 1px 더 연다 — 칩의 1px 덮개(아래 .nd-cat box-shadow)가 히어로 경계에서 같이 잘리지 않게 */
  to {
    clip-path: inset(0 0 -1px 0);
  }
}

/* 아이보리 배경 · 안쪽 여백은 블록 설정. 글자 높이를 14px로 맞춰 블록 높이가 시안(25px)과 같게 */
.tpl-single-post-news .nd-cat {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  line-height: 14px;
  white-space: nowrap;
  /* 배너 높이가 소수 px(예: 381.11)라 맨 아래 줄이 칩 밑에 반투명하게 한 줄 비친다 — 칩 바탕을 아래로 1px 늘려 덮는다.
     늘어난 1px은 페이지 배경과 같은 색이라 보이지 않는다 */
  box-shadow: 0 1px 0 var(--wp--preset--color--ivory);
}

/* ---------- BODY — 시안 .nd-body. 열 수는 에디터 그리드 설정(데스크톱 2열 · 태블릿/모바일 1열) ----------
   데스크톱은 왼쪽 제목 · 날짜(.nd-info)가 헤더 아래에 붙어 따라오고 오른쪽 본문(.nd-text)이 흐른다(시안 비율 1 : 1.046) */
.tpl-single-post-news .nd-body {
  align-items: start;
  gap: clamp(24px, calc(20.6px + 0.906 * var(--wp--custom--vwc)), 38px);
}

@media (min-width: 1024px) {
  .tpl-single-post-news .nd-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.046fr);
    gap: clamp(28px, calc(4.1 * var(--wp--custom--vwc)), 70px);
  }

  .tpl-single-post-news .nd-info {
    position: sticky;
    top: calc(var(--thesmc-header-height, 72px) + clamp(16px, 2.6vh, 30px)); /* 화면 높이 안의 위치라 vh(Works 상세 정보 칸과 같다) */
  }
}

/* 제목 · 날짜 — 굵기 · 행간 · 자간 · 색은 블록 설정 */
.tpl-single-post-news .nd-title {
  margin: 0;
  font-family: var(--wp--preset--font-family--brand);
  font-size: clamp(21px, calc(2.05 * var(--wp--custom--vwc)), 32px);
  word-break: keep-all;
  text-wrap: pretty;
}

.tpl-single-post-news .nd-date {
  margin: clamp(12px, calc(10.058px + 0.518 * var(--wp--custom--vwc)), 20px) 0 0;
  font-family: var(--wp--preset--font-family--brand);
  font-size: clamp(14px, calc(1.15 * var(--wp--custom--vwc)), 18px);
}

/* ---------- 본문 — 시안 .nd-text. 글 콘텐츠는 기존 글 그대로라 문단 · 목록 · 소제목 · 이미지 · 표 · 뉴스레터(메일 HTML)가 섞여 있다.
   블록 사이 간격 · 행간 · 글자 색은 theme.json 글 콘텐츠 블록(core/post-content) 설정, 여기서는 글자 · 소제목 · 이미지만 ---------- */
.tpl-single-post-news .nd-text {
  min-width: 0;
}

/* 메일 HTML(뉴스레터)은 표 폭이 고정이라 좁은 화면에서 넘친다 — 페이지가 아니라 본문 안에서만 가로로 밀리게 */
.tpl-single-post-news .nd-text .wp-block-post-content {
  overflow-x: auto;
}

.tpl-single-post-news .nd-text .wp-block-post-content :is(p, li, td, th) {
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--news-body);
  word-break: keep-all;
}

/* FAQ 질문(h2)은 theme.json FAQ 블록 스타일(우선순위 0)을 따르게 뺀다 */
.tpl-single-post-news .nd-text .wp-block-post-content :is(h2, h3, h4):not(.thesmc-faq-item__question) {
  font-family: var(--wp--preset--font-family--brand);
  font-weight: 600;
  font-size: var(--wp--preset--font-size--news-subhead);
  line-height: 1.6;
  color: var(--wp--preset--color--ink);
  word-break: keep-all;
}

/* 앞에 다른 요소가 있을 때만 — 본문 첫 요소에 붙으면 왼쪽 제목과 윗선이 어긋난다 */
.tpl-single-post-news .nd-text .wp-block-post-content > * + :is(h2, h3, h4) {
  margin-top: clamp(34px, calc(29.146px + 1.294 * var(--wp--custom--vwc)), 54px);
}

.tpl-single-post-news .nd-text .wp-block-post-content > * + :is(figure, .wp-block-image, .wp-block-embed) {
  margin-top: clamp(30px, calc(25.748px + 1.134 * var(--wp--custom--vwc)), 47.52px);
}

.tpl-single-post-news .nd-text .wp-block-post-content :is(ul, ol) {
  padding-left: 1.2em;
}

.tpl-single-post-news .nd-text .wp-block-post-content img {
  max-width: 100%;
  height: auto;
}

.tpl-single-post-news .nd-text .wp-block-post-content figcaption {
  margin-top: 10px;
  font-family: var(--wp--preset--font-family--brand);
  font-size: clamp(12px, calc(0.92 * var(--wp--custom--vwc)), 13.5px);
  line-height: 1.6;
  color: var(--wp--preset--color--mid);
  word-break: keep-all;
}

/* ---------- 뉴스레터 — 스티비 메일을 변환한 블록 묶음(그룹 .thesmc-newsletter-mail, 플러그인 thesmc-core 뉴스레터 블록이 만든다).
   글자는 위 뉴스 본문과 같은 모양(본문 · 소제목 · 캡션 크기, 색, 줄 간격)이고, 블록 사이 여백은 없다. 폭은 뉴스 본문 폭을 꽉 채운다(좌우 여백 없음).
   메일마다 다른 값(상자 위아래 여백 · 빈 줄 간격 · 정렬)은 블록 설정(인라인 style)으로 들어 있어 여기 규칙보다 앞선다.
   에디터에서도 같은 모양이 보이게 에디터 본문(.editor-styles-wrapper) 아래에도 건다 — 에디터에는 위 뉴스 본문 규칙이 없어 값을 다시 적는다.
   위 본문 규칙(:is(p, li …) · :is(h2 …))과 우선순위가 같거나 높아야 해서 같은 조상을 앞에 둔다 ---------- */
:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail {
  line-height: 1.75;
  color: var(--wp--preset--color--graphite);
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail :is(p, li) {
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--news-body);
  line-height: inherit;
  color: inherit;
  word-break: keep-all;
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail :is(h2, h3, h4) {
  font-family: var(--wp--preset--font-family--brand);
  font-size: var(--wp--preset--font-size--news-subhead);
  font-weight: 600;
  line-height: 1.6;
  color: var(--wp--preset--color--ink);
  word-break: keep-all;
}

/* 태그 · 연락처 같은 작은 글씨는 캡션 크기 · 색 */
:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .thesmc-newsletter-small {
  font-size: clamp(12px, calc(0.92 * var(--wp--custom--vwc)), 13.5px);
  color: var(--wp--preset--color--mid);
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail :is(p, h2, h3, h4, ul, ol, figure, .wp-block-columns, .wp-block-buttons) {
  margin-block: 0;
}

/* 이미지 폭 — 변환기가 메일 모양대로 나눠 둔다.
   - 메일에서 꽉 채우던 한 단 이미지(.thesmc-newsletter-fill, 배너 · 본문 사진)는 원본보다 커져도 꽉 채운다
   - 2단 칸 안 이미지(카드 사진 · 구독하기 버튼)는 2단일 때 칸을 꽉 채우고(아래 768px 이상 규칙), 1단으로 쌓이면 원본 크기까지만, 칸이 더 넓으면 가운데 —
     767px 이하에서 1단으로 쌓이면 칸이 메일의 두 배 가까이 넓어져 꽉 채우면 흐리고 너무 크다
   - 메일에서 좁은 px 폭이던 이미지는 블록에 폭 · 가운데 정렬이 들어 있다(.is-resized). 에디터에서 크기를 바꿔도 이쪽
   링크 이미지는 감싼 a가 inline-block이라 a도 맞춘다(캡션 안 링크는 빼려고 바로 아래 a만) */
:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-image:not(.is-resized) > a {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-image:not(.is-resized) img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-image.thesmc-newsletter-fill:not(.is-resized) > a,
:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-image.thesmc-newsletter-fill:not(.is-resized) img {
  width: 100%;
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns {
  /* 칸 사이(가로) 간격은 변환기가 메일 값을 단 블록 간격(blockGap)으로 넣는다. 위아래 간격은 블록 위 여백으로 들어 있어 세로 간격만 없앤다 */
  row-gap: 0;
}

/* 「1단으로 보기」 — 칸을 지우지 않고 화면 폭과 상관없이 위아래로 쌓는다.
   단 블록 기본 CSS가 칸 폭(flex-basis)을 !important로 거는 화면 폭이 있어 같은 !important로 덮는다 */
:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns.thesmc-newsletter-stacked {
  flex-direction: column;
}

:is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns.thesmc-newsletter-stacked > .wp-block-column {
  flex-basis: auto !important;
}

/* 2단은 화면 767px 이하에서만 쌓는다. 단 블록 기본값은 781px 이하에서 쌓아(flex-basis 100% !important)
   768~781px 태블릿에서도 1단이 되므로 같은 !important로 되돌린다.
   「1단으로 보기」를 켠 단 블록(.thesmc-newsletter-stacked, 플러그인 thesmc-core 뉴스레터 블록의 스위치)은 화면 폭과 상관없이 쌓으므로 뺀다 */
@media (min-width: 768px) {
  :is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns:not(.thesmc-newsletter-stacked) {
    flex-wrap: nowrap !important;
  }

  :is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns:not(.thesmc-newsletter-stacked) > .wp-block-column {
    flex-basis: 0 !important;
    flex-grow: 1;
  }

  /* 2단일 때 칸 안 이미지는 메일처럼 칸을 꽉 채운다 */
  :is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns:not(.thesmc-newsletter-stacked) .wp-block-image:not(.is-resized) > a,
  :is(.tpl-single-post-news .nd-text .wp-block-post-content, .editor-styles-wrapper) .thesmc-newsletter-mail .wp-block-columns:not(.thesmc-newsletter-stacked) .wp-block-image:not(.is-resized) img {
    width: 100%;
  }
}

/* ---------- 원문 링크 — 시안 .nd-src: 본문 끝 위 선 + 링크. 글자는 Works 상세 원본 링크(.wd-plink)와 같고, 화살표 「↗」는 global.css ----------
   선은 분리자 블록(색 line은 블록 설정), 링크는 원본 링크 블록(thesmc/project-links, .nd-src) */
.tpl-single-post-news .nd-text .wp-block-separator {
  margin: clamp(36px, calc(31.106px + 1.305 * var(--wp--custom--vwc)), 56.16px) 0 0;
  border-top-width: 1px;
}

/* 원문 링크가 없으면 원본 링크 블록이 아무것도 그리지 않아 선이 마지막 자식으로 남는다 */
.tpl-single-post-news .nd-text .wp-block-separator:last-child {
  display: none;
}

.tpl-single-post-news .nd-src {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--xs);
  margin: clamp(17px, calc(15.058px + 0.518 * var(--wp--custom--vwc)), 25px) 0 0;
  padding: 0;
  list-style: none;
}

/* 화살표 간격은 margin으로 — 링크를 flex(gap)로 두면 글자가 줄바꿈될 때 글자 칸이 폭을 다 차지해 화살표가 오른쪽 끝으로 밀린다 */
.tpl-single-post-news .nd-src .thesmc-project-links__arrow {
  margin-left: var(--wp--preset--spacing--xs);
}

.tpl-single-post-news .nd-src a {
  font-family: var(--wp--preset--font-family--pretendard);
  font-weight: 600;
  font-size: clamp(14px, calc(1.08 * var(--wp--custom--vwc)), 16.5px);
  letter-spacing: 0;
  color: var(--wp--preset--color--ink);
}

/* ---------- 첨부 파일 — 첨부 파일 블록(thesmc/news-files, .nd-files). 시안 .nd-files(261012) ----------
   원문 링크 바로 아래, 「파일명 + 내려받기 아이콘」을 세로로. 파일이 없으면 블록이 아무것도 그리지 않는다.
   글자는 원문 링크(.nd-src)와 같고, 아이콘은 글자 크기(1em)를 따라 hover 때 3px 내려간다 */
.tpl-single-post-news .nd-files {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

/* 원문 링크가 없어 분리자 바로 뒤에 오면 원문 링크와 같은 간격으로 */
.tpl-single-post-news .nd-text .wp-block-separator + .nd-files {
  margin-top: clamp(17px, calc(15.058px + 0.518 * var(--wp--custom--vwc)), 25px);
}

/* 아이콘은 글자 흐름 안에 둔다 — flex로 나란히 두면 파일명이 줄바꿈될 때 이름 칸이 폭을 다 차지해 아이콘이 오른쪽 끝으로 밀린다 */
.tpl-single-post-news .nd-files a {
  font-family: var(--wp--preset--font-family--pretendard);
  font-weight: 600;
  font-size: clamp(14px, calc(1.08 * var(--wp--custom--vwc)), 16.5px);
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--wp--preset--color--ink);
  word-break: keep-all;
}

.tpl-single-post-news .nd-files .thesmc-news-files__tail {
  white-space: nowrap; /* 파일명 마지막 글자 + 아이콘(블록이 묶어 준다) — 아이콘만 다음 줄로 넘어가지 않게 */
}

.tpl-single-post-news .nd-files .thesmc-news-files__icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: var(--wp--preset--spacing--xs);
  vertical-align: -0.125em;
  transition: transform var(--thesmc-dur) var(--thesmc-ease);
}

.tpl-single-post-news .nd-files a:hover .thesmc-news-files__icon {
  transform: translateY(3px);
}

@media (prefers-reduced-motion: reduce) {
  .tpl-single-post-news .nd-back a,
  .tpl-single-post-news .nd-back a::before,
  .tpl-single-post-news .nd-files .thesmc-news-files__icon {
    transition: none;
  }
}
