@import url("fonts.css");

/* =========================================================
   Tovia 1.2.0 — 디자인 명세 v0.1 기준
   색: 먹색 + 형광펜 하나. 그림자 없음. 깊이는 선과 배경으로.
   ========================================================= */
:root {
  --paper: #ffffff;
  --surface: #f4f5f3;
  --surface-2: #eceee9;
  --ink: #15171c;
  --ink-soft: #3a3f49;
  --muted: #6b7280;
  --rule: #e2e4e0;
  --rule-strong: #c9ccc5;
  --mark: #fbe489;
  --mark-deep: #f5d35a;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans KR", monospace;
  --reading: 38rem;
  --shell: 72rem;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 5.5rem); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  letter-spacing: -0.004em;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
button, input { font: inherit; }

.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 4px; text-decoration: none; }
main:focus { outline: none; }

.shell { width: min(100% - 2.5rem, var(--shell)); margin-inline: auto; }
@media (max-width: 40rem) { .shell { width: calc(100% - 2rem); } }

/* ---------- 공통 조각 ---------- */
.mark { background: linear-gradient(to top, var(--mark) 46%, transparent 46%); padding: 0 .12em; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem; font-size: .9375rem; font-weight: 600;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
  padding: .65rem 1.15rem; border-radius: 4px; text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn:hover { opacity: .88; }
.pbtn {
  font-size: .8125rem; font-weight: 600; padding: .45rem .8rem; border-radius: 4px;
  border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); cursor: pointer; line-height: 1.4;
}
.pbtn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pbtn:hover { opacity: .85; }
.pbtn.is-done { background: var(--mark); border-color: var(--mark-deep); color: var(--ink); }
.sec-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.5rem; }
.sec-head h2 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.4; margin: 0; }
.sec-head p { margin: 0; color: var(--muted); font-size: .9375rem; }
.sec-head .more { margin-left: auto; font-size: .875rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.sec-head .more:hover { color: var(--ink); }

/* ---------- 헤더 ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(140%) blur(10px); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.admin-bar .site-header { top: calc(env(safe-area-inset-top, 0px) + 32px); }
@media (max-width: 782px) { .admin-bar .site-header { top: env(safe-area-inset-top, 0px); } }
.header-inner { display: flex; align-items: center; gap: 1.5rem; height: 4.25rem; position: relative; }
.brand {
  font-weight: 700; font-size: 1.3125rem; letter-spacing: -0.03em; line-height: 1;
  text-decoration: none; color: var(--ink); display: inline-flex; align-items: baseline; gap: .1em;
}
.brand i { font-style: normal; width: .34em; height: .34em; border-radius: 50%; background: var(--mark-deep); display: inline-block; }
.primary-nav { margin-left: auto; display: flex; gap: 1.75rem; align-items: center; }
.primary-nav a {
  text-decoration: none; font-size: .9375rem; color: var(--ink-soft);
  padding: .35rem 0; position: relative; z-index: 0;
}
.primary-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .3rem; height: .5rem;
  background: var(--mark); opacity: 0; z-index: -1; transform: scaleX(.8);
  transition: opacity .15s ease, transform .15s ease;
}
.primary-nav a:hover { color: var(--ink); }
.primary-nav a:hover::after, .primary-nav a[aria-current]::after { opacity: 1; transform: none; }
.primary-nav a[aria-current] { color: var(--ink); font-weight: 600; }
@media (max-width: 40rem) { .primary-nav { gap: 1rem; } }

/* ---------- 홈 히어로 ---------- */
.hero { padding: 4.5rem 0 3.75rem; border-bottom: 1px solid var(--rule); }
.hero-copy { max-width: 36rem; }
.hero h1 { font-size: clamp(2.1rem, 4.4vw, 3.1rem); line-height: 1.22; font-weight: 700; letter-spacing: -0.04em; margin: 0 0 1.25rem; }
.hero-copy p { margin: 0 0 1.75rem; color: var(--ink-soft); max-width: 30rem; }
.hero .search-form { max-width: 32rem; }
@media (max-width: 52rem) { .hero { padding: 2.75rem 0 2.5rem; } }

.home-section { padding-top: 3.5rem; }
.empty-state { padding: 2rem 0; border-top: 1px solid var(--rule); color: var(--muted); }
.empty-state p { margin: 0 0 .3rem; }
.empty-state strong { color: var(--ink); }

/* ---------- 아티클 카드 ---------- */
.cards { display: grid; }
.card {
  display: grid; grid-template-columns: 15rem 1fr; gap: 1.75rem; align-items: start;
  padding: 1.75rem 0; border-bottom: 1px solid var(--rule); position: relative;
}
.cards > .card:first-child { border-top: 1px solid var(--rule); }
.card-thumb {
  display: block; aspect-ratio: 16 / 10; border-radius: 5px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--rule);
}
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-thumb-empty {
  display: flex; flex-direction: column; justify-content: flex-end; gap: .45rem; height: 100%; padding: .9rem 1rem;
  font-size: .8125rem; font-weight: 600; color: var(--ink-soft); background: var(--surface-2);
}
.card-thumb-empty::before { content: ""; width: 2rem; height: .45rem; background: var(--mark-deep); }
.card-title { margin: .5rem 0 .5rem; font-size: 1.1875rem; line-height: 1.45; font-weight: 600; letter-spacing: -0.025em; }
.card-title a { text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; } /* 카드 전체 클릭 */
.card:hover .card-title span { box-shadow: inset 0 -.5em 0 var(--mark); }
.card-excerpt {
  margin: 0; color: var(--muted); font-size: .9375rem; line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; gap: .9rem; align-items: center; margin-top: .8rem; font-size: .8125rem; color: var(--muted); }
