/* หน้าแรก (ดีไซน์ใหม่) — pages/home.php | หน้าเดิมใช้ css/home-hero.css */
/* style.css ตั้ง img { min-width: 150px } ทั้งเว็บ — การ์ด/โลโก้ที่แคบกว่านั้นภาพจะล้น */
.hm-page img { min-width: 0; }

.hm-page {
    --hm-bg: #020d18;
    --hm-card: #0a1a2b;
    --hm-text: #e8ecf0;
    --hm-muted: #abb7c4;
    --hm-dim: #6f8296;
    --hm-accent: #2984e8;
    --hm-accent-2: #4a9bf0;
    --hm-gutter: clamp(16px, 4vw, 64px);
    font-family: 'Noto Sans Thai', sans-serif;
    background: var(--hm-bg);
    color: var(--hm-muted);
    overflow-x: hidden;
    padding-bottom: 80px;
}

/* ═════════ Banner (โหมด link) — ภาพในกรอบ มีระยะห่างรอบด้าน ═════════ */
.hm-banner-wrap {
    position: relative; isolation: isolate; overflow: hidden;
    padding: 96px var(--hm-gutter) 8px;
}
.hm-banner-ambient { position: absolute; inset: 0; z-index: -2; }
.hm-banner-ambient img { width: 100%; height: 100%; object-fit: cover; filter: blur(48px) saturate(1.25); opacity: .45; transform: scale(1.15); }
/* ไล่พื้นหลังให้กลืนกับ header ด้านบนและเนื้อหาด้านล่าง */
.hm-banner-wrap::after {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(180deg, rgba(2, 13, 24, .75) 0%, rgba(2, 13, 24, .25) 30%, rgba(2, 13, 24, .45) 70%, var(--hm-bg) 100%);
}
.hm-page .hm-banner {
    position: relative; display: block; width: 100%; margin: 0 auto; line-height: 0; overflow: hidden;
    border-radius: 18px; background: #040c18;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .08);
    transition: transform .3s ease, box-shadow .3s ease;
}
.hm-banner img { width: 100%; height: auto; max-height: 72vh; object-fit: cover; display: block; user-select: none; -webkit-touch-callout: none; }
.hm-banner-wrap + .hm-sections { padding-top: 28px; }
@media (hover: hover) {
    .hm-page a.hm-banner:hover { transform: translateY(-3px); box-shadow: 0 30px 70px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .22); }
}
.hm-page a.hm-banner:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 4px; }

