/* =============================================
   style.css - signal-worth.com 블로그
   라이트 테마 / 애드센스 최적화
   ============================================= */

/* ---------- 기본 리셋 & 변수 ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text-primary: #1a202c;
  --color-text-secondary: #4a5568;
  --color-text-muted: #718096;
  --color-accent: #2b6cb0;
  --color-accent-hover: #2c5282;
  --color-tag-bg: #ebf8ff;
  --color-tag-text: #2b6cb0;
  --color-up: #e53e3e;
  --color-down: #3182ce;
  --color-neutral: #718096;
  --color-ad-bg: #f7fafc;
  --color-ad-border: #bee3f8;

  --font-base: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'Courier New', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);

  --container-width: 1100px;
  --content-width: 720px;
  --sidebar-width: 300px;
}

html { font-size: 16px; }

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.7;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

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

/* ---------- 레이아웃 ---------- */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* 본문 + 사이드바 2열 */
.layout-wrap {
  display: flex;
  gap: 40px;
  margin-top: 32px;
  align-items: flex-start;
}

.main-content {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
}

/* ---------- 헤더 ---------- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.5px;
}

.site-logo span {
  color: var(--color-text-primary);
}

.site-nav a {
  margin-left: 24px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}
.site-nav a:hover { color: var(--color-accent); text-decoration: none; }

/* ---------- 광고 영역 ---------- */

/* 광고 1: 상단 배너 (헤더 바로 아래) */
.ad-top-banner {
  background: var(--color-ad-bg);
  border-top: 1px solid var(--color-ad-border);
  border-bottom: 1px solid var(--color-ad-border);
  padding: 12px 0;
  text-align: center;
  min-height: 0px;
}

