/* =====================================================
   BlogOS — main.css  (Mobile-first, CLS-optimized)
   ===================================================== */

/* ── Variables ───────────────────────────────────── */
:root {
  --color-primary:  #1a73e8;
  --color-primary-dark: #1558b0;
  --color-text:     #1a1a1a;
  --color-muted:    #666;
  --color-border:   #e0e0e0;
  --color-bg:       #fff;
  --color-bg-alt:   #f8f9fa;
  --color-accent:   #e8f0fe;
  --font-base:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-content:    720px;
  --max-site:       1140px;
  --radius:         8px;
  --shadow:         0 2px 8px rgba(0,0,0,.08);
}

/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

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

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

ul, ol { padding-left: 1.4em; }

/* ── Accessibility ───────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  top: 0; left: 0;
  width: auto; height: auto;
  padding: .5rem 1rem;
  background: var(--color-primary);
  color: #fff;
  z-index: 9999;
}

/* ── Layout ──────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 1rem;
}

.content-wrapper {
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 2rem 1rem;
}

.content-wrapper.with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* ── Header ──────────────────────────────────────── */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-branding { flex-shrink: 0; }

.site-title-link {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -.5px;
  text-decoration: none;
}
.site-title-link:hover { color: var(--color-primary); text-decoration: none; }

.primary-nav { display: none; flex: 1; }

.primary-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: .25rem;
}

.primary-nav ul li a {
  display: block;
  padding: .5rem .75rem;
  font-size: .9rem;
  font-weight: 500;
  color: var(--color-text);
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.primary-nav ul li a:hover { background: var(--color-accent); color: var(--color-primary); text-decoration: none; }
.primary-nav ul li.current-menu-item > a { color: var(--color-primary); font-weight: 700; }

.menu-toggle {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.header-search { position: relative; margin-left: auto; }

.search-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
}

.search-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  width: 280px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
  z-index: 200;
}

.search-dropdown[hidden] { display: none; }

/* Mobile Nav Drawer */
.mobile-nav-open .primary-nav {
  display: block;
  position: fixed;
  top: 60px; left: 0; right: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem;
  z-index: 99;
}

.mobile-nav-open .primary-nav ul { flex-direction: column; gap: 0; }
.mobile-nav-open .primary-nav ul li a { padding: .75rem 1rem; font-size: 1rem; }

/* ── Hero Section ────────────────────────────────── */
.hero-section {
  background: var(--color-bg-alt);
}

.hero-inner {
  max-width: var(--max-site);
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-image { border-radius: var(--radius); overflow: hidden; }
.hero-thumb { width: 100%; height: 260px; object-fit: cover; }

.hero-cats { font-size: .8rem; color: var(--color-primary); font-weight: 600; text-transform: uppercase; margin-bottom: .5rem; }
.hero-cats a { color: inherit; }
.hero-cats a:hover { text-decoration: none; }

.hero-title { font-size: 1.5rem; font-weight: 800; line-height: 1.3; margin-bottom: .75rem; }
.hero-title a { color: var(--color-text); }
.hero-title a:hover { color: var(--color-primary); text-decoration: none; }

.hero-excerpt { color: var(--color-muted); font-size: .95rem; margin-bottom: 1.25rem; }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  padding: .6rem 1.4rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; text-decoration: none; }

/* ── Section ─────────────────────────────────────── */
.section-gap { padding: 2.5rem 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  padding-bottom: .4rem;
  border-bottom: 3px solid var(--color-primary);
  display: inline-block;
}

.more-link {
  font-size: .85rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ── Post Grid ───────────────────────────────────── */
.post-grid { display: grid; gap: 1.5rem; }
.grid-2, .grid-3 { grid-template-columns: 1fr; }

/* ── Post Card ───────────────────────────────────── */
.post-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.post-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.card-thumb { width: 100%; height: 180px; object-fit: cover; }
.card-thumb-link { display: block; overflow: hidden; }

.card-body { padding: 1rem; }

.card-cats { font-size: .75rem; color: var(--color-primary); font-weight: 600; margin-bottom: .4rem; text-transform: uppercase; }
.card-cats a { color: inherit; }

.card-title { font-size: 1rem; font-weight: 700; line-height: 1.4; margin-bottom: .5rem; }
.card-title a { color: var(--color-text); }
.card-title a:hover { color: var(--color-primary); text-decoration: none; }

.card-excerpt { font-size: .875rem; color: var(--color-muted); line-height: 1.5; margin-bottom: .75rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.card-meta { display: flex; gap: .75rem; font-size: .78rem; color: var(--color-muted); }
.card-meta time, .readtime { white-space: nowrap; }

/* ── Popular List ────────────────────────────────── */
.popular-list { list-style: none; padding: 0; }
.popular-list li { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--color-border); }
.popular-list li:last-child { border-bottom: none; }
.popular-list .rank { flex-shrink: 0; width: 1.5rem; height: 1.5rem; background: var(--color-primary); color: #fff; border-radius: 50%; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.popular-list a { font-size: .9rem; color: var(--color-text); line-height: 1.4; }
.popular-list a:hover { color: var(--color-primary); text-decoration: none; }

/* ── Article ─────────────────────────────────────── */
.single-article {
  max-width: var(--max-content);
}

.featured-image { margin-bottom: 1.5rem; border-radius: var(--radius); overflow: hidden; }
.cover-img { width: 100%; max-height: 420px; object-fit: cover; }

.article-header { margin-bottom: 1.5rem; }
.article-title { font-size: 1.6rem; font-weight: 800; line-height: 1.3; margin: .75rem 0 .75rem; }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  font-size: .85rem;
  color: var(--color-muted);
  margin-top: .5rem;
}
.meta-sep { color: var(--color-border); }
.meta-cats a { color: var(--color-primary); }

/* ── Breadcrumb ──────────────────────────────────── */
.breadcrumb ol { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; font-size: .8rem; color: var(--color-muted); }
.breadcrumb li { display: flex; align-items: center; }
.breadcrumb li + li::before { content: "›"; margin-right: .25rem; }
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-primary); text-decoration: none; }
.breadcrumb .current { color: var(--color-text); }

