/*
Theme Name: 365 Magazine
Theme URI: https://365everyknowledge.com
Description: GeneratePress 자식 테마. 매거진 시안(고정 카테고리 사이드바 + 카테고리 테마 + 배지 시스템)을 옮긴 것.
Author: 365everyknowledge
Template: generatepress
Version: 1.3.0
*/

/* ──────────────────────────────────────────────
   디자인 토큰 — 시안에서 뽑은 값
   ────────────────────────────────────────────── */
:root {
  --paper: #e7e3d9;
  --card: #f4f1ea;
  --card-2: #efebe2;
  --ink: #16150f;
  --accent: #c7361f;

  --line: rgba(22, 21, 15, 0.12);
  --line-soft: rgba(22, 21, 15, 0.07);
  --muted: rgba(22, 21, 15, 0.45);
  --muted-2: rgba(22, 21, 15, 0.6);

  --serif: "Noto Serif KR", serif;

  /* 'Pretendard Variable' 이 먼저다.
     CDN 의 변수 버전은 패밀리 이름이 'Pretendard Variable' 이라
     'Pretendard' 만 적으면 매칭에 실패해 맑은 고딕으로 떨어진다. */
  --sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo",
    "IBM Plex Sans KR", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --rail: 300px;
  --topbar: 76px;
  --r-sm: 4px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 99px;

  --cat: var(--ink);
}

/* 카테고리 색은 functions.php 가 인라인으로 내려보낸다.
   여기 값은 그게 없을 때의 대비용이다. */
body.cat-money      { --cat: #17554a; }
body.cat-movie      { --cat: #6b2c46; }
body.cat-review     { --cat: #a6531c; }
body.cat-shopping   { --cat: #5b6234; }
body.cat-family     { --cat: #2e3a8c; }
body.cat-beauty     { --cat: #c7361f; }
body.cat-supplement { --cat: #5e2c0e; }

/* ──────────────────────────────────────────────
   바탕
   GeneratePress 가 자체 배경색을 인라인으로 내보내므로 이겨야 한다.
   ────────────────────────────────────────────── */
body,
body.separate-containers,
body.one-container {
  background-color: var(--paper) !important;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.75;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
}

.site-content,
.site.grid-container,
.inside-page-header { background: transparent !important; }

a { color: var(--ink); text-decoration: none; }
a:hover, a:focus { color: var(--accent); }

h1, h2, h3,
.entry-title,
.site-title, .main-title,
.site-title a, .main-title a {
  font-family: var(--serif);
  letter-spacing: -0.025em;
  color: var(--ink);
}

.site-title a, .main-title a { font-weight: 900; }
.entry-title { font-weight: 700; line-height: 1.32; }

/* ──────────────────────────────────────────────
   스크롤바 — 평소엔 숨기고 스크롤 중에만 옅게 보인다
   assets/scroll.js 가 html 에 .is-scrolling 을 붙였다 뗀다.
   ────────────────────────────────────────────── */
html { scrollbar-width: thin; scrollbar-color: transparent transparent; }
html.is-scrolling { scrollbar-color: rgba(22, 21, 15, 0.2) transparent; }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background-color 0.25s ease;
}

html.is-scrolling *::-webkit-scrollbar-thumb,
*:hover::-webkit-scrollbar-thumb { background-color: rgba(22, 21, 15, 0.2); }

/* 어두운 면(상단바) 위에서는 밝은 쪽으로 */
.mag-topbar.is-scrolling *::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.25); }

/* ──────────────────────────────────────────────
   상단 브랜드 바 — 시안의 얼굴
   ────────────────────────────────────────────── */
.mag-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar);
  z-index: 80;
  background: var(--ink);
  display: flex;
  align-items: center;
}

.mag-topbar-inner {
  width: 100%;
  padding: 0 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.mag-brand { display: flex; align-items: baseline; gap: 16px; min-width: 0; }

.mag-brand-ko {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #fff;
}

.mag-brand-en {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: rgba(244, 241, 234, 0.62);
  white-space: nowrap;
}

.mag-brand:hover .mag-brand-ko { color: #fff; }
.mag-brand:hover .mag-brand-en { color: rgba(244, 241, 234, 0.9); }

.mag-search { display: flex; align-items: center; gap: 0; flex: none; }

.mag-search input[type="search"] {
  width: 168px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(244, 241, 234, 0.22);
  border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  background: rgba(244, 241, 234, 0.06);
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
}

.mag-search input::placeholder { color: rgba(244, 241, 234, 0.45); }
.mag-search input:focus { outline: 0; border-color: rgba(244, 241, 234, 0.45); }

.mag-search button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(244, 241, 234, 0.22);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: rgba(244, 241, 234, 0.1);
  color: rgba(244, 241, 234, 0.85);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.mag-search button:hover { background: rgba(244, 241, 234, 0.18); color: #fff; }

/* GeneratePress 기본 헤더와 내비게이션은 상단바가 대신한다 */
.site-header,
.main-navigation { display: none !important; }

/* ──────────────────────────────────────────────
   고정 카테고리 사이드바 — 시안 300px
   ────────────────────────────────────────────── */
.mag-rail {
  background: var(--card-2);
  border-right: 1px solid var(--line);
}

.mag-rail-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px 28px;
}

.mag-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mag-rail-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(22, 21, 15, 0.5);
}

.mag-rail-note { font-size: 10.5px; color: rgba(22, 21, 15, 0.35); }

/* 카테고리 카드 */
.mag-cat {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.mag-cat-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--cat);
  overflow: hidden;
}

/* 시안은 카테고리마다 무늬가 다르다 — 사선과 점 두 가지 */
.mag-cat-head::before { content: ""; position: absolute; inset: 0; }

.mag-cat-head.pat-stripe::before {
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.09) 0 6px,
    transparent 6px 14px
  );
}

