/*!
 * Naver Blog Feed — front.css
 *
 * 규칙 (TRD §11.1 / 부록 G.4):
 *   - 선택자 특이도 최대 (0,2,0). ID·요소 선택자·!important 전면 금지.
 *   - 모든 클래스 `nbf-` 접두사. 전역 요소 스타일링 금지.
 *   - 모든 값은 `--nbf-*` 커스텀 프로퍼티. 하드코딩 금지.
 *   - ★ 브레이크포인트(min-width / max-width) 미디어쿼리는 이 파일 마지막
 *     RESPONSIVE 섹션에만 존재한다. 기능 질의(@supports, prefers-reduced-motion)는
 *     대상 규칙 옆에 두어야 의미가 분명하므로 FALLBACKS 섹션에 둔다.
 *   - @layer 미사용 (iOS 14 미지원 시 블록 전체가 무시되어 스타일이 통째로 날아감).
 *
 * ★ 관리자 미리보기와 프론트엔드가 이 파일을 함께 사용한다 (CSS SSOT — TRD §1.2).
 */

/* ══════════════════════════ TOKENS ══════════════════════════ */

.nbf {
  /*
   * ★ 인라인 style 로 주입되는 값은 "-pc" 계열이다.
   *
   *   인라인 선언은 스타일시트의 어떤 규칙보다도 우선하므로(미디어쿼리 포함),
   *   --nbf-cols 를 직접 인라인으로 주입하면 아래 RESPONSIVE 재정의가 영원히
   *   적용되지 않는다. 그래서 인라인은 --nbf-cols-pc 만 건드리고,
   *   실제로 쓰이는 --nbf-cols 는 스타일시트가 브레이크포인트별로 계산한다.
   */
  --nbf-cols-pc: 3;
  --nbf-cols-tablet: 2;
  --nbf-cols-mobile: 1;
  --nbf-gap-pc: 24px;

  /* 실사용 값 — RESPONSIVE 섹션에서만 재정의한다 (F-06-5). */
  --nbf-cols: var(--nbf-cols-pc);
  --nbf-gap: var(--nbf-gap-pc);

  --nbf-radius: 12px;
  --nbf-ratio: 16 / 9;
  --nbf-title-lines: 2;
  --nbf-excerpt-lines: 3;
  --nbf-aside-width: 40%;

  /* 색상 — WCAG 2.1 AA 검증 완료 (SA-12) */
  --nbf-accent: #1a6c4f;   /* 흰 배경 대비 5.1:1 */
  --nbf-text: #1f2328;     /* 15.3:1 */
  --nbf-muted: #5b6470;    /* 5.3:1 — 보조 텍스트도 4.5:1 이상 */
  --nbf-bg: #ffffff;
  --nbf-border: #e5e7eb;
  --nbf-thumb-bg: #f3f4f6;

  /*
   * 제목 강조색.
   *
   * 시안 원색은 #32b44c 이지만 흰 배경 대비가 2.70:1 로 WCAG AA 최저선(대형 텍스트 3:1)에
   * 미달한다. 같은 색상(hue)에서 명도만 낮춘 #2fa847 (3.08:1) 을 기본값으로 쓴다.
   * ★ 이 색은 .nbf-text__title 안에서만 사용한다 — 대형 텍스트 기준이 성립하는 유일한 곳이다.
   *
   * 시안 원색이 꼭 필요하면 테마 CSS 에서 한 줄로 재정의할 수 있다.
   *   .nbf { --nbf-highlight: #32b44c; }   (단, AA 미달을 감수하는 선택이다)
   */
  --nbf-highlight: #2fa847;

  /* 텍스트 영역 (2단 좌측) */
  --nbf-logo-height: 36px;
  --nbf-logo-max-width: 88px; /* 원본 87px — 테마가 width 를 늘려도 이 이상 커지지 않는다 */
  --nbf-caption-size: 0.875rem;
  --nbf-aside-title-size: clamp(1.375rem, 1.05rem + 1.15vw, 2rem);

  /* 타이포 — 테마 상속을 기본으로 하고 상대 단위만 쓴다 */
  --nbf-title-size: 1.0625rem;
  --nbf-excerpt-size: 0.9375rem;
  --nbf-date-size: 0.8125rem;
  --nbf-line-height: 1.5;
}

