/* Minimal, readable styles without any build tools */
:root {
  --bg: #f7f7f7;
  --fg: #1f2937;  /* gray-800 */
  --muted: #6b7280; /* gray-500 */
  --brand: #0f766e; /* teal-700 */
  --card: #ffffff;
  --border: #e5e7eb; /* gray-200 */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.site {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.topbar .nav a {
  margin-left: 1rem;
  color: var(--fg);
  text-decoration: none;
}
.topbar .nav a:hover { text-decoration: underline; }

.hero {
  text-align: center;
  padding: 2rem 0 1rem;
}

.hero h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.hero .tagline {
  /* color: var(--muted); */
  margin-bottom: 1rem;

}

img {
  max-width: 100%;
  height: auto;
  display: block;
}


.qr img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border: 6px solid #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  background: #fff;
}

.qr-note {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  margin-top: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.post h1 { margin-top: 0; }
.post .meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.post-body p { margin: 0.75rem 0; }
.back-home a { color: var(--brand); text-decoration: none; }
.back-home a:hover { text-decoration: underline; }

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}


/* --- Tiles Grid --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1rem 0 2rem;
}
.tile {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-decoration: none;
  color: var(--fg);
  transition: transform .06s ease, box-shadow .2s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.tile-title { font-weight: 700; margin-bottom: .25rem; }
.tile-sub { color: var(--muted); font-size: .95rem; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: .65rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  margin: .25rem;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn-secondary:hover,
.btn-primary:hover { opacity: .95; }

.cta-row { margin-top: .75rem; }

/* --- Card --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

/* --- Sticky QR Footer --- */
.sticky-qr {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  padding: .5rem;
  background: rgba(255,255,255,.92);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}
.sticky-qr__btn {
  display: inline-block;
  padding: .6rem .9rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

/* --- Muted helper --- */
.muted { color: var(--muted); font-size: .95rem; }

/* Accessible hide */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Modal base (hidden by default) */
.modal { 
  position: fixed; inset: 0; display: none;
}
.modal:target { 
  display: block; 
}
.modal__overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
}
.modal__content {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: #fff; border-radius: 16px;
  padding: 1rem; width: min(92vw, 520px);
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  text-align: center;
}
.modal__img {
  width: 100%; height: auto; border-radius: 8px; background: #fff;
}
.modal__hint { margin-top: .5rem; color: var(--muted); }
.modal__close {
  position: absolute; top: .5rem; right: .75rem;
  text-decoration: none; font-size: 1.1rem; color: #666;
}
.modal__close:hover { color: #000; }


.tile-img img {
  /* max-width: 100px;   or whatever size you want */
  max-height: 100px; /* maintain aspect ratio */
  height: auto;
  display: block;
  /* margin: 0 auto;      */
}


.tile {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #eee;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: background 0.2s;
}


.tile-img img {
  max-width: 200px; /* thumbnail size */
  height: auto;
  border-radius: 4px;
  display: block;
}


/* Home tiles only */
.tiles-home {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}

/* Card */
.tiles-home .tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  padding: 1rem;
  text-align: center;
  height: 300px;               /* equal height on desktop */
}

/* Image */
.tiles-home .tile-img img {
  max-width: 120px;
  max-height: 120px;
  margin-bottom: 0.75rem;
  object-fit: contain;
}

.tile-img img {
  max-width: 300px; /* thumbnail size */
  height: auto;
  border-radius: 4px;
  display: block;
}

