/* ==========================================================
   KM Library — หน้าแรกแบบ Netflix (ใช้เฉพาะ view.php, body.nf-page)
   ========================================================== */

.nf-page {
  --nf-bg: #0b0d14;
  --nf-bg-2: #141824;
  --nf-line: rgba(255, 255, 255, .10);
  --nf-text: #e8eaf0;
  --nf-muted: #9aa3b5;
  --nf-accent: #e50914;          /* แดงแบบ Netflix ใช้กับปุ่มหลัก/ป้าย */
  --nf-accent-2: #3b82f6;
  --nf-card-w: 260px;
  background: var(--nf-bg);
  color: var(--nf-text);
}
.nf-page a:not(.btn):not(.dropdown-item):not(.page-link) { color: inherit; }

/* ---------- Navbar & footer ในโทนมืด ---------- */
.nf-page .app-navbar {
  background: linear-gradient(180deg, rgba(5, 7, 12, .96), rgba(11, 13, 20, .88));
  box-shadow: 0 1px 0 var(--nf-line);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}
.nf-page .app-navbar .brand-mark { background: var(--nf-accent); box-shadow: none; }
.nf-page .app-navbar .nav-link.active,
.nf-page .app-navbar .nav-link:hover { background: rgba(255, 255, 255, .10); }
.nf-page .app-footer { background: #07090e; border-top-color: var(--nf-line); color: var(--nf-muted); margin-top: 0; }
.nf-page .app-footer .fw-semibold { color: var(--nf-text); }
.nf-page .app-footer .text-muted, .nf-page .footer-link { color: var(--nf-muted) !important; }
.nf-page .app-footer .text-primary { color: var(--nf-accent) !important; }
.nf-page .alert { border: 0; }

/* ---------- Hero (แบนเนอร์บทความเด่น) ---------- */
.nf-hero { position: relative; height: clamp(440px, 72vh, 680px); overflow: hidden; background: #000; }
.nf-hero .carousel-inner, .nf-hero .carousel-item { height: 100%; }
.nf-hero-bg { position: absolute; inset: 0; }
.nf-hero-bg img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); animation: nfZoom 14s ease-out forwards; }
.carousel-item:not(.active) .nf-hero-bg img { animation: none; }
@keyframes nfZoom { to { transform: scale(1.0); } }
.nf-hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(11, 13, 20, .96) 0%, rgba(11, 13, 20, .78) 32%, rgba(11, 13, 20, .15) 70%),
    linear-gradient(0deg, var(--nf-bg) 0%, rgba(11, 13, 20, 0) 38%);
}
.nf-hero-body { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: clamp(3rem, 8vh, 5.5rem); }
.nf-hero-kicker { display: flex; align-items: center; gap: .55rem; font-size: .95rem; color: #fff; opacity: .92; margin-bottom: .6rem; }
.nf-top-badge {
  display: inline-grid; place-items: center; min-width: 2.4rem; height: 2rem; padding: 0 .55rem; border-radius: 4px;
  background: var(--nf-accent); color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .5px;
}
.nf-top-badge.nf-new { background: #16a34a; }
.nf-top-badge.nf-pick { background: #f59e0b; color: #111; }
.nf-hero-title {
  font-size: clamp(1.7rem, 4.2vw, 3.3rem); font-weight: 700; line-height: 1.22; color: #fff; max-width: 820px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .55); margin: 0 0 .7rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.nf-hero-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; color: #d3d8e3; font-size: .92rem; margin-bottom: .8rem; }
.nf-hero-meta i { opacity: .75; margin-right: .2rem; }
.nf-hero-desc { max-width: 640px; color: #cfd4de; font-size: 1.02rem; line-height: 1.7; margin-bottom: 1.3rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nf-hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.nf-hero-actions .btn { border-radius: 6px; padding: .65rem 1.5rem; font-size: 1.02rem; }
.btn-nf-ghost { background: rgba(109, 109, 110, .55); color: #fff; border: 0; }
.btn-nf-ghost:hover { background: rgba(109, 109, 110, .4); color: #fff; }
.nf-hero .carousel-indicators { z-index: 3; margin-bottom: 1.1rem; justify-content: flex-end; margin-right: max(1rem, calc((100vw - 1320px) / 2 + .75rem)); }
.nf-hero .carousel-indicators [data-bs-target] { width: 22px; height: 4px; border-radius: 2px; border: 0; opacity: .45; }
.nf-hero .carousel-indicators .active { opacity: 1; background: #fff; }
.nf-hero .carousel-control-prev, .nf-hero .carousel-control-next { width: 5%; z-index: 3; opacity: 0; transition: opacity .2s; }
.nf-hero:hover .carousel-control-prev, .nf-hero:hover .carousel-control-next { opacity: .8; }

/* ---------- แถบค้นหาและทางลัด ---------- */
.nf-toolbar { position: relative; z-index: 4; margin-top: -1.2rem; }
.nf-search {
  display: flex; align-items: center; gap: .5rem; background: rgba(255, 255, 255, .08); border: 1px solid var(--nf-line);
  border-radius: 999px; padding: .3rem .35rem .3rem 1.1rem; max-width: 760px; transition: border-color .2s, background .2s;
}
.nf-search:focus-within { border-color: rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .12); }
.nf-search > i { color: var(--nf-muted); }
.nf-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; padding: .45rem .2rem; font-size: 1rem; }
.nf-search input::placeholder { color: #8b93a6; }
.nf-search select { background: transparent; color: var(--nf-muted); border: 0; border-left: 1px solid var(--nf-line); padding: .3rem .5rem; outline: 0; font-size: .9rem; }
.nf-search select option { color: #111; }
.nf-search button { background: var(--nf-accent); color: #fff; border: 0; border-radius: 999px; padding: .45rem 1.2rem; font-weight: 500; }
.nf-search button:hover { filter: brightness(1.1); }
.nf-jump { display: flex; gap: .4rem; overflow-x: auto; padding: .9rem 0 .2rem; scrollbar-width: none; }
.nf-jump::-webkit-scrollbar { display: none; }
.nf-jump a {
  flex: 0 0 auto; text-decoration: none; color: #d6dae3; border: 1px solid var(--nf-line); border-radius: 999px;
  padding: .3rem .9rem; font-size: .88rem; transition: background .15s, color .15s;
}
.nf-jump a:hover { background: #fff; color: #111; }

/* ---------- แถว ---------- */
.nf-rows { padding: 1.2rem 0 3rem; }
.nf-row { margin: 1.4rem 0 1.9rem; }
.nf-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0 max(1rem, calc((100vw - 1320px) / 2 + .75rem)); margin-bottom: .55rem; }
.nf-row-head h2 { font-size: clamp(1.05rem, 1.8vw, 1.35rem); font-weight: 600; margin: 0; color: #fff; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.nf-row-head h2 i { color: var(--nf-accent); font-size: .95em; }
.nf-row-head h2 small { font-size: .78rem; font-weight: 400; color: var(--nf-muted); }
.nf-more { color: var(--nf-muted) !important; text-decoration: none; font-size: .88rem; white-space: nowrap; }
.nf-more:hover { color: #fff !important; }
.nf-more i { font-size: .7rem; transition: transform .2s; }
.nf-more:hover i { transform: translateX(3px); }
.nf-section-title { margin-top: 2.6rem; margin-bottom: -.4rem; }
.nf-section-title span { font-size: .8rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--nf-muted); border-left: 3px solid var(--nf-accent); padding-left: .6rem; }

/* แทร็กเลื่อนแนวนอน */
.nf-slider { position: relative; }
.nf-track {
  --pad: max(1rem, calc((100vw - 1320px) / 2 + .75rem));
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--nf-card-w); gap: .7rem;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad);
  padding: .6rem var(--pad) 1rem; scrollbar-width: none;
}
.nf-track::-webkit-scrollbar { display: none; }
.nf-track > * { scroll-snap-align: start; }
.nf-arrow {
  position: absolute; top: .6rem; bottom: 1rem; z-index: 5; width: clamp(2.2rem, 3.5vw, 3.4rem); border: 0; color: #fff;
  background: rgba(11, 13, 20, .65); font-size: 1.3rem; opacity: 0; transition: opacity .2s, background .2s; display: none;
}
.nf-prev { left: 0; border-radius: 0 6px 6px 0; }
.nf-next { right: 0; border-radius: 6px 0 0 6px; }
.nf-arrow:hover { background: rgba(11, 13, 20, .9); }
@media (hover: hover) and (min-width: 768px) {
  .nf-arrow { display: block; }
  .nf-slider:hover .nf-arrow:not([hidden]) { opacity: 1; }
}
.nf-arrow[hidden] { display: none !important; }

/* ---------- การ์ด ---------- */
.nf-card { display: block; position: relative; text-decoration: none; border-radius: 6px; outline: none; }
.nf-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--nf-bg-2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); transition: transform .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s;
}
.nf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nf-thumb-text { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: .4rem; padding: 1rem 1.1rem 2.6rem; color: rgba(255, 255, 255, .92); font-weight: 600; font-size: 1.02rem; line-height: 1.45; }
.nf-thumb-text i { font-size: 1.3rem; opacity: .55; }
.nf-shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0, 0, 0, .88) 0%, rgba(0, 0, 0, .35) 42%, rgba(0, 0, 0, 0) 68%); }
.nf-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: .6rem .75rem .55rem; }
.nf-title { color: #fff; font-weight: 500; font-size: .95rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.nf-meta { display: flex; gap: .4rem; align-items: center; color: #c3c9d6; font-size: .76rem; margin-top: .15rem; min-width: 0; max-height: 0; opacity: 0; overflow: hidden; transition: max-height .25s, opacity .25s; }
.nf-badges { position: absolute; top: .45rem; left: .45rem; display: flex; gap: .3rem; z-index: 2; }
.nf-badge { background: rgba(0, 0, 0, .65); color: #fff; font-size: .7rem; font-weight: 500; padding: .12rem .45rem; border-radius: 3px; }
.nf-badge-new { background: var(--nf-accent); }
.nf-thumb-text + .nf-badges + .nf-shade + .nf-cap .nf-title { display: none; } /* การ์ดไม่มีรูป: ชื่อแสดงตรงกลางแล้ว */

@media (hover: hover) {
  .nf-card:hover .nf-thumb { transform: scale(1.07); box-shadow: 0 14px 32px rgba(0, 0, 0, .6); z-index: 3; }
  .nf-card:hover .nf-meta { max-height: 2em; opacity: 1; }
}
.nf-card:focus-visible .nf-thumb { outline: 3px solid #fff; outline-offset: 2px; }
@media (hover: none) { .nf-meta { max-height: 2em; opacity: 1; } }

/* การ์ด Top 10 (ตัวเลขใหญ่ด้านซ้าย) */
.nf-track-rank { grid-auto-columns: calc(var(--nf-card-w) * .58 + 4.6rem); }
.nf-card-rank { display: flex; align-items: flex-end; }
.nf-rank {
  flex: 0 0 auto; width: 4.8rem; margin-right: -.9rem; text-align: right; font-size: 8.4rem; font-weight: 700; line-height: .82;
  color: var(--nf-bg); -webkit-text-stroke: 3px #59627a; letter-spacing: -6px; font-family: 'Arial Black', 'Kanit', sans-serif; user-select: none;
}
.nf-card-rank .nf-thumb { flex: 1; aspect-ratio: 3 / 4; }
.nf-card-rank .nf-thumb-text { font-size: .95rem; }
.nf-card-rank:hover .nf-rank { -webkit-text-stroke-color: #c6cbd8; }

/* ---------- CTA / empty ---------- */
.nf-cta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2.5rem;
  padding: 1.3rem 1.5rem; border-radius: 10px; border: 1px solid var(--nf-line);
  background: linear-gradient(120deg, rgba(229, 9, 20, .18), rgba(59, 130, 246, .10));
}
.nf-cta strong { color: #fff; }
.nf-empty { text-align: center; padding: 4rem 1rem; color: var(--nf-muted); }
.nf-empty i { font-size: 3rem; opacity: .35; margin-bottom: 1rem; display: block; }
.nf-empty h1, .nf-empty h2 { color: #fff; }

/* ---------- โหมดผลลัพธ์ (กริด) ---------- */
.nf-results { padding-top: 1.6rem; padding-bottom: 3rem; }
.nf-back { color: var(--nf-muted) !important; text-decoration: none; font-size: .9rem; }
.nf-back:hover { color: #fff !important; }
.nf-results-title { color: #fff; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 600; margin-bottom: 1.1rem; }
.nf-results-title small { font-size: .9rem; font-weight: 400; color: var(--nf-muted); margin-left: .4rem; }
.nf-search-inline { max-width: none; }
.nf-filter-bar { display: flex; flex-wrap: wrap; gap: .45rem; margin: .9rem 0; }
.nf-chip {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--nf-line); background: rgba(255, 255, 255, .05);
  color: #d6dae3; border-radius: 999px; padding: .3rem .85rem; font-size: .86rem; cursor: pointer; text-decoration: none; user-select: none;
}
.nf-chip:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.nf-chip.is-on, .btn-check:checked + .nf-chip { background: #fff; color: #111; border-color: #fff; }
.nf-chip-clear { color: #fca5a5; }
.nf-filter-panel { border: 1px solid var(--nf-line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--nf-bg-2); }
.nf-filter-panel fieldset { margin-bottom: .9rem; }
.nf-filter-panel legend { font-size: .85rem; color: var(--nf-muted); margin-bottom: .4rem; float: none; }
.nf-checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.nf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 1.4rem .9rem; margin-top: .6rem; }
.nf-pagination .page-link { background: transparent; border-color: var(--nf-line); color: #d6dae3; }
.nf-pagination .page-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nf-pagination .page-item.active .page-link { background: var(--nf-accent); border-color: var(--nf-accent); color: #fff; }
.nf-pagination .page-item.disabled .page-link { background: transparent; color: #4b5263; border-color: var(--nf-line); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) { .nf-page { --nf-card-w: 230px; } }
@media (max-width: 575.98px) {
  .nf-page { --nf-card-w: 70vw; }
  .nf-track-rank { grid-auto-columns: calc(40vw + 3.4rem); }
  .nf-rank { width: 3.4rem; font-size: 5.4rem; margin-right: -.8rem; -webkit-text-stroke-width: 2px; letter-spacing: -4px; }
  .nf-hero { height: 78vh; min-height: 440px; }
  .nf-hero-shade { background: linear-gradient(0deg, var(--nf-bg) 4%, rgba(11, 13, 20, .82) 45%, rgba(11, 13, 20, .2) 100%); }
  .nf-hero-desc { font-size: .95rem; -webkit-line-clamp: 2; }
  .nf-hero-actions .btn { flex: 1; padding: .6rem .9rem; font-size: .95rem; }
  .nf-hero .carousel-indicators { justify-content: center; margin-right: 15%; }
  .nf-search { padding-left: .85rem; }
  .nf-search select { display: none; }
  .nf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem .6rem; }
  .nf-grid .nf-title { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .nf-hero-bg img { animation: none; transform: none; }
  .nf-thumb, .nf-meta { transition: none; }
}
@media print { .nf-page { background: #fff; color: #000; } .nf-hero, .nf-toolbar, .nf-arrow { display: none !important; } }