/* ══════════════════════════ BASE ══════════════════════════ */

/*
 * ★ 피드 블록은 shortcode 가 놓인 래퍼의 폭에 정확히 100% 맞춘다.
 *   고정 폭·음수 여백을 쓰지 않으므로 어떤 컨테이너(본문·컬럼·페이지빌더 위젯)에
 *   넣어도 넘치거나 남지 않는다. box-sizing 을 블록 전체에 상속시켜
 *   테마의 전역 box-sizing 설정과 무관하게 계산이 일치하게 한다.
 */
.nbf {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 100%;
  color: var(--nbf-text);
  line-height: var(--nbf-line-height);
}

.nbf *,
.nbf *::before,
.nbf *::after {
  box-sizing: inherit;
}

/* ══════════════════════════ LAYOUT (2단) ══════════════════════════ */

.nbf__inner {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 40px);
  align-items: stretch;
  width: 100%;
  max-width: 100%;
}

.nbf__feed {
  flex: 1 1 auto;
  min-width: 0; /* grid overflow 방지 */
  max-width: 100%;
}

.nbf__aside {
  min-width: 0;
  max-width: 100%;
}

/* ══════════════════════════ TEXT AREA ══════════════════════════ */

.nbf-text {
  max-width: 100%;
}

.nbf-text__logo {
  margin: 0 0 26px;
  line-height: 0;
}

/*
 * ★ 선택자를 `.nbf` 와 묶어 (0,2,0) 으로 올린다.
 *
 * 테마·페이지빌더의 래퍼 안에 넣으면 대개 `.wrapper img { width: 100%; height: auto }`
 * 같은 규칙(0,1,1)이 걸려 있어, 클래스 하나짜리(0,1,0) 규칙이 밀리고 로고가
 * 단 폭 전체로 늘어난다. 상한을 함께 둬서 width 가 강제되더라도 커지지 않는다.
 */
.nbf .nbf-text__logo-img {
  display: block;
  width: auto;
  max-width: var(--nbf-logo-max-width);
  height: var(--nbf-logo-height);
  max-height: var(--nbf-logo-height);
  object-fit: contain;
  object-position: left center;
}

.nbf-text__caption {
  margin: 0 0 10px;
  color: var(--nbf-muted);
  font-size: var(--nbf-caption-size);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nbf-text__title {
  margin: 0 0 0.75em;
  color: var(--nbf-text);
  font-size: var(--nbf-aside-title-size);
  font-weight: 700;
  line-height: 1.45;
  /* 한글은 어절 단위로 줄을 나눈다. 단어 중간에서 끊기지 않게. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

/*
 * 제목 강조 — text_title_html() 이 `*강조*` 표기를 이 span 으로 바꾼다.
 * 대형 텍스트(--nbf-aside-title-size 최소 1.375rem = 22px, 700 weight)에서만
 * 쓰이므로 WCAG 대형 텍스트 3:1 기준이 적용된다 (SA-12).
 */
.nbf-text__accent {
  color: var(--nbf-highlight);
}

.nbf-text__desc {
  margin: 0 0 1.25em;
  color: var(--nbf-muted);
  overflow-wrap: break-word;
}

.nbf-text__html {
  max-width: 100%;
  overflow-wrap: break-word;
}

.nbf-text__html > :first-child {
  margin-top: 0;
}

.nbf-text__html > :last-child {
  margin-bottom: 0;
}

.nbf-text__actions {
  margin: 0;
}

/* 시안: 흰 배경 + 회색 테두리 + 진한 텍스트 + 화살표. 초록을 텍스트에 쓰지 않는다. */
.nbf-text__button {
  --nbf-arrow-shift: 0px;

  display: inline-flex;
  gap: 0.7em;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0.85em 1.5em;
  border: 1px solid var(--nbf-border);
  border-radius: 999px;
  background: var(--nbf-bg);
  color: var(--nbf-text);
  font-size: 0.9375rem;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

/*
 * 화살표 이동을 후손 선택자 대신 커스텀 프로퍼티로 전달한다.
 * `.nbf-text__button:hover .nbf-text__button-icon` 는 특이도 (0,3,0) 으로
 * 상한 (0,2,0) 을 넘기 때문이다 (부록 G.4).
 */
.nbf-text__button:hover {
  --nbf-arrow-shift: 3px;

  border-color: var(--nbf-muted);
  background: var(--nbf-thumb-bg);
  color: var(--nbf-text);
}

.nbf-text__button:focus-visible {
  outline: 2px solid var(--nbf-accent);
  outline-offset: 2px;
}

.nbf-text__button-label {
  min-width: 0;
}

.nbf-text__button-icon {
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  transform: translateX(var(--nbf-arrow-shift, 0px));
  transition: transform 0.15s ease;
}

/* ══════════════════════════ LIST ══════════════════════════ */

.nbf__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nbf__item {
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}

/* ══════════════════════════ GRID ══════════════════════════ */

.nbf--grid .nbf__list {
  display: grid;
  grid-template-columns: repeat(var(--nbf-cols), minmax(0, 1fr));
  gap: var(--nbf-gap);
}

/* ══════════════════════════ CARD ══════════════════════════ */

.nbf-card {
  position: relative; /* 오버레이 링크 기준 (SA-5) */
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--nbf-border);
  border-radius: var(--nbf-radius);
  background: var(--nbf-bg);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.nbf-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
}

.nbf-card__thumb {
  position: relative;
  aspect-ratio: var(--nbf-ratio); /* ★ 비율 고정 = CLS 0 (F-05-7 / G-6) */
  overflow: hidden;
  background: var(--nbf-thumb-bg); /* 로딩 전 자리 표시 */
}

.nbf-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* ★ 비율 불균일 흡수 — crop 만 발생, 찌그러짐 없음 */
  object-position: center;
}

.nbf-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.5em;
  padding: 16px;
}