/* ── Summary Box ─────────────────────────────────── */
.summary-box {
  background: var(--color-accent);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.summary-box ul { list-style: none; padding: 0; }
.summary-box ul li { padding: .35rem 0; padding-left: 1.4rem; position: relative; font-size: .95rem; }
.summary-box ul li::before { content: "✔"; position: absolute; left: 0; color: var(--color-primary); font-size: .85rem; }

/* ── TOC ─────────────────────────────────────────── */
#toc-box {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: .9rem;
}
#toc-box:empty { display: none; }
#toc-box ul { list-style: none; padding: 0; }
#toc-box ul li { padding: .3rem 0; border-bottom: 1px solid var(--color-border); }
#toc-box ul li:last-child { border-bottom: none; }
#toc-box ul li a { color: var(--color-text); }
#toc-box ul li a:hover { color: var(--color-primary); text-decoration: none; }
#toc-box::before { content: "목차"; display: block; font-weight: 700; font-size: 1rem; margin-bottom: .75rem; color: var(--color-text); }

/* ── Article Body ────────────────────────────────── */
.article-body { font-size: 1rem; line-height: 1.8; }
.article-body h2 { font-size: 1.35rem; font-weight: 800; margin: 2rem 0 .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--color-border); }
.article-body h3 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.article-body p { margin-bottom: 1rem; }
.article-body ul, .article-body ol { margin-bottom: 1rem; }
.article-body li { margin-bottom: .25rem; }
.article-body img { border-radius: var(--radius); margin: 1.25rem 0; }
.article-body a { text-decoration: underline; }
.article-body strong { font-weight: 700; }
.article-body em { font-style: italic; }
.article-body table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: .9rem; overflow-x: auto; display: block; }
.article-body th, .article-body td { border: 1px solid var(--color-border); padding: .5rem .75rem; }
.article-body th { background: var(--color-bg-alt); font-weight: 700; }
.article-body blockquote { border-left: 4px solid var(--color-primary); padding-left: 1rem; margin: 1.25rem 0; color: var(--color-muted); font-style: italic; }

/* ── FAQ ─────────────────────────────────────────── */
.faq-section { margin: 2rem 0; }
.faq-section h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 1rem; }
.faq-item { border-bottom: 1px solid var(--color-border); padding: 1rem 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; color: var(--color-text); }
.faq-q::before { content: "Q. "; color: var(--color-primary); }
.faq-a { font-size: .95rem; color: var(--color-muted); line-height: 1.6; }

/* ── Article Footer / Tags ───────────────────────── */
.article-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.article-tags { font-size: .85rem; }
.article-tags .tag-label { font-weight: 700; margin-right: .25rem; }
.article-tags a { display: inline-block; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 20px; padding: .2rem .7rem; margin: .2rem .15rem; font-size: .8rem; color: var(--color-muted); }
.article-tags a:hover { background: var(--color-accent); color: var(--color-primary); text-decoration: none; }

