/*
Theme Name: FV Article Reader
Theme URI: https://github.com/withoutglass/wp-theme-build
Author: withoutglass
Description: 유튜브→article 서비스용 리더형 1단 테마. 미드나잇 인디고 팔레트, 본문 흐름 안 광고·추천 배치. MSN 피드 공급 + 광고 수익형 사이트.
Version: 0.5.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: fv-article-reader
Update URI: false
*/

/* 미드나잇 인디고: 틀(헤더·히어로·푸터)만 짙게, 바탕은 한 단계 어둡게, 읽는 지면은 밝게. */
:root {
  --max-width: 1080px;
  --stage-width: 920px;
  --read-width: 680px;
  --bg: #d7d8e3;
  --surface: #eeeff5;
  --chrome: #1a1f3a;
  --text: #191c2e;
  --muted: #585d75;
  --accent: #b23a27;
  --on-accent: #ffffff;
  --on-chrome: #e7e8f2;
  --chrome-muted: #9ea3bf;
  --accent-on-chrome: #ff8a70;
  --line: #d3d5e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; }

img { max-width: 100%; height: auto; display: block; }

/* ---------- Header ---------- */

.site-header { background: var(--chrome); }

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.625rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  color: var(--on-chrome);
  text-decoration: none;
  font-weight: 700;
}

.brand-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.brand-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-on-chrome);
  color: var(--chrome);
  font-size: 0.875rem;
}

.brand-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-nav .nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: inline-block;
  padding: 0.25rem 0;
  color: var(--chrome-muted);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover { color: var(--on-chrome); }

/* ---------- Layout ---------- */

/* 히어로 띠가 화면 폭을 채우도록 main은 폭 제한 없이 두고, 안쪽 블록이 각자 폭을 잡는다. */
.site-content { display: block; }

.hero { background: var(--chrome); }

.hero-inner {
  max-width: calc(var(--read-width) + 3rem);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2.25rem;
}

.hero-meta {
  margin: 0;
  color: var(--chrome-muted);
  font-size: 0.875rem;
}

.hero-title {
  margin: 0.5rem 0 0;
  color: var(--on-chrome);
  font-size: 2rem;
  line-height: 1.35;
  word-break: keep-all;
}

/* 기사 상세: 가운데 지면 1단 + (넓은 화면에서만) 오른쪽 여백 광고 */
.reader-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, calc(var(--read-width) + 5rem)) minmax(0, 1fr);
  padding-bottom: 3rem;
}

.reader-column {
  grid-column: 2;
  max-width: calc(var(--read-width) + 5rem);
  width: 100%;
  margin: 0 auto;
  padding: 1rem 2.5rem 2.5rem;
  background: var(--surface);
}

.reader-rail { display: none; }

