/* ===== 基礎設定 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:      #1e293b;
  --ink-soft: #64748b;
  --line:     #e2e8f0;
  --bg:       #f8fafc;
  --card:     #ffffff;
  --brand:    #0f766e;
  --brand-lt: #ccfbf1;
  --accent:   #f59e0b;
  --radius:   14px;
  --shadow:   0 1px 3px rgba(15,23,42,.08), 0 6px 16px rgba(15,23,42,.05);
}

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ===== 頁首 ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  display: flex; align-items: center; gap: 20px;
  padding-top: 14px; padding-bottom: 14px;
}
.logo { font-size: 21px; font-weight: 800; color: var(--brand); white-space: nowrap; }

.search { display: flex; gap: 8px; margin-left: auto; }
.search input {
  width: 260px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; outline: none; font-family: inherit;
}
.search input:focus { border-color: var(--brand); }
.search button {
  padding: 9px 20px; border: 0; border-radius: 999px;
  background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.search button:hover { background: #0d5f59; }

/* ===== 頂部廣告 ===== */
.ad-top { margin-top: 16px; }
.ad-top img {
  width: 100%; border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== 篩選列 ===== */
.filters { padding-top: 18px; padding-bottom: 8px; }
.filter-row {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px;
}
.filter-label {
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
  padding-top: 7px; white-space: nowrap; min-width: 32px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 14px; color: var(--ink-soft);
  transition: .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on {
  background: var(--brand); border-color: var(--brand);
  color: #fff; font-weight: 600;
}
.chip .cnt {
  font-style: normal; font-size: 11px; opacity: .6; margin-left: 3px;
}

/* ===== 主版面 ===== */
.layout {
  display: grid; grid-template-columns: 1fr 300px;
  gap: 24px; align-items: start;
  padding-top: 14px; padding-bottom: 40px;
}
.layout:has(.tools:only-child) { grid-template-columns: 1fr; }

.result-bar {
  font-size: 13px; color: var(--ink-soft); margin-bottom: 12px;
}
.result-bar strong { color: var(--brand); font-size: 15px; }

/* ===== 教具卡片 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.card {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(15,23,42,.1), 0 12px 28px rgba(15,23,42,.09);
}
.card-thumb {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, var(--brand-lt), #e0f2fe);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-icon { font-size: 46px; }

.card-body { padding: 13px 15px 15px; flex: 1; display: flex; flex-direction: column; }
.card-body h3 { font-size: 16px; font-weight: 700; margin-bottom: 5px; line-height: 1.4; }
.card-sum {
  font-size: 13px; color: var(--ink-soft); flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--brand-lt); color: var(--brand); font-weight: 600;
}
.tag.grade { background: #fef3c7; color: #b45309; }
.tag.ad    { background: #fee2e2; color: #b91c1c; }

.ad-card .card-thumb { background: #fff7ed; }

/* ===== 側邊廣告 ===== */
.sidebar { display: flex; flex-direction: column; gap: 14px; }
.side-label {
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  letter-spacing: 1px; padding-left: 2px;
}
.ad-side {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: transform .18s;
}
.ad-side:hover { transform: translateY(-2px); }
.ad-side img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.ad-side-body { padding: 12px 14px 14px; }
.ad-side-body strong { display: block; font-size: 15px; margin-bottom: 4px; }
.ad-side-body p {
  font-size: 13px; color: var(--ink-soft); margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ===== 空狀態 ===== */
.empty {
  background: var(--card); border-radius: var(--radius);
  padding: 60px 20px; text-align: center; color: var(--ink-soft);
  box-shadow: var(--shadow);
}
.empty-icon { font-size: 42px; margin-bottom: 10px; }
.empty a {
  display: inline-block; margin-top: 14px;
  padding: 9px 22px; border-radius: 999px;
  background: var(--brand); color: #fff; font-weight: 600;
}

/* ===== 頁尾 ===== */
.site-footer {
  background: var(--card); border-top: 1px solid var(--line);
  padding: 24px 0; text-align: center;
  font-size: 14px; color: var(--ink-soft);
}
.site-footer .small { font-size: 12px; margin-top: 4px; }

/* ===== 平板 ===== */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; overflow-x: auto;
    padding-bottom: 6px; -webkit-overflow-scrolling: touch;
  }
  .side-label { display: none; }
  .sidebar .ad-side { min-width: 260px; flex-shrink: 0; }
}

/* ===== 手機 ===== */
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; gap: 10px; padding-top: 11px; padding-bottom: 11px; }
  .logo { font-size: 18px; }
  .search { width: 100%; margin-left: 0; }
  .search input { width: 100%; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 10px 11px 12px; }
  .card-body h3 { font-size: 14px; }
  .card-sum { font-size: 12px; }
  .thumb-icon { font-size: 34px; }

  .filter-row { gap: 8px; margin-bottom: 8px; }
  .chips { gap: 6px; }
  .chip { font-size: 13px; padding: 5px 11px; }
  .filter-label { font-size: 12px; padding-top: 6px; }

  /* 手機廣告改為橫躺卡片 */
  .sidebar { flex-direction: column; overflow: visible; gap: 10px; }
  .sidebar .ad-side {
    min-width: 0; display: flex; align-items: stretch;
  }
  .ad-side img { width: 110px; aspect-ratio: 1 / 1; flex-shrink: 0; }
  .ad-side-body { padding: 10px 12px; }
  .ad-side-body strong { font-size: 14px; }
  .ad-side-body p { -webkit-line-clamp: 2; font-size: 12px; margin-bottom: 6px; }
}

/* ===== 頁尾（版權與連結） ===== */
.site-footer { padding: 30px 0 34px; }
.foot-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 6px;
}
.site-footer .small {
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 auto 4px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
  margin-top: 16px;
}
.foot-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: .15s;
}
.foot-links a:hover {
  border-color: var(--brand);
  background: var(--brand-lt);
  color: var(--brand);
}
.fl-ico { font-size: 14px; line-height: 1; }

/* ===== 條款文件頁 ===== */
.doc {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 860px;
  padding: 34px 40px 40px;
  margin-top: 24px;
  margin-bottom: 40px;
}
.doc h1 { font-size: 25px; color: var(--brand); margin-bottom: 4px; }
.doc-date { font-size: 12px; color: var(--ink-soft); margin-bottom: 26px; }
.doc section { margin-bottom: 26px; scroll-margin-top: 80px; }
.doc h2 {
  font-size: 17px;
  color: var(--ink);
  padding-bottom: 7px;
  margin-bottom: 11px;
  border-bottom: 2px solid var(--brand-lt);
}
.doc p { font-size: 14.5px; line-height: 1.9; color: #334155; margin-bottom: 11px; }
.doc ul { margin: 0 0 12px 20px; }
.doc li { font-size: 14.5px; line-height: 1.9; color: #334155; margin-bottom: 4px; }
.doc a { color: var(--brand); text-decoration: underline; }
.doc-warn {
  background: var(--brand-lt);
  color: #115e59;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px !important;
  border-left: 4px solid var(--brand);
}
.doc-contact { list-style: none; margin-left: 0; }
.doc-contact li { padding: 3px 0; }
.doc-back { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.doc-back a { font-weight: 700; }

@media (max-width: 640px) {
  .doc { padding: 24px 20px 30px; margin-top: 16px; }
  .doc h1 { font-size: 21px; }
  .doc h2 { font-size: 16px; }
  .doc p, .doc li { font-size: 14px; }
  .foot-links a { font-size: 12px; padding: 5px 11px; }
}