.mag-cat-head.pat-dot::before {
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.3px);
  background-size: 9px 9px;
}

.mag-cat-name,
.mag-cat-count { position: relative; }

.mag-cat-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.mag-cat-count { font-size: 10.5px; font-weight: 500; color: rgba(255, 255, 255, 0.7); }
.mag-cat-head:hover .mag-cat-count { color: #fff; }

.mag-cat-list { display: flex; flex-direction: column; }

.mag-cat-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.mag-cat-item:last-child { border-bottom: 0; }
.mag-cat-item:hover { background: var(--card); }

.mag-cat-rank {
  flex: none;
  width: 16px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  color: var(--cat);
  line-height: 1.3;
}

.mag-cat-item:nth-child(n + 2) .mag-cat-rank { opacity: 0.55; }

.mag-cat-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.mag-cat-title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
}

.mag-cat-meta { display: flex; align-items: center; gap: 6px; }

.mag-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--accent);
  padding: 2px 5px;
  border-radius: 2px;
}

.mag-cat-date { font-size: 10.5px; color: var(--muted); }

.mag-cat-empty {
  margin: 0;
  padding: 14px 12px;
  font-size: 12px;
  color: var(--muted);
}

/* 데스크톱: 상단바 아래에 붙여 화면에 고정 */
@media (min-width: 1025px) {
  body.has-mag-rail { padding-top: var(--topbar); padding-left: var(--rail); }

  .mag-rail {
    position: fixed;
    top: var(--topbar);
    left: 0;
    bottom: 0;
    width: var(--rail);
    overflow-y: auto;
    z-index: 60;
  }
}

/* 모바일: 시안 1f — 카드 스택으로 내려온다 */
@media (max-width: 1024px) {
  :root { --topbar: 60px; }

  body.has-mag-rail { padding-top: var(--topbar); }

  .mag-topbar-inner { padding: 0 18px; }
  .mag-brand-ko { font-size: 24px; }
  .mag-brand-en { display: none; }
  .mag-search input[type="search"] { width: 120px; }

  .mag-rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .mag-rail-inner { padding: 16px 14px 20px; }
  .mag-cat-list { display: none; }        /* 목록은 접고 카테고리 헤더만 */
  .mag-cat-head { padding: 14px 16px; }
}

/* ──────────────────────────────────────────────
   헤더 · 네비게이션
   ────────────────────────────────────────────── */
.site-header { background: var(--paper) !important; border-bottom: 1px solid var(--line); }

.main-navigation { background: transparent !important; border-bottom: 1px solid var(--line); }

.main-navigation .main-nav ul li a {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.main-navigation .main-nav ul li a:hover,
.main-navigation .main-nav ul li.current-menu-item a {
  color: var(--accent);
  background: transparent;
}

/* ──────────────────────────────────────────────
   글 카드
   ────────────────────────────────────────────── */
.separate-containers .inside-article,
.one-container .site-main > article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 26px 28px;
}

