/* ============================================================
   layout-single.css — DailyFinLab Unified Single/Post
   Scope: Single Post only (opt-in for pages)
   ============================================================ */

/* ------------------------------------------------------------
   1) Container
------------------------------------------------------------ */
body.single #main article.type-post > .inside-article {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
}

/* ------------------------------------------------------------
   2) Header + Meta
------------------------------------------------------------ */
body.single #main article.type-post > .inside-article > .entry-header {
  order: 1;
  margin: 0 0 16px;
}

body.single #main article.type-post .entry-title {
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 8px 0 10px;
}

body.single #main article.type-post .entry-header .entry-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  margin: 6px 0 16px;
}

body.single #main article.type-post .entry-meta a {
  color: var(--muted);
  text-decoration: none;
}

body.single #main article.type-post .entry-meta .cat-links a {
  color: var(--accent);
  font-weight: 700;
}

/* hide tags — 이 선택자 자체가 GP 코어의 .tags-links 보다 훨씬
   구체적(specificity 높음)이라 !important 불필요 */
body.single article.type-post
:is(.entry-header .tags-links,
    .entry-meta .tags-links,
    .entry-footer .tags-links) {
  display: none;
}

/* ------------------------------------------------------------
   3) Featured Image
------------------------------------------------------------ */
body.single #main article.type-post
> .inside-article
> :is(.page-header-image-single, .featured-image) {
  order: 2;
  margin-bottom: 16px;
}

body.single #main article.type-post
:is(.page-header-image-single img, .featured-image img) {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: var(--shadow-base);
  display: block;
}

/* ------------------------------------------------------------
   4) Content Typography
------------------------------------------------------------ */
body.single #main article.type-post > .inside-article > .entry-content {
  order: 3;
}

.entry-content p {
  margin: 0 0 0.5rem 0.5rem;
  /*line-height: 1.9;*/
  font-size: 1rem;
}

.entry-content h2 {
  font-size: 1.8rem;
  margin: 1.4em 0 0.7em;
  font-weight: 800;
}
.entry-content h3 {
  font-size: 1.4rem;
  margin: 1.1em 0 0.5em 0.2rem;
  font-weight: 700;
}

.entry-content a {
  color: var(--link);
  text-decoration: none;
}
.entry-content a:hover {
  text-decoration: underline;
}

.entry-content img {
  max-width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin-bottom: 10px;
}

.entry-content figcaption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

.entry-content hr {
  height: 1px;
  border: 0;
  background: var(--divider);
  margin: 24px 0;
}

.entry-content blockquote {
  margin: 1.8em 0;
  padding: 20px 24px;
  background: var(--page-bg);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-base);
  font-style: italic;
  position: relative;
}

.entry-content blockquote::before {
  content: "“";
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 34px;
  color: var(--accent);
  opacity: 0.18;
}

/* code */
.entry-content pre {
  background: #0f172a;
  color: #e5e7eb;
  padding: 14px 16px;
  border-radius: 10px;
  overflow: auto;
}

/* tables */
.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
}

.entry-content th,
.entry-content td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
}

.entry-content thead th {
  background: var(--card-bg);
  font-weight: 700;
}

/* ------------------------------------------------------------
   5) Easy TOC (Single only) - Modern Card Style
------------------------------------------------------------ */

/* TOC Container - 블로그 카드 스타일과 통일 */
body.single-post .entry-content #ez-toc-container {
  max-width: 720px;
  margin: 32px auto;
  padding: 22px 26px 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow-base);
  transition: all 0.2s ease;
}

body.single-post .entry-content #ez-toc-container:hover {
  box-shadow: var(--shadow-hover);
}

/* TOC Title */
#ez-toc-container .ez-toc-title-container {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#ez-toc-container .ez-toc-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  display: flex;
  align-items: center;
}

/* TOC Toggle Button - 세련된 Chevron 아이콘 */
#ez-toc-container .ez-toc-title-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-right: 0;
  background: transparent;
  border: 1px solid var(--divider);
  border-radius: 6px;
  position: relative;
}

#ez-toc-container .ez-toc-title-toggle:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--link);
}