.nbf-card__title {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--nbf-title-lines);
  font-size: var(--nbf-title-size);
  font-weight: 600;
  line-height: 1.45;
  color: var(--nbf-text);
}

.nbf-card__link {
  color: inherit;
  text-decoration: none;
}

/* 카드 전체를 하나의 링크로 — 접근 가능한 링크는 카드당 1개 (SA-5) */
.nbf-card__link::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
}

.nbf-card__link:hover {
  text-decoration: underline;
}

/* 포커스 표시를 제거하지 않는다 (SA-13) */
.nbf-card__link:focus-visible {
  outline: 2px solid var(--nbf-accent);
  outline-offset: 2px;
}

.nbf-card__date {
  display: block;
  color: var(--nbf-muted);
  font-size: var(--nbf-date-size);
  font-variant-numeric: tabular-nums;
}

.nbf-card__excerpt {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--nbf-excerpt-lines);
  color: var(--nbf-muted);
  font-size: var(--nbf-excerpt-size);
}

/*
 * 읽기 전용 텍스트 — 제목을 화면에 표시하지 않는 구성에서 링크의 이름을 제공한다.
 * display:none 이면 스크린리더도 읽지 않으므로 화면 밖으로 밀어내는 방식을 쓴다.
 */
.nbf-card__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ─── 카드 구성 변형 (프리셋보다 뒤에 와야 오버레이 규칙을 되돌릴 수 있다) ─── */

/* 썸네일 없음 — 텍스트만 */
.nbf-card--no-thumb .nbf-card__body {
  padding: 20px 18px;
}

/*
 * 썸네일만 — 본문이 없으므로 카드 높이를 썸네일 비율이 결정한다.
 * 같은 행의 다른 카드 때문에 카드가 늘어나면 썸네일이 그만큼 함께 늘어나
 * 빈 공간이 생기지 않는다.
 */
.nbf-card--thumb-only .nbf-card__thumb {
  flex: 1 1 auto;
}

/* ══════════════════════════ CAROUSEL ══════════════════════════ */

.nbf-carousel {
  position: relative;
  overflow: hidden;
}

.nbf-carousel .nbf__item {
  height: auto; /* Swiper 슬라이드 높이 균일화 */
}

.nbf-carousel__prev,
.nbf-carousel__next {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid var(--nbf-border);
  border-radius: 999px;
  background: var(--nbf-bg);
  color: var(--nbf-text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.12);
}

.nbf-carousel__prev {
  left: 6px;
}

.nbf-carousel__next {
  right: 6px;
}

.nbf-carousel__prev:focus-visible,
.nbf-carousel__next:focus-visible {
  outline: 2px solid var(--nbf-accent);
  outline-offset: 2px;
}

