@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@600;700&display=swap');

:root {
  --color-ink: #1c1b1a;
  --color-paper: #f6f1e7;
  --color-paper-dim: #ece4d3;
  --color-accent: #2d6cdf;
  --color-games: #d9762e;
  --color-games-tint: #fbe8d8;
  --color-seedling: #5b8c5a;
  --color-seedling-tint: #e3ede2;
  --color-ai: #2d6cdf;
  --color-ai-tint: #dde8fb;
  --color-article: #a0522d;
  --color-article-tint: #f3e4da;
  --font-display: 'Noto Serif TC', Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse 90% 50% at 50% -10%, #fffbf3 0%, var(--color-paper) 60%);
  color: var(--color-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei',
    sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.logo {
  display: block;
  width: 200px;
  max-width: 60vw;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 10px 28px rgba(45, 108, 223, 0.18));
}

.logo--seedling {
  border-radius: 50%;
  filter: drop-shadow(0 10px 28px rgba(91, 140, 90, 0.25));
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: rgba(28, 27, 26, 0.65);
  text-decoration: none;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--color-ink);
}

h1 {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(28, 27, 26, 0.6);
  margin: 0 0 2.5rem;
}

.page-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.intro {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.8;
  color: rgba(28, 27, 26, 0.75);
  margin: 0 auto 3rem;
  max-width: 520px;
}

.projects,
.books {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-card,
.book-card {
  display: block;
  background: white;
  border-radius: 1rem;
  border-left: 3px solid transparent;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.08);
}

.project-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(28, 27, 26, 0.1);
}

.project-card:active {
  transform: scale(0.98);
}

.project-card--games {
  border-left-color: var(--color-games);
}

.project-card--seedling {
  border-left-color: var(--color-seedling);
}

.project-card--ai {
  border-left-color: var(--color-ai);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 0.85rem;
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-icon--games {
  background: var(--color-games-tint);
}

.card-icon--seedling {
  background: var(--color-seedling-tint);
}

.card-icon--ai {
  background: var(--color-ai-tint);
}

.project-card--article {
  border-left-color: var(--color-article);
}

.card-icon--article {
  background: var(--color-article-tint);
}

.project-card h2,
.book-card h2 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.project-card p,
.book-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(28, 27, 26, 0.6);
}

.project-card .link {
  display: block;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
}

.badge {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: #fdf0d9;
  color: #92650f;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.book-card {
  border-left-color: var(--color-seedling);
}

.book-card .age-tag {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--color-seedling-tint);
  font-size: 0.7rem;
  color: #3f6140;
}

.book-card--sample {
  border-left-color: #92650f;
}

.book-card--sample .edition-link {
  background: #fdf0d9;
  color: #92650f;
}

.book-card--sample .edition-link:hover {
  background: #92650f;
  color: white;
}

.book-card .editions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.book-card .edition-link {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--color-seedling-tint);
  font-size: 0.75rem;
  color: var(--color-seedling);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.book-card .edition-link:hover {
  background: var(--color-seedling);
  color: white;
}

.book-card .edition-link:active {
  transform: scale(0.96);
}

footer {
  margin-top: 4rem;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(28, 27, 26, 0.65);
}

.updated {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(28, 27, 26, 0.65);
  margin: -0.25rem 0 2.5rem;
}

.content-section {
  margin-top: 2rem;
}

.content-section h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}

.content-section p,
.content-section li {
  font-size: 0.9rem;
  line-height: 1.75;
  color: rgba(28, 27, 26, 0.75);
}

.content-section ul {
  margin: 0.5rem 0;
  padding-left: 1.3rem;
}

.content-section li + li {
  margin-top: 0.4rem;
}

.content-section a {
  color: var(--color-accent);
}

.footer-links {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(28, 27, 26, 0.65);
  margin-top: 1rem;
}

.footer-links a {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.footer-links a:hover {
  color: var(--color-ink);
}

/* ---- 文章列表 ---- */

.article-card {
  display: block;
  background: white;
  border-radius: 1rem;
  border-left: 3px solid var(--color-article);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.08);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(28, 27, 26, 0.1);
}

.article-card .category-tag {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--color-article-tint);
  color: var(--color-article);
  font-size: 0.7rem;
  font-weight: 600;
}

.article-card h2 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.article-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(28, 27, 26, 0.6);
}

/* ---- 文章搜尋 + 篩選 + 分頁 ---- */

.search-filter-panel {
  background: linear-gradient(180deg, var(--color-paper-dim) 0%, rgba(236, 228, 211, 0.4) 100%);
  border-radius: 1.5rem;
  padding: 1.1rem 1.1rem 1.25rem;
  margin: 0 0 2rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: white;
  border-radius: 999px;
  padding: 0.75rem 0.6rem 0.75rem 1.2rem;
  margin: 0 0 0.9rem;
  border: 1.5px solid transparent;
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar:focus-within {
  border-color: var(--color-article);
  box-shadow: 0 6px 18px rgba(160, 82, 45, 0.16);
}

.search-bar .search-icon {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.55;
}

.search-input {
  appearance: none;
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--color-ink);
}

