/* Phase 2 viewer — additions on top of style.css (shared PWI look & feel) */

/* ---- Copy-to-clipboard buttons (Insight docs, video transcript, posts) ---- */
.pwi-copy-btn {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
  background: transparent; border: 1px solid var(--pwi-line); color: #64748b;
  border-radius: 999px; padding: 3px 11px; font-size: .74rem; font-weight: 700;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.pwi-copy-btn:hover { background: var(--pwi-bg); color: var(--pwi-primary); border-color: var(--pwi-primary); }
.pwi-copy-btn .pwi-copy-icon { display: inline-flex; }
.pwi-copy-btn .pwi-copy-icon svg { display: block; }
.pwi-copy-btn.pwi-copy-btn-done { color: #fff; background: var(--pwi-accent); border-color: var(--pwi-accent); }

/* ---- Shared date/badge chips (digest posts) ---- */
.pwi-p2-date { font-size: .78rem; color: #94a3b8; font-weight: 600; }
.pwi-badge-hw {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff4e6; color: #d9480f; border: 1px solid #ffd8a8;
  border-radius: 999px; padding: 2px 10px; font-size: .76rem; font-weight: 700;
}

/* ---- Post modal content (curated sections) ---- */
.pwi-p2-section { padding: 4px 16px 14px; }
.pwi-p2-section h5 {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--pwi-accent); font-weight: 800; margin: 14px 0 6px;
}
.pwi-p2-section h5:first-child { margin-top: 4px; }
.pwi-md { font-size: 15px; line-height: 1.6; color: #1e293b; word-break: break-word; }
.pwi-md p { margin: 0 0 .6em; }
.pwi-md ul, .pwi-md ol { margin: 0 0 .6em; padding-left: 1.3em; }
.pwi-md li { margin-bottom: .25em; }
.pwi-md li > ul, .pwi-md li > ol { margin-top: .25em; }
.pwi-md h3, .pwi-md h4 { color: var(--pwi-primary); font-weight: 700; margin: .8em 0 .3em; }
.pwi-md h3 { font-size: 1.02rem; }
.pwi-md h4 { font-size: .95rem; }
.pwi-md hr { border: none; border-top: 1px solid var(--pwi-line); margin: .9em 0; }
.pwi-md strong { color: #0f172a; }
.pwi-md a { color: var(--fb-blue, #1877f2); }
.pwi-md code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---- Video transcript sections (วิดีโอ tab detail view) ---- */
.pwi-lec-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--pwi-line); }
.pwi-lec-section:last-child { border-bottom: none; }
.pwi-lec-range {
  display: inline-block; background: #ecfdf9; color: var(--pwi-accent); font-weight: 700;
  border-radius: 999px; padding: 3px 12px; font-size: .82rem; margin-bottom: 10px;
}

/* ---- Source videos tab (original full-length files, gallery grid) ---- */
.pwi-src-tile {
  background: var(--pwi-card); border: 1px solid var(--pwi-line); border-radius: 14px;
  overflow: hidden; cursor: pointer; height: 100%;
  transition: transform .12s, box-shadow .12s;
}
.pwi-src-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(15, 76, 129, .15); }

.pwi-src-tile-poster {
  position: relative; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--pwi-primary), var(--pwi-accent));
  display: flex; align-items: center; justify-content: center;
}
.pwi-src-tile-ep { color: #fff; font-weight: 800; font-size: 1.5rem; letter-spacing: .02em; text-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.pwi-src-tile-play {
  position: absolute; right: 10px; bottom: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: var(--pwi-primary);
  display: flex; align-items: center; justify-content: center;
  padding-left: 2px; /* optical centering of the play triangle */
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: transform .15s, background .15s;
}
.pwi-src-tile-play svg { width: 13px; height: 13px; }
.pwi-src-tile:hover .pwi-src-tile-play { transform: scale(1.15); background: #fff; }

.pwi-src-tile-label { padding: 10px 12px 12px; }
.pwi-src-tile-title {
  display: -webkit-box; font-weight: 600; font-size: .82rem; color: #334155;
  line-height: 1.4; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- วิดีโอ detail view (video on top, transcript below) ---- */
#videoDetailView .pwi-player { max-height: 70vh; }
#videoDetailTitle { margin-bottom: 14px; }

@media (max-width: 576px) {
  .pwi-src-tile-title { font-size: .78rem; -webkit-line-clamp: 2; }
}

/* ---- Digest (read-all) ---- */
.pwi-digest-toc {
  position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto;
  background: #fff; border: 1px solid var(--pwi-line); border-radius: 12px; padding: 10px;
}
.pwi-digest-toc a {
  display: block; padding: 5px 8px; border-radius: 6px; font-size: .84rem;
  color: #334155; text-decoration: none;
}
.pwi-digest-toc a:hover { background: var(--pwi-bg); }
.pwi-digest-toc .toc-heading { font-weight: 800; color: var(--pwi-primary); margin-top: 8px; font-size: .78rem; text-transform: uppercase; }

.pwi-digest-body { background: var(--pwi-card); border: 1px solid var(--pwi-line); border-radius: 14px; padding: 20px 24px; }
.pwi-digest-entry { margin-bottom: 34px; padding-bottom: 26px; border-bottom: 2px dashed var(--pwi-line); scroll-margin-top: 80px; }
.pwi-digest-entry:last-child { border-bottom: none; }
.pwi-digest-entry-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pwi-digest-entry-head h5 { margin: 0; color: var(--pwi-primary); font-weight: 800; }
.pwi-digest-entry-head .pwi-p2-date { font-size: .8rem; }

/* ---- Insight tab (Phase 3 synthesis docs) ---- */
.pwi-phase3-nav {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--pwi-card); border: 1px solid var(--pwi-line); border-radius: 12px;
  padding: 10px; position: sticky; top: 76px; margin-bottom: 16px;
}
.pwi-phase3-navbtn {
  text-align: left; border: none; background: transparent; border-radius: 8px;
  padding: 10px 12px; font-size: .86rem; font-weight: 700; color: #334155; cursor: pointer;
  transition: background .12s, color .12s; line-height: 1.35;
}
.pwi-phase3-navbtn:hover { background: var(--pwi-bg); }
.pwi-phase3-navbtn.active { background: var(--pwi-primary); color: #fff; }

.pwi-phase3-body {
  background: var(--pwi-card); border: 1px solid var(--pwi-line); border-radius: 14px; padding: 20px 24px;
}
.pwi-phase3-doc h1 { color: var(--pwi-primary); font-weight: 800; font-size: 1.3rem; margin: 0 0 .6em; }

/* ---- Markdown pipe tables (used by Phase 3 docs, e.g. คำทำนาย) ---- */
.pwi-table-wrap { overflow-x: auto; margin: .6em 0 1.1em; -webkit-overflow-scrolling: touch; }
.pwi-table { border-collapse: collapse; width: 100%; font-size: .88rem; min-width: 460px; }
.pwi-table th, .pwi-table td { border: 1px solid var(--pwi-line); padding: 8px 10px; text-align: left; vertical-align: top; }
.pwi-table thead th { background: var(--pwi-bg); color: var(--pwi-primary); font-weight: 800; white-space: nowrap; }
.pwi-table tbody tr:nth-child(even) { background: rgba(15, 76, 129, .03); }

@media (max-width: 991px) {
  .pwi-phase3-nav { position: static; flex-direction: row; overflow-x: auto; }
  .pwi-phase3-navbtn { white-space: nowrap; }
}

/* ---- Misc ---- */
#postSearch { max-width: 100%; }

@media (max-width: 576px) {
  #statBar .pwi-stat { min-width: 60px; }
}
