/* =============================================================
   AI·디지털 수업 레퍼런스 허브 — Phase 1 스타일
   ============================================================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #1c2433;
  --ink-soft: #5a6478;
  --line: #e3e8f0;
  --brand: #2f6df6;
  --brand-dark: #1c4fd1;
  --brand-soft: #eaf1ff;
  --accent: #00b3a6;
  --warn: #f6a609;
  --shadow: 0 2px 8px rgba(28, 36, 51, .06);
  --shadow-lg: 0 8px 30px rgba(28, 36, 51, .12);
  --radius: 14px;
  --maxw: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 14px;
  height: 62px;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.05rem; flex-shrink: 0; }
.logo .mark { font-size: 1.4rem; }
.logo small { display: block; font-weight: 500; font-size: .68rem; color: var(--ink-soft); }
.header-search { flex: 1; max-width: 420px; margin-left: auto; position: relative; }
.header-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: .92rem; outline: none;
}
.header-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.header-search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 7px 12px; border-radius: 8px; font-size: .9rem; font-weight: 600; color: var(--ink-soft);
}
.nav-links a:hover, .nav-links a.active { background: var(--brand-soft); color: var(--brand-dark); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; }

/* ---------- Hero (home) ---------- */
.hero { padding: 44px 0 30px; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin: 0 0 10px; letter-spacing: -.5px; }
.hero p.sub { color: var(--ink-soft); margin: 0 auto 26px; max-width: 640px; font-size: 1.02rem; }
.hero-search { max-width: 600px; margin: 0 auto; position: relative; }
.hero-search input {
  width: 100%; height: 56px; padding: 0 18px 0 50px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 1.05rem; outline: none;
  box-shadow: var(--shadow);
}
.hero-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.hero-search .ico { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--ink-soft); }
.hero-stat { margin-top: 16px; color: var(--ink-soft); font-size: .9rem; }
.hero-stat b { color: var(--brand-dark); }

/* ---------- 3 entry cards ---------- */
.entry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 8px 0 34px; }
.entry-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 22px; box-shadow: var(--shadow); transition: .18s; display: block;
}
.entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.entry-card .ec-ico { font-size: 2rem; }
.entry-card h3 { margin: 12px 0 6px; font-size: 1.18rem; }
.entry-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; }
.entry-card .ec-go { margin-top: 14px; color: var(--brand); font-weight: 700; font-size: .9rem; }

