/* ==========================================================================
   🎬 site-effects.css — เอฟเฟกต์ที่ใช้ร่วมกันทุกหน้าฝั่งผู้อ่าน
   1) การ์ดมังงะ "พับกระดาษ" ตอนกด ก่อนเด้งไปหน้ารายละเอียด
   2) ขอบเคลื่อนไหว (วิ่งวน) สำหรับการ์ด/ตอนที่เพิ่งอัปเดตใหม่
   3) ชื่อเรื่องไล่สี RGB แบบเคลื่อนไหว
   4) นาวบาร์/เมนูโปรไฟล์ สไตล์เรียบ อ่านง่าย (ปุ่มไอคอนกลม + การ์ดโปรไฟล์)
   ========================================================================== */

/* ---------- 1) เอฟเฟกต์พับกระดาษตอนกดการ์ด ---------- */
.fold-anim {
    position: relative;
    cursor: pointer;
    transform-origin: center center;
    will-change: transform;
}
.fold-anim.is-folding {
    animation: cardFoldShrink .38s ease forwards;
    pointer-events: none;
    overflow: hidden; /* กันมุมพับโผล่ออกนอกขอบการ์ดที่ไม่ได้ตั้ง overflow:hidden ไว้แต่แรก */
    border-radius: inherit;
}
.fold-anim.is-folding::after {
    content: '';
    position: absolute;
    top: 0; right: 0; width: 0; height: 0;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.92) 50.5%);
    box-shadow: -8px 8px 16px rgba(0,0,0,.45);
    animation: cardFoldCorner .38s ease forwards;
    z-index: 30;
    border-bottom-left-radius: 6px;
}
@keyframes cardFoldCorner {
    0%   { width: 0;   height: 0; }
    100% { width: 55%; height: 55%; }
}
@keyframes cardFoldShrink {
    0%   { transform: scale(1) rotate(0deg); filter: brightness(1); }
    55%  { transform: scale(.95) rotate(-1.5deg); filter: brightness(.92); }
    100% { transform: scale(.9) rotate(-2.5deg); filter: brightness(.8); opacity: .88; }
}
@media (prefers-reduced-motion: reduce) {
    .fold-anim.is-folding,
    .fold-anim.is-folding::after { animation: none !important; }
}

/* ---------- 2) เครื่องหมายของใหม่/อัปเดตใหม่ (เอาขอบเคลื่อนไหวสีชมพู/เหลืองออกแล้วตามคำขอ) ---------- */
.new-glow-wrap {
    position: relative;
    border-radius: 18px;
}

/* ---------- 3) ชื่อเรื่องไล่สี RGB เคลื่อนไหว ---------- */
.rgb-title {
    background: linear-gradient(90deg, #ff5c5c, #ffb347, #ffee58, #66e07a, #55c1ff, #b98bff, #ff5c5c);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #d4af37; /* fallback สำหรับเบราว์เซอร์ที่ไม่รองรับ background-clip:text */
    animation: rgbTitleFlow 5s linear infinite;
}
@keyframes rgbTitleFlow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}
@media (prefers-reduced-motion: reduce) {
    .rgb-title { animation: none; }
}

