/* scrollbar 常駐，避免 modal 開啟時版面抖動 */
body {
    overflow-y: scroll;
}

/* ── Banner 電視牆 ─────────────────────────────── */

#blockBannerDisplay {
    width: 100%;
    aspect-ratio: 5 / 2;
    margin-top: 0;
    overflow: hidden;
    background: #fff;
    position: relative;
}

@media (max-width: 767px) {
    #blockBannerDisplay {
        aspect-ratio: auto;
        margin-top: 0;
    }

    .banner-slide img {
        width: 100%;
        height: auto;
    }
}

#blockBannerSlides {
    width: 100%;
    height: 100%;
    position: relative;
}

.banner-group {
    width: 100%;
    height: 100%;
    position: relative;
}

.banner-slides {
    width: 100%;
    height: 100%;
    position: relative;
}

.banner-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 1rem;
    pointer-events: none;
}

.banner-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2;
}

#blockBannerDots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2;
}

#bannerPlaceholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 1rem;
    pointer-events: none;
}

.banner-slide {
    display: none;
    width: 100%;
    height: 100%;
    text-align: center;
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.banner-slide video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.banner-slide iframe.banner-youtube {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
    background: #000;
}

/* 投影片導航點 */
.banner-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background .2s;
}

.banner-dot.active {
    background: #fff;
}

/* 投影片底部文字說明列 */
.banner-caption {
    position: absolute;
    bottom: 28px;
    left: 0;
    right: 0;
    color: #fff;
    font-size: 14px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.banner-caption-close {
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    opacity: 0.8;
    flex-shrink: 0;
}

.banner-caption-close:hover {
    opacity: 1;
}

/* ── Menu Modal ───────────────────────────────── */
#blockMenuModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

/* ───────────────────────────────────────────────
   Modal 風格 (Modern Premium)
   ─────────────────────────────────────────────── */

.hb-modal-overlay {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease-out;
}

.hb-modal-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: min(var(--hb-modal-width, 420px), calc(100vw - 40px));
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
    transform: translateY(0);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: visible;
}

.v2-header-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -75%);
    z-index: 4;
    pointer-events: none;
}