/* 키보드 포커스 스타일 (접근성) */
#ez-toc-container .ez-toc-title-toggle:focus {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

#ez-toc-container .ez-toc-title-toggle:focus:not(:focus-visible) {
  outline: none;
}

#ez-toc-container .ez-toc-title-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* 기존 토글 텍스트/아이콘 숨기기
   Easy TOC 플러그인 자체 CSS/JS 가 이 요소들을 직접 제어하므로
   (우리가 로드 순서를 보장할 수 없는 외부 플러그인) !important 로 확실히 이긴다. */
#ez-toc-container .ez-toc-title-toggle span,
#ez-toc-container .ez-toc-title-toggle svg,
#ez-toc-container .ez-toc-title-toggle i {
  display: none !important;
}

/* 커스텀 Chevron 아이콘 생성 (CSS only) */
#ez-toc-container .ez-toc-title-toggle::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--link);
  border-bottom: 2px solid var(--link);
  transform: rotate(45deg);
  margin-top: -3px;
  transition: all 0.2s ease;
}

/* 닫힌 상태 (Chevron Down) */
#ez-toc-container.ez-toc-collapsed .ez-toc-title-toggle::before {
  transform: rotate(45deg);
  margin-top: -3px;
}

/* 열린 상태 (Chevron Up) */
#ez-toc-container:not(.ez-toc-collapsed) .ez-toc-title-toggle::before {
  transform: rotate(-135deg);
  margin-top: 2px;
}

#ez-toc-container .ez-toc-title-toggle:hover::before {
  border-color: var(--link);
}

/* TOC List - 부드러운 애니메이션 */
#ez-toc-container nav {
  max-height: 2000px;
  opacity: 1;
  overflow: hidden;
  visibility: visible;
  pointer-events: auto;
}

/* JavaScript로 loaded 클래스가 추가된 후에만 transition 활성화 */
#ez-toc-container.ez-toc-loaded nav {
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              visibility 0s linear;
}

#ez-toc-container.ez-toc-collapsed nav {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#ez-toc-container.ez-toc-loaded.ez-toc-collapsed nav {
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              visibility 0s linear 0.3s;
}

#ez-toc-container nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#ez-toc-container nav ul li {
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* TOC Links - 모던하고 깔끔한 스타일 (점 제거) */
#ez-toc-container nav ul li a {
  display: block;
  padding: 7px 10px;
  color: var(--text);
  text-decoration: none !important;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 6px;
  transition: all 0.15s ease;
  position: relative;
}

/* 호버 효과 */
#ez-toc-container nav ul li a:hover {
  background: rgba(37, 99, 235, 0.06);
  color: var(--link);
  padding-left: 14px;
  text-decoration: none !important;
}

/* 계층 구조 - 2단계 (h3) */
#ez-toc-container nav ul ul {
  margin-left: 18px;
  margin-top: 2px;
  margin-bottom: 2px;
}

#ez-toc-container nav ul ul li a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 10px;
  opacity: 0.9;
}

#ez-toc-container nav ul ul li a:hover {
  opacity: 1;
}

/* 계층 구조 - 3단계 (h4) */
#ez-toc-container nav ul ul ul {
  margin-left: 18px;
}

#ez-toc-container nav ul ul ul li a {
  font-size: 13px;
  color: var(--muted);
  padding: 5px 8px;
  opacity: 0.85;
}

#ez-toc-container nav ul ul ul li a:hover {
  opacity: 1;
}

/* 현재 활성화된 링크 (스크롤 위치) */
#ez-toc-container nav ul li.active > a,
#ez-toc-container nav ul li a.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--link);
  font-weight: 600;
  border-left: 3px solid var(--link);
  padding-left: 10px;
  opacity: 1 !important;
}