.nbf-icon {
  width: 20px;
  height: 20px;
}

.nbf-carousel__pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

/* Swiper 페이지네이션 불릿 — 우리 컨테이너 안에서만 스타일링한다 */
.nbf-carousel__pagination .swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--nbf-border);
  opacity: 1;
  cursor: pointer;
}

.nbf-carousel__pagination .swiper-pagination-bullet-active {
  width: 22px;
  background: var(--nbf-accent);
}

/* ────────── scroll-snap 폴백 (F-07-9 / E-10 / S-8 / S-9) ──────────
 *
 * ★ 이 클래스는 서버가 처음부터 부여한다. Swiper 초기화가 성공하면 JS 가 제거한다.
 *   그래서 JS 가 아예 실행되지 않아도(S-9) 가로 스크롤 목록으로 정상 표시된다.
 *
 * ★ 특이도가 (0,2,0) 이므로 Swiper 자체 CSS(`.swiper-wrapper` / `.swiper-slide`,
 *   각각 (0,1,0))보다 항상 우선한다 — 스타일시트 로드 순서에 의존하지 않는다.
 */

.nbf-carousel--native .nbf__list {
  display: flex;
  height: auto;
  gap: var(--nbf-gap);
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  transform: none;
}

.nbf-carousel--native .nbf__item {
  flex: 0 0 calc((100% - var(--nbf-gap) * (var(--nbf-cols) - 1)) / var(--nbf-cols));
  height: auto;
  scroll-snap-align: start;
}

.nbf-carousel--native .nbf-carousel__prev,
.nbf-carousel--native .nbf-carousel__next,
.nbf-carousel--native .nbf-carousel__pagination {
  display: none;
}

/* 폴백 상태에서도 키보드로 스크롤할 수 있다 (§21.2) */
.nbf-carousel--native:focus-visible {
  outline: 2px solid var(--nbf-accent);
  outline-offset: 4px;
}

/* ══════════════════════════ ERROR ══════════════════════════ */

.nbf--error {
  margin: 1.5em 0;
}

.nbf__error {
  padding: 20px 24px;
  border: 1px solid var(--nbf-border);
  border-radius: var(--nbf-radius);
  background: var(--nbf-thumb-bg);
  text-align: center;
}

.nbf__error-text {
  margin: 0;
  color: var(--nbf-muted);
  font-size: 0.9375rem;
}

.nbf__error-admin {
  margin: 10px 0 0;
  color: var(--nbf-muted);
  font-size: 0.8125rem;
}

/* ══════════════════════════ PRESETS (F-11) ══════════════════════════ */

/* 01 기본 Grid — 토큰 기본값 그대로. 추가 규칙 없음. */

/* 02 이미지 중심 Grid — 썸네일 위 텍스트 오버레이 */
.nbf--style-02 {
  --nbf-ratio: 3 / 4;
}

.nbf--style-02 .nbf-card__thumb {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  aspect-ratio: auto;
}

.nbf--style-02 .nbf-card {
  aspect-ratio: var(--nbf-ratio);
}

.nbf--style-02 .nbf-card__body {
  position: relative;
  justify-content: flex-end;
  margin-top: auto;
  padding: 24px 16px 16px;
  /* 최악의 밝은 이미지 기준으로 흰 텍스트 대비를 확보한다 (§21.3) */
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.45) 55%, transparent);
  color: #fff;
}

.nbf--style-02 .nbf-card__title {
  color: #fff;
}

.nbf--style-02 .nbf-card__date {
  color: rgba(255, 255, 255, 0.85);
}

.nbf--style-02 .nbf-card__excerpt {
  display: none;
}

/* 03 텍스트 강조 Grid — 썸네일 축소, 요약 확대 */
.nbf--style-03 {
  --nbf-ratio: 21 / 9;
  --nbf-excerpt-lines: 5;
  --nbf-title-lines: 2;
}

.nbf--style-03 .nbf-card__body {
  padding: 18px 18px 20px;
}

.nbf--style-03 .nbf-card__excerpt {
  font-size: 0.9375rem;
}

/* 04 기본 Carousel — 01과 동일 카드. 추가 규칙 없음. */

