/* AI 오늘의 강의 — 공통 스타일 */

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --fg-muted: #767676;
  --accent: #0b9c8a;
  --accent-strong: #41c9b4;
  --border: #e6e6e6;
  --surface: #f5f6f6;
  --code-bg: #f3f4f4;
  --code-fg: #26292b;
  --quote-border: #d5d5d5;
  --tag-bg: #e8f7f4;
  --tag-fg: #0b8676;
  --summary-bg: #f2faf8;
  --summary-border: #bfe8e0;
  --topbar-h: 64px;
  --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8eaec;
    --fg-muted: #979ba1;
    --accent: #4fd3bd;
    --accent-strong: #41c9b4;
    --border: #292d33;
    --surface: #1b1e23;
    --code-bg: #21252b;
    --code-fg: #d7dae0;
    --quote-border: #3a3f47;
    --tag-bg: #17322e;
    --tag-fg: #6fdcc8;
    --summary-bg: #16272a;
    --summary-border: #2a4b4a;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 카드 그리드가 들어가는 홈은 더 넓게 */
.container--wide {
  max-width: 1120px;
  padding: 0 28px;
}

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

a:hover {
  text-decoration: underline;
}

/* 헤더 */
.site-header {
  padding: 40px 0 24px;
  border-bottom: 1px solid var(--border);
}

.site-header .site-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-header .site-title a {
  color: var(--fg);
}

.site-header .site-desc {
  margin: 6px 0 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

/* 상단 바 */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  flex: none;
  color: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar .brand:hover {
  text-decoration: none;
}

.topbar-search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.topbar-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--fg-muted);
  stroke-width: 2;
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.topbar-search input::placeholder {
  color: var(--fg-muted);
}

/* 사이드바 */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  padding: 24px 12px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
}

body.has-sidebar {
  padding: var(--topbar-h) 0 0 var(--sidebar-w);
}

/* 상단 바가 브랜드를 대신하므로 페이지 안의 헤더는 감춘다 */
body.has-sidebar .site-header {
  display: none;
}

.sidebar-heading {
  margin: 0 0 6px;
  padding: 0 12px;
  color: var(--fg-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.9rem;
}

.sidebar-link:hover {
  background: var(--surface);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-weight: 700;
}

.sidebar-link-count {
  flex: none;
  color: var(--fg-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.sidebar-link.is-active .sidebar-link-count {
  color: inherit;
}

/* 목록 헤더 */
.list-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin: 36px 0 18px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.list-head-sub {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--fg-muted);
}

/* 글 카드 그리드 */
.article-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 28px 24px;
  margin: 0;
  padding: 0 0 72px;
}

.article-list li {
  margin: 0;
}

.article-list .article-item {
  display: block;
  color: inherit;
}

.article-list .article-item:hover {
  text-decoration: none;
}

.article-list .article-item:hover .item-title {
  color: var(--accent);
}

.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.11) 0 2px, transparent 2px 22px);
}

.card-thumb-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 1;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.card-thumb-part {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 1;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.article-item .item-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 12px 0 6px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.article-item .item-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 10px;
  color: var(--fg-muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.article-item .item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.article-item .item-category {
  font-weight: 700;
  color: var(--accent);
}

.article-item .item-date {
  font-variant-numeric: tabular-nums;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
  color: var(--fg-muted);
}

/* 태그 */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: 0.78rem;
  font-weight: 500;
}

/* 글 페이지 */
.article-header {
  padding: 48px 0 8px;
}

.article-header .article-date {
  font-size: 0.9rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.article-header h1 {
  margin: 8px 0 14px;
  font-size: 2rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.article-body {
  padding-bottom: 40px;
}

.article-body h2 {
  margin: 2.2em 0 0.6em;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.article-body h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.15rem;
}

.article-body p {
  margin: 0 0 1.1em;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
  margin: 0 0 1.1em;
}

.article-body li {
  margin-bottom: 0.3em;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

/* 핵심 요약 박스 */
.key-summary {
  margin: 28px 0 36px;
  padding: 18px 22px;
  background: var(--summary-bg);
  border: 1px solid var(--summary-border);
  border-radius: 12px;
}

.key-summary .key-summary-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.key-summary ul {
  margin: 0;
  padding-left: 1.2em;
}

.key-summary li {
  margin-bottom: 0.35em;
}

.key-summary li:last-child {
  margin-bottom: 0;
}

/* 코드 */
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.6;
  margin: 0 0 1.3em;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

/* 인용구 */
blockquote {
  margin: 1.3em 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--quote-border);
  color: var(--fg-muted);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* 표 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.3em;
  font-size: 0.95rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

th {
  background: var(--surface);
}

/* 이전/다음 편 내비게이션 */
.article-nav {
  display: flex;
  gap: 12px;
  margin: 40px 0 24px;
}

.article-nav-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
}

.article-nav-card:hover {
  background: var(--surface);
  text-decoration: none;
}

.article-nav-next {
  text-align: right;
  margin-left: auto;
}

.article-nav-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.article-nav-title {
  font-weight: 600;
  font-size: 0.95rem;
}

/* 홈으로 돌아가기 */
.back-home {
  display: inline-block;
  margin: 8px 0 64px;
  font-size: 0.95rem;
}

/* 푸터 */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 48px;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* 태블릿 이하 — 사이드바를 가로 스크롤 탭으로 전환 */
@media (max-width: 900px) {
  body.has-sidebar {
    padding-left: 0;
  }

  .sidebar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 10;
    width: auto;
    bottom: auto;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }

  .sidebar-heading {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-link {
    flex: none;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    white-space: nowrap;
  }

  .list-head {
    margin-top: 24px;
  }

  .article-header {
    padding-top: 28px;
  }
}

/* 모바일 */
@media (max-width: 600px) {
  .container {
    padding: 0 16px;
  }

  .container--wide {
    padding: 0 16px;
  }

  .site-header {
    padding: 24px 0 18px;
  }

  /* 카드 그리드 → 썸네일을 오른쪽에 둔 리스트 */
  .article-list {
    grid-template-columns: 1fr;
    gap: 0;
    padding-bottom: 48px;
  }

  .article-list li + li {
    border-top: 1px solid var(--border);
  }

  .article-list .article-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px;
    grid-template-areas:
      "title thumb"
      "summary thumb"
      "meta thumb";
    column-gap: 14px;
    padding: 18px 0;
  }

  .card-thumb {
    grid-area: thumb;
    align-self: start;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
  }

  .card-thumb-label {
    display: none;
  }

  .card-thumb-part {
    left: 6px;
    right: auto;
    top: 6px;
    padding: 1px 7px;
    font-size: 0.68rem;
  }

  .article-item .item-title {
    grid-area: title;
    margin-top: 0;
    font-size: 0.98rem;
  }

  .article-item .item-summary {
    grid-area: summary;
  }

  .article-item .item-meta {
    grid-area: meta;
    align-self: end;
  }

  .article-header h1 {
    font-size: 1.5rem;
  }

  .article-body h2 {
    font-size: 1.25rem;
  }

  .key-summary {
    padding: 14px 16px;
  }

  pre {
    padding: 12px 14px;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .article-nav {
    flex-direction: column;
  }

  .article-nav-next {
    text-align: left;
    margin-left: 0;
  }
}