.search-input::placeholder {
  color: rgba(28, 27, 26, 0.55);
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
}

.search-clear {
  appearance: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  font-size: 0.68rem;
  line-height: 1;
  background: var(--color-paper-dim);
  color: rgba(28, 27, 26, 0.65);
  transition: background 0.15s ease, color 0.15s ease;
}

.search-clear:hover {
  background: var(--color-article-tint);
  color: var(--color-article);
}

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

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0;
}

.result-count {
  text-align: center;
  font-size: 0.78rem;
  color: rgba(28, 27, 26, 0.65);
  margin: 0 0 1rem;
}

.filter-pill {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  min-height: 2.25rem;
  border-radius: 999px;
  background: white;
  color: rgba(28, 27, 26, 0.6);
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.08);
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.filter-pill:hover {
  transform: translateY(-1px);
}

.filter-pill:active {
  transform: scale(0.97);
}

.filter-pill.active {
  background: var(--color-article);
  color: white;
  box-shadow: 0 4px 12px rgba(160, 82, 45, 0.3);
}

.empty-state {
  text-align: center;
  font-size: 0.9rem;
  color: rgba(28, 27, 26, 0.65);
  padding: 2rem 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 2rem 0 0;
}

.page-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.page-btn,
.page-nav {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border-radius: 0.65rem;
  background: white;
  color: rgba(28, 27, 26, 0.65);
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.08);
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.page-btn.active {
  background: var(--color-article);
  color: white;
}

.page-btn:not(.active):hover,
.page-nav:not(:disabled):hover {
  background: var(--color-article-tint);
  color: var(--color-article);
}

.page-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ---- 文章內頁 ---- */

.article-meta {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(28, 27, 26, 0.65);
  margin: -0.25rem 0 2rem;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 2.5rem 0 0.75rem;
}

.article-body p {
  font-size: 0.95rem;
  line-height: 1.85;
  color: rgba(28, 27, 26, 0.8);
  margin: 0 0 1rem;
}

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

.article-body li {
  font-size: 0.95rem;
  line-height: 1.85;
  color: rgba(28, 27, 26, 0.8);
  margin-bottom: 0.4rem;
}

.audio-example {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: white;
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  margin: 0.6rem 0;
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.06);
}

.audio-example .label {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
}

.audio-example .label .jp {
  font-weight: 600;
  color: var(--color-ink);
}

.audio-example .label .reading,
.audio-example .label .meaning {
  display: block;
  font-size: 0.78rem;
  color: rgba(28, 27, 26, 0.65);
  margin-top: 0.15rem;
}

.audio-example audio {
  height: 32px;
  max-width: 180px;
}

.cta-box {
  margin-top: 3rem;
  padding: 1.5rem;
  border-radius: 1rem;
  background: var(--color-ai-tint);
  text-align: center;
}

.cta-box h3 {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.cta-box p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(28, 27, 26, 0.7);
}

.article-hero {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 2.5rem;
  border-radius: 1rem;
  box-shadow: 0 10px 24px rgba(28, 27, 26, 0.12);
}

.listen-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: white;
  border-radius: 1rem;
  border-left: 3px solid var(--color-article);
  padding: 1rem 1.25rem;
  margin: 0 0 2.5rem;
  box-shadow: 0 1px 3px rgba(28, 27, 26, 0.08);
}

.listen-box .listen-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.listen-box .listen-text {
  flex: 1;
  min-width: 0;
}

.listen-box .listen-text strong {
  display: block;
  font-size: 0.9rem;
}

.listen-box .listen-text span {
  display: block;
  font-size: 0.78rem;
  color: rgba(28, 27, 26, 0.65);
  margin-top: 0.1rem;
}

.listen-box audio {
  flex-shrink: 0;
  max-width: 240px;
  height: 36px;
}

/* ---- 手機版：裝置原生 audio 控制項（尤其 iOS）寬度比 CSS 設定的大，
   跟文字擠在同一行會變形，窄螢幕下改成音檔獨佔一行、滿版寬度 ---- */
@media (max-width: 600px) {
  main {
    padding: 2rem 1rem 3rem;
  }

  .listen-box {
    flex-wrap: wrap;
  }

  .listen-box .listen-text {
    flex: 1 1 auto;
  }

  .listen-box audio {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    margin-top: 0.25rem;
  }

  .audio-example {
    flex-wrap: wrap;
  }

  .audio-example .label {
    flex: 1 1 100%;
  }

  .audio-example audio {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    margin-top: 0.25rem;
  }

  .filter-pill {
    font-size: 0.78rem;
    padding: 0.45rem 0.85rem;
  }
}