.hb-modal-header-v2 {
    background: var(--hb-block-color, #5B8FD4);
    color: #fff;
    padding: 8px 20px;
    border-radius: 99px;
    font-size: var(--hb-item-font-size, inherit);
    text-align: center;
    position: relative;
    border: 4px solid #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.hb-modal-header-v2 strong {
    font-size: 1.0rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
    line-height: 1.2;
}

.hb-modal-logo-v2 {
    height: 22px;
    width: auto;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* modal body 頂部留空間給膠囊標題 */
.hb-modal-body {
    padding: 24px 16px 16px;
    overflow-y: auto;
    border-radius: 16px;
}

/* 選單列 */
.hb-menu-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    width: 100%;
}

/* 主選項卡片 */
.hb-menu-card {
    background: var(--theme-color);
    border-radius: 8px;
    padding: 0 16px;
    height: 48px;
    color: #fff;
    font-weight: 500;
    letter-spacing: 0.5px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 主選項文字 */
.hb-menu-text {
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
    text-align: left;
    font-size: var(--hb-item-font-size, inherit);
}

/* 選單卡片項目，垂直排列主選項與副選項 */
.hb-menu-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    width: 100%;
    min-width: 0;
}

/* 有副選項的項目：淺色漸層背景 + 左側裝飾線 */
.hb-menu-item.has-sub {
    background: linear-gradient(90deg, color-mix(in srgb, var(--theme-color, #cbd5e1) 5%, #fbfcfd) 0%, #fbfcfd 50%);
    border-radius: 12px;
    padding: 10px 12px 10px 20px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: inset 0 3px 6px rgba(15, 23, 42, 0.08);
}

.hb-menu-item.has-sub::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 12px;
    bottom: 12px;
    width: 4px;
    border-radius: 4px;
    background: var(--theme-color, #cbd5e1);
    opacity: 0.25;
}

/* 主選項連結（包在卡片外層） */
.hb-menu-link {
    text-decoration: none;
    display: block;
    width: 100%;
    border-radius: 8px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.hb-menu-link:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 副選項按鈕（鋪滿整列，與主項目同寬） */
.hb-menu-sub-link,
.hb-menu-sub {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: var(--hb-sub-font-size, 0.82rem);
    font-weight: 600;
    text-decoration: none;
    color: var(--theme-color);
    background: color-mix(in srgb, var(--theme-color) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--theme-color) 15%, transparent);
    transition: all 0.2s ease;
    position: relative;
    overflow: visible;
}

.hb-menu-sub-link:hover {
    text-decoration: none;
    background: var(--theme-color);
    color: #fff;
    transform: translateY(-1.5px);
    box-shadow: 0 3px 6px color-mix(in srgb, var(--theme-color) 25%, transparent);
}

.hb-menu-sub-link:focus,
.hb-menu-sub-link:active {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.hb-sub-badge {
    position: absolute;
    top: -12px;
    right: -8px;
    background: #fff;
    color: var(--theme-color, #5B8FD4);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--theme-color, #5B8FD4);
    z-index: 10;
}

.hb-menu-card {
    position: relative;
}

/* 整體進場動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* dialog 由下往上滑入 */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 副選項內的輔助文字 */
.hb-menu-item small {
    font-size: 0.72rem;
    opacity: 0.82;
}

.hb-menu-arrow {
    opacity: 0.7;
}

.menu-empty {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* ── 巧克力塊卡片 ──────────────────────────────── */

.homeblock-cards {
    background-color: #fff;
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* 飄浮氣球裝飾層 — 蓋滿 .homeblock-cards 但不擋點擊；卡片用 z-index:1 蓋在上面 */
.homeblock-balloons {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.homeblock-cards>.container {
    position: relative;
    z-index: 1;
}

.balloon {
    position: absolute;
    opacity: 0.22;
    animation: balloon-float 8s ease-in-out infinite;
    will-change: transform;
    color: #5B8FD4;
}

.balloon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.balloon.b1 {
    left: 5%;
    top: 14%;
    width: 46px;
    height: 66px;
    color: #5B8FD4;
    animation-duration: 7s;
    animation-delay: 0s;
}

.balloon.b2 {
    left: 24%;
    top: 58%;
    width: 38px;
    height: 56px;
    color: #FF8C69;
    animation-duration: 9s;
    animation-delay: -2s;
}

.balloon.b3 {
    left: 47%;
    top: 10%;
    width: 34px;
    height: 50px;
    color: #FFB319;
    animation-duration: 8s;
    animation-delay: -4s;
}

.balloon.b4 {
    left: 70%;
    top: 62%;
    width: 44px;
    height: 64px;
    color: #6BCB77;
    animation-duration: 10s;
    animation-delay: -1.5s;
}

.balloon.b5 {
    left: 88%;
    top: 20%;
    width: 40px;
    height: 58px;
    color: #A267AC;
    animation-duration: 7.5s;
    animation-delay: -3.5s;
}

.balloon.b6 {
    left: 15%;
    top: 42%;
    width: 36px;
    height: 52px;
    color: #FF6B9D;
    animation-duration: 8.5s;
    animation-delay: -6s;
}

.balloon.b7 {
    left: 82%;
    top: 32%;
    width: 42px;
    height: 60px;
    color: #48C9B0;
    animation-duration: 9.5s;
    animation-delay: -5s;
}

@keyframes balloon-float {
    0% {
        transform: translateY(0) rotate(-2deg);
    }

    50% {
        transform: translateY(-14px) rotate(2deg);
    }

    100% {
        transform: translateY(0) rotate(-2deg);
    }
}

/* 卡片區連結與網格 */
.homeblock-cards a {
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.homeblock-cards .homeblock-row {
    margin: 5px auto;
    width: 100%;
}

.homeblock-cards .col-md-3 {
    padding: 0 5px;
    margin: 5px 0;
}

/* 巧克力塊卡片本體 */
.homeblock-card.card {
    border: 0;
    text-align: center;
    background-color: #a0b4c8;
    color: #fff;
    border-radius: 15px;
    height: 110px;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.22),
        0 2px 6px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    cursor: pointer;
    transition: filter 0.2s;
    overflow: hidden;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.homeblock-card.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 48%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 100%);
    border-radius: 0 0 60% 60%;
    pointer-events: none;
    z-index: 1;
}

.homeblock-card.card:hover {
    filter: brightness(1.1);
    animation: feBlockNod 0.42s ease-out forwards;
}

/* 卡片內容垂直置中 */
.homeblock-cards .card-body {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 3;
    user-select: none;
}

/* 卡片 Logo 圖示（反白 + 漂浮動畫，hover 才動） */
.homeblock-cards .card-body img {
    margin-bottom: 5px;
    filter: brightness(0) invert(1);
    animation: feHomeBlockLogoFloat 3.5s ease-in-out infinite;
    animation-play-state: paused;
}

.homeblock-card:hover .card-body img {
    animation-play-state: running;
}

.homeblock-cards .card-body label {
    font-size: 16px;
    cursor: pointer;
}

.homeblock-cards .card-body span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

/* ── Shine 高光條紋 ────────────────────────────── */

/* 高光條紋層 — 覆蓋在卡片上方，hover 時掃過 */
.fe-home-block-shine {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: inherit;
    z-index: 2;
}

.fe-home-block-shine::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 30%;
    width: 40%;
    height: 300%;
    background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 0.50) 50%, transparent 100%);
    transform: rotate(-30deg) translateX(300%);
}

.fe-home-block-shine.is-entering::before {
    animation: feShineEnter 0.55s ease-out forwards;
}

.fe-home-block-shine.is-leaving::before {
    animation: feShineLeave 0.45s ease-in forwards;
}

@keyframes feShineEnter {
    from {
        transform: rotate(-30deg) translateX(300%);
    }

    to {
        transform: rotate(-30deg) translateX(-300%);
    }
}

@keyframes feShineLeave {
    from {
        transform: rotate(-30deg) translateX(-300%);
    }

    to {
        transform: rotate(-30deg) translateX(300%);
    }
}

/* 卡片 hover 點頭動畫 */
@keyframes feBlockNod {
    0% {
        transform: translateY(0);
    }

    28% {
        transform: translateY(5px);
    }

    58% {
        transform: translateY(-3px);
    }

    78% {
        transform: translateY(1px);
    }

    100% {
        transform: translateY(0);
    }
}

/* Logo 漂浮動畫（hover 時觸發） */
@keyframes feHomeBlockLogoFloat {

    0%,
    100% {
        transform: translateY(0px) rotate(-2deg);
    }

    33% {
        transform: translateY(-5px) rotate(1deg);
    }

    66% {
        transform: translateY(-2px) rotate(-1deg);
    }
}

/* ===== 徽章 Badge 樣式 ===== */

/* 主選項卡片右上角 badge（白底 + 主題色文字/邊框） */
.hb-menu-card .hb-menu-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #fff;
    color: var(--theme-color, #5B8FD4);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--theme-color, #5B8FD4);
    z-index: 10;
}

.hb-menu-link:hover .hb-menu-badge {
    background: var(--theme-color, #5B8FD4);
    color: #fff;
    border-color: #fff;
}

.hb-menu-sub:hover .hb-sub-badge,
.hb-menu-sub-link:hover .hb-sub-badge {
    background: var(--theme-color, #5B8FD4);
    color: #fff;
    border-color: #fff;
}

/* 巧克力塊卡片右上角 badge */
.homeblock-card .card-body .hb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
    line-height: 1.6;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

/* 巧克力塊卡片右上角 badge 圖片 */
.homeblock-card .card-body .hb-badge-img {
    position: absolute;
    top: -4px;
    right: -4px;
    max-width: 60px;
    max-height: 24px;
    z-index: 5;
    pointer-events: none;
}

/* Modal header 中的 overlaying 徽章（膠囊 header 右上角） */
.hb-modal-header-v2 .hb-badge-overlay {
    position: absolute;
    top: -8px;
    right: -8px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 12px;
    border-radius: 12px;
    white-space: nowrap;
    line-height: 1.6;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    min-width: 20px;
    min-height: 20px;
}

/* ── HomeBlocks 外容器 ───────────────────────────── */
.homeblocks-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

@media (min-width: 1200px) {
    .homeblocks-wrapper {
        margin-top: -40px;
        height: calc(100vh - 15px);
    }
}

@media (max-width: 1199px) {
    .homeblocks-wrapper {
        height: auto;
        overflow: visible;
    }

    #blockBannerDisplay {
        overflow: visible;
    }

    .homeblock-cards {
        overflow: visible;
    }
}

@media (max-width: 991px) {
    .homeblocks-wrapper {
        padding-top: 0;
    }
    /* 手機板取消 hover 改用 active */
    .homeblock-card.card:hover {
        filter: none;
        animation: none;
    }
    .homeblock-card.card:active {
        filter: brightness(1.1);
        animation: feBlockNod 0.42s ease-out forwards;
    }
    .homeblock-card:hover .card-body img,
    .homeblock-card.card:active .card-body img {
        animation-play-state: paused;
    }
    .homeblock-card.card:active .card-body img {
        animation-play-state: running;
    }
}

@media (max-width: 767px) {
    #blockBannerDisplay {
        aspect-ratio: 16 / 9;
        margin-top: 0;
    }
}