/* ---------- 4) นาวบาร์แบบเรียบ + เมนูโปรไฟล์ ---------- */
.nav-clean-link {
    color: #c4c4c9; text-decoration: none; font-size: 0.9rem; font-weight: 600;
    padding: 8px 14px; border-radius: 10px; display: inline-flex; align-items: center; gap: 7px;
    white-space: nowrap; transition: all .2s;
}
.nav-clean-link i { font-size: 0.85rem; color: #6b6b70; transition: color .2s; }
.nav-clean-link:hover, .nav-clean-link.active { color: #fff; background: rgba(255,255,255,.06); }
.nav-clean-link:hover i, .nav-clean-link.active i { color: var(--primary-color); }

.nav-icon-btn {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid #27272a;
    background: #17171a; color: #c4c4c9; display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; transition: all .2s; flex-shrink: 0;
}
.nav-icon-btn:hover { color: #fff; border-color: var(--primary-color); background: #1c1c20; }
.nav-icon-dot {
    position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 50%;
    background: #e11d48; border: 2px solid #17171a;
}

.btn-signup-pill {
    background: linear-gradient(135deg, var(--primary-color) 0%, #f2c94c 100%); color: #1a1305 !important;
    font-weight: 700; border-radius: 20px; padding: 8px 18px; font-size: 0.86rem;
    text-decoration: none; white-space: nowrap;
}

.profile-avatar-btn { background: transparent; border: none; padding: 0; line-height: 0; }
.profile-avatar-circle {
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #b8860b 100%); color: #1a1305;
    font-weight: 800; font-size: 0.95rem; border: 2px solid rgba(212,175,55,.35); flex-shrink: 0;
}
.profile-avatar-circle.lg { width: 52px; height: 52px; font-size: 1.2rem; }

/* ---------- 5) แก้นาวบาร์ตกบรรทัดที่ 2 บนจอแคบ (แท็บเล็ต/มือถือแนวนอน) ----------
   ปัญหาเดิม: แถวนาวบาร์ (โลโก้ + เมนู + กลุ่มไอคอนขวาสุด) ใช้ Bootstrap class "flex-wrap" และ .main-menu
   มี overflow-x:auto ไว้เลื่อนแนวนอนอยู่แล้ว แต่ flexbox ไม่ยอมให้ .main-menu หดตัวเล็กกว่าความกว้างเนื้อหา
   จริงของมันเอง (ค่าเริ่มต้น min-width ของ flex item คือ "auto" ไม่ใช่ 0) ผลคือ .main-menu แย่งพื้นที่จนกลุ่ม
   ไอคอนขวาสุด (กระดิ่ง/ค้นหา/เข้าสู่ระบบ/สมัครสมาชิก) ล้นไปตกบรรทัดที่ 2 ทั้งที่อยากให้อยู่แถวเดียวกันเสมอ
   วิธีแก้: บังคับแถวนี้ไม่ให้ตกบรรทัด (nowrap) + ปลดล็อกให้ .main-menu หดตัวได้จริงด้วย min-width:0 (เมื่อพื้นที่
   ไม่พอ เมนูจะเลื่อนแนวนอนแทนการดันของอื่นล้น) + กันกลุ่มไอคอนขวาสุดหดจนบี้ ด้วย flex-shrink:0 พร้อมให้เลื่อน
   แนวนอนได้เองเป็นทางสำรองสุดท้ายถ้าไอคอนเยอะเกินจอมือถือจริงๆ (เหมือนกลไกเดียวกับ .main-menu) */
.custom-navbar .container.d-flex,
.custom-navbar .container { flex-wrap: nowrap !important; }
.custom-navbar .navbar-brand { flex-shrink: 0; }
.main-menu { min-width: 0; flex-wrap: nowrap !important; }
/* ⚠️ แก้บั๊ก 22/9: ห้ามใส่ overflow-x:auto ให้ .nav-icon-cluster เด็ดขาด — กลุ่มไอคอนนี้มีเมนู dropdown
   ของปุ่มแจ้งเตือนและปุ่มโปรไฟล์ (วงกลมตัวอักษรชื่อผู้ใช้) ซ้อนอยู่ข้างในเป็นลูกโดยตรง การตั้ง overflow-x
   ให้ไม่ใช่ visible จะทำให้เบราว์เซอร์บังคับ overflow-y เป็น auto ไปด้วยโดยอัตโนมัติ (พฤติกรรมมาตรฐานของ
   CSS overflow) กลายเป็นว่ากล่องนี้ "ตัด" เมนู dropdown ที่กางออกมาด้านล่างจนมองไม่เห็น/กดไม่ได้ทันที
   ไอคอนกลุ่มนี้มีจำนวนคงที่ไม่กี่ปุ่ม ไม่จำเป็นต้องเลื่อนแนวนอนเหมือน .main-menu (ซึ่งมีลิงก์เมนูเยอะกว่ามาก
   และไม่มี dropdown ซ้อนอยู่ข้างใน) แค่ flex-shrink:0 ก็เพียงพอกันไม่ให้ไอคอนถูกบีบจนเสียรูปแล้ว */
.nav-icon-cluster {
    flex-shrink: 0;
}

/* 🖥️ โหมดจอกลาง (แท็บเล็ต/หน้าต่างเบราว์เซอร์แคบกว่าเดสก์ท็อปเต็มจอ): ตอนนี้ทุกหน้าที่มีนาวบาร์แบบเต็ม
   ใช้เมนูชุดเดียวกัน 8 รายการเสมอ (เพิ่ม "ข่าวสาร" เข้ามาให้ครบทุกหน้า) แน่นกว่าจอเดสก์ท็อปกว้างๆ เล็กน้อย
   ย่อ padding/ระยะห่างของลิงก์เมนูลงอีกขั้นตรงนี้ ก่อนจะถึงเบรกพอยต์มือถือด้านล่าง เพื่อให้เห็นเมนูได้มากขึ้น
   ก่อนต้องเลื่อนแนวนอน (แถวเมนูเลื่อนซ้าย-ขวาได้อยู่แล้วถ้าพื้นที่ไม่พอ ไม่มีทางตกบรรทัดที่ 2 แน่นอน) */
@media (max-width: 992px) {
    .main-menu.d-flex { gap: 4px !important; }
    .nav-clean-link { padding: 7px 12px; font-size: 0.88rem; }
}

/* 📱 โหมดมือถือ: ย่อขนาด/ระยะห่างของโลโก้ เมนู และปุ่มไอคอนลงอีกขั้น ให้ดูโปร่ง อ่านง่าย ไม่แน่นอัดกัน
   (เดิมใช้ขนาดเดียวกับจอเดสก์ท็อปทั้งหมด บนจอมือถือจริงจึงดูแน่นเกินไป) */
@media (max-width: 576px) {
    .custom-navbar { padding: 10px 0; }
    .custom-navbar .navbar-brand { font-size: 1.05rem !important; gap: 6px !important; }
    .custom-navbar .navbar-brand img { height: 30px !important; }
    .main-menu.d-flex { gap: 2px !important; }
    .nav-clean-link { padding: 6px 10px; font-size: 0.8rem; }
    .nav-icon-cluster.d-flex { gap: 6px !important; }
    .nav-icon-btn { width: 34px; height: 34px; font-size: 0.85rem; }
    .btn-signup-pill { padding: 6px 14px; font-size: 0.8rem; }
}

.profile-dropdown-card {
    width: 300px !important; background: #121215 !important; border-radius: 18px !important;
    border: 1px solid rgba(212,175,55,.3) !important; box-shadow: 0 20px 45px rgba(0,0,0,.7) !important;
    padding: 16px !important;
}
.profile-card-header { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 12px; border-bottom: 1px solid #27272a; }
.profile-card-meta { min-width: 0; }
.profile-card-name { color: #fff; font-weight: 700; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-role-chip {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; background: rgba(212,175,55,.14); color: var(--primary-color);
    border: 1px solid rgba(212,175,55,.35); font-size: 0.68rem; font-weight: 700; padding: 2px 10px; border-radius: 20px;
}

.profile-balance-row {
    display: flex; align-items: center; gap: 10px; background: #18181b; border: 1px solid #27272a;
    border-radius: 14px; padding: 10px 12px; margin-bottom: 10px;
}
.profile-balance-row.earnings { border-color: rgba(34,197,94,.25); }
.profile-balance-icon {
    width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: rgba(212,175,55,.14); color: var(--primary-color); font-size: 0.95rem; flex-shrink: 0;
}
.profile-balance-row.earnings .profile-balance-icon { background: rgba(34,197,94,.14); color: #4ade80; }
.profile-balance-text { flex: 1; min-width: 0; }
.profile-balance-amount { color: #fff; font-weight: 800; font-size: 0.98rem; line-height: 1.1; }
.profile-balance-label { color: #8b8b92; font-size: 0.72rem; margin-top: 1px; }
.profile-balance-action {
    background: var(--primary-color); color: #1a1305; font-weight: 700; font-size: 0.78rem;
    padding: 6px 12px; border-radius: 10px; text-decoration: none; white-space: nowrap;
}
.profile-balance-action.alt { background: #22c55e; color: #052e16; }

.profile-menu-list { display: flex; flex-direction: column; }
.profile-menu-item {
    display: flex; align-items: center; gap: 10px; color: #d4d4d8; text-decoration: none;
    padding: 9px 10px; border-radius: 10px; font-size: 0.86rem; font-weight: 500; border: none;
    background: transparent; width: 100%; text-align: left;
}
.profile-menu-item i { width: 16px; text-align: center; color: #8b8b92; }
.profile-menu-item:hover { background: #1c1c20; color: #fff; }
.profile-menu-item.logout { color: #fca5a5; margin-top: 4px; padding-top: 11px; border-top: 1px solid #27272a; border-radius: 0; }
.profile-menu-item.logout i { color: #fca5a5; }
.profile-logout-form { margin: 0; }

/* ---------- 5) แถบสถิติเว็บ / หมวดหมู่ด่วน / อ่านต่อจากที่ค้างไว้ (หน้าแรก) ---------- */
.home-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.home-stat-box {
    background: #121215; border: 1px solid rgba(212,175,55,.25); border-radius: 16px;
    padding: 18px 10px; text-align: center;
}
.home-stat-number { font-size: 1.5rem; font-weight: 800; color: #fff; line-height: 1.2; font-variant-numeric: tabular-nums; }
.home-stat-label { color: #8b8b92; font-size: 0.78rem; margin-top: 4px; }

.home-category-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 32px; }
.home-category-card {
    background: #121215; border: 1px solid #27272a; border-radius: 16px; padding: 14px;
    display: flex; align-items: center; gap: 10px; text-decoration: none; transition: all .25s;
}
.home-category-card:hover { border-color: var(--primary-color); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.home-category-icon {
    /* เดิมรับสีพื้นหลังต่างกันทุกใบผ่าน inline style (น้ำเงิน/แดง/ส้ม/เขียว/ม่วง) ทำให้แถวหมวดหมู่ดูลายตา
       เปลี่ยนเป็นโทนทองเข้ม-อำพันเดียวกันทุกใบ ให้เข้ากับธีมทองมินิมอลของทั้งเว็บ */
    width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(212,175,55,.22) 0%, rgba(184,134,11,.14) 100%);
    border: 1px solid rgba(212,175,55,.3);
    color: var(--primary-color, #d4af37); font-size: 1.05rem; flex-shrink: 0;
}
.home-category-card:hover .home-category-icon {
    background: linear-gradient(135deg, var(--primary-color, #d4af37) 0%, #b8860b 100%);
    color: #1a1305;
}
.home-category-label { color: #fff; font-weight: 700; font-size: 0.88rem; line-height: 1.2; }
.home-category-count { color: #8b8b92; font-size: 0.74rem; }

.continue-reading-card { min-width: 190px; max-width: 190px; background: #121215; border: 1px solid #27272a; border-radius: 14px; padding: 8px; flex-shrink: 0; transition: all .3s; }
.continue-reading-card:hover { transform: translateY(-4px); border-color: var(--primary-color); }
.continue-progress-track { background: #27272a; border-radius: 20px; height: 5px; overflow: hidden; margin-top: 8px; }
.continue-progress-fill { background: linear-gradient(90deg, var(--primary-color) 0%, #f2c94c 100%); height: 100%; border-radius: 20px; }

@media (max-width: 480px) {
    .home-category-row { grid-template-columns: repeat(2, 1fr); }
    .home-stat-number { font-size: 1.2rem; }
}

/* ---------- 7) โหมดเนื้อหาสำหรับผู้ใหญ่ 18+ — ปุ่มสลับ (แทนที่ปุ่มสลับธีมสว่าง/มืดเดิมที่เอาออกแล้ว
   เพราะเว็บนี้เป็นธีมมืดล้วน ไม่มีธีมสว่างรองรับจริง) + เบลอรูปปกเรื่องที่ติดเรต 18+ จนกว่าจะยืนยันอายุ
   หรือเอาเมาส์ไปชี้ที่รูปนั้นๆ ชั่วคราว ---------- */
.nav-icon-btn.nsfw-toggle-btn.active { background: var(--primary-color); color: #1a1305; border-color: var(--primary-color); }

/* 🖼️ ที่ว่างแทนรูปปกตอนยังไม่มีรูป — ใช้ร่วมกันได้ทุกหน้าที่โหลดไฟล์นี้ (เดิมแต่ละหน้าใช้กล่องเทาทึบ + ตัวหนังสือ "No Image" ดูหยาบ) */
.no-cover-ph {
    width: 100%; height: 100%;
    background: linear-gradient(160deg, #1c1a12 0%, #121215 65%);
    display: flex; align-items: center; justify-content: center;
    color: rgba(212, 175, 55, 0.45); font-size: 1.6rem;
}

/* 🔞 ปกเรื่อง 18+ ในหน้ารายการ (หน้าแรก/คลังมังงะ/จัดอันดับ/ค้นหา) — เบลอไว้เป็นค่าเริ่มต้นเสมอ
   ตามที่เจ้าของเว็บระบุ: เอาเมาส์ไปชี้ที่รูปให้เห็นภาพชั่วคราว (แอบดูก่อนตัดสินใจ) แต่พอเมาส์ออกจากรูป
   กลับไปเบลอเหมือนเดิมทันที ถ้าอยากให้เห็นภาพแบบไม่ต้องชี้เมาส์ทุกครั้ง ต้องกดยืนยันอายุ/เปิดโหมด 18+
   ก่อน (body.nsfw-on) ถึงจะเอาเบลอออกถาวรได้ — บนมือถือ/แตะหน้าจอไม่มี hover จะยังเบลอไว้จนกว่าจะเปิด
   โหมด 18+ หรือกดเข้าไปดูหน้ารายละเอียดเรื่องโดยตรง */
.nsfw-cover { position: relative; overflow: hidden; }
.nsfw-cover img { filter: blur(22px) saturate(70%); transform: scale(1.1); transition: filter .3s ease; }
.nsfw-cover:hover img { filter: none; transform: none; }
body.nsfw-on .nsfw-cover img { filter: none !important; transform: none; }
.nsfw-cover::after {
    content: "🔞 18+"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 0.72rem; letter-spacing: .5px;
    background: rgba(0,0,0,.35); pointer-events: none; transition: opacity .3s ease; z-index: 2;
}
.nsfw-cover:hover::after { opacity: 0; }
body.nsfw-on .nsfw-cover::after { opacity: 0; }

/* ---------- 6) Creator Ranking (อันดับนักเขียนยอดนิยม จากยอดวิวรวมของผลงานจริง) ---------- */
.creator-rank-panel { margin-top: 20px; background: #121215; border: 1px solid #27272a; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.creator-rank-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #27272a; }
.creator-rank-tabs { display: flex; gap: 4px; background: rgba(0,0,0,.3); padding: 4px; border-radius: 10px; flex-shrink: 0; }
.creator-rank-tab-btn { background: transparent; border: none; color: #9ca3af; padding: 6px 12px; font-weight: 600; font-size: 0.78rem; border-radius: 8px; transition: .2s; white-space: nowrap; }
.creator-rank-tab-btn.active, .creator-rank-tab-btn:hover { background: var(--primary-color); color: #1a1305; }
.creator-rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.05); }
.creator-rank-row:last-child { border-bottom: none; }
.creator-rank-icon { width: 28px; text-align: center; font-weight: 800; color: #52525b; font-size: 0.92rem; flex-shrink: 0; }
.creator-rank-icon.gold { color: #FFD700; text-shadow: 0 0 12px rgba(255,215,0,.6); }
.creator-rank-icon.silver { color: #E5E7EB; text-shadow: 0 0 12px rgba(229,231,235,.5); }
.creator-rank-icon.bronze { color: #D97706; text-shadow: 0 0 12px rgba(217,119,6,.5); }

/* ---------- 7) ปุ่มลอย "กลับขึ้นบนสุด" — โผล่มุมขวาล่างเมื่อเลื่อนหน้าลงมาระดับหนึ่ง ---------- */
.back-to-top-btn {
    position: fixed; bottom: 26px; right: 22px; width: 46px; height: 46px; border-radius: 50%;
    background: #3b82f6; color: #fff; border: none; display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; box-shadow: 0 8px 22px rgba(0,0,0,.4); z-index: 1040; cursor: pointer;
    opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .25s ease, transform .25s ease, background .15s ease;
}
.back-to-top-btn.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top-btn:hover { background: #2563eb; }
@media (max-width: 576px) { .back-to-top-btn { bottom: 18px; right: 16px; width: 42px; height: 42px; } }

/* ---------- 8) ป็อปอัพประกาศหน้าบ้าน (ลูกค้า/ผู้อ่าน) — สร้างด้วย JS ล้วนใน site-effects.js ---------- */
.site-popup-overlay {
    position: fixed; inset: 0; z-index: 1080; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(2px);
    opacity: 0; transition: opacity .2s ease;
}
.site-popup-overlay.is-open { opacity: 1; }
.site-popup-overlay.is-closing { opacity: 0; }
.site-popup-box {
    position: relative; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
    background: #121215; border: 1px solid rgba(212,175,55,.3); border-radius: 18px;
    box-shadow: 0 25px 60px rgba(0,0,0,.6); transform: scale(.94) translateY(8px); transition: transform .2s ease;
}
.site-popup-overlay.is-open .site-popup-box { transform: scale(1) translateY(0); }
.site-popup-close {
    position: absolute; top: 10px; right: 10px; z-index: 2; width: 32px; height: 32px; border-radius: 50%;
    background: rgba(0,0,0,.5); color: #fff; border: 1px solid rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .2s;
}
.site-popup-close:hover { background: rgba(0,0,0,.75); }
.site-popup-image { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: 18px 18px 0 0; }
.site-popup-body { padding: 22px 22px 24px; }
.site-popup-title { color: #fff; font-weight: 800; font-size: 1.15rem; margin: 0 0 10px; }
.site-popup-content { color: #c4c4c9; font-size: 0.92rem; line-height: 1.6; white-space: pre-line; margin: 0 0 16px; }
.site-popup-link-btn {
    display: inline-block; background: linear-gradient(135deg, var(--primary-color, #d4af37) 0%, #f2c94c 100%);
    color: #1a1305; font-weight: 700; text-decoration: none; padding: 10px 22px; border-radius: 12px; font-size: 0.9rem;
}
@media (max-width: 480px) {
    .site-popup-body { padding: 18px 18px 20px; }
    .site-popup-title { font-size: 1.05rem; }
}
