/*
Theme Name: FV Article Rail
Theme URI: https://github.com/withoutglass/wp-theme-build
Author: withoutglass
Description: 유튜브→article 서비스용 채널 레일형 테마. 왼쪽 고정 레일(채널 프로필·실시간 TOP) + 본문 + 오른쪽 광고 칼럼, 딥 포레스트 팔레트. MSN 피드 공급 + 광고 수익형 사이트.
Version: 0.4.1
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-rail
Update URI: false
*/

/* 딥 포레스트: 틀(레일·푸터)만 짙게, 바탕은 한 단계 어둡게, 읽는 지면은 밝게. */
:root {
  --rail-width: 280px;
  --paper-width: 760px;
  --stage-width: 920px;
  --bg: #d3dbd5;
  --surface: #ecf0ed;
  --chrome: #1b2a22;
  --text: #16201a;
  --muted: #536259;
  --accent: #7a5a00;
  --on-accent: #ffffff;
  --on-chrome: #e4ece6;
  --chrome-muted: #9db0a4;
  --accent-on-chrome: #e8c24a;
  --line: #d0d9d2;
  --chrome-line: rgba(228, 236, 230, 0.14);
}

* { 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; }

/* ---------- 페이지 골격: 왼쪽 레일 + 본문 영역 ---------- */

.site-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
}

.site-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.site-content {
  flex: 1;
  padding: 2rem 2rem 3rem;
}

/* ---------- 채널 레일 ---------- */

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

/* 레일 내용이 화면보다 길면 레일 안에서만 스크롤 */
.rail-inner {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1.75rem 1.5rem 2rem;
  display: grid;
  /* 모바일 가로 TOP 칩이 칼럼 폭을 밀어내지 않도록 0까지 줄어들게 */
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-content: start;
}

.rail-brand {
  display: grid;
  gap: 0.875rem;
}

.rail-home {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--on-chrome);
  text-decoration: none;
}

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

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

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

.rail-name {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  word-break: keep-all;
}

.rail-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.rail-nav a {
  color: var(--chrome-muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

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

.rail-detail {
  padding-top: 1.25rem;
  border-top: 1px solid var(--chrome-line);
}

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

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

.rail-description {
  margin: 0.5rem 0 0;
  color: var(--chrome-muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.rail-title {
  margin: 0 0 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--chrome-line);
  color: var(--on-chrome);
  font-size: 0.9375rem;
}

.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: top-rank;
}

.top-item {
  counter-increment: top-rank;
  display: flex;
  gap: 0.625rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--chrome-line);
}

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

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

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

/* ---------- Footer (본문 영역 하단) ---------- */

.site-footer {
  background: var(--chrome);
  color: var(--chrome-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--chrome-line);
}

.footer-inner {
  max-width: calc(var(--paper-width) + 200px);
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.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; }

/* ---------- 기사 지면 + 오른쪽 광고 칼럼 ---------- */

.article-stage {
  display: grid;
  grid-template-columns: minmax(0, var(--paper-width));
  justify-content: center;
  gap: 2rem;
  align-items: start;
}

.article-paper {
  background: var(--surface);
  border-radius: 10px;
  padding: 2rem 2.5rem 2.5rem;
}

/* 정적 페이지·404는 article-stage 없이 지면만 쓴다 */
body.page .article-paper,
.error-404.article-paper {
  max-width: var(--paper-width);
  margin: 0 auto;
}

.ad-column { display: none; }

@media (min-width: 1280px) {
  .article-stage { grid-template-columns: minmax(0, var(--paper-width)) 160px; }

  .ad-column { display: block; }

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

/* ---------- 홈·목록 ---------- */

.front-stage,
.list-stage {
  max-width: var(--stage-width);
  margin: 0 auto;
}

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

.weekly-popular,
.latest-articles { padding: 0.25rem 1.75rem 1.75rem; }

.latest-articles { margin-top: 1.5rem; }

.list-stage { padding: 1.5rem 1.75rem 1.75rem; }

/* ---------- 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; }

/* ---------- 홈: 주간 많이 본 기사 (2×2 카드) ---------- */

.weekly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 1.25rem;
}

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

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

.card-title {
  margin: 0.75rem 0 0;
  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;
}

.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-on-chrome);
  color: var(--chrome);
  font-size: 0.875rem;
  font-weight: 800;
}

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

.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: 제목 영역 ---------- */

.single-header {
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--chrome);
}

.single-header .entry-meta { margin: 0; }

.single-title {
  margin: 0.375rem 0 0;
  font-size: 1.875rem;
  line-height: 1.4;
  word-break: keep-all;
}

.btn-original-video {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--chrome);
  color: var(--accent-on-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 { color: var(--on-chrome); }

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

.entry-content {
  margin-top: 0.5rem;
  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-avatar { flex: 0 0 auto; }

.channel-avatar img,
.channel-avatar .channel-avatar-fallback {
  width: 80px;
  height: 80px;
  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: 2rem;
  font-weight: 800;
}

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

.channel-box .channel-description {
  margin: 0.25rem 0 0;
  color: var(--chrome-muted);
  font-size: 0.875rem;
}

/* 레일·채널 박스 공용 SNS 버튼 (둘 다 어두운 바탕) */
.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;
}

.rail-detail .channel-links a { padding: 0.35rem 0.75rem; font-size: 0.75rem; }

.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);
}

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

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

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

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

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

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

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

.next-title {
  color: var(--text);
  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); }

/* ---------- 404 ---------- */

.error-404 .entry-title { margin: 0 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;
}

/* ---------- 태블릿·모바일: 레일 → 상단 채널 바 + 가로 TOP 칩 ---------- */

@media (max-width: 1023px) {
  .site-shell { grid-template-columns: minmax(0, 1fr); }

  .rail-inner {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
  }

  .rail-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .rail-home { flex: 1; }

  .rail-nav { flex: 0 0 auto; }

  .rail-avatar img,
  .rail-avatar-fallback {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }

  .rail-name {
    font-size: 1rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* 채널 소개·SNS 버튼은 홈에서만 */
  .rail-detail { display: none; }

  body.home .rail-detail {
    display: block;
    padding-top: 0.75rem;
  }

  .rail-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .top-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }

  .top-list::-webkit-scrollbar { display: none; }

  .top-item {
    flex: 0 0 auto;
    max-width: 72vw;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.875rem;
    background: var(--chrome-line);
    border-radius: 999px;
  }

  .top-item::before { font-size: 0.8125rem; }

  .top-item a {
    font-size: 0.8125rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .site-content { padding: 1.25rem 1.25rem 2rem; }
}

@media (max-width: 720px) {
  /* 모바일: 지면과 패널은 화면 폭을 꽉 채운다 */
  .site-content { padding: 0 0 1.5rem; }

  .article-paper,
  .weekly-popular,
  .latest-articles,
  .list-stage {
    border-radius: 0;
  }

  .article-paper { padding: 1.5rem 1.25rem 2rem; }

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

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

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

  .weekly-grid { gap: 1.25rem 0.875rem; }

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

  .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; }

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