﻿/* หน้าบทเพลงแบบใหม่ (Views/Hymnal/Song.cshtml, Scripts/Hymnal/Song.js) — ใช้ prefix hp- กันชนกับสไตล์เดิมของเว็บ */
.hp {
    --hp-green: #1f7a4d;
    --hp-green-dark: #155c39;
    --hp-green-soft: #e6f3ec;
    --hp-green-line: #cfe6d9;
    --hp-ink: #1d2b24;
    --hp-muted: #66756d;
    --hp-bg: #f3f8f5;
    --hp-card: #ffffff;
    --hp-border: #e3ece7;
    --hp-red: #e5322d;
    --hp-gold: #f5b301;
    --hp-radius: 16px;
    --hp-shadow: 0 1px 2px rgba(20, 60, 40, .05), 0 6px 20px rgba(20, 60, 40, .06);
    --hp-lyric-size: 17px;

    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    /* ด้านล่างเว้นที่ให้แถบลิขสิทธิ์ (footer fixed) และปุ่มกลับขึ้นบนของเว็บ ไม่ให้บังปุ่มเพลงก่อนหน้า/ถัดไป */
    padding: 20px 20px 110px;
    background: var(--hp-bg);
    color: var(--hp-ink);
    font-family: Sarabun, sans-serif;
    min-height: calc(100vh - 120px);
}
.hp [hidden] { display: none !important; }
.hp *, .hp *::before, .hp *::after { box-sizing: border-box; }
.hp a { color: var(--hp-green); }
.hp button { font-family: inherit; cursor: pointer; }
.hp :focus-visible { outline: 2px solid var(--hp-green); outline-offset: 2px; }

.hp-card {
    background: var(--hp-card);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    box-shadow: var(--hp-shadow);
}

/* ---------- แถบซ้าย ---------- */
.hp-side {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: calc(100vh - 24px);
    min-height: 0;
}
.hp-brand { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.hp-brand-icon {
    flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px;
    display: grid; place-items: center;
    background: var(--hp-green); color: #fff; font-size: 22px;
}
.hp-brand-text { flex: 1 1 auto; min-width: 0; }
.hp-brand-title { font-size: 22px; font-weight: 700; color: var(--hp-green-dark); line-height: 1.2; }
.hp-brand-sub { font-size: 14px; color: var(--hp-muted); margin-top: 2px; }
.hp-side-close { display: none; }
.hp-icon-btn {
    border: 1px solid var(--hp-border); background: #fff; border-radius: 10px;
    width: 38px; height: 38px; color: var(--hp-muted);
}

.hp-search {
    display: flex; align-items: center; gap: 10px; margin: 0;
    padding: 0 16px; height: 48px; min-height: 48px; flex-shrink: 0;
    background: #fff; border: 1px solid var(--hp-border); border-radius: 14px;
    box-shadow: var(--hp-shadow); color: var(--hp-muted); font-weight: normal;
}
.hp-search:focus-within { border-color: var(--hp-green); box-shadow: inset 0 0 0 1px var(--hp-green); }
.hp .hp-search input:focus,
.hp .hp-search input:focus-visible { outline: none; box-shadow: none; }
.hp-search input { flex: 1 1 auto; min-width: 0; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--hp-ink); }