@media (min-width: 1200px) {
  .reader-rail {
    display: block;
    grid-column: 3;
    padding: 1.5rem 0 0 2rem;
  }

  .ad-slot.ad-slot-rail {
    position: sticky;
    top: 1.5rem;
    width: 160px;
    height: 600px;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* 홈·목록: 지면보다 넓은 무대에 밝은 패널을 쌓는다 */
.front-stage,
.list-stage {
  max-width: calc(var(--stage-width) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.weekly-popular,
.latest-articles,
.list-stage {
  background: var(--surface);
}

.weekly-popular,
.latest-articles {
  margin-top: 2rem;
  padding: 0.25rem 1.75rem 1.75rem;
  border-radius: 10px;
}

.list-stage {
  margin-top: 2rem;
  margin-bottom: 3rem;
  padding-top: 1.5rem;
  border-radius: 10px;
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--chrome);
  color: var(--chrome-muted);
  font-size: 0.8125rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.footer-logo img { max-height: 40px; width: auto; border-radius: 50%; }

.footer-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--on-chrome);
  text-decoration: none;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  margin: 1.25rem 0 0;
  padding: 0;
}

.footer-links li:not(:last-child)::after {
  content: "|";
  margin: 0 0.75rem;
  color: var(--muted);
}

.footer-links a {
  color: var(--on-chrome);
  font-weight: 600;
  text-decoration: none;
}

.footer-links a:hover { color: var(--accent-on-chrome); }

.footer-info {
  margin: 1.25rem 0 0;
  line-height: 1.9;
}

.footer-info span + span::before {
  content: "|";
  margin: 0 0.625rem;
  color: var(--muted);
}

.footer-copyright { margin: 1.5rem 0 0; }

/* ---------- Front page: 채널 히어로 ---------- */

.channel-hero .hero-inner { max-width: calc(var(--stage-width) + 3rem); }

.channel-profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.channel-profile .channel-info {
  flex: 1;
  min-width: 0;
}

.channel-avatar { flex: 0 0 auto; }

.channel-avatar img,
.channel-avatar .channel-avatar-fallback {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-on-chrome);
  color: var(--chrome);
  font-size: 2.25rem;
  font-weight: 800;
}

.channel-name {
  margin: 0;
  color: var(--on-chrome);
  font-size: 1.625rem;
}

.channel-count {
  margin: 0.25rem 0 0;
  color: var(--chrome-muted);
  font-size: 0.9375rem;
}

.channel-count strong {
  color: var(--on-chrome);
  margin-left: 0.25rem;
}

.channel-description {
  margin: 0.5rem 0 0;
  color: var(--chrome-muted);
  font-size: 0.9375rem;
}

/* ---------- Sections ---------- */

.section-title {
  font-size: 1.125rem;
  margin: 2.25rem 0 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 2px solid var(--chrome);
}

.weekly-popular .section-title,
.latest-articles .section-title { margin-top: 1.5rem; }

/* ---------- Front page: 주간 많이 본 기사 (대표 1 + 3) ---------- */

.featured {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-rows: repeat(3, auto);
  gap: 1rem 1.5rem;
}

.featured a {
  color: var(--text);
  text-decoration: none;
}

.featured a:hover .card-title { color: var(--accent); }

.featured-lead { grid-row: 1 / span 3; }

.featured-lead .card-title {
  margin: 0.875rem 0 0;
  font-size: 1.3125rem;
  line-height: 1.45;
  word-break: keep-all;
}

.featured-item a {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 0.875rem;
  align-items: center;
}

.featured-item .card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

/* object-fit은 파일 하단 "썸네일 블러 배경" 블록에서 contain으로 일괄 지정 */
.card-thumb img,
.thumb-placeholder {
  width: 100%;
  height: 100%;
}

.thumb-placeholder { background: var(--line); }

.rank-badge {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.875rem;
  font-weight: 700;
}

/* ---------- 목록 (홈 최신 기사 / 아카이브 / 검색) ---------- */

.list-item {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.list-item:last-of-type { border-bottom: 0; }

.list-thumb {
  flex: 0 0 180px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

.list-thumb img {
  width: 100%;
  height: 100%;
}

.list-body { min-width: 0; }

.list-body .entry-title {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-title a {
  color: var(--text);
  text-decoration: none;
}

.entry-title a:hover { color: var(--accent); }

.entry-summary {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.archive-header { margin-bottom: 0.5rem; }

.archive-title { margin: 0; font-size: 1.375rem; }

.archive-description { color: var(--muted); }

/* ---------- Pagination ---------- */

.front-pagination,
.list-stage .nav-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 1.75rem;
}

.page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
}

a.page-numbers:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-numbers.current {
  background: var(--chrome);
  border-color: var(--chrome);
  color: var(--on-chrome);
  font-weight: 700;
}

.page-numbers.dots {
  border: 0;
  color: var(--muted);
}

/* ---------- Single: 원본 영상 버튼 ---------- */

.btn-original-video {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.25rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--accent-on-chrome);
  color: var(--chrome);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-original-video svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.btn-original-video:hover { background: var(--on-chrome); }

/* ---------- Single: 본문 ---------- */

.entry-content {
  font-size: 1.0625rem;
  line-height: 1.85;
}

.entry-content p { margin: 1.25rem 0; }

.entry-content a { color: var(--accent); }

.entry-content img {
  margin: 1.5rem auto;
  border-radius: 6px;
}

.entry-content figure { margin: 1.5rem 0; }

/* figure가 바깥 여백을 담당하므로 내부 이미지는 여백 없이 캡션과 밀착 */
.entry-content figure img { margin: 0; }

.entry-content figcaption {
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* 광고 슬롯 플레이스홀더 — 실제 광고 코드로 교체 예정 */
.ad-slot {
  margin: 1.75rem 0;
  padding: 2.5rem 1rem;
  background: var(--bg);
  border: 1px dashed var(--muted);
  border-radius: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
}

/* 본문 끝 원본 영상 임베드 */
.video-embed {
  aspect-ratio: 16 / 9;
  margin-top: 2rem;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Single: 채널 박스 (어두운 카드) ---------- */

.channel-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0 0;
  padding: 1.25rem;
  background: var(--chrome);
  border-radius: 10px;
}

.channel-box .channel-info { min-width: 0; }

.channel-box-name {
  margin: 0;
  color: var(--on-chrome);
  font-weight: 700;
}

.channel-box .channel-description {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}

.channel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

.channel-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.channel-links svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.channel-links a:hover { opacity: 0.85; }

.btn-youtube { background: #f00; }

.btn-instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.btn-facebook { background: #1877f2; }

.btn-naver-blog,
.btn-naver-cafe { background: #03c75a; }

/* 카카오 노랑 위에는 흰 글자가 안 보여 브랜드 가이드대로 검은 글자 */
.btn-kakao { background: #fee500; }

.channel-links .btn-kakao { color: #191919; }

.btn-band { background: #1ec800; }

/* 어두운 틀 위에서도 구분되도록 X·틱톡·스레드·메일은 테두리를 둔다 */
.btn-x,
.btn-tiktok,
.btn-threads,
.btn-mail {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--chrome-muted);
}

/* .channel-links a의 흰 글자를 덮어 밝은 틀 팔레트에서도 보이게 */
.channel-links .btn-x,
.channel-links .btn-tiktok,
.channel-links .btn-threads,
.channel-links .btn-mail { color: var(--on-chrome); }

/* ---------- Single: 다음 기사 카드 ---------- */

.next-article {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--chrome);
  border-radius: 10px;
  text-decoration: none;
}

.next-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: var(--muted);
}

.next-thumb img {
  width: 100%;
  height: 100%;
}

.next-body {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.next-label {
  color: var(--accent-on-chrome);
  font-size: 0.8125rem;
  font-weight: 700;
}

.next-title {
  color: var(--on-chrome);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.45;
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.next-article:hover .next-title { text-decoration: underline; }

/* ---------- Single: 함께 볼만한 기사 ---------- */

.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.related-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.related-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

.related-thumb img {
  width: 100%;
  height: 100%;
}

.related-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-item:hover .related-title { color: var(--accent); }

/* ---------- Single: 최근 업로드 영상 ---------- */

.video-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.video-item { text-decoration: none; }

.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 플레이 버튼 오버레이 */
.video-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 42px;
  height: 30px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
}

.video-play::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #fff;
}

.video-item:hover .video-play { background: #f00; }

.video-title {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-item:hover .video-title { color: var(--accent); }

/* ---------- 실시간 TOP 띠 (기사 상세 하단) ---------- */

.top-strip {
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.top-strip-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.5rem 1.5rem 2rem;
}

.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: top-rank;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem;
}

.top-item {
  counter-increment: top-rank;
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.top-item::before {
  content: counter(top-rank);
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.2;
}

.top-item a {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.top-item a:hover { color: var(--accent); }

/* ---------- 정적 페이지 / 404 ---------- */

body.page .reader-column,
.error-404.reader-column {
  margin-bottom: 3rem;
}

.error-404 .entry-title { margin: 1rem 0 0.5rem; }

/* ---------- 썸네일 블러 배경 ----------
   세로형(쇼츠) 썸네일도 잘리지 않게 contain으로 올리고,
   빈 공간은 같은 이미지(--thumb, 템플릿에서 주입)를 블러로 깔아 채운다. */

.card-thumb,
.list-thumb,
.related-thumb,
.next-thumb {
  position: relative;
}

.card-thumb::before,
.list-thumb::before,
.related-thumb::before,
.next-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--thumb);
  background-size: cover;
  background-position: center;
  filter: blur(14px);
  transform: scale(1.15);
}

.card-thumb img,
.list-thumb img,
.related-thumb img,
.next-thumb img {
  position: relative;
  object-fit: contain;
}

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
  .top-list { grid-template-columns: 1fr; gap: 0.75rem; }

  .featured { grid-template-columns: minmax(0, 1fr); }

  .featured-lead { grid-row: auto; }
}

@media (max-width: 720px) {
  .hero-inner { padding: 1.75rem 1.25rem 1.5rem; }

  .hero-title { font-size: 1.5rem; }

  /* 모바일: 지면과 패널은 화면 폭을 꽉 채운다 */
  .reader-column { padding: 0.5rem 1.25rem 2rem; }

  .reader-stage { padding-bottom: 0; }

  .front-stage,
  .list-stage {
    padding-left: 0;
    padding-right: 0;
  }

  .weekly-popular,
  .latest-articles,
  .list-stage {
    border-radius: 0;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .weekly-popular,
  .latest-articles { margin-top: 0.75rem; }

  .list-stage { margin-top: 0; margin-bottom: 0; }

  .channel-profile { gap: 1rem; align-items: flex-start; }

  .channel-avatar img,
  .channel-avatar .channel-avatar-fallback {
    width: 64px;
    height: 64px;
    font-size: 1.75rem;
  }

  .list-body .entry-title { -webkit-line-clamp: 2; }

  .list-thumb { flex-basis: 120px; }

  .related-list { grid-template-columns: minmax(0, 1fr); }

  .next-article { grid-template-columns: 112px minmax(0, 1fr); }

  .next-title { font-size: 0.9375rem; }

  .featured-item a { grid-template-columns: 112px minmax(0, 1fr); }
}