/* ═════════ Hero ═════════ */
.hm-hero {
    position: relative; isolation: isolate;
    height: min(90vh, 860px); min-height: 560px;
    display: flex; align-items: flex-end;
}
.hm-hero-media { position: absolute; inset: 0; z-index: -1; overflow: hidden; background: #040c18; }
.hm-hero-ambient { display: none; }
/* ribbon รอบฉายบนมุมโปสเตอร์ — ใช้เฉพาะมือถือ (เดสก์ท็อปใช้ .hm-hero-eyebrow) */
.hm-hero-ribbon { display: none; }
.hm-hero-img, .hm-hero-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hm-hero-img { object-position: center 25%; animation: hm-kenburns 22s ease-out both; }
@keyframes hm-kenburns { from { transform: scale(1.08); } to { transform: scale(1); } }
/* วิดีโอเข้ามาแบบฟุ้ง: จาง + เบลอ → ชัด (ภาพนิ่งด้านล่างค่อย ๆ ถูกแทนที่ ไม่เห็นรอยสลับ) */
.hm-hero-video { opacity: 0; filter: blur(18px); transform: scale(1.04); transition: opacity 1.2s ease, filter 1.8s ease, transform 1.8s ease; }
.hm-hero.video-playing .hm-hero-video { opacity: 1; filter: blur(0); transform: scale(1); }
/* ขอบภาพ/วิดีโอจางหายเข้าพื้นหลังของหน้า (ซ้าย ขวา ล่าง) — ไม่เห็นเส้นตัดระหว่าง hero กับเนื้อหา */
.hm-hero-media {
    -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%), linear-gradient(90deg, rgba(0,0,0,.6) 0%, #000 3%, #000 97%, rgba(0,0,0,.6) 100%);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(180deg, #000 55%, transparent 100%), linear-gradient(90deg, rgba(0,0,0,.6) 0%, #000 3%, #000 97%, rgba(0,0,0,.6) 100%);
    mask-composite: intersect;
}
.hm-hero-shade {
    position: absolute; inset: 0;
    background:
        linear-gradient(90deg, rgba(2, 13, 24, .72) 0%, rgba(2, 13, 24, .38) 28%, rgba(2, 13, 24, 0) 52%),
        linear-gradient(0deg, var(--hm-bg) 0%, rgba(2, 13, 24, .55) 22%, rgba(2, 13, 24, 0) 48%),
        linear-gradient(180deg, rgba(2, 13, 24, .55) 0%, rgba(2, 13, 24, 0) 18%);
}

.hm-hero-body { width: 100%; max-width: calc(560px + var(--hm-gutter)); padding: 0 0 190px var(--hm-gutter); }
.hm-hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 4px 12px; border-radius: 999px;
    background: rgba(41, 132, 232, .18); border: 1px solid rgba(41, 132, 232, .45); color: #cfe3ff;
    font-size: 12px; font-weight: 500; letter-spacing: .3px;
}
.hm-page .hm-hero-title {
    margin: 0 0 14px; color: #fff; font-size: clamp(32px, 4.4vw, 60px); font-weight: 700; line-height: 1.15;
    text-transform: none; text-shadow: 0 2px 18px rgba(0, 0, 0, .5);
}
.hm-hero-logo { display: block; width: auto; max-width: min(440px, 100%); max-height: 170px; object-fit: contain; object-position: left bottom; filter: drop-shadow(0 4px 18px rgba(0, 0, 0, .55)); }
.hm-hero-title.has-logo .hm-hero-title-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hm-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin: 0 0 14px; padding: 0; list-style: none; font-size: 14px; color: var(--hm-text); }
.hm-hero-meta li { display: inline-flex; align-items: center; }
.hm-hero-meta li + li::before { content: ''; width: 4px; height: 4px; margin: 0 10px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.hm-hero-meta .hm-rate { padding: 1px 8px; border: 1px solid rgba(255, 255, 255, .5); border-radius: 4px; font-size: 12px; font-weight: 600; }
.hm-hero-meta .hm-rate + li::before { display: none; }
.hm-hero-meta .hm-rate { margin-right: 10px; }
.hm-hero-desc {
    margin: 0 0 24px; font-size: 15px; line-height: 1.75; color: #d6dee6; text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.hm-hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hm-page .hm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 50px; padding: 0 28px; border-radius: 10px;
    font-size: 16px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: transform .15s, background .15s, color .15s;
}
.hm-btn i { font-size: 20px; line-height: 1; }
.hm-page .hm-btn.is-play { background: #fff; color: #06121f; }
.hm-page .hm-btn.is-play:hover { background: #dfe9f5; color: #06121f; transform: translateY(-1px); }
.hm-page .hm-btn.is-ghost { background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hm-page .hm-btn.is-ghost:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.hm-btn:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 3px; }

.hm-hero-controls { position: absolute; right: var(--hm-gutter); bottom: 200px; display: flex; gap: 10px; }
.hm-round {
    width: 44px; height: 44px; padding: 0; border-radius: 50%; cursor: pointer; align-items: center; justify-content: center; display: flex;
    background: rgba(2, 13, 24, .45); border: 1px solid rgba(255, 255, 255, .4); color: #fff; font-size: 20px;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .15s, border-color .15s;
}
.hm-round:hover { background: rgba(255, 255, 255, .15); border-color: #fff; }
/* ปุ่มเสียง: ปกติเป็นวงกลม — ถูกบล็อกเสียง (.needs-unmute) ขยายตัวเองเป็นแคปซูล "คลิกเพื่อเปิดเสียง" แล้วหดกลับเมื่อมีเสียง */
.hm-round.hm-mute {
    width: auto; min-width: 44px; padding: 0 11px; justify-content: flex-start; border-radius: 22px; font-family: inherit;
    transition: background .35s ease, border-color .35s ease, color .35s ease, padding .45s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease;
}
.hm-mute i { flex: 0 0 auto; width: 20px; text-align: center; line-height: 1; }
.hm-mute-label {
    display: inline-block; max-width: 0; margin-left: 0; overflow: hidden; opacity: 0; white-space: nowrap; font-size: 15px; font-weight: 600;
    transition: max-width .45s cubic-bezier(.2, .8, .2, 1), margin-left .45s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
.hm-hero.needs-unmute .hm-round.hm-mute {
    padding: 0 18px 0 13px; background: rgba(255, 255, 255, .92); border-color: transparent; color: #06121f;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: hm-hint-pulse 2.4s ease-in-out .6s 3;
}
.hm-hero.needs-unmute .hm-round.hm-mute:hover { background: #fff; }
.hm-hero.needs-unmute .hm-mute-label { max-width: 200px; margin-left: 8px; opacity: 1; transition-delay: 0s, 0s, .12s; }
@keyframes hm-hint-pulse { 0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, .35), 0 0 0 0 rgba(255, 255, 255, .45); } 50% { box-shadow: 0 8px 24px rgba(0, 0, 0, .35), 0 0 0 10px rgba(255, 255, 255, 0); } }
@media (prefers-reduced-motion: reduce) {
    .hm-round.hm-mute, .hm-mute-label { transition: none; }
    .hm-hero.needs-unmute .hm-round.hm-mute { animation: none; }
}

/* ── หน้าต้อนรับครั้งแรก — สมาชิก: เลือกโปรไฟล์ | ยังไม่เป็นสมาชิก: landing page (.is-landing) ── */
html.hm-gate-lock { overflow: hidden; }
.hm-gate {
    position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
    overflow-y: auto; background: var(--hm-bg); color: var(--hm-muted); animation: hm-gate-fade .4s ease both;
}
.hm-gate[hidden] { display: none !important; } /* ชนะ .hm-gate.is-landing { display: flex } ที่อยู่ด้านล่าง */
.hm-gate::before {
    content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background:
        radial-gradient(ellipse 70% 60% at 50% 45%, rgba(2, 13, 24, .55) 0%, rgba(2, 13, 24, .82) 60%, rgba(2, 13, 24, .96) 100%),
        linear-gradient(180deg, rgba(2, 13, 24, .6) 0%, rgba(2, 13, 24, 0) 25%, rgba(2, 13, 24, 0) 70%, var(--hm-bg) 100%);
}
.hm-gate-bg {
    position: absolute; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px); max-width: none; object-fit: cover;
    filter: blur(24px) saturate(1.25); opacity: .85; transform: scale(1.05); animation: hm-gate-drift 24s ease-in-out infinite alternate;
}
.hm-page .hm-gate .hm-btn { border: 0; cursor: pointer; font-family: inherit; }
.hm-page .hm-gate .hm-btn.is-ghost { border: 1px solid rgba(255, 255, 255, .22); }

/* สมาชิก: เลือกโปรไฟล์ */
.hm-gate-panel { position: relative; z-index: 2; width: 100%; max-width: 520px; margin: auto; text-align: center; animation: hm-gate-rise .55s cubic-bezier(.2, .8, .2, 1) .05s both; }
.hm-gate-logo { display: block; height: 44px; width: auto; margin: 0 auto 28px; }
.hm-gate-title { margin: 0 0 32px; font-size: 34px; line-height: 1.3; font-weight: 700; color: #fff; text-shadow: 0 4px 30px rgba(0, 0, 0, .5); }
.hm-gate-profile {
    display: inline-flex; flex-direction: column; align-items: center; gap: 14px; max-width: 100%; padding: 0;
    border: 0; background: none; color: var(--hm-muted); font-family: inherit; cursor: pointer;
}
.hm-gate-avatar {
    width: 144px; height: 144px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--hm-accent-2) 0%, #1b4f8f 100%); color: #fff; font-size: 64px; font-weight: 700; line-height: 1;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .45); outline: 3px solid transparent; outline-offset: 4px; transition: outline-color .15s, transform .2s;
}
.hm-gate-profile-name { max-width: 220px; font-size: 18px; transition: color .15s; }
.hm-gate-profile:hover .hm-gate-avatar, .hm-gate-profile:focus-visible .hm-gate-avatar { outline-color: #fff; transform: scale(1.04); }
.hm-gate-profile:hover .hm-gate-profile-name, .hm-gate-profile:focus-visible .hm-gate-profile-name { color: #fff; }
.hm-gate-profile:focus-visible { outline: none; }

/* collage โปสเตอร์เอียงแบบหน้า login (css/auth.css .auth-collage) — ใช้ทั้งหน้าเลือกโปรไฟล์และ landing */
.hm-gate.is-landing { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.hm-gate-collage { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.hm-gate-collage-grid {
    --tile-gap: 10px; --tile-w: calc((170vmax - 6 * var(--tile-gap)) / 7);
    position: absolute; left: 50%; top: 50%; width: 170vmax; display: flex; flex-direction: column; gap: var(--tile-gap);
    transform: translate(-50%, -50%) rotate(-12deg); opacity: 0; animation: hm-gate-fade 1.2s ease .2s forwards;
}
/* แถวคี่เลื่อนซ้าย แถวคู่เลื่อนขวา — ภาพในแถวมี 2 ชุด เลื่อนไปครึ่งหนึ่ง (-50%) แล้ววนกลับพอดี */
.hm-gate-collage-row { display: flex; width: max-content; animation: hm-row-left 260s linear infinite; }
.hm-gate-collage-row:nth-child(even) { animation-name: hm-row-right; animation-duration: 300s; }
.hm-gate-collage-row img {
    flex: 0 0 auto; display: block; width: var(--tile-w); max-width: none; height: auto; margin-right: var(--tile-gap);
    aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--hm-card);
}
.hm-land-top {
    position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 24px var(--hm-gutter); animation: hm-gate-fade .6s ease .1s both;
}
.hm-land-logo { display: block; height: 40px; width: auto; }
.hm-page .hm-land-login {
    display: inline-flex; align-items: center; height: 40px; padding: 0 20px; border-radius: 8px; font-size: 15px; font-weight: 600;
    color: #fff; text-decoration: none; background: var(--hm-accent); transition: background .15s;
}
.hm-page .hm-land-login:hover { background: var(--hm-accent-2); color: #fff; }
.hm-land-login:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.hm-land {
    position: relative; z-index: 2; flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; max-width: 960px; margin: 0 auto; padding: 16px 16px 64px; text-align: center;
}
.hm-land > * { animation: hm-gate-rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.hm-land > :nth-child(1) { animation-delay: .15s; }
.hm-land > :nth-child(2) { animation-delay: .3s; }
.hm-land > :nth-child(3) { animation-delay: .45s; }
.hm-land > :nth-child(4) { animation-delay: .65s; }
.hm-land-title {
    margin: 0 0 18px; font-size: clamp(34px, 5.6vw, 66px); line-height: 1.2; font-weight: 700; color: #fff;
    text-shadow: 0 4px 30px rgba(0, 0, 0, .5); text-wrap: balance;
}
.hm-land-title span {
    display: block; background: linear-gradient(90deg, #fff 0%, var(--hm-accent-2) 50%, #fff 100%) 0 0 / 200% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent; animation: hm-land-shine 6s ease-in-out 1s infinite;
}
.hm-land-sub { max-width: 640px; margin: 0 0 32px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.7; color: var(--hm-text); }
/* แบ่ง 2 บรรทัดตามความหมาย — แต่ละบรรทัดไม่ตัดกลางประโยค (จอเล็กปล่อยตัดตามปกติ) */
.hm-land-sub span { display: block; }
@media (min-width: 768px) { .hm-land-sub span { white-space: nowrap; } }
.hm-land-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.hm-page .hm-land-actions .hm-btn { height: 56px; padding: 0 32px; font-size: 17px; }
.hm-land-actions .hm-btn.is-play { box-shadow: 0 10px 30px rgba(255, 255, 255, .15); }
/* ปุ่มรอง: กระจกฝ้า — เบลอ collage ที่อยู่ด้านหลัง */
.hm-page .hm-land-actions .hm-btn.is-ghost {
    background: rgba(255, 255, 255, .1); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.hm-page .hm-land-actions .hm-btn.is-ghost:hover { background: rgba(255, 255, 255, .18); }
.hm-land-actions .hm-btn.is-play i { transition: transform .2s; }
.hm-land-actions .hm-btn.is-play:hover i { transform: translateX(4px); }
.hm-land-perks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: 100%; margin: 64px 0 0; padding: 0; list-style: none; text-align: left; }
.hm-land-perks li {
    display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 2px; align-items: center;
    padding: 18px; border-radius: 14px; background: rgba(10, 26, 43, .55); border: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s, transform .2s;
}
.hm-land-perks li:hover { border-color: rgba(74, 155, 240, .45); transform: translateY(-2px); }
.hm-land-perks i {
    grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--hm-accent-2); background: rgba(41, 132, 232, .15);
}
.hm-land-perks strong { font-size: 16px; font-weight: 600; color: #fff; }
.hm-land-perks span { font-size: 14px; line-height: 1.5; color: var(--hm-muted); }

@keyframes hm-gate-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hm-gate-rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes hm-gate-drift { from { transform: scale(1.05); } to { transform: scale(1.12) translate(-1%, -1%); } }
@keyframes hm-row-left { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes hm-row-right { from { transform: translateX(-50%); } to { transform: translateX(0); } }
@keyframes hm-land-shine { 0%, 100% { background-position: 0 0; } 50% { background-position: 100% 0; } }
@media (max-width: 767px) {
    .hm-land-top { padding: 16px; }
    .hm-land-logo { height: 32px; }
    .hm-page .hm-land-login { height: 36px; padding: 0 16px; font-size: 14px; }
    .hm-land { padding-bottom: 40px; }
    .hm-land-actions { flex-direction: column; width: 100%; max-width: 360px; }
    .hm-page .hm-land-actions .hm-btn { width: 100%; }
    .hm-land-perks { grid-template-columns: 1fr; gap: 10px; margin-top: 40px; max-width: 420px; }
    .hm-land-perks li { padding: 14px; }
    .hm-gate-collage-grid { --tile-gap: 6px; --tile-w: calc((150vmax - 6 * var(--tile-gap)) / 7); width: 150vmax; }
    .hm-gate-collage-row img { border-radius: 5px; }
}
@media (max-width: 480px) {
    .hm-gate-title { font-size: 28px; }
    .hm-gate-avatar { width: 120px; height: 120px; font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
    .hm-gate, .hm-gate-panel, .hm-gate-bg, .hm-gate-collage-row, .hm-land-top, .hm-land > *, .hm-land-title span { animation: none; }
    .hm-gate-collage-grid { animation: none; opacity: 1; }
}

/* ── Hero ตอนวิดีโอเล่น ── */
.hm-hero-eyebrow, .hm-hero-meta, .hm-hero-desc { transition: opacity .5s ease, max-height .6s ease, margin .6s ease; }
.hm-hero-eyebrow { max-height: 3em; }
.hm-hero-meta { max-height: 4em; }
.hm-hero-desc { max-height: 6em; }
.hm-hero-logo { transition: max-height .6s ease, max-width .6s ease; }
.hm-page .hm-hero-title { transition: font-size .6s ease, margin .6s ease; }
.hm-page .hm-btn { transition: height .4s ease, padding .4s ease, font-size .4s ease, transform .15s, background .15s, color .15s; }
.hm-hero-shade { transition: opacity .8s ease; }
.hm-hero.video-playing .hm-hero-shade { opacity: .75; }
.hm-hero.video-playing .hm-hero-body:not(:hover) .hm-hero-eyebrow,
.hm-hero.video-playing .hm-hero-body:not(:hover) .hm-hero-meta,
.hm-hero.video-playing .hm-hero-body:not(:hover) .hm-hero-desc {
    opacity: 0; max-height: 0; margin-top: 0; margin-bottom: 0; overflow: hidden;
}
.hm-hero.video-playing .hm-hero-body:not(:hover) .hm-hero-logo { max-height: 96px; max-width: min(300px, 100%); }
.hm-page .hm-hero.video-playing .hm-hero-body:not(:hover) .hm-hero-title { font-size: clamp(24px, 2.6vw, 36px); margin-bottom: 16px; }
.hm-page .hm-hero.video-playing .hm-hero-body:not(:hover) .hm-btn { height: 42px; padding: 0 20px; font-size: 14px; }

/* ═════════ Sections / rails ═════════ */
.hm-sections { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 36px; padding-top: 36px; }
/* ไม่มี hero (โหมดแบนเนอร์ / โหลดหนังไม่ได้) → เว้นที่ให้ header */
.hm-page > .hm-sections:first-child { padding-top: 108px; }
.hm-sections.is-overlap { margin-top: -100px; padding-top: 0; }
.hm-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 0 var(--hm-gutter); margin-bottom: 12px; }
.hm-page .hm-section-title { margin: 0; color: #fff; font-size: clamp(18px, 1.6vw, 22px); font-weight: 600; line-height: 1.3; text-transform: none; }
.hm-page .hm-viewall { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; font-size: 13px; color: var(--hm-muted); text-decoration: none; transition: color .15s, gap .15s; }
.hm-page .hm-viewall:hover { color: #fff; gap: 8px; }
.hm-viewall i { font-size: 14px; }

.hm-rail { position: relative; }
.hm-track {
    display: flex; gap: 10px; margin: 0; padding: 6px var(--hm-gutter) 10px; list-style: none;
    overflow-x: auto; overflow-y: hidden; touch-action: pan-x pan-y; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scroll-padding-inline: var(--hm-gutter);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
@media (hover: hover) and (pointer: fine) { .hm-track { cursor: grab; } }
.hm-track.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.hm-track.is-dragging .hm-card { pointer-events: none; }
/* แถววนลูป: สำเนาฝั่งซ้ายซ่อนไว้จนกว่าจะเลื่อนไปทางขวาครั้งแรก (pages/home.php) */
.hm-rail.is-loop:not(.is-unlocked) .hm-item.is-pre { visibility: hidden; }
.hm-track::-webkit-scrollbar { display: none; }
.hm-item { flex: 0 0 auto; width: clamp(128px, 13vw, 210px); scroll-snap-align: start; }
.hm-rail.is-h .hm-item { width: clamp(240px, 23vw, 380px); }

/* การ์ด */
.hm-page .hm-card {
    position: relative; display: block; aspect-ratio: 7 / 10; overflow: hidden; border-radius: 8px;
    background: var(--hm-card); -webkit-user-drag: none;
}
/* กรอบ: วาดเป็นชั้นบนสุดในการ์ด — ไม่ล้นออกนอกการ์ด (track ตัดส่วนที่ล้นทิ้ง) */
.hm-card::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07); transition: box-shadow .2s;
}
.hm-page .hm-card.is-h { aspect-ratio: 16 / 9; }
.hm-card img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; transition: transform .35s ease; }
.hm-card-shade {
    position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 10px 12px;
    background: linear-gradient(0deg, rgba(2, 13, 24, .92) 0%, rgba(2, 13, 24, 0) 55%);
    opacity: 0; transition: opacity .2s;
}
.hm-card-title { color: #fff; font-size: 13px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (hover: hover) {
    .hm-card:hover img { transform: scale(1.06); }
    .hm-card:hover::after { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85); }
    .hm-card:hover .hm-card-shade { opacity: 1; }
}
.hm-page .hm-card:focus-visible { outline: 2px solid var(--hm-accent); outline-offset: 3px; }

/* ดูต่อ: ปุ่มเล่น + แถบความคืบหน้า */
.hm-card-play {
    position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; background: rgba(2, 13, 24, .55); border: 1.5px solid rgba(255, 255, 255, .85);
    color: #fff; font-size: 20px; padding-left: 3px; transition: background .2s, transform .2s;
}
.hm-card:hover .hm-card-play { background: var(--hm-accent); border-color: var(--hm-accent); transform: scale(1.08); }
.hm-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.hm-progress span { display: block; height: 100%; background: var(--hm-accent); }

/* อันดับ: ตัวเลขขอบใหญ่ด้านซ้ายโปสเตอร์ */
.hm-item.has-rank { display: flex; align-items: flex-end; width: auto; }
.hm-item.has-rank .hm-card { width: clamp(118px, 11.5vw, 190px); flex: 0 0 auto; }
.hm-rail.is-h .hm-item.has-rank .hm-card { width: clamp(220px, 21vw, 340px); }
.hm-rank {
    flex: 0 0 auto; margin-right: -0.04em; font-size: clamp(96px, 11vw, 176px); font-weight: 700; line-height: .8; letter-spacing: -0.06em;
    color: var(--hm-bg); -webkit-text-stroke: 2px rgba(255, 255, 255, .6); paint-order: stroke fill;
    font-family: 'Noto Sans Thai', sans-serif; user-select: none;
}
.hm-rail.is-h .hm-rank { font-size: clamp(80px, 8vw, 130px); }

/* ปุ่มเลื่อน */
.hm-arrow {
    position: absolute; top: 6px; bottom: 10px; z-index: 3; width: var(--hm-gutter); min-width: 44px; padding: 0; border: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px;
    opacity: 0; transition: opacity .2s, background .2s;
}
.hm-arrow[hidden] { display: none; }
.hm-arrow.is-prev { left: 0; background: linear-gradient(90deg, rgba(2, 13, 24, .9), rgba(2, 13, 24, 0)); }
.hm-arrow.is-next { right: 0; background: linear-gradient(270deg, rgba(2, 13, 24, .9), rgba(2, 13, 24, 0)); }
.hm-rail:hover .hm-arrow, .hm-arrow:focus-visible { opacity: 1; }
.hm-arrow:hover i { transform: scale(1.2); }
.hm-arrow i { transition: transform .15s; }
@media (hover: none) { .hm-arrow { display: none !important; } }

/* ═════════ Responsive ═════════ */
@media (max-width: 991px) {
    /* header ทึบตั้งแต่ ≤991px (css/nav.css) — เลื่อน hero ลงพ้น header */
    .hm-hero { min-height: 520px; margin-top: 60px; }
    .hm-hero-body { padding-bottom: 160px; }
    .hm-sections.is-overlap { margin-top: -120px; }
    .hm-hero-controls { bottom: 170px; }
}
@media (max-width: 767px) {
    /* มือถือ: แบบหน้า classic — โปสเตอร์แนวตั้ง 7:10 ในกรอบกลางจอ (home-hero.js สลับเป็นภาพแนวตั้งให้) */
    .hm-hero { display: block; height: auto; min-height: 0; margin-top: 0; padding: 84px 0 28px; overflow: hidden; }
    .hm-hero-ambient {
        position: absolute; inset: -40px; z-index: -2; width: calc(100% + 80px); height: calc(100% + 80px); object-fit: cover;
        filter: blur(36px) saturate(1.3); opacity: .55; transform: scale(1.1);
    }
    .hm-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(2, 13, 24, .35) 0%, var(--hm-bg) 96%); }
    .hm-hero-media {
        position: relative; inset: auto; z-index: auto; width: min(86vw, 400px); margin: 0 auto; aspect-ratio: 7 / 10;
        border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .08);
    }
    .hm-hero-media { overflow: visible; -webkit-mask-image: none; mask-image: none; } /* ให้ ribbon ยื่นออกนอกขอบโปสเตอร์ได้ — ภาพโค้งตามกรอบเอง */
    .hm-hero-img { animation: none; object-position: center; border-radius: inherit; }
    .hm-hero-ribbon {
        display: flex; align-items: center; position: absolute; top: 12px; left: -6px; z-index: 2;
        height: 30px; padding: 0 14px 0 12px; border-radius: 0 999px 999px 0;
        background: var(--hm-accent); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
        box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
    }
    /* ส่วนที่พับไปด้านหลังโปสเตอร์ (มุมซ้ายล่างของ ribbon) */
    .hm-hero-ribbon::before {
        content: ''; position: absolute; left: 0; bottom: -6px;
        border-top: 6px solid #1b5aa3; border-left: 6px solid transparent;
    }
    .hm-hero-eyebrow { display: none; }
    .hm-hero-video, .hm-hero-shade, .hm-hero-controls { display: none; }
    .hm-hero-body { max-width: none; padding: 16px 16px 0; text-align: center; }
    .hm-page .hm-hero-title, .hm-hero-desc { display: none; }
    .hm-hero-meta { justify-content: center; font-size: 13px; margin-bottom: 16px; }
    .hm-hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 420px; margin: 0 auto; }
    .hm-page .hm-btn { height: 46px; padding: 0 12px; font-size: 15px; }
    /* แบนเนอร์: มีภาพแนวตั้ง → การ์ดแนวตั้งกลางจอแบบเดียวกับ hero หนัง / ไม่มี → ภาพแนวนอนเต็มความกว้างในกรอบ */
    .hm-banner-wrap { padding: 80px 16px 4px; }
    .hm-page .hm-banner { border-radius: 14px; }
    .hm-banner-wrap.has-v .hm-banner { width: min(86vw, 420px); }
    .hm-banner img { max-height: none; }
    .hm-banner-wrap + .hm-sections { padding-top: 24px; }
    .hm-sections { gap: 28px; }
    .hm-sections.is-overlap { margin-top: 8px; }
    /* จำนวนการ์ดที่เห็นในจอ = (ความกว้างจอ − ขอบซ้าย 16px − ช่องไฟ) ÷ จำนวน — ส่วนเกินโผล่ให้รู้ว่าเลื่อนต่อได้ */
    .hm-track { gap: 8px; scroll-snap-type: none; } /* มือถือ: free scroll ไม่ดูดเข้าการ์ด */
    .hm-item { width: calc((100vw - 16px - 3 * 8px) / 3.8); }                /* แนวตั้ง: 3.8 ใบ */
    .hm-rail.is-h .hm-item { width: calc((100vw - 16px - 2 * 8px) / 2.5); }  /* แนวนอน: 2.5 ใบ */
    /* อันดับ: เห็นครบอย่างน้อย 3 อันดับแรก (ตัวเลข ≈ 0.3 เท่าของความกว้างโปสเตอร์) */
    .hm-item.has-rank, .hm-rail.is-h .hm-item.has-rank { width: auto; } /* กว้างตามตัวเลข + โปสเตอร์ */
    .hm-item.has-rank { --hm-cw: calc((100vw - 16px - 3 * 8px) / 4.88); } /* แนวตั้ง: เห็น 3.8 อันดับ */
    .hm-rail.is-h .hm-item.has-rank { --hm-cw: calc((100vw - 16px - 3 * 8px) / 3.75); }
    .hm-item.has-rank .hm-card, .hm-rail.is-h .hm-item.has-rank .hm-card { width: var(--hm-cw); }
    .hm-rank { font-size: calc(var(--hm-cw) * .6); -webkit-text-stroke-width: 1.5px; }
    .hm-rail.is-h .hm-rank { font-size: calc(var(--hm-cw) * .42); -webkit-text-stroke-width: 1.5px; }
}
@media (prefers-reduced-motion: reduce) {
    .hm-hero-img { animation: none; }
    .hm-page .hm-card, .hm-card-shade { transition: none; }
    .hm-hero-video { transition: opacity .4s ease; filter: none; transform: none; }
}
