/* 오늘의 지원금 — 레이아웃: 좌 광고레일 / 본문 / 우 광고레일 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ec;
  --text: #16181d;
  --muted: #656c7a;
  --accent: #2b5fd9;
  --accent-soft: #eaf0ff;
  --danger: #d13438;
  --danger-soft: #fdecec;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --ok: #1a7f4b;
  --ok-soft: #e6f5ec;
  --radius: 12px;
  --max-width: 1800px;   /* 레이아웃 전체 상한 */
  --rail-width: 176px;   /* 광고 레일 (넓은 화면에서 300px로 확대) */
  --prose-width: 880px;  /* 본문 성격의 글이 넓어지지 않도록 */
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 4px 14px rgba(16, 20, 30, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #191c22;
    --border: #2a2f39;
    --text: #e8eaee;
    --muted: #98a0b0;
    --accent: #7ea2ff;
    --accent-soft: #1d2740;
    --danger: #ff8a8d;
    --danger-soft: #3a2022;
    --warn: #f0b657;
    --warn-soft: #3a2e18;
    --ok: #6fd39b;
    --ok-soft: #16301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  word-break: keep-all;
}
a { color: inherit; }

/* ---------- 3단 레이아웃 ---------- */
.layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 28px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.col { min-width: 0; }

/* 각 칸을 트랙에 못박아 둔다. 광고차단기가 .ad-rail을 display:none 하면
   1·3번 auto 트랙은 0으로 접히고 본문(2번 1fr)이 남는 폭을 전부 가져간다.
   (배치를 안 걸면 본문이 1번 트랙으로 밀려나 2번 트랙이 빈 공간으로 남는다) */
.layout > .ad-rail:first-child { grid-column: 1; }
.layout > .col { grid-column: 2; }
/* 상세/404 같은 글 성격 페이지는 컬럼 자체를 읽기 좋은 폭으로 좁혀 가운데 정렬한다 */
.col-prose { width: 100%; max-width: var(--prose-width); margin-inline: auto; }
.layout > .ad-rail:last-child { grid-column: 3; }

.ad-rail { display: block; width: var(--rail-width); }
/* 레일 2개가 들어갈 폭이 안 되면 본문 한 컬럼만 */
@media (max-width: 1279px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 960px; }
  .layout > .col { grid-column: 1; }
  .ad-rail { display: none; }
}
/* 넓은 화면에서는 레일을 300x600 규격으로 키워 남는 여백을 회수 */
@media (min-width: 1600px) {
  :root { --rail-width: 300px; }
  .layout { gap: 36px; }
}

/* ---------- 광고 슬롯 (자리만 잡아둠) ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(135deg, transparent, transparent 9px, rgba(128, 138, 160, .07) 9px, rgba(128, 138, 160, .07) 18px);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}
.ad-sticky { position: sticky; top: 24px; width: 100%; height: 600px; }
.ad-leaderboard { height: 90px; margin: 20px 0 4px; }
.ad-inline { height: 250px; margin: 24px 0; }
/* 다단 그리드에서도 한 줄 전체를 차지하도록 */
.ad-infeed { grid-column: 1 / -1; height: 120px; margin: 4px 0 12px; list-style: none; }

/* ---------- 헤더 ---------- */
.site-head { padding: 36px 0 8px; }
.brand {
  display: inline-block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand::before { content: "📌 "; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.updated { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- 현황 요약 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.stat {
  appearance: none;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
  font: inherit;
  color: inherit;
}
.stat:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.stat .n { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat .k { display: block; font-size: 12.5px; color: var(--muted); }
.stat.fresh .n { color: var(--ok); }
.stat.soon .n { color: var(--danger); }

/* ---------- 검색 / 필터 ---------- */
.controls { margin: 22px 0 8px; }
.searchbar { display: flex; gap: 8px; }
.searchbar input {
  flex: 1; min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.searchbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.searchbar button {
  padding: 12px 20px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.filter-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.select-wrap { display: inline-flex; align-items: center; gap: 6px; }
.select-label { font-size: 12.5px; color: var(--muted); }
.select-wrap select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip, .chip-btn {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.chip-btn { cursor: pointer; font-family: inherit; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.active-filters { margin-top: 10px; font-size: 13px; color: var(--muted); }
.active-filters button {
  border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline;
}

/* ---------- 결과 목록 ---------- */
.results-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.results-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.count { color: var(--muted); font-size: 13px; }
.cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 10px;
  /* 컬럼이 넓어지면 2~3단으로 자동 전환 (한 줄이 너무 길어지지 않게) */
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.45; letter-spacing: -.01em; }
.card h3 a { text-decoration: none; }
/* 카드 전체를 클릭 영역으로 */
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card .desc {
  margin: 0 0 10px; color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.urgent { background: var(--danger-soft); color: var(--danger); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.open { background: var(--ok-soft); color: var(--ok); }
.badge.always { background: var(--accent-soft); color: var(--accent); }
.badge.new { background: var(--ok); color: #fff; }
.dot { color: var(--border); }

.list-state { padding: 28px 0; text-align: center; color: var(--muted); font-size: 14px; }
.skeleton { height: 96px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(128, 138, 160, .12), transparent);
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.more {
  width: 100%; margin-top: 14px; padding: 13px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.more:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 상세 페이지 (Worker SSR) ---------- */
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-top: 18px; box-shadow: var(--shadow); }
.crumb { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumb a { color: var(--accent); text-decoration: none; }
.detail h1 { margin: 0 0 12px; font-size: 24px; line-height: 1.4; letter-spacing: -.02em; }
.detail h2 { font-size: 16px; margin: 26px 0 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 18px 0 0; }
.facts div { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.facts dt { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.facts dd { margin: 0; font-size: 14.5px; font-weight: 600; }
.body { color: var(--text); font-size: 15px; }
.cta {
  display: inline-block; margin-top: 18px; padding: 13px 22px;
  background: var(--accent); color: #fff; border-radius: var(--radius);
  text-decoration: none; font-weight: 700;
}
.disclaimer { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; padding: 80px 0; }

.site-foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.site-foot p { margin: 4px 0; }

@media (max-width: 640px) {
  .layout { padding: 0 14px 60px; }
  .stats { grid-template-columns: 1fr; }
  .detail { padding: 20px 16px; }
  .brand { font-size: 22px; }
}

.notice {
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: 13.5px;
}

/* 지역 필터 옆 '전국 공고 포함' 토글 */
.check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
/* display를 지정하면 hidden 속성이 무시되므로 명시적으로 되살린다 */
.check-wrap[hidden] { display: none; }
.check-wrap:hover { border-color: var(--accent); }
.check-wrap input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.check-wrap:has(input:not(:checked)) { color: var(--muted); }
.check-wrap em { font-style: normal; color: var(--muted); font-size: 12.5px; margin-left: 5px; }