/* 05 카드형 Carousel — 그림자·여백 강조 */
.nbf--style-05 {
  --nbf-gap: 28px;
}

.nbf--style-05 .nbf-card {
  border: 0;
  box-shadow: 0 6px 24px rgba(17, 24, 39, 0.1);
}

.nbf--style-05 .nbf-card__body {
  padding: 20px;
}

.nbf--style-05 .nbf-carousel {
  padding: 8px 4px 4px;
  margin: -8px -4px -4px;
}

/* ══════════════════════════ FALLBACKS ══════════════════════════ */

/* aspect-ratio 미지원(구형 Safari) 대비 padding 비율 박스 */
@supports not (aspect-ratio: 1 / 1) {
  .nbf-card__thumb {
    height: 0;
    padding-top: 56.25%; /* 16:9 기본. 다른 비율은 아래 modifier 로 덮는다 */
  }

  .nbf-card__img {
    position: absolute;
    top: 0;
    left: 0;
  }

  .nbf--style-02 .nbf-card__thumb,
  .nbf--style-03 .nbf-card__thumb {
    padding-top: 0;
    height: auto;
  }
}

/* -webkit-line-clamp 미지원 대비 */
@supports not (-webkit-line-clamp: 2) {
  .nbf-card__title {
    max-height: calc(var(--nbf-title-lines) * 1.45em);
  }

  .nbf-card__excerpt {
    max-height: calc(var(--nbf-excerpt-lines) * 1.5em);
  }
}

/* prefers-reduced-motion 존중 (SA-10) */
@media (prefers-reduced-motion: reduce) {
  .nbf-card,
  .nbf-text__button,
  .nbf-text__button-icon {
    transition: none;
  }

  .nbf-card:hover {
    transform: none;
  }

  .nbf-text__button:hover {
    --nbf-arrow-shift: 0px;
  }
}

/* ══════════════════════════ RESPONSIVE ══════════════════════════
 * ★ 브레이크포인트는 이 섹션에만 존재한다 (TRD §11.1).
 *   oneup_v01 테마 체계와 정합: Mobile ≤767px / Tablet 768~1023px / PC ≥1024px
 *   --nbf-cols 하나만 재정의하면 grid 와 carousel-native 폴백이 함께 따라온다 (F-06-5).
 * ════════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
  /* 시안처럼 좌측 텍스트를 우측 피드 높이에 맞춰 세로 가운데 정렬한다. */
  .nbf--two-col .nbf__inner {
    flex-direction: row;
    align-items: center;
    gap: clamp(24px, 4vw, 56px);
  }

  /*
   * 좌측 폭은 %, 우측은 남은 폭 전부. 둘의 합이 항상 래퍼의 100% 다
   * (gap 은 flex 가 계산하므로 넘치지 않는다).
   */
  .nbf--two-col .nbf__aside {
    flex: 0 0 var(--nbf-aside-width);
    max-width: var(--nbf-aside-width);
  }

  /*
   * 좌우 반전 — order 대신 row-reverse 를 쓴다.
   * order 는 시각 순서만 바꾸고 Tab 순서는 DOM 을 따르므로 시각-포커스 순서
   * 불일치(WCAG 2.4.3)를 만든다. row-reverse 도 같은 성질이지만 데스크톱
   * 좌우 배치에 한정되고 모바일에서 해제되므로 영향이 작다 (TRD §11.6).
   */
  .nbf--reverse .nbf__inner {
    flex-direction: row-reverse;
  }
}

@media (max-width: 1023px) {
  .nbf {
    --nbf-cols: var(--nbf-cols-tablet);
  }
}

@media (max-width: 767px) {
  .nbf {
    --nbf-cols: var(--nbf-cols-mobile);
    /* 관리자가 정한 간격을 존중하되 모바일에서는 16px 를 넘기지 않는다. */
    --nbf-gap: min(var(--nbf-gap-pc), 16px);
    --nbf-logo-height: 30px;
  }

  .nbf-card__body {
    padding: 14px;
  }

  .nbf-text__logo {
    margin-bottom: 14px;
  }

  .nbf-text__button {
    padding: 0.8em 1.25em;
  }

  .nbf-carousel__prev,
  .nbf-carousel__next {
    width: 34px;
    height: 34px;
  }

  .nbf-icon {
    width: 17px;
    height: 17px;
  }
}
