/* หน้า /cartoon — การ์ตูนธรรมบท ๓๐๒ เรื่อง (ฐานธีมห้องฉาย app/css/study-cinema.css)
   สีหมวด = มรกต (--ct-acc) ชุดเดียวกับป้าย "การ์ตูน" ของ /story · ทอง = เลขเรื่องในเล่ม · ขนาดตัวอักษรผูก --reading-scale */
.ct-page { --ct-acc: #34d399; --ct-acc-fill: #047857; }
html[data-ui="light"] .ct-page { --ct-acc: #047857; }
.ct-page [hidden] { display: none !important; }
.ct-page .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html.ct-lock { overflow: hidden; }

/* ── ป้ายใหญ่: ผนังโปสเตอร์ปกเรื่องจริงทุกภาค ── */
.ct-wall { position: absolute; z-index: -2; top: -6%; right: -4%; width: min(72%, 980px); display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; transform: rotate(-6deg); transform-origin: 70% 40%; opacity: .95; }
.ct-wall img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .7); }
.ct-wall img:nth-child(12n + 2), .ct-wall img:nth-child(12n + 5), .ct-wall img:nth-child(12n + 9) { transform: translateY(18px); }
.ct-bill-inner { min-height: clamp(460px, 64vh, 600px); }
.ct-stats { display: flex; flex-wrap: wrap; gap: .4rem .5rem; margin: .4rem 0 0 !important; padding: 0; list-style: none; }
.ct-stats li { padding: .2rem .75rem; border-radius: 999px; background: rgba(var(--ui-tint), .08); border: 1px solid var(--sc-line); color: var(--sc-muted); font-weight: 700; font-size: calc(.84rem * var(--reading-scale, 1)); }
.ct-stats b { color: var(--ui-strong); }
.ct-stats .ct-stat-seen b { color: var(--ct-acc); }
html[data-ui="light"] .ct-stats li { background: rgba(255, 255, 255, .85); }