.card-meta time { font-family: var(--mono); font-size: .75rem; }
@media (max-width: 46rem) {
  .card { grid-template-columns: 1fr; gap: 1rem; }
  .card-thumb { aspect-ratio: 16 / 9; }
}

/* ---------- 목록·검색 ---------- */
.archive { padding-top: 3rem; }
.archive-head { margin-bottom: 1.75rem; }
.archive-head h1 { font-size: clamp(1.75rem, 3.6vw, 2.25rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.3; margin: .25rem 0 .5rem; }
.archive-head p, .archive-desc { margin: 0; color: var(--muted); }
.archive-desc p { margin: 0; }
.archive-tools { display: grid; gap: 1rem; margin-bottom: 2rem; }
.search-form { display: flex; gap: .5rem; max-width: 40rem; }
.search-form input[type="search"] {
  flex: 1; min-width: 0; padding: .7rem .95rem; border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--paper); color: var(--ink); font-size: 1rem;
}
.search-form input[type="search"]:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.search-form input::placeholder { color: var(--muted); }
.search-form button {
  padding: .7rem 1.2rem; border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  border-radius: 4px; font-weight: 600; cursor: pointer;
}
.pagination { margin-top: 2.5rem; }
.pagination .nav-links { display: flex; gap: .35rem; flex-wrap: wrap; }
.pagination .page-numbers {
  min-width: 2.25rem; padding: .4rem .7rem; text-align: center; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 4px; font-size: .875rem; color: var(--ink-soft);
}
.pagination .page-numbers.current { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.empty h2 { font-size: 1.25rem; margin: 0 0 .4rem; }
.empty > p { margin: 0; color: var(--muted); }
.empty-sub { font-size: 1.125rem !important; margin: 0 0 1rem !important; }

/* ---------- 아티클 ---------- */
.single { padding: 3rem 0 2rem; }
.article-grid { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.article-main { width: min(100%, var(--reading)); }
.step-rail { display: none; }
@media (min-width: 64rem) {
  .article-grid.has-rail {
    grid-template-columns: 11rem minmax(0, var(--reading)) 11rem;
    column-gap: 3rem; justify-content: center; justify-items: stretch;
  }
  .article-grid.has-rail .article-main { width: auto; grid-column: 2; }
  .article-grid.has-rail .step-rail:not([hidden]) {
    display: block; grid-column: 1; grid-row: 1; align-self: start;
    position: sticky; top: 6.5rem; font-size: .8125rem;
  }
}
.step-rail-title { margin: 0 0 .75rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
.step-rail ol { margin: 0; padding: 0; list-style: none; counter-reset: rail; display: grid; gap: .1rem; }
.step-rail li { counter-increment: rail; }
.step-rail a {
  display: flex; gap: .55rem; text-decoration: none; color: var(--muted);
  padding: .4rem .5rem; border-radius: 4px; line-height: 1.45;
}
.step-rail a::before { content: counter(rail); font-family: var(--mono); font-size: .625rem; padding-top: .2rem; flex: none; }
.step-rail a:hover { color: var(--ink); background: var(--surface); }
.step-rail a.is-on { color: var(--ink); font-weight: 600; background: var(--mark); }

.art-head { margin-bottom: 2.5rem; }
.art-head h1 { font-size: clamp(1.75rem, 3.6vw, 2.4rem); line-height: 1.3; font-weight: 700; letter-spacing: -0.035em; margin: .6rem 0 1rem; }
.art-meta {
  display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .8125rem; color: var(--muted);
  padding-bottom: 1.1rem; border-bottom: 1px solid var(--rule);
}
.art-meta time, .art-meta b { font-family: var(--mono); font-weight: 400; font-size: .75rem; color: var(--ink-soft); }
.art-end { margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-size: .9375rem; }
.art-end a { text-decoration: none; color: var(--ink-soft); }
.art-end a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- 본문 타이포그래피 ---------- */
.entry-content > * { margin-top: 0; margin-bottom: 1.15rem; }
.entry-content > *:last-child { margin-bottom: 0; }
.entry-content a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.entry-content a:hover { background: var(--mark); }
.entry-content h2 {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.45;
  margin: 2.75rem 0 1rem;
}
.entry-content h3 { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.5; margin: 2rem 0 .75rem; }
.entry-content h4 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.entry-content strong { font-weight: 700; }
.entry-content ul, .entry-content ol { padding-left: 1.4rem; }
.entry-content li { margin-bottom: .35rem; }
.entry-content li::marker { color: var(--muted); }
.entry-content blockquote, .entry-content .wp-block-quote {
  margin-inline: 0; padding: .95rem 1.15rem; border-left: 3px solid var(--mark-deep);
  background: rgba(251, 228, 137, .16); border-radius: 0 5px 5px 0;
}
.entry-content blockquote p { margin: 0 0 .5rem; }
.entry-content blockquote p:last-child { margin-bottom: 0; }
.entry-content blockquote cite { display: block; margin-top: .5rem; font-size: .8125rem; font-style: normal; color: var(--muted); }
.entry-content hr, .entry-content .wp-block-separator { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.entry-content figure { margin-inline: 0; }
.entry-content .wp-block-image img { border-radius: 6px; border: 1px solid var(--rule); }
.entry-content figcaption, .entry-content .wp-element-caption { font-size: .8125rem; color: var(--muted); margin-top: .5rem; text-align: left; }
.entry-content .wp-block-table { overflow-x: auto; }
.entry-content table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.entry-content th, .entry-content td { border-bottom: 1px solid var(--rule); padding: .6rem .7rem; text-align: left; vertical-align: top; }
.entry-content thead th { border-bottom: 2px solid var(--ink); font-weight: 700; }
.entry-content code {
  font-family: var(--mono); font-size: .875em; background: var(--surface); padding: .1em .35em; border-radius: 3px;
}
.entry-content pre {
  font-family: var(--mono); font-size: .8125rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--paper); color: var(--ink-soft); border: 1px solid var(--rule-strong); border-radius: 6px;
  padding: 1.15rem; max-height: 32rem; overflow: auto;
}
.entry-content pre code { background: none; padding: 0; font-size: inherit; }
.entry-content .alignwide, .entry-content .alignfull { max-width: 100%; }
.entry-content .wp-block-buttons .wp-block-button__link {
  background: var(--ink); color: var(--paper); border-radius: 4px; padding: .65rem 1.15rem;
  font-size: .9375rem; font-weight: 600; text-decoration: none;
}
.entry-content .wp-block-file { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; background: var(--surface); border-radius: 4px; font-size: .875rem; }
.entry-content .wp-block-file a:not(.wp-block-file__button) { flex: 1; text-decoration: none; }
.entry-content .wp-block-file__button {
  background: var(--paper) !important; color: var(--ink) !important; border: 1px solid var(--rule-strong);
  border-radius: 4px; padding: .4rem .8rem; font-size: .8125rem; font-weight: 600; text-decoration: none;
}
.entry-content .wp-block-embed { margin-block: 1.5rem; }

/* 코어 코드 블록 → 복사 상자 */
.codebox { border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; margin-bottom: 1.5rem; }
.codebox pre { border: 0; border-radius: 0; margin: 0; }
.codebox-bar { display: flex; gap: .5rem; padding: .7rem 1.15rem; border-top: 1px solid var(--rule); background: var(--surface); }

.page-links { margin-top: 2rem; display: flex; gap: .5rem; }

/* ---------- 푸터 ---------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 5rem; padding: 2.5rem 0 3rem; background: var(--surface); }
.footer-top { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-start; }
.footer-brand p { margin: .6rem 0 0; font-size: .8125rem; color: var(--muted); }
.footer-nav { margin-left: auto; display: flex; gap: .5rem 1.5rem; flex-wrap: wrap; }
.footer-nav a { font-size: .875rem; color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--ink); }
.footer-bottom {
  margin-top: 2rem; display: flex; gap: 1rem; flex-wrap: wrap; align-items: center;
  font-size: .75rem; color: var(--muted);
}
.footer-bottom small { font-family: var(--mono); font-size: .75rem; }
.footer-bottom a { color: var(--muted); }
.policy-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .step-rail, .codebox-bar, .tovia-prompt-actions { display: none !important; }
}