.hp-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hp-tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 12px 6px; border-radius: 14px;
    background: #fff; border: 1px solid var(--hp-border); color: var(--hp-ink);
    box-shadow: var(--hp-shadow);
}
.hp-tab i { font-size: 20px; color: var(--hp-green); margin-bottom: 4px; }
.hp-tab[data-tab="fav"] i { color: var(--hp-red); }
.hp-tab b { font-size: 14px; font-weight: 600; }
.hp-tab small { font-size: 12px; color: var(--hp-muted); }
.hp-tab.active { background: var(--hp-green); border-color: var(--hp-green); color: #fff; }
.hp-tab.active i, .hp-tab.active small { color: #fff; }

.hp-goto { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.hp-goto-badge {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--hp-green-soft); color: var(--hp-green); font-weight: 700; font-size: 14px;
}
.hp-goto-text { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.hp-goto-text b { display: block; font-size: 14px; }
.hp-goto-text small { color: var(--hp-muted); font-size: 12px; }
.hp-goto input {
    width: 70px; height: 40px; border: 1px solid var(--hp-border); border-radius: 10px;
    text-align: center; font-size: 15px; -moz-appearance: textfield;
}
.hp-goto input::-webkit-inner-spin-button { -webkit-appearance: none; }
.hp-goto-btn {
    height: 40px; padding: 0 14px; border: 0; border-radius: 10px;
    background: var(--hp-green); color: #fff; font-weight: 600; white-space: nowrap;
}
.hp-goto-btn:hover { background: var(--hp-green-dark); }

.hp-listbox { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.hp-list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.hp-list-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.hp-list-head select {
    border: 1px solid var(--hp-border); border-radius: 10px; padding: 6px 8px;
    font-family: inherit; font-size: 13px; background: #fff; color: var(--hp-ink);
}
.hp-list {
    list-style: none; margin: 0; padding: 0 10px 10px;
    overflow-y: auto; min-height: 160px; flex: 1 1 auto;
    display: flex; flex-direction: column; gap: 4px;
}
.hp-list li { display: flex; align-items: center; border-radius: 12px; border-left: 4px solid transparent; }
.hp-list li:hover { background: #f6faf8; }
.hp-list li.active { background: var(--hp-green-soft); border-left-color: var(--hp-green); }
.hp-list a {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px;
    padding: 8px 6px 8px 8px; color: var(--hp-ink); text-decoration: none;
}
.hp-no {
    flex: 0 0 auto; min-width: 46px; height: 32px; padding: 0 8px; border-radius: 10px;
    display: grid; place-items: center;
    background: #f0f5f2; color: var(--hp-green-dark); font-size: 14px; font-weight: 600;
}
.hp-list li.active .hp-no { background: #fff; }
.hp-name { flex: 1 1 auto; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-yt { flex: 0 0 auto; color: var(--hp-red); font-size: 20px; }
.hp-star {
    flex: 0 0 auto; width: 38px; height: 38px; border: 0; background: transparent;
    color: #b8c4bd; font-size: 18px; border-radius: 10px;
}
.hp-star:hover { color: var(--hp-gold); }
.hp-star.on { color: var(--hp-gold); }
.hp-empty { padding: 24px; text-align: center; color: var(--hp-muted); }

/* ---------- เนื้อหาเพลง ---------- */
.hp-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.hp-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.hp-back {
    display: none; align-items: center; gap: 8px; border: 0; background: transparent;
    color: var(--hp-ink); font-size: 15px; padding: 6px 4px;
}
.hp-oldlink { font-size: 14px; margin-left: auto; }

/* วิดีโอ: รูปย่อในหัวเพลง -> กดแล้วเปิดเครื่องเล่นลอยมุมจอ เนื้อเพลงจึงอยู่บนสุดเสมอ */
.hp-thumb {
    position: relative; flex: 0 0 auto; width: 168px; aspect-ratio: 16 / 9; padding: 0;
    border: 0; border-radius: 12px; overflow: hidden; background: #0d1a14;
}
.hp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .85; transition: opacity .15s; }
.hp-thumb:hover img { opacity: 1; }
.hp-thumb-play {
    position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
    width: 44px; height: 31px; border-radius: 9px; background: var(--hp-red); color: #fff;
    display: grid; place-items: center; font-size: 14px; box-shadow: 0 3px 12px rgba(0, 0, 0, .35);
}
.hp-thumb-label {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 0 4px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-size: 12px; font-weight: 600;
}
.hp-head-actions .hp-btn-video { display: none; }
.hp-lbl-short { display: none; }

/* ช่องไปยังเพลงหมายเลขในหัวเพลง: แสดงเฉพาะจอที่รายการเพลงซ่อนเป็นแผง (ดู media ด้านล่าง) */
.hp-goto-inline { display: none; align-items: center; gap: 10px; width: 100%; padding-top: 14px; border-top: 1px solid var(--hp-border); }
.hp-goto-inline .hp-goto-badge { width: 40px; height: 40px; }
.hp-goto-inline-text { flex: 1 1 auto; min-width: 0; margin: 0; line-height: 1.3; font-weight: normal; }
.hp-goto-inline-text b { display: block; font-size: 14px; }
.hp-goto-inline-text small { color: var(--hp-muted); font-size: 12px; }
.hp-goto-inline input {
    width: 92px; height: 40px; border: 1px solid var(--hp-border); border-radius: 10px;
    text-align: center; font-size: 15px; font-family: inherit; -moz-appearance: textfield;
}
.hp-goto-inline input::-webkit-inner-spin-button { -webkit-appearance: none; }
.hp-btn-video i { color: var(--hp-red); }

.hp-mini {
    position: fixed; z-index: 2000; right: 24px; bottom: 84px; width: 360px;
    background: #0d1a14; border-radius: 14px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
    transition: width .2s ease;
}
.hp-mini.hp-mini-large { width: min(640px, calc(100vw - 48px)); }
.hp-mini-bar { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; color: #fff; font-size: 13px; }
.hp-mini-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-mini-title i { color: var(--hp-red); margin-right: 4px; }
.hp-mini-btn {
    flex: 0 0 auto; width: 30px; height: 30px; border: 0; border-radius: 8px;
    background: rgba(255, 255, 255, .12); color: #fff;
}
.hp-mini-btn:hover { background: rgba(255, 255, 255, .25); }
.hp-mini-body { position: relative; aspect-ratio: 16 / 9; }
.hp-mini-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* จอกว้าง: วิดีโออยู่ในคอลัมน์ซ้ายเหนือรายการเพลง (Song.js ย้ายเข้าไป) จึงไม่บังเนื้อเพลง */
.hp-side .hp-mini { position: static; width: auto; flex: 0 0 auto; box-shadow: var(--hp-shadow); }
.hp-side .hp-mini #hpMiniSize { display: none; }

.hp-head { display: flex; align-items: center; gap: 20px; padding: 18px 24px; flex-wrap: wrap; }
.hp-head-no { display: flex; flex-direction: column; line-height: 1; padding-right: 20px; border-right: 1px solid var(--hp-border); }
.hp-head-no small { font-size: 14px; color: var(--hp-muted); margin-bottom: 6px; }
.hp-head-no strong { font-size: 44px; font-weight: 700; color: var(--hp-green); font-variant-numeric: tabular-nums; }
.hp-head-title { flex: 1 1 260px; min-width: 0; }
.hp-head-title h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; color: var(--hp-green-dark); line-height: 1.35; }
.hp-head-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--hp-muted); }
.hp-head-meta span + span::before { content: "·"; margin-right: 14px; color: var(--hp-green-line); }
.hp-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hp-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
    border: 1px solid var(--hp-border); border-radius: 22px; background: #fff;
    color: var(--hp-ink); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.hp-btn:hover { border-color: var(--hp-green-line); background: #f8fbf9; text-decoration: none; color: var(--hp-ink); }
#hpFav i { color: var(--hp-red); }
#hpShare i { color: var(--hp-green); }

.hp-lyrics { padding: 18px 24px 26px; }
.hp-lyrics-tools { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.hp-seg { display: inline-flex; border: 1px solid var(--hp-border); border-radius: 10px; overflow: hidden; }
.hp-seg button { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; color: var(--hp-muted); min-width: 40px; }
.hp-seg button + button { border-left: 1px solid var(--hp-border); }
.hp-seg button.active { background: var(--hp-green-soft); color: var(--hp-green-dark); font-weight: 600; }
.hp-stanzas { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px 28px; }
.hp-stanza { display: flex; gap: 14px; align-items: flex-start; scroll-margin-top: 80px; }
.hp-stanza-no {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--hp-green-soft); color: var(--hp-green); font-weight: 700; font-size: 15px;
}
.hp-stanza-label { width: auto; min-width: 34px; padding: 0 10px; border-radius: 17px; font-size: 13px; }
.hp-stanza-lines { flex: 1 1 auto; min-width: 0; font-size: var(--hp-lyric-size); line-height: 1.75; }
.hp-stanza-lines p { margin: 0; padding-left: 1em; text-indent: -1em; }
.hp-chorus { background: #f6fbf8; border: 1px dashed var(--hp-green-line); border-radius: 14px; padding: 12px 14px; }
.hp-chorus .hp-stanza-lines { font-style: italic; }
.hp-repeat { display: inline-block; margin-top: 4px; font-size: .85em; font-weight: 600; }
.hp-stanza.hp-flash { animation: hp-flash 1.6s ease; }
@keyframes hp-flash { 0%, 40% { background: #fff3c4; } 100% { background: #f6fbf8; } }
.hp-missing { padding: 24px; color: var(--hp-muted); text-align: center; margin: 0; }

.hp-mr { padding: 16px 24px; }
.hp-mr h2 { margin: 0 0 10px; font-size: 16px; font-weight: 700; color: var(--hp-green-dark); }
.hp-mr h2 i { color: var(--hp-gold); }
.hp-mr ul { margin: 0; padding-left: 20px; line-height: 1.9; font-size: 15px; }
.hp-link-btn { border: 0; background: transparent; color: var(--hp-green); padding: 4px 0; font-size: 14px; font-weight: 600; }

.hp-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; }
.hp-play {
    display: inline-flex; align-items: center; gap: 12px; border: 0; background: transparent;
    color: var(--hp-green-dark); font-size: 17px; font-weight: 700;
}
.hp-play-circle {
    width: 52px; height: 52px; border-radius: 50%; background: var(--hp-green); color: #fff;
    display: grid; place-items: center; font-size: 20px; padding-left: 3px;
}
.hp-play:hover .hp-play-circle { background: var(--hp-green-dark); }

.hp-backdrop { display: none; }
.hp-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 3000;
    background: var(--hp-ink); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

/* ---------- จอแคบ (รวมเมนูซ้ายของเว็บแล้วเหลือที่ไม่พอ 2 คอลัมน์): รายการเพลงเป็นแผงเลื่อนออกจากซ้าย ---------- */
@media (max-width: 1199px) {
    .hp { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 110px; }
    .hp-side {
        position: fixed; z-index: 2100; top: 0; left: 0; bottom: 0;
        width: min(380px, 92vw); max-height: none; padding: 12px;
        background: var(--hp-bg); box-shadow: 0 0 40px rgba(0, 0, 0, .25);
        transform: translateX(-105%); transition: transform .25s ease; visibility: hidden;
    }
    .hp.hp-list-open .hp-side { transform: none; visibility: visible; }
    .hp.hp-list-open .hp-backdrop { display: block; position: fixed; inset: 0; z-index: 2050; background: rgba(10, 30, 20, .35); }
    .hp-side-close { display: grid; place-items: center; }
    .hp-back { display: inline-flex; }
    .hp-goto-inline { display: flex; }
    /* วิดีโอลอยมุมขวาล่าง: เว้นที่ด้านล่างให้เลื่อนอ่านเนื้อเพลงท่อนท้ายได้ */
    .hp.hp-video-open .hp-main { padding-bottom: 260px; }
}
@media (max-width: 767px) {
    .hp-thumb { display: none; }
    .hp-head-actions .hp-btn-video { display: inline-flex; }
    .hp { padding-bottom: 140px; } /* footer สูงขึ้นเป็น 2 บรรทัดบนจอแคบ */
    .hp-mini, .hp-mini.hp-mini-large { left: 12px; right: 12px; bottom: 72px; width: auto; }
    #hpMiniSize { display: none; }
    .hp.hp-video-open .hp-main { padding-bottom: calc((100vw - 24px) * 9 / 16 + 50px); }
}
@media (max-width: 576px) {
    .hp-head { padding: 16px; gap: 14px; }
    .hp-head-no { padding-right: 14px; }
    .hp-head-no strong { font-size: 36px; }
    .hp-head-title { flex: 1 1 0; } /* ชื่อเพลงอยู่ข้างเลขเพลงแถวเดียวกัน ไม่ตกลงไปบรรทัดใหม่ */
    .hp-head-title h1 { font-size: 21px; }
    .hp-head-meta { gap: 2px 12px; }
    .hp-head-meta span + span::before { content: none; } /* ขึ้นบรรทัดใหม่แล้วไม่ให้มีจุดนำหน้า */
    .hp-head-actions { width: 100%; }
    .hp-head-actions .hp-btn { flex: 1 1 0; justify-content: center; }
    .hp-lyrics { padding: 14px 16px 20px; }
    .hp-stanzas { grid-template-columns: minmax(0, 1fr); }
    .hp-pager { padding: 10px 12px; }
    .hp-pager .hp-btn { padding: 0 12px; }
    .hp-pager .hp-btn span { display: none; }
    .hp-play { font-size: 15px; }
}
@media print {
    .hp { display: block; background: #fff; padding: 0; }
    .hp-side, .hp-topbar, .hp-video, .hp-head-actions, .hp-lyrics-tools, .hp-mr, .hp-pager { display: none !important; }
    .hp-card { box-shadow: none; border: 0; }
}

/* จอเล็ก: ดูวิดีโอ / เพลงโปรด / แชร์ อยู่แถวเดียวกัน (ป้ายเพลงโปรดแบบสั้น) */
@media (max-width: 767px) {
    .hp-head-actions { width: 100%; flex-wrap: nowrap; gap: 8px; }
    .hp-head-actions .hp-btn { flex: 1 1 0; min-width: 0; justify-content: center; gap: 6px; padding: 0 8px; }
    .hp-lbl-long { display: none; }
    .hp-lbl-short { display: inline; }
}