/* ── แถบภาค ── */
.ct-vols .sc-chip[aria-pressed="true"] { background: #fff; border-color: #fff; color: #0a0f1e; }
.ct-vols .sc-chip[aria-pressed="true"] .sc-chip-no { background: #0a0f1e; color: #fff; }
.ct-vols .sc-chip[aria-pressed="true"] .sc-chip-n { background: rgba(10, 15, 30, .1); color: #0a0f1e; }
html[data-ui="light"] .ct-vols .sc-chip[aria-pressed="true"] { background: #1e1b4b; border-color: #1e1b4b; color: #fff; }
html[data-ui="light"] .ct-vols .sc-chip[aria-pressed="true"] .sc-chip-no { background: #f5bf45; color: #3b2600; }
html[data-ui="light"] .ct-vols .sc-chip[aria-pressed="true"] .sc-chip-n { background: rgba(255, 255, 255, .18); color: #fff; }

/* ── เครื่องมือค้นหา/กรอง ── */
.ct-body { scroll-margin-top: 8rem; }
.ct-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .75rem 1rem; margin-bottom: 1.6rem; }
.ct-search { position: relative; display: flex; align-items: center; grid-column: 1 / -1; }
.ct-search > i { position: absolute; left: 1.05rem; color: var(--sc-dim); pointer-events: none; }
.ct-search input { width: 100%; min-height: 54px; padding: 0 3rem 0 2.8rem; border-radius: 14px; border: 1px solid var(--sc-line); background: var(--sc-bg2); color: var(--ui-strong); font: inherit; font-weight: 600; font-size: max(16px, calc(1.02rem * var(--reading-scale, 1))); box-shadow: 0 8px 24px -18px rgba(0, 0, 0, .6); }
.ct-search input::placeholder { color: var(--sc-dim); font-weight: 500; }
.ct-search input:focus { outline: none; border-color: var(--ct-acc); box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.ct-search input::-webkit-search-cancel-button { display: none; }
.ct-search-x { position: absolute; right: .5rem; width: 40px; height: 40px; border: 0; border-radius: 999px; background: rgba(var(--ui-tint), .08); color: var(--sc-muted); cursor: pointer; }
.ct-search-x:hover { background: rgba(var(--ui-tint), .16); color: var(--ui-strong); }
.ct-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.ct-seg { display: inline-flex; flex-wrap: wrap; padding: 3px; border-radius: 12px; background: rgba(var(--ui-tint), .06); border: 1px solid var(--sc-line); }
.ct-seg button, .ct-toggle { min-height: 40px; padding: 0 .85rem; border: 0; border-radius: 9px; background: transparent; color: var(--sc-muted); font: inherit; font-weight: 700; font-size: calc(.86rem * var(--reading-scale, 1)); cursor: pointer; white-space: nowrap; }
.ct-seg button:hover, .ct-toggle:hover { color: var(--ui-strong); }
.ct-seg button[aria-pressed="true"] { background: var(--ui-sel-bg); color: var(--ui-sel-ink); box-shadow: 0 2px 8px -4px rgba(0, 0, 0, .5); }
html[data-ui="light"] .ct-seg button[aria-pressed="true"] { background: #1e1b4b; color: #fff; }
.ct-toggle { border: 1px solid var(--sc-line); border-radius: 12px; min-height: 46px; }
.ct-toggle i { margin-right: .3rem; }
.ct-toggle[aria-pressed="true"] { background: var(--ct-acc-fill); border-color: var(--ct-acc-fill); color: #fff; }
.ct-count { margin: 0; justify-self: end; color: var(--sc-muted); font-weight: 700; font-size: calc(.88rem * var(--reading-scale, 1)); white-space: nowrap; }
.ct-page button:focus-visible, .ct-page a:focus-visible { outline: 3px solid var(--sc-gold); outline-offset: 2px; }

/* ── หัวภาค ── */
.ct-vol { scroll-margin-top: 8rem; }
.ct-vol + .ct-vol { margin-top: 3rem; }
.ct-vol-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding-bottom: .9rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--sc-line); }
.ct-vol-cover { width: 68px; height: 68px; flex: none; border-radius: 14px; object-fit: cover; box-shadow: 0 0 0 1px rgba(var(--ui-tint), .12), 0 10px 22px -14px rgba(0, 0, 0, .8); }
.ct-vol-copy { flex: 1 1 200px; min-width: 0; }
.ct-vol-copy > * { margin: 0; }
.ct-vol-kicker { color: var(--sc-gold); font-weight: 800; font-size: calc(.8rem * var(--reading-scale, 1)); }
.ct-vol-copy h2 { color: var(--ui-strong); font-weight: 800; line-height: 1.25; font-size: calc(clamp(1.45rem, 2.4vw, 1.85rem) * var(--reading-scale, 1)); }
.ct-vol-facts { display: flex; flex-wrap: wrap; gap: .2rem .9rem; color: var(--sc-muted); font-weight: 700; font-size: calc(.86rem * var(--reading-scale, 1)); }
.ct-vol-n { color: var(--sc-muted); font-weight: 700; font-size: calc(.86rem * var(--reading-scale, 1)); }
.ct-vol-n b { color: var(--ui-strong); }
.ct-vol-read { display: inline-flex; align-items: center; gap: .45rem; min-height: 42px; padding: 0 .95rem; border-radius: 10px; border: 1px solid var(--sc-line); background: rgba(var(--ui-tint), .05); color: var(--ui-ink2); font-weight: 800; text-decoration: none; font-size: calc(.85rem * var(--reading-scale, 1)); }
.ct-vol-read i { color: var(--ct-acc); }
.ct-vol-read:hover { background: rgba(var(--ui-tint), .12); color: var(--ui-strong); }

/* ── การ์ดเรื่อง ── */
.ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 1.1rem; margin: 0; padding: 0; list-style: none; }
.ct-card { position: relative; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--sc-bg2); box-shadow: 0 0 0 1px rgba(var(--ui-tint), .08); transition: transform .3s cubic-bezier(.25, 1, .5, 1), box-shadow .25s ease; }
.ct-card:hover, .ct-card:focus-within { transform: translateY(-4px); box-shadow: 0 0 0 1px rgba(var(--ui-tint), .2), 0 18px 40px -20px rgba(0, 0, 0, .85); }
html[data-ui="light"] .ct-card { box-shadow: 0 0 0 1px rgba(20, 26, 51, .08), 0 8px 20px -16px rgba(20, 26, 51, .35); }
.ct-card.is-last { box-shadow: 0 0 0 3px var(--ct-acc), 0 18px 40px -20px rgba(4, 120, 87, .6); }
.ct-main { display: flex; flex: 1; flex-direction: column; color: inherit; text-decoration: none; }
.ct-thumb { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--sc-panel); }
.ct-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.ct-card:hover .ct-thumb img { transform: scale(1.05); }
.ct-no { position: absolute; z-index: 2; left: .5rem; top: .5rem; min-width: 32px; height: 32px; padding: 0 .4rem; display: grid; place-items: center; border-radius: 999px; background: var(--sc-gold-fill, #f5bf45); color: #3b2600; font-weight: 800; font-size: calc(.88rem * var(--reading-scale, 1)); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .55); }
.ct-dur { position: absolute; z-index: 2; right: .5rem; bottom: .5rem; padding: .05rem .45rem; border-radius: 6px; background: rgba(10, 15, 30, .82); color: #fff; font-weight: 700; font-size: calc(.76rem * var(--reading-scale, 1)); }
.ct-seen { position: absolute; z-index: 2; right: .5rem; top: .5rem; display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; background: var(--ct-acc-fill); color: #fff; font-weight: 800; font-size: calc(.72rem * var(--reading-scale, 1)); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .55); }
.ct-playbtn { position: absolute; z-index: 2; left: 50%; top: 50%; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 999px; background: rgba(4, 120, 87, .9); color: #fff; transform: translate(-50%, -50%) scale(.85); opacity: 0; transition: opacity .2s ease, transform .2s ease; font-size: calc(1.05rem * var(--reading-scale, 1)); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .6); }
.ct-playbtn i { margin-left: 3px; }
.ct-card:hover .ct-playbtn, .ct-main:focus-visible .ct-playbtn { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ct-card.is-soon .ct-playbtn { display: none; }
.ct-info { display: flex; flex: 1; flex-direction: column; gap: .25rem; padding: .7rem .85rem .55rem; }
.ct-label { color: var(--ct-acc); font-weight: 800; font-size: calc(.76rem * var(--reading-scale, 1)); }
.ct-title { color: var(--ui-strong); font-weight: 800; line-height: 1.4; font-size: calc(1rem * var(--reading-scale, 1)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-hook { color: var(--sc-muted); line-height: 1.5; font-size: calc(.82rem * var(--reading-scale, 1)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-read { display: flex; align-items: center; gap: .4rem; min-height: 40px; margin: 0 .85rem .7rem; padding: 0 .1rem; border-top: 1px solid var(--sc-line); color: var(--sc-muted); font-weight: 700; text-decoration: none; font-size: calc(.8rem * var(--reading-scale, 1)); }
.ct-read i { color: var(--ct-acc); }
.ct-read:hover { color: var(--ui-strong); }

/* ── ไม่พบ ── */
.ct-empty { margin: 1rem auto 0; max-width: 520px; padding: 2.4rem 1.2rem; border-radius: 18px; border: 1px dashed var(--sc-line); text-align: center; color: var(--sc-muted); }
.ct-empty > i { font-size: 1.8rem; color: var(--sc-dim); }
.ct-empty p { margin: .6rem 0 0; line-height: 1.6; }
.ct-empty-t { color: var(--ui-strong); font-weight: 800; font-size: calc(1.08rem * var(--reading-scale, 1)); }
.ct-empty .sc-btn { margin-top: 1rem; }
.ct-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin: 3rem 0 0; }
.ct-foot a { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--sc-line); color: var(--ui-ink2); font-weight: 700; text-decoration: none; font-size: calc(.86rem * var(--reading-scale, 1)); }
.ct-foot a:hover { background: rgba(var(--ui-tint), .08); color: var(--ui-strong); }
.ct-foot .fa-youtube { color: #ff4e45; }
.ct-foot .fa-feather, .ct-foot .fa-video { color: var(--ct-acc); }

/* ── ตัวเล่น (มืดเสมอทั้งสองโหมด) ── */
.ct-player { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(6, 9, 20, .9); backdrop-filter: blur(6px); }
.ct-player-in { position: relative; width: min(100%, calc((100dvh - 150px) * 9 / 16)); min-width: min(100%, 330px); max-width: 480px; }
.ct-player video { display: block; width: 100%; max-height: calc(100dvh - 150px); aspect-ratio: 9 / 16; border-radius: 16px; background: #000; }
.ct-player-x { position: absolute; top: -14px; right: -14px; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 999px; background: #fff; color: #141a33; font-size: 20px; cursor: pointer; box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .6); }
.ct-p-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; margin-top: .7rem; color: #fff; }
.ct-p-copy { min-width: 0; flex: 1 1 160px; }
.ct-p-copy p { margin: 0; }
.ct-p-label { color: #6ee7b7; font-weight: 800; font-size: 13px; }
.ct-p-title { font-weight: 800; font-size: 16px; line-height: 1.35; }
.ct-p-acts { display: flex; gap: .4rem; }
.ct-p-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-width: 44px; min-height: 44px; padding: 0 .8rem; border: 0; border-radius: 11px; background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-weight: 800; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.ct-p-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.ct-p-btn:disabled { opacity: .35; cursor: default; }
.ct-p-yt .fa-youtube { color: #ff4e45; font-size: 18px; }
.ct-p-next { background: #047857; }
.ct-p-next:hover:not(:disabled) { background: #065f46; }
.ct-player.is-ended .ct-p-next:not(:disabled) { box-shadow: 0 0 0 3px #6ee7b7; }
.ct-player button:focus-visible, .ct-player a:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }

@media (max-width: 820px) {
	.ct-tools { grid-template-columns: minmax(0, 1fr); }
	.ct-count { justify-self: start; }
	.ct-wall { width: 120%; right: -30%; top: -10%; opacity: .55; }
}
@media (max-width: 640px) {
	.ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
	.ct-info { padding: .55rem .65rem .45rem; }
	.ct-title { font-size: calc(.92rem * var(--reading-scale, 1)); }
	.ct-hook { display: none; }
	.ct-read { margin: 0 .65rem .5rem; min-height: 38px; }
	.ct-playbtn { display: none; }
	.ct-no { min-width: 28px; height: 28px; font-size: calc(.8rem * var(--reading-scale, 1)); }
	.ct-vol-cover { width: 56px; height: 56px; }
	.ct-vol-read { margin-left: auto; }
	.ct-seg { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.ct-seg button { padding: 0 .3rem; white-space: normal; line-height: 1.2; }
	.ct-toggle { width: 100%; }
	.ct-player { padding: 10px; align-content: center; }
	.ct-player-in { width: 100%; min-width: 0; }
	.ct-player video { max-height: calc(100dvh - 170px); width: auto; max-width: 100%; margin: 0 auto; }
	.ct-player-x { top: 6px; right: 6px; }
	.ct-p-acts { width: 100%; }
	.ct-p-read { flex: 1; }
	.ct-p-next span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.ct-card, .ct-thumb img, .ct-playbtn { transition: none; }
}
