/* ===== TrangCCTV components (หน้าแรก + หน้าบทความ) ===== */

/* ── พื้นหลัง hero เคลื่อนไหว + เส้นสแกนแบบจอกล้องวงจรปิด ── */
.has-anim { position: relative; overflow: hidden; }
.has-anim > .container { position: relative; z-index: 2; }
.hero-anim { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.hero-anim::before {
    content: ""; position: absolute; inset: -48px;
    background-image: linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
            mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    animation: tcGrid 18s linear infinite;
}
.hero-anim::after {
    content: ""; position: absolute; left: 0; right: 0; top: -30%; height: 30%;
    background: linear-gradient(180deg, transparent, rgba(56,189,248,.07) 60%, rgba(56,189,248,.14) 98%, transparent);
    animation: tcScan 7s linear infinite;
}
.hero-anim span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .38; animation: tcFloat 16s ease-in-out infinite; }
.hero-anim span:nth-child(1) { width: 420px; height: 420px; background: #f97316; top: -170px; left: -120px; }
.hero-anim span:nth-child(2) { width: 460px; height: 460px; background: #2563eb; bottom: -220px; right: -120px; animation-delay: -6s; }
.hero-anim span:nth-child(3) { width: 260px; height: 260px; background: #10b981; top: 35%; left: 55%; opacity: .22; animation-delay: -11s; }
@keyframes tcGrid  { to { transform: translate(48px, 48px); } }
@keyframes tcScan  { to { top: 110%; } }
@keyframes tcFloat { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(50px,35px) scale(1.12); } 66% { transform: translate(-40px,25px) scale(.92); } }

/* ป้าย REC + นาฬิกา มุมจอ */
.cam-overlay { position: absolute; top: 16px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 2; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .78rem; letter-spacing: .08em; color: rgba(226,232,240,.75); pointer-events: none; }
.cam-rec { display: inline-flex; align-items: center; gap: 7px; }
.cam-rec::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 10px #ef4444; animation: tcBlink 1.2s steps(2, start) infinite; }
@keyframes tcBlink { to { visibility: hidden; } }

/* ข้อความบริการหมุนเวียน */
.hero-rotator { font-size: 1.05rem !important; color: #cbd5e1 !important; margin: -22px 0 34px !important; min-height: 1.7em; }
.hero-rotator .rot { display: inline-block; color: #fb923c; font-weight: 700; border-bottom: 2px solid rgba(251,146,60,.5); transition: opacity .35s ease, transform .35s ease; }
.hero-rotator .rot.out { opacity: 0; transform: translateY(-8px); }

/* ── แถบตัวเลข ── */
.stats { position: relative; z-index: 5; margin-top: -42px; padding: 0 20px; }
.stats-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-radius: 16px; box-shadow: 0 12px 34px rgba(15,23,42,.12); overflow: hidden; }
.stat { padding: 22px 14px; text-align: center; position: relative; }
.stat + .stat::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 1px; background: #e5e7eb; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: #1e3a8a; font-weight: 700; }
.stat b small { font-size: 1.1rem; color: #f97316; margin-left: 2px; }
.stat > span { font-size: .88rem; color: #6b7280; }
@media (max-width: 768px) {
    .stats { margin-top: -30px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat:nth-child(3)::before { display: none; }
    .stat:nth-child(n+3) { border-top: 1px solid #e5e7eb; }
    .stat b { font-size: 1.6rem; }
}

/* ── การ์ดบทความ ── */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 26px; }
.post-card { display: flex; flex-direction: column; background: #fff; border-radius: 14px; overflow: hidden; text-decoration: none; color: #1f2937; box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: transform .35s cubic-bezier(.4,0,.2,1), box-shadow .35s, opacity .8s ease-out; transition-delay: calc(var(--index, 0) * .08s); }
.post-card:hover { transform: translateY(-6px); box-shadow: 0 16px 34px rgba(15,23,42,.14); }
.post-card-img { position: relative; aspect-ratio: 16/10; background: linear-gradient(135deg, #1e293b, #334155); overflow: hidden; }
.post-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.post-card:hover .post-card-img img { transform: scale(1.06); }
.post-card-noimg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.35); font-size: 2.6rem; }
.post-card-cat { position: absolute; left: 12px; bottom: 12px; background: rgba(15,23,42,.78); backdrop-filter: blur(4px); color: #fff; font-size: .75rem; padding: 3px 10px; border-radius: 99px; }
.post-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.post-card-body time { font-size: .8rem; color: #9ca3af; }
.post-card-body h2, .post-card-body h3 { font-size: 1.12rem; font-weight: 700; line-height: 1.4; margin: 6px 0 8px; color: #1e3a8a; }
.post-card-body p { font-size: .9rem; color: #6b7280; margin-bottom: 14px; flex: 1; }
.post-card-more { font-size: .9rem; font-weight: 600; color: #f97316; }
.post-card-more i { transition: transform .25s; }
.post-card:hover .post-card-more i { transform: translateX(5px); }

.btn-outline { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; border: 2px solid #1e3a8a; color: #1e3a8a; border-radius: 30px; text-decoration: none; font-weight: 600; transition: all .3s; background: transparent; }
.btn-outline:hover { background: #1e3a8a; color: #fff; transform: translateY(-2px); }

/* ── ปุ่มติดต่อลอย ── */
.float-contact { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 12px; z-index: 999; }
.float-contact a { position: relative; width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.45rem; text-decoration: none; box-shadow: 0 6px 18px rgba(0,0,0,.25); transition: transform .25s; }
.float-contact a:hover { transform: scale(1.1); }
.float-contact a::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid currentColor; animation: tcPulse 2.2s ease-out infinite; }
.fc-line { background: #06c755; color: #06c755 !important; }
.fc-line i, .fc-phone i { color: #fff; }
.fc-phone { background: #f97316; color: #f97316 !important; }
.fc-phone::after { animation-delay: 1.1s !important; }
@keyframes tcPulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.7); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .hero-anim::before, .hero-anim::after, .hero-anim span, .cam-rec::before, .float-contact a::after { animation: none !important; }
    .hero-rotator .rot { transition: none; }
}