/* 모바일 반응형 */
@media (max-width: 640px) {
  body.single-post .entry-content #ez-toc-container {
    margin: 28px 0;
    padding: 20px 20px 22px;
    border-radius: 12px;
  }

  #ez-toc-container .ez-toc-title {
    font-size: 17px;
  }

  /* 모바일 터치 타겟 크기 확대 (접근성) */
  #ez-toc-container .ez-toc-title-toggle {
    width: 44px;
    height: 44px;
  }

  /* TOC 스크롤 가능 영역 제한 (열린 상태일 때만) */
  #ez-toc-container:not(.ez-toc-collapsed) nav {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #ez-toc-container nav ul li a {
    font-size: 14px;
    padding: 7px 10px;
    padding-left: 18px;
  }

  #ez-toc-container nav ul ul li a {
    font-size: 13px;
  }
}


/* ------------------------------------------------------------
   6) Previous / Next Navigation - Modern Card Style
------------------------------------------------------------ */
.dfl-post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 48px 0 40px;
  max-width: 720px;
  width: 100%;
}

.dfl-post-navigation a {
  min-height: 120px;
  max-height: 120px;
  padding: 20px 24px;
  background: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: var(--shadow-base);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.dfl-post-navigation a:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.12);
}

/* 이전글 (왼쪽) */
.dfl-post-navigation .nav-previous a {
  text-align: left;
}

/* 다음글 (오른쪽) */
.dfl-post-navigation .nav-next a {
  text-align: right;
}

/* 레이블 ("이전 글" / "다음 글") */
.dfl-post-navigation a::before {
  content: attr(data-label);
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  transition: all 0.2s ease;
}

.dfl-post-navigation .nav-previous a::before {
  content: "← 이전 글";
}

.dfl-post-navigation .nav-next a::before {
  content: "다음 글 →";
}

/* 호버 시 라벨에만 밑줄 */
.dfl-post-navigation a:hover::before {
  text-decoration: underline;
  color: var(--accent);
}

/* 글 제목 - 2줄 제한 + ellipsis (블로그 카드와 동일한 방식) */
.dfl-post-navigation a span {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  /* 2줄 제한 + ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  text-align: left;
}

.dfl-post-navigation a:hover span {
  color: var(--text);
}

/* ------------------------------------------------------------
   7) Mobile (Single only) - 최적 가독성
------------------------------------------------------------ */
@media (max-width: 640px) {
  /* 싱글포스트 컨테이너 모바일 최적화 - 패딩 축소 */
  body.single #main article.type-post > .inside-article {
    padding: 0 4px;
    max-width: 100%;
  }

  /* 제목 크기 최적화 */
  body.single #main article.type-post .entry-title {
    font-size: clamp(26px, 6vw, 32px);
    line-height: 1.3;
    margin: 12px 0 14px;
  }

  /* 메타 정보 */
  body.single #main article.type-post .entry-header .entry-meta {
    font-size: 14px;
    margin: 8px 0 20px;
  }

  /* 본문 텍스트 최적 크기 (17px = 모바일 최적 가독성) */
  body.single .entry-content p,
  body.single .entry-content li {
    font-size: 17px;
    line-height: 1.75;
    margin-bottom: 1.2em;
  }

  /* 제목 크기 최적화 */
  body.single .entry-content h2 {
    font-size: 24px;
    line-height: 1.4;
    margin: 1.8em 0 0.9em;
    font-weight: 800;
  }

  body.single .entry-content h3 {
    font-size: 20px;
    line-height: 1.4;
    margin: 1.5em 0 0.7em;
    font-weight: 700;
  }

  body.single .entry-content h4 {
    font-size: 18px;
    line-height: 1.4;
    margin: 1.3em 0 0.6em;
    font-weight: 700;
  }

  /* 링크 */
  body.single .entry-content a {
    font-size: inherit;
  }

  /* 이미지 */
  body.single .entry-content img,
  body.single .entry-content figure {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1.5em;
  }

  body.single .entry-content figcaption {
    font-size: 13px;
    margin-top: 8px;
  }

  /* 테이블 */
  body.single .entry-content table {
    display: block;
    overflow-x: auto;
    font-size: 15px;
  }

  /* 인용구 */
  body.single .entry-content blockquote {
    font-size: 16px;
    padding: 18px 20px;
    margin: 2em 0;
  }

  /* 코드 */
  body.single .entry-content pre {
    font-size: 14px;
    padding: 12px 14px;
    overflow-x: auto;
  }

  /* 네비게이션 - 모바일 세로 배치 */
  .dfl-post-navigation {
    flex-direction: column;
    gap: 16px;
    margin: 40px 0 32px;
  }

  .dfl-post-navigation a {
    min-height: 100px;
    padding: 18px 20px;
  }

  .dfl-post-navigation a span {
    font-size: 15px;
  }

  /* 배경 색상 통일 - 좌우 패딩 축소 */
  body.single .inside-article {
    background: var(--page-bg);
    padding: 20px 8px;
  }
}