/* 광고 2: 사이드바 광고 */
.ad-sidebar {
  background: var(--color-ad-bg);
  border: 1px solid var(--color-ad-border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  min-height: 0px;
  margin-bottom: 24px;
}

.ad-sidebar-sticky {
  position: sticky;
  top: 80px; /* 헤더 높이만큼 */
}

/* 광고 3: 하단 광고 (본문 끝) */
.ad-bottom {
  background: var(--color-ad-bg);
  border: 1px solid var(--color-ad-border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  min-height: 0px;
  margin: 40px 0 24px;
}

/* 광고 라벨 (애드센스 정책 대응) */
.ad-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

/* ---------- 메인 페이지 - 글 목록 ---------- */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

.hero {
  margin: 8px 0 16px;
}

.hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.date-section {
  margin-top: 18px;
}

.related-posts + .date-section {
  margin-top: 24px;
}

.date-section h2 {
  margin: 0 0 10px;
  font-size: 1.0625rem;
  color: var(--color-accent);
}

/* 메인 상단 날짜(예: 2026.04.18): 기본 대비 약 3단계 확대, 색상 동일(파란 계열) */
.today-section > h2 {
  font-size: 1.8125rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
  color: var(--color-accent);
}

.today-section {
  margin-bottom: 20px;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card-tag {
  display: inline-block;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.post-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.post-card-summary {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-card-date {
  color: var(--color-text-muted);
}

/* 메인 인덱스: 날짜 + 제목 한 줄, 납작한 카드 */
.today-section .cards {
  gap: 6px;
}

.today-section .cards .post-card {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.today-section .cards .post-card:hover {
  transform: translateY(-1px);
}

.post-card-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.today-section .cards .post-card-line .post-card-date {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.today-section .cards .post-card-line .post-card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  min-width: 0;
  flex: 1;
  color: var(--color-text-primary);
}

.post-card-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-accent);
}

.archive-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.archive-date-section {
  width: 100%;
}

.archive-date-toggle {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-primary);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.archive-arrow {
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.archive-date-toggle[aria-expanded="true"] .archive-arrow {
  transform: rotate(90deg);
}

.archive-date-panel {
  margin-top: 8px;
}

.empty {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ---------- 상세 페이지 ---------- */
/* 상단 사이트 제목 박스: 아래 .post-header(글 제목)와 동일 너비·박스 톤 */
.post-header-nav-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.post-header-nav-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.post-header-nav-home {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  padding: 6px 16px;
  border: 1px solid var(--color-accent);
  border-radius: 20px;
}

.post-header-nav-home:hover {
  background: var(--color-tag-bg);
  text-decoration: none;
}

.post-header {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.post-title {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 0;
  color: var(--color-text-primary);
}

/* 본문 섹션 */
.post-body {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.post-body h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}

.post-body h2:first-child { margin-top: 0; }

.post-body p {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-bottom: 14px;
  line-height: 1.8;
}

/* 주식 데이터 테이블 */
.stock-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.875rem;
}

.stock-table th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
}

.stock-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.stock-table tr:hover td { background: var(--color-bg); }

/* 등락률 색상 */
.up   { color: var(--color-up);  font-weight: 600; }
.down { color: var(--color-down); font-weight: 600; }
.neutral { color: var(--color-neutral); }

/* 시황 요약 박스 */
.summary-box {
  background: var(--color-tag-bg);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  font-weight: 500;
}

/* 섹터 배지 */
.sector-badge {
  display: inline-block;
  background: #edf2f7;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  margin: 2px;
}

/* 상한가 강도 표시 */
.limit-strong  { color: #c53030; font-weight: 700; }
.limit-chase   { color: #d69e2e; font-weight: 600; }
.limit-closing { color: #718096; font-weight: 500; }

/* ---------- 사이드바 위젯 ---------- */
.sidebar-widget {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.sidebar-widget-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.recent-post-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.recent-post-item:last-child { border-bottom: none; }

.recent-post-item a {
  color: var(--color-text-primary);
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.recent-post-item a:hover { color: var(--color-accent); text-decoration: none; }

.recent-post-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ---------- 관련글 (내부 링크 SEO) ---------- */
.related-posts {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

.related-posts-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-text-primary);
}

.related-post-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-primary);
  font-weight: 500;
}

.related-post-link:last-child { border-bottom: none; }
.related-post-link:hover { color: var(--color-accent); text-decoration: none; }

.related-post-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-right: 8px;
  flex-shrink: 0;
}

.related-post-title-text {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  font-weight: 500;
}

.accordion-header {
  cursor: pointer;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-body {
  display: none;
  padding: 8px 0;
}

.accordion-body.open {
  display: block;
}

/* ---------- 날짜 페이지네이션 + 아코디언 (메인·포스트 공통) ---------- */
.date-pagination {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 12px;
  max-width: 100%;
}

.date-pagination-nav {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.date-chip-list {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  padding: 2px 0 4px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.date-page-btn {
  flex-shrink: 0;
  min-width: 40px;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.date-page-btn:hover:not(:disabled):not(.is-disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.date-page-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.date-page-btn:disabled,
.date-page-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.date-chip {
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 40px;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
}

.date-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.date-chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.date-chip.is-active {
  background: var(--color-tag-bg);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.date-chip.is-hidden {
  display: none;
}

.date-chip[hidden] {
  display: none !important;
}

.date-accordion-wrap {
  margin-top: 10px;
}

.date-accordion-panel {
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
}

.date-accordion-panel[hidden] {
  display: none !important;
}

.date-accordion-panel .related-post-link {
  padding: 9px 0;
}

/* ---------- 푸터 ---------- */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 32px 0;
  margin-top: 60px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.site-footer a {
  color: var(--color-text-muted);
  margin: 0 10px;
}

/* ---------- 반응형 ---------- */
@media (max-width: 768px) {
  .layout-wrap {
    flex-direction: column;
    gap: 0;
  }

  .sidebar {
    display: none;
  }

  .ad-sidebar-sticky {
    position: static;
  }

  .container {
    padding: 0 12px;
    box-sizing: border-box;
  }

  .main-content {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .post-header-nav-wrap,
  .post-header-nav,
  .post-header,
  .post-body {
    padding: 16px 14px;
    box-sizing: border-box;
    width: 100%;
  }

  .post-header-nav-title {
    font-size: 1rem;
  }

  .post-title {
    font-size: 1.2rem;
    word-break: keep-all;
    line-height: 1.5;
  }

  .post-body p,
  .post-body h2 {
    word-break: keep-all;
    overflow-wrap: break-word;
  }

  .stock-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .wrap {
    padding: 16px 14px 28px;
  }

  .hero h1 {
    font-size: 1.25rem;
  }

  .today-section > h2 {
    font-size: 1.5rem;
  }

  .cards {
    gap: 10px;
  }

  .date-pagination {
    padding: 10px;
  }

  .date-pagination-nav {
    gap: 6px;
  }

  .date-page-btn {
    min-width: 38px;
    min-height: 38px;
    font-size: 0.85rem;
  }

  .date-chip {
    font-size: 0.75rem;
    padding: 7px 10px;
    min-height: 38px;
  }

  .date-chip-list {
    gap: 5px;
  }

  .site-nav { display: none; } /* 모바일 메뉴는 추후 확장 */
}

@media (min-width: 768px) {
  .wrap {
    padding: 24px 20px 36px;
  }

  .hero h1,
  .post-header-nav-title {
    font-size: 1.625rem;
  }

  .cards {
    gap: 12px;
  }
}