/* ── Related Posts ───────────────────────────────── */
.related-posts { margin: 2rem 0; }
.related-posts h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 1rem; padding-bottom: .4rem; border-bottom: 2px solid var(--color-border); }
.related-grid { display: grid; gap: 1rem; }
.related-card { display: flex; gap: .75rem; align-items: flex-start; }
.related-thumb { width: 80px; height: 60px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.related-info h4 { font-size: .9rem; font-weight: 600; margin-bottom: .25rem; line-height: 1.4; }
.related-info h4 a { color: var(--color-text); }
.related-info h4 a:hover { color: var(--color-primary); text-decoration: none; }
.related-info time { font-size: .78rem; color: var(--color-muted); }

/* ── Ad Slots ────────────────────────────────────── */
.ad-slot {
  margin: 1.5rem 0;
  min-height: 90px;
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  font-size: .75rem;
}
.ad-slot::before { content: "AD"; letter-spacing: .1em; opacity: .4; }
.ad-slot--sidebar { min-height: 250px; }
.ad-slot--top { min-height: 90px; }
.ad-slot--mid { min-height: 280px; }
.ad-slot--post-faq { min-height: 90px; }
.ad-slot--pre-related { min-height: 90px; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar { width: 100%; }

.sidebar .widget { margin-bottom: 1.75rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--color-border); }
.sidebar .widget:last-child { border-bottom: none; }

.widget-title { font-size: 1rem; font-weight: 800; margin-bottom: .75rem; padding-bottom: .35rem; border-bottom: 3px solid var(--color-primary); display: inline-block; }

.sidebar .widget-categories ul { list-style: none; padding: 0; }
.sidebar .widget-categories ul li { padding: .35rem 0; border-bottom: 1px solid var(--color-border); font-size: .9rem; display: flex; justify-content: space-between; }
.sidebar .widget-categories ul li:last-child { border-bottom: none; }
.sidebar .widget-categories ul li a { color: var(--color-text); }
.sidebar .widget-categories ul li a:hover { color: var(--color-primary); text-decoration: none; }

.recent-list { list-style: none; padding: 0; }
.recent-list li { padding: .5rem 0; border-bottom: 1px solid var(--color-border); }
.recent-list li:last-child { border-bottom: none; }
.recent-list a { font-size: .9rem; color: var(--color-text); display: block; line-height: 1.4; margin-bottom: .15rem; }
.recent-list a:hover { color: var(--color-primary); text-decoration: none; }
.recent-date { font-size: .75rem; color: var(--color-muted); }

.tagcloud a { display: inline-block; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 20px; padding: .2rem .7rem; margin: .2rem; font-size: .8rem !important; color: var(--color-muted); }
.tagcloud a:hover { background: var(--color-accent); color: var(--color-primary); text-decoration: none; }

/* ── Archive / Search Header ─────────────────────── */
.archive-header, .search-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--color-border); }
.archive-title, .search-title { font-size: 1.35rem; font-weight: 800; margin-top: .5rem; }
.archive-desc { color: var(--color-muted); font-size: .9rem; margin-top: .4rem; }
.search-count { color: var(--color-muted); font-size: .9rem; margin-bottom: 1rem; }

/* ── Search Form ─────────────────────────────────── */
.search-form { display: flex; gap: .4rem; }
.search-form .search-field { flex: 1; padding: .5rem .75rem; border: 1px solid var(--color-border); border-radius: 4px; font-size: .9rem; }
.search-form .search-submit { padding: .5rem 1rem; background: var(--color-primary); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: .9rem; }
.search-form .search-submit:hover { background: var(--color-primary-dark); }

/* ── Pagination ──────────────────────────────────── */
.nav-links { display: flex; justify-content: center; gap: .5rem; margin: 2rem 0; }
.page-numbers { padding: .5rem .85rem; border: 1px solid var(--color-border); border-radius: 4px; color: var(--color-text); font-size: .9rem; }
.page-numbers.current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-numbers:hover { background: var(--color-accent); text-decoration: none; }

/* ── Footer ──────────────────────────────────────── */
.site-footer {
  background: #1a1a1a;
  color: #ccc;
  margin-top: 3rem;
}
.footer-inner { max-width: var(--max-site); margin: 0 auto; padding: 2rem 1rem; }
.footer-nav ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-bottom: 1rem; }
.footer-nav ul li a { color: #aaa; font-size: .9rem; }
.footer-nav ul li a:hover { color: #fff; text-decoration: none; }
.copyright { font-size: .85rem; color: #666; }

/* ── Comments ────────────────────────────────────── */
.comments-area { margin-top: 2rem; }
.comment-reply-title, .comments-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* ── Responsive: Tablet+ ─────────────────────────── */
@media (min-width: 640px) {
  .hero-inner { flex-direction: row; align-items: center; }
  .hero-image { flex: 0 0 45%; }
  .hero-thumb { height: 300px; }
  .hero-title { font-size: 1.75rem; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .related-grid { grid-template-columns: repeat(3, 1fr); }
  .related-card { flex-direction: column; }
  .related-thumb { width: 100%; height: 120px; }
}

/* ── Responsive: Desktop ─────────────────────────── */
@media (min-width: 1024px) {
  .primary-nav { display: flex; }
  .menu-toggle { display: none; }
  .header-search { margin-left: 0; }

  .content-wrapper.with-sidebar {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .hero-thumb { height: 360px; }
  .hero-title { font-size: 2rem; }

  .grid-3 { grid-template-columns: repeat(3, 1fr); }

  .article-title { font-size: 2rem; }
}