.separate-containers .site-main > article { margin-bottom: 22px; }

.blog .entry-title,
.archive .entry-title,
.search .entry-title,
.home .entry-title { font-size: clamp(18px, 1.9vw, 21px); margin-bottom: 10px; }

.single .entry-title { font-size: clamp(24px, 2.8vw, 31px); }

.entry-summary p { font-size: 14.5px; line-height: 1.75; color: var(--muted-2); }

.entry-meta { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.entry-meta a { color: var(--muted); }
.entry-meta a:hover { color: var(--accent); }

/* 카테고리 배지 */
.entry-meta .cat-links a,
.cat-links a {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--cat);
  color: #fff !important;
  font-size: 11.5px;
  font-weight: 700;
}

.cat-links a:hover { opacity: 0.86; }

.post-image img, .page-header-image img { border-radius: var(--r-md); display: block; }

/* ──────────────────────────────────────────────
   카테고리 아카이브 헤더
   ────────────────────────────────────────────── */
.mag-archive-head {
  position: relative;
  background: var(--cat);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 30px 30px 26px;
  margin: 0 0 24px;
  overflow: hidden;
}

.mag-archive-head::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08) 0 8px,
    transparent 8px 18px
  );
}

.mag-archive-head h1,
.mag-archive-head p,
.mag-archive-head .mag-count { position: relative; }

.mag-archive-head h1 {
  color: #fff;
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 900;
}

.mag-archive-head p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.82);
  max-width: 640px;
}

.mag-archive-head .mag-count {
  display: inline-block;
  margin-top: 14px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
}

.archive .page-header, .search .page-header { display: none; }

/* ──────────────────────────────────────────────
   오른쪽 사이드바 위젯
   블록 위젯(widget_block)도 함께 잡는다.
   ────────────────────────────────────────────── */
.sidebar .widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.sidebar .widget .widget-title,
.sidebar .widget h2,
.sidebar .widget h3,
.sidebar .widget .wp-block-heading {
  font-family: var(--sans) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em;
  color: var(--muted) !important;
  margin: 0 0 14px !important;
  padding: 0;
  border: 0;
}

.sidebar .widget ul { margin: 0; padding: 0; list-style: none; }

.sidebar .widget li {
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 13.5px;
  line-height: 1.55;
}

.sidebar .widget li:first-child { border-top: 0; padding-top: 0; }
.sidebar .widget li a { font-weight: 500; }

.sidebar .widget .wp-block-search__input {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  font-size: 14px;
}

.sidebar .widget .wp-block-search__button {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
}

@media (min-width: 1025px) {
  .sidebar { align-self: flex-start; position: sticky; top: 24px; }
}

/* ──────────────────────────────────────────────
   글 상세
   목차·관련글은 파이프라인이 본문에 넣는다. 여기선 톤만 맞춘다.
   ────────────────────────────────────────────── */
.single .inside-article { padding: 34px 40px 44px; }

/* 사이드바를 껐으니 본문이 넓어졌다.
   그렇다고 한 줄이 너무 길면 읽기 나쁘므로 읽기 폭만 가운데로 묶는다. */
.single .entry-content > * { max-width: 820px; margin-left: auto; margin-right: auto; }

.single .entry-content > .wp-ig,
.single .entry-content > figure,
.single .entry-content > table { max-width: none; }

/* 본문 글씨 — GeneratePress 기본값이 크다 */
.entry-content p,
.entry-content li { font-size: 15.5px; line-height: 1.85; }

.entry-content h2 { font-size: 21px !important; }
.entry-content h3 { font-size: 16.5px !important; }

.wp-toc {
  background: var(--card-2) !important;
  border-color: var(--line) !important;
  border-radius: var(--r-md) !important;
}

.wp-toc a:hover { color: var(--accent) !important; }
.wp-related { border-top: 2px solid var(--cat); padding-top: 16px; }
.wp-ig figure, .wp-callout { border-radius: var(--r-md) !important; }

.entry-content table {
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
  border-radius: var(--r-md);
  overflow: hidden;
}