/* Text */
.tiles-home .tile-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.tiles-home .tile-sub {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.35;
  display: -webkit-box;        /* optional: clamp to 3 lines */
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Responsive breakpoints ---------- */

/* Large tablets: 3 across */
@media (max-width: 1200px) {
  .tiles-home { grid-template-columns: repeat(3, 1fr); }
}

/* Tablets: 2x2 grid */
@media (max-width: 900px) {
  .tiles-home { grid-template-columns: repeat(2, 1fr); }
  .tiles-home .tile { height: 240px; }
  .tiles-home .tile-img img { max-width: 72px; max-height: 72px; }
}

/* Phones: 1 per row */
@media (max-width: 560px) {
  .tiles-home { grid-template-columns: 1fr; }
  .tiles-home .tile { height: auto; padding: 1rem 1.25rem; }
  .tiles-home .tile-img img { max-width: 64px; max-height: 64px; }
  .tiles-home .tile-sub { -webkit-line-clamp: unset; }  /* let it wrap on phones */
}

/* Hero with background image */
.hero--landing.has-bg{
  position: relative;
  min-height: 90vh;              /* good on mobile */
  display: grid;
  place-items: center;
  padding: 3rem 1rem;
  color: #fff;
  background: center/cover no-repeat url("/img/lantern.png");
  border-radius: 16px;
  overflow: hidden;
}

/* dark gradient overlay for readability */
.hero--landing.has-bg .hero__overlay{
  position:absolute; inset:0;
  background: linear-gradient(180deg, rgba(0,0,0,.1), rgba(0,0,0,.1));
}

/* keep text above overlay */
.hero--landing.has-bg .hero__content{ 
  position: relative; 
  text-align: center;
  max-width: 720px;
}
.hero--landing.has-bg h1{ margin: 0 0 .5rem; }
.hero--landing.has-bg .tagline{ margin:.1rem 0; opacity:.95 }

/* CTA row */
.hero--landing.has-bg .cta-row{
  margin-top: 1rem;
  display: flex; gap:.6rem; flex-wrap: wrap; justify-content: center;
}

/* Audio button state */
.btn-audio[aria-pressed="true"]{ 
  background:#1a915a; color:#fff; 
}

.lang-switch{display:flex;gap:.5rem;margin:.5rem 0 1rem}
.lang-switch a{padding:.15rem .5rem;border-radius:.5rem;text-decoration:none;opacity:.8}
.lang-switch a.active{font-weight:600;opacity:1;outline:1px solid currentColor}


/* Collapsed remainder */
.collapsed-body { position: relative; }

/* Clamp when collapsed */
.collapsed-body.is-collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 6;      /* show first N lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Soft fade at the bottom */
.collapsed-body.is-collapsed::after {
  content: "";
  position: absolute; inset: auto 0 0 0;
  height: 3.25rem;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #fff);
  pointer-events: none;
}

/* Toggle button sits on the fade when collapsed */
.collapsed-body .continue-btn {
  position: absolute;
  bottom: .5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: .35rem .75rem;
  border-radius: .75rem;
  cursor: pointer;
}

/* When expanded, make the button flow below the content */
.collapsed-body:not(.is-collapsed) .continue-btn {
  position: static;
  transform: none;
  margin-top: .75rem;
}

/* ---- Recommended (scoped) ---- */
.rec { margin-top: 1.5rem; }
.rec__heading { margin: 0 0 .75rem; font-size: 1.125rem; font-weight: 700; }

/* mobile-first: single column */
.rec__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
}

/* cards */
.rec__card {
  display: grid;
  grid-template-columns: 96px 1fr;        /* image + text */
  gap: .75rem;
  align-items: start;
  padding: .75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
}

/* image */
.rec__media { width: 96px; height: 96px; overflow: hidden; border-radius: 8px; }
.rec__img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* text */
.rec__body { min-width: 0; }
.rec__title { margin: 0 0 .25rem; font-size: 1rem; line-height: 1.3; font-weight: 700; }
.rec__date { font-size: .82rem; opacity: .7; margin-bottom: .25rem; }
.rec__summary {
  margin: 0;
  font-size: .92rem; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}

/* widen at breakpoints */
@media (min-width: 480px) {
  .rec__grid { grid-template-columns: repeat(2, 1fr); }
  .rec__card { grid-template-columns: 110px 1fr; }
  .rec__media { width: 110px; height: 110px; }
}
@media (min-width: 768px) {
  .rec__grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .rec__grid { grid-template-columns: repeat(4, 1fr); }
}


/* ---- Chapter page (scoped) ---- */
.chap__title { 
  text-align: center;
  margin-bottom: 1rem; 
}
.chap__pager {
  display: flex; justify-content: space-between; gap: .75rem;
  margin: 1rem 0 1.25rem;
}
.chap__pager a { text-decoration: none; }

.chap__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  margin: 1rem 0 1.5rem;
}
@media (min-width: 640px) { .chap__grid { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 1024px){ .chap__grid { grid-template-columns: repeat(14, 1fr);} }

.chap__cell {
  display: block;
  text-align: center;
  padding: .5rem .25rem;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.chap__cell.is-active {
  font-weight: 700;
  outline: 1px solid currentColor;
}

/* ---- Section/list pages (scoped) ---- */
.sec__title { margin: .25rem 0 .5rem; }
.sec__intro { margin-bottom: 1rem; }

/* cards for subsections */
.sec__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
}
.sec__card {
  display: block;
  padding: .9rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.sec__cardTitle { margin: 0 0 .25rem; font-size: 1.05rem; font-weight: 700; }
.sec__cardSummary { margin: 0; opacity: .85; }

@media (min-width: 640px) { .sec__grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px){ .sec__grid { grid-template-columns: repeat(3, 1fr); } }

/* chapter grid */
.sec__gridChapters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-top: 1rem;
}
@media (min-width: 640px) { .sec__gridChapters { grid-template-columns: repeat(7, 1fr); } }
@media (min-width: 1024px){ .sec__gridChapters { grid-template-columns: repeat(14, 1fr); } }

.sec__cell {
  display: block; text-align: center;
  padding: .5rem .25rem;
  border: 1px solid #e5e7eb; border-radius: .5rem;
  background: #fff; text-decoration: none; color: inherit;
}
.sec__cell.is-active { font-weight: 700; outline: 1px solid currentColor; }