/* ------------------------------------------------------------
   8) Background sync (Single only)
------------------------------------------------------------ */
body.single {
  background: var(--page-bg);
}
body.single .inside-article {
  background: var(--page-bg);
  padding: 28px 16px;
}

/* ===========================================================
   9) 가로 모드 최적화 (Landscape)
=========================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  body.single #main article.type-post > .inside-article {
    max-width: 100%;
    padding: 0 12px;
  }

  body.single #main article.type-post .entry-title {
    font-size: clamp(20px, 3.5vw, 28px);
    margin: 8px 0 8px;
  }

  body.single #main article.type-post .entry-header .entry-meta {
    font-size: 13px;
    margin: 4px 0 12px;
  }

  body.single #main article.type-post
  :is(.page-header-image-single img, .featured-image img) {
    max-height: 200px;
    margin-bottom: 12px;
  }

  body.single #main article.type-post > .inside-article > .entry-content {
    margin-bottom: 12px;
  }

  body.single .entry-content p,
  body.single .entry-content li {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 0.8em;
  }

  body.single .entry-content h2 {
    font-size: 20px;
    margin: 1.2em 0 0.5em;
  }

  body.single .entry-content h3 {
    font-size: 18px;
    margin: 1em 0 0.4em;
  }

  body.single .entry-content blockquote {
    padding: 14px 16px;
    margin: 1.2em 0;
    font-size: 14px;
  }

  body.single .entry-content pre {
    font-size: 12px;
    padding: 10px 12px;
  }

  /* TOC 축소 */
  body.single-post .entry-content #ez-toc-container {
    margin: 16px 0;
    padding: 14px 16px 16px;
  }

  #ez-toc-container .ez-toc-title {
    font-size: 15px;
  }

  #ez-toc-container .ez-toc-title-toggle {
    width: 32px;
    height: 32px;
  }

  #ez-toc-container nav ul li a {
    font-size: 13px;
    padding: 5px 8px;
  }

  /* 네비게이션 축소 */
  .dfl-post-navigation {
    gap: 12px;
    margin: 24px 0 16px;
  }

  .dfl-post-navigation a {
    min-height: 80px;
    padding: 14px 16px;
  }

  .dfl-post-navigation a::before {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .dfl-post-navigation a span {
    font-size: 14px;
  }

  body.single .inside-article {
    padding: 16px 12px;
  }
}

/* ===========================================================
   10) 초소형 가로 모드 (max-height: 400px)
=========================================================== */
@media (max-height: 400px) and (orientation: landscape) {
  body.single #main article.type-post .entry-title {
    font-size: clamp(18px, 2.5vw, 24px);
    margin: 6px 0 6px;
  }

  body.single #main article.type-post .entry-header .entry-meta {
    font-size: 12px;
    margin: 2px 0 8px;
  }

  body.single #main article.type-post
  :is(.page-header-image-single img, .featured-image img) {
    max-height: 150px;
    margin-bottom: 8px;
  }

  body.single .entry-content p,
  body.single .entry-content li {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 0.6em;
  }

  body.single .entry-content h2 {
    font-size: 18px;
    margin: 0.8em 0 0.3em;
  }

  body.single .entry-content h3 {
    font-size: 16px;
    margin: 0.7em 0 0.2em;
  }

  .dfl-post-navigation {
    gap: 8px;
    margin: 16px 0 8px;
  }

  .dfl-post-navigation a {
    min-height: 70px;
    padding: 10px 12px;
  }

  .dfl-post-navigation a span {
    font-size: 13px;
  }

  body.single .inside-article {
    padding: 12px 10px;
  }
}