.entry-content th { background: var(--card-2); font-weight: 700; text-align: left; }
.entry-content th, .entry-content td { border: 1px solid var(--line); padding: 9px 12px; }

/* ──────────────────────────────────────────────
   페이지네이션 · 푸터
   ────────────────────────────────────────────── */
.paging-navigation .page-numbers {
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--line);
}

.paging-navigation .page-numbers.current {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.site-footer, .footer-widgets {
  background: var(--card) !important;
  border-top: 1px solid var(--line);
}

.site-info { font-size: 12.5px; color: var(--muted); }

/* 푸터의 필수 페이지 링크 */
.mag-footer-nav { padding: 22px 0 4px; text-align: center; }

.mag-footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mag-footer-nav li { font-size: 13px; }

.mag-footer-nav a {
  color: var(--muted-2);
  font-weight: 600;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.mag-footer-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ──────────────────────────────────────────────
   모바일 세부
   ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .separate-containers .inside-article { padding: 20px 18px; }
  .single .inside-article { padding: 24px 18px 30px; }
  .mag-archive-head { padding: 22px 20px 20px; border-radius: var(--r-md); }
  .sidebar .widget { padding: 16px 18px; }
}

/* ──────────────────────────────────────────────
   글 목록 카드 (B안)
   썸네일 왼쪽, 제목 오른쪽. 한 줄에 2개.

   사진을 크게 쓰면 이미지가 제목을 눌러버리고 한 화면에 몇 개 안 들어온다.
   그래서 썸네일 폭을 고정하고 제목이 카드의 주인공이 되게 했다.
   왼쪽 카테고리 레일은 그대로 두고 본문 영역만 바꾼다.
   ────────────────────────────────────────────── */
.mag-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.mag-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  min-width: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.mag-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(22, 21, 15, 0.09);
}

.mag-card:focus-within {
  outline: 2px solid var(--c, var(--accent));
  outline-offset: 2px;
}

/* 카드 전체가 링크다. a 안에 h2 가 들어가므로 색을 다시 잡아준다. */
.mag-card-link,
.mag-card-link:hover,
.mag-card-link:focus {
  display: flex;
  flex-direction: row;
  height: 100%;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.mag-card-link:focus { outline: none; }

/* ── 썸네일 ──
   폭을 고정한다. 세로는 카드 높이를 따라가서 글 길이와 무관하게 줄이 맞는다.
   대표 이미지가 없으면 카테고리 색 무늬가 대신 채운다. */
.mag-card-thumb {
  position: relative;
  width: 124px;
  flex: none;
  align-self: stretch;
  background-color: color-mix(in srgb, var(--c, var(--ink)) 16%, var(--card-2));
  overflow: hidden;
}

.mag-card-thumb.pat-stripe {
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.22) 0 2px,
    transparent 2px 11px
  );
}

.mag-card-thumb.pat-dot {
  background-image: radial-gradient(rgba(255, 255, 255, 0.3) 1.4px, transparent 1.5px);
  background-size: 13px 13px;
}

.mag-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── 글자 ── */
.mag-card-body {
  padding: 13px 15px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  flex: 1;
  min-height: 112px;
}

.mag-card-chip {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--c, var(--ink));
  border: 1px solid color-mix(in srgb, var(--c, var(--ink)) 35%, transparent);
  background: color-mix(in srgb, var(--c, var(--ink)) 7%, transparent);
  padding: 3px 9px;
  border-radius: var(--r-pill);
}

.mag-card-title {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.02em;
  text-wrap: balance;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mag-card:hover .mag-card-title { color: var(--c, var(--accent)); }

.mag-card-meta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mag-empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.mag-empty p { margin: 0; }

/* GeneratePress 가 목록에 붙이는 기본 글 상자는 카드와 겹치므로 감춘다. */
.blog .site-main > .post,
.archive .site-main > .post,
.search .site-main > .post { display: none; }

/* 레일 때문에 본문 폭이 좁아지는 구간. 2열은 유지하고 썸네일만 줄인다. */
@media (max-width: 1100px) {
  .mag-card-thumb { width: 104px; }
  .mag-card-title { font-size: 15px; }
}

@media (max-width: 680px) {
  .mag-cards { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mag-card-thumb { width: 96px; }
  .mag-card-body { min-height: 92px; padding: 12px 14px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .mag-card { transition: none; }
  .mag-card:hover { transform: none; }
}
