/* ------------------------------------------------------------------
 * fab.css — ปุ่มลอยติดต่อเรา
 * ------------------------------------------------------------------
 * หลักการออกแบบ
 *   - ปุ่มหลักเด่นด้วยสีแบรนด์ + เงานุ่ม ไม่ใช่เงาแข็งแบบเดิม
 *   - กดแล้วรายการไล่โผล่ทีละอัน (stagger) ให้รู้สึกลื่นไหล
 *   - ทุกปุ่มมีชื่อกำกับ ไม่ต้องเดาจากไอคอน
 *   - เว้นระยะให้พ้นแถบล่างของ iPhone ด้วย safe-area
 *   - ถ้าผู้ใช้ตั้งค่าลดการเคลื่อนไหว จะไม่มีอนิเมชันเลย
 * ------------------------------------------------------------------ */

.mhs-fab {
    --fab-size: 60px;
    --fab-item: 48px;
    --fab-brand: #a10000;
    --fab-brand-2: #d94b00;

    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 9980;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* ---------- ฉากหลังจางๆ ตอนเปิดเมนู ---------- */
.mhs-fab-scrim {
    position: fixed;
    inset: 0;
    background: rgba(20, 10, 10, .35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .25s ease;
    z-index: -1;
}

.mhs-fab-scrim[hidden] {
    display: none;
}

.mhs-fab.is-open .mhs-fab-scrim {
    opacity: 1;
}

/* ---------- รายการช่องทางติดต่อ ---------- */
.mhs-fab-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.mhs-fab-item {
    opacity: 0;
    transform: translateY(14px) scale(.85);
    pointer-events: none;
    transition: opacity .22s ease, transform .28s cubic-bezier(.34, 1.56, .64, 1);
    transition-delay: 0s;
}

.mhs-fab.is-open .mhs-fab-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    /* ไล่โผล่ทีละอันจากล่างขึ้นบน */
    transition-delay: calc(var(--i, 1) * .045s);
}

.mhs-fab-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

/* ป้ายชื่อ */
.mhs-fab-text {
    background: #fff;
    color: #333;
    font-family: 'Prompt', 'Noto Sans Thai', Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    padding: 10px 14px;
    border-radius: 30px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

/* วงกลมไอคอน */
.mhs-fab-dot {
    width: var(--fab-item);
    height: var(--fab-item);
    flex: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 19px;
    background: #666;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
    transition: transform .18s ease, box-shadow .18s ease;
}

.mhs-fab-item a:hover .mhs-fab-dot,
.mhs-fab-item a:focus-visible .mhs-fab-dot {
    transform: scale(1.08);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
}

.mhs-fab-item a:focus-visible .mhs-fab-text {
    outline: 3px solid var(--fab-brand);
    outline-offset: 2px;
}

/* สีประจำแต่ละช่องทาง */
.mhs-fab-item.is-call   .mhs-fab-dot { background: linear-gradient(135deg, #ff9000, #ef6c00); }
.mhs-fab-item.is-line   .mhs-fab-dot { background: linear-gradient(135deg, #22c55e, #06a64a); }
.mhs-fab-item.is-messenger .mhs-fab-dot { background: linear-gradient(135deg, #3b82f6, #7c3aed); }
.mhs-fab-item.is-map    .mhs-fab-dot { background: linear-gradient(135deg, #38bdf8, #0284c7); }

/* ---------- ปุ่มหลัก ---------- */
.mhs-fab-main {
    position: relative;
    width: var(--fab-size);
    height: var(--fab-size);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--fab-brand-2), var(--fab-brand));
    box-shadow: 0 8px 24px rgba(161, 0, 0, .42);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
}

.mhs-fab-main:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 30px rgba(161, 0, 0, .5);
}

.mhs-fab-main:active {
    transform: scale(.96);
}

.mhs-fab-main:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(161, 0, 0, .45);
}

/* ไอคอนสองตัวซ้อนกัน สลับกันตอนเปิด/ปิด */
.mhs-fab-main i {
    position: absolute;
    font-size: 26px;
    transition: opacity .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.mhs-fab-ico-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.5);
}

.mhs-fab.is-open .mhs-fab-ico-open {
    opacity: 0;
    transform: rotate(90deg) scale(.5);
}

.mhs-fab.is-open .mhs-fab-ico-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ---------- วงแหวนกระเพื่อมเรียกสายตา ---------- */
.mhs-fab-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--fab-brand);
    opacity: 0;
}

.mhs-fab:not(.is-open):not(.is-touched) .mhs-fab-ring {
    animation: mhs-fab-pulse 2.6s ease-out infinite;
}

@keyframes mhs-fab-pulse {
    0%   { transform: scale(1);   opacity: .55; }
    70%  { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- ป้ายบอกใบ้ข้างปุ่ม ---------- */
.mhs-fab-hint {
    position: absolute;
    right: calc(var(--fab-size) + 12px);
    bottom: 16px;
    background: #fff;
    color: #a10000;
    font-family: 'Prompt', 'Noto Sans Thai', Tahoma, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    padding: 10px 14px;
    border-radius: 30px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateX(8px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}

.mhs-fab:not(.is-open) .mhs-fab-main:hover ~ .mhs-fab-hint,
.mhs-fab.is-hinting .mhs-fab-hint {
    opacity: 1;
    transform: translateX(0);
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 575px) {
    .mhs-fab {
        --fab-size: 56px;
        --fab-item: 46px;
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .mhs-fab-text {
        font-size: 13px;
        padding: 9px 12px;
    }

    .mhs-fab-hint {
        display: none;
    }
}

/* ไม่ให้ทับแถบคุกกี้ตอนที่แถบยังแสดงอยู่ */
body.mhs-consent-open .mhs-fab {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

/* ---------- เคารพการตั้งค่าลดการเคลื่อนไหว ---------- */
@media (prefers-reduced-motion: reduce) {
    .mhs-fab-item,
    .mhs-fab-main,
    .mhs-fab-main i,
    .mhs-fab-hint,
    .mhs-fab-scrim {
        transition: none !important;
    }

    .mhs-fab-ring {
        animation: none !important;
    }

    .mhs-fab.is-open .mhs-fab-item {
        transition-delay: 0s !important;
    }
}