/* ---------- Sections ---------- */
.section { padding: 6px 0 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 16px; gap: 12px; }
.section-head h2 { font-size: 1.4rem; margin: 0; letter-spacing: -.3px; }
.section-head .sub { color: var(--ink-soft); font-size: .9rem; }
.crumbs { font-size: .88rem; color: var(--ink-soft); margin: 18px 0 4px; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs span { margin: 0 6px; opacity: .5; }

/* ---------- Consult banner ---------- */
.consult-banner {
  background: linear-gradient(120deg, #1c4fd1, #2f6df6);
  color: #fff; border-radius: var(--radius); padding: 22px 24px; margin: 4px 0 34px;
}
.consult-banner h3 { margin: 0 0 4px; font-size: 1.15rem; }
.consult-banner p { margin: 0 0 16px; opacity: .9; font-size: .9rem; }
.school-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.school-chip {
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; padding: 7px 13px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.school-chip small { opacity: .8; font-weight: 400; margin-right: 5px; }
.consult-note { font-size: .8rem; opacity: .82; margin-top: 12px; }

/* ---------- Tile grids (subjects / purposes / tools) ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: .16s; cursor: pointer; text-align: left;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.tile .t-ico { font-size: 1.7rem; }
.tile h3 { margin: 8px 0 2px; font-size: 1.08rem; }
.tile .t-count { color: var(--brand-dark); font-weight: 700; font-size: .85rem; }
.tile .t-desc { color: var(--ink-soft); font-size: .86rem; margin-top: 6px; }
.tile.is-placeholder { opacity: .72; border-style: dashed; }
.tile .ph-badge { display: inline-block; font-size: .7rem; background: #fff4e0; color: #a86a00; padding: 2px 8px; border-radius: 999px; margin-top: 8px; }

/* purpose tiles a bit taller */
.purpose-tile h3 { display: flex; align-items: center; gap: 8px; }

/* ---------- Filter bar ---------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 18px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 6px 13px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-label { font-size: .82rem; color: var(--ink-soft); margin-right: 2px; }
.result-count { margin-left: auto; font-size: .85rem; color: var(--ink-soft); }

/* ---------- Card grid ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.lesson-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: .16s; cursor: pointer;
  display: flex; flex-direction: column;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.lc-top { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.badge.subject { background: var(--brand-soft); color: var(--brand-dark); }
.badge.grade { background: #eef1f6; color: var(--ink-soft); }
.badge.source { background: #e9faf7; color: #018577; }
.lc-title { font-size: 1.02rem; font-weight: 700; margin: 0 0 10px; line-height: 1.4; }
.lc-meta { font-size: .85rem; color: var(--ink-soft); margin: 2px 0; display: flex; gap: 6px; }
.lc-meta .k { flex-shrink: 0; }
.lc-tools { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 0; }
.tool-tag { font-size: .76rem; background: #f3f5f9; color: #444c5e; padding: 3px 8px; border-radius: 6px; }
.lc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.purpose-pill { font-size: .73rem; color: var(--accent); background: #e9faf7; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.lc-source { font-size: .73rem; color: var(--ink-soft); margin-top: 10px; opacity: .85; }

/* ---------- Purpose detail header ---------- */
.purpose-hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.purpose-hero .ph-ico { font-size: 2rem; }
.purpose-hero h2 { margin: 8px 0 6px; font-size: 1.5rem; }
.purpose-hero .lead { font-size: 1.05rem; font-weight: 600; margin: 0 0 8px; }
.purpose-hero .frame { color: var(--ink-soft); margin: 0; }
.rec-tools { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.rec-tools .lbl { font-size: .82rem; color: var(--ink-soft); }

/* ---------- Empty / placeholder ---------- */
.empty {
  text-align: center; padding: 50px 20px; color: var(--ink-soft);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty .big { font-size: 2.4rem; }

/* ---------- Modal (card detail / share) ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 28, 44, .5); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: .18s;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 18px; max-width: 540px; width: 100%;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(10px); transition: .18s;
}
.modal-back.open .modal { transform: translateY(0); }
.modal-head { padding: 22px 24px 0; }
.modal-body { padding: 14px 24px 24px; }
.modal-close {
  position: absolute; top: 14px; right: 16px; background: #f1f3f7; border: none;
  width: 34px; height: 34px; border-radius: 50%; font-size: 1.1rem; color: var(--ink-soft);
}
.modal { position: relative; }
.detail-row { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .dk { flex-shrink: 0; width: 84px; color: var(--ink-soft); font-weight: 600; }
.detail-row .dv { flex: 1; }
.source-box {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: .82rem; color: var(--ink-soft); margin-top: 16px; line-height: 1.5;
}
.source-box b { color: var(--ink); }

/* ---------- 카드 상세 풍부화 섹션 ---------- */
.detail-block { margin-top: 18px; }
.detail-block h4 { margin: 0 0 9px; font-size: .98rem; color: var(--ink); }
.goal-list { margin: 0; padding-left: 18px; }
.goal-list li { font-size: .9rem; margin: 3px 0; }
.flow-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.flow-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.flow-list li:last-child { border-bottom: none; }
.flow-step { flex-shrink: 0; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700;
  font-size: .78rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.flow-title { font-size: .9rem; line-height: 1.45; }
.recipe-tool { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-bottom: 9px; }
.recipe-tool .rt-name { font-weight: 700; font-size: .88rem; color: var(--accent); margin-bottom: 5px; }
.recipe-tool ul { margin: 0; padding-left: 17px; }
.recipe-tool li { font-size: .87rem; margin: 4px 0; line-height: 1.5; }
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.shot { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.shot img { width: 100%; height: 110px; object-fit: cover; object-position: top; display: block; transition: .15s; }
.shot:hover img { transform: scale(1.04); }
.shot-note { font-size: .73rem; color: var(--ink-soft); margin: 8px 0 0; }
.detail-hint { font-size: .82rem; color: var(--ink-soft); background: #fffaf0; border: 1px solid #ffe6b8;
  border-radius: 8px; padding: 9px 12px; margin-top: 16px; }
.lc-detail-flags { font-size: .73rem; color: var(--brand-dark); background: var(--brand-soft);
  border-radius: 6px; padding: 4px 8px; margin-top: 9px; font-weight: 600; }

/* ---------- Share / QR ---------- */
.share-qr { text-align: center; }
.share-qr img { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.copy-row { display: flex; gap: 8px; margin-top: 16px; }
.copy-row input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: .85rem; }
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-weight: 700; font-size: .9rem; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: #f1f3f7; color: var(--ink); }

/* floating share button */
.fab-share {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--brand); color: #fff; border: none; border-radius: 999px;
  padding: 12px 18px; font-weight: 700; box-shadow: var(--shadow-lg); display: flex; gap: 7px; align-items: center;
}
.fab-share:hover { background: var(--brand-dark); }

/* ---------- Tools 도감 ---------- */
.tool-cat { margin-bottom: 26px; }
.tool-cat h3 { font-size: 1.12rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.tool-cat h3 .cnt { font-size: .82rem; color: var(--ink-soft); font-weight: 500; }
.tool-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tool-pill {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; box-shadow: var(--shadow); cursor: pointer; transition: .14s;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tool-pill:hover { border-color: var(--brand); transform: translateY(-1px); }
.tool-pill .tn { font-weight: 700; font-size: .92rem; }
.tool-pill .tc { font-size: .78rem; color: var(--ink-soft); background: #f3f5f9; border-radius: 999px; padding: 1px 8px; }
.tool-pill.easy { border-color: #ffd98a; background: #fffaf0; }
.easy-star { color: var(--warn); font-size: .8rem; }
.legend { font-size: .82rem; color: var(--ink-soft); margin: 0 0 16px; }
.legend .easy-star { margin-right: 3px; }

/* ---------- Sources page ---------- */
.source-list { display: grid; gap: 14px; }
.source-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.source-item h3 { margin: 0 0 4px; font-size: 1.05rem; }
.source-item .meta { font-size: .85rem; color: var(--ink-soft); }
.source-item .cnt { color: var(--brand-dark); font-weight: 700; }
.source-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.dl-btn { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; padding: 8px 15px; border-radius: 8px; }
.dl-btn:hover { background: var(--brand-dark); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0; margin-top: 30px; color: var(--ink-soft); font-size: .85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .entry-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; position: absolute; top: 62px; left: 0; right: 0; background: #fff;
    flex-direction: column; padding: 8px; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 11px 14px; }
  .menu-toggle { display: block; }
  .header-search { max-width: none; }
}
@media (max-width: 560px) {
  .header-search { display: none; }
  .site-header .wrap { gap: 8px; }
  .card-grid { grid-template-columns: 1fr; }
}
.hidden { display: none !important; }
