/* หน้ากระทู้ความรู้ — ใช้ตัวแปรสีและ topbar จาก style.css */

/* ---------- Layout ---------- */
.forum { max-width: 800px; }

.f-head { margin: 4px 0 18px; }
.f-head h2 { margin: 0; font-size: 22px; }
.f-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- รายการกระทู้ ---------- */
.t-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.t-card {
  --c: var(--pink); --c-soft: var(--pink-soft);
  display: block; padding: 16px 20px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); color: inherit; text-decoration: none;
  border-left: 5px solid var(--c); transition: box-shadow .15s, transform .15s;
}
.t-card--gold { --c: var(--gold); --c-soft: var(--gold-soft); }
.t-card:hover { box-shadow: 0 0 0 2px var(--c-soft), var(--shadow); transform: translateY(-1px); }
.t-card h3 { margin: 8px 0 4px; font-size: 17px; line-height: 1.35; }
.t-card p { margin: 0; color: var(--muted); font-size: 14px; }
.t-card.is-pinned { background: linear-gradient(90deg, var(--pink-soft), var(--card) 55%); }

.t-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.pin {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  background: var(--pink); color: #fff; font-weight: 600;
}
.pin svg { width: 13px; height: 13px; }

/* ---------- หน้ากระทู้ ---------- */
.back { display: inline-block; margin: 4px 0 14px; color: var(--pink-strong); font-weight: 600; font-size: 14px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.post + .back { margin: 18px 0 0; }

.post {
  --c: var(--pink); --c-strong: var(--pink-strong); --c-soft: var(--pink-soft);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 5px solid var(--c); padding: 22px 26px 26px;
}
.post--gold { --c: var(--gold); --c-strong: var(--gold-strong); --c-soft: var(--gold-soft); }
.p-head h2 { margin: 10px 0 8px; font-size: 24px; line-height: 1.3; }
.p-intro { margin: 0; font-size: 15.5px; line-height: 1.7; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 20px 0 0; }
.facts div { background: var(--c-soft); border-radius: 12px; padding: 10px 14px; }
.facts dt { font-size: 12px; color: var(--c-strong); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 600; }

.p-sec { margin-top: 26px; }
.p-sec h3, .learn h3 { margin: 0 0 10px; font-size: 18px; }
.p-sec > p { margin: 0; line-height: 1.7; }
.p-items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.p-items li { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.p-items b { font-size: 14.5px; }
.p-items span { color: var(--muted); font-size: 14.5px; }
.p-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.p-link { display: inline-block; margin-top: 10px; color: var(--pink-strong); font-weight: 600; text-decoration: none; }
.p-link:hover { text-decoration: underline; }

.learn { margin-top: 28px; padding: 16px 20px; border-radius: 14px; background: var(--ok-soft); }
.learn h3 { color: var(--ok); }
.learn ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

.sources { margin-top: 24px; padding-top: 14px; border-top: 1px dashed var(--line); }
.sources h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sources ul { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.sources a { color: var(--muted); overflow-wrap: anywhere; }
.sources a:hover { color: var(--pink-strong); }

@media (max-width: 720px) {
  .post { padding: 18px 16px 20px; }
  .p-head h2 { font-size: 20px; }
  .p-items li { grid-template-columns: minmax(0, 1fr); }
  .t-card { padding: 14px 16px; }
}
@media (max-width: 480px) {
  .facts { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- รูปปกบนการ์ดกระทู้ ---------- */
.t-card.has-cover { display: grid; grid-template-columns: 200px minmax(0, 1fr); padding: 0; overflow: hidden; }
.t-cover { display: block; width: 100%; height: 100%; min-height: 132px; object-fit: cover; background: var(--c-soft); }
.t-card.has-cover .t-body { padding: 14px 20px 16px; }
.t-card.is-pinned.has-cover { grid-template-columns: 300px minmax(0, 1fr); }
.t-count { display: inline-flex; align-items: center; gap: 4px; }
.t-count svg { width: 14px; height: 14px; }

/* ---------- รูปปกในกระทู้ ---------- */
.p-cover { margin: 20px -26px 0; }
.p-cover button { display: block; width: 100%; padding: 0; border: 0; background: var(--c-soft); cursor: zoom-in; }
.p-cover img { display: block; width: 100%; height: auto; max-height: 440px; object-fit: cover; }
.p-cover figcaption { padding: 8px 26px 0; font-size: 12.5px; color: var(--muted); }
.p-cover figcaption a, .lightbox figcaption a { color: inherit; }

/* ---------- แกลเลอรี ---------- */
.p-gallery { margin-top: 28px; }
.p-gallery h3 { margin: 0 0 10px; font-size: 18px; }
.p-gallery h3 small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.g-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.g-grid button {
  position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 12px; overflow: hidden;
  background: var(--c-soft); cursor: zoom-in; aspect-ratio: 32 / 21;
}
.g-grid img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.g-grid button:hover img { transform: scale(1.04); }
.g-grid span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 7px; text-align: left;
  font-size: 12px; line-height: 1.35; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
}
.g-grid button:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #140c12; color: #fff;
}
.lightbox::backdrop { background: #140c12; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lb-stage { margin: 0; padding: 56px 72px 20px; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.lb-stage img { display: block; max-width: 100%; max-height: calc(100% - 64px); width: auto; height: auto; border-radius: 8px; object-fit: contain; }
.lb-stage figcaption { text-align: center; font-size: 15px; max-width: 760px; }
.lb-stage figcaption small { display: block; margin-top: 3px; font-size: 12px; opacity: .7; }
.lb-btn {
  position: absolute; z-index: 1; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 28px; line-height: 1;
}
.lb-btn:hover { background: rgba(255, 255, 255, .26); }
.lb-close { top: 12px; right: 12px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 34px; padding-bottom: 4px; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lightbox.is-single .lb-nav { display: none; }

@media (max-width: 720px) {
  .t-card.has-cover, .t-card.is-pinned.has-cover { grid-template-columns: minmax(0, 1fr); }
  .t-cover { height: auto; aspect-ratio: 16 / 9; min-height: 0; }
  .t-card.has-cover .t-body { padding: 12px 16px 14px; }
  .p-cover { margin: 16px -16px 0; }
  .p-cover figcaption { padding: 8px 16px 0; }
  .g-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lb-stage { padding: 56px 8px 16px; }
  .lb-nav { top: auto; bottom: 14px; transform: none; }
}
