/* 丸島賞主站：手機版底部選單（components/bottom-nav.blade.php、dist/js/bottom-nav.js）
   五格：官方島｜一番島｜卡牌島｜丸預購｜我的（未登入是「登入」）。只在 767px 以下出現，電腦與平板維持上方選單。
   顏色都是 .wk-bnav-root 上的變數，節慶主題（後台「節慶活動」→ 手機底部選單）在 #site-theme 覆寫；
   圖示與上緣裝飾換圖由 Blade 處理（SiteTheme::asset('nav_*')）。 */
.wk-bnav-root {
  --bnav-h: 58px;
  --bnav-safe: env(safe-area-inset-bottom, 0px);
  --bnav-space: calc(var(--bnav-h) + var(--bnav-safe));
  --bnav-bg: #ffffff;          /* 底色（上） */
  --bnav-bg2: #e6f6fd;         /* 底色（下），也是選中泡泡的底 */
  --bnav-active: #ffcc02;      /* 選中泡泡的外框與光暈 */
  --bnav-text: #6a8a99;        /* 文字 */
  --bnav-text-active: #1e6482; /* 選中文字 */
  --bnav-head-bg: linear-gradient(135deg, #29a3d6, #62c8ef);
  --bnav-head-text: #ffffff;
}
.wk-bnav, .wk-bsheet { display: none; }

@media (max-width: 767.98px) {
  .wk-bnav {
    display: flex; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1025;
    height: var(--bnav-space); padding: 0 2px var(--bnav-safe);
    background: linear-gradient(180deg, var(--bnav-bg) 0%, var(--bnav-bg2) 100%);
    filter: drop-shadow(0 -3px 8px rgba(20, 70, 100, .16));
    transition: transform .28s ease;
    font-family: 'Noto Sans', 'Noto Sans TC', sans-serif;
  }
  /* 上緣雲朵波浪邊 */
  .wk-bnav::before {
    content: ""; position: absolute; left: 0; right: 0; top: -9px; height: 10px; pointer-events: none;
    background: var(--bnav-bg);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='10'%3E%3Cpath d='M0 10Q8.5 0 17 10Q25.5 0 34 10Z'/%3E%3C/svg%3E") repeat-x left bottom / 34px 10px;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='10'%3E%3Cpath d='M0 10Q8.5 0 17 10Q25.5 0 34 10Z'/%3E%3C/svg%3E") repeat-x left bottom / 34px 10px;
  }
  /* 節慶上緣裝飾（左右重複），在波浪邊上方 */
  .wk-bnav-deco {
    position: absolute; left: 0; right: 0; top: -34px; height: 30px; pointer-events: none;
    background-repeat: repeat-x; background-position: center bottom; background-size: auto 100%;
  }
  .wk-bnav.is-hidden { transform: translateY(calc(100% + 40px)); }

  .wk-bnav-item {
    flex: 1 1 0; min-width: 0; position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding: 0 0 6px; color: var(--bnav-text) !important; text-decoration: none !important;
    font-size: 11.5px; font-weight: 700; line-height: 1.2; letter-spacing: .03em;
    background: none; border: 0; cursor: pointer;
    -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  }
  .wk-bnav-ico {
    position: relative; width: 44px; height: 44px; margin-bottom: 0;
    display: flex; align-items: center; justify-content: center; border-radius: 50%;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), background-color .25s, box-shadow .25s;
  }
  .wk-bnav-ico img { width: 32px; height: 32px; object-fit: contain; pointer-events: none; transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }
  .wk-bnav-ico img.is-avatar { width: 32px; height: 32px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #fff; }
  .wk-bnav-label { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: transform .3s; }

  /* 選中：圖示跳進泡泡、浮出列外，旁邊兩顆星星一閃一閃 */
  .wk-bnav-item.is-active { color: var(--bnav-text-active) !important; }
  .wk-bnav-item.is-active .wk-bnav-ico {
    background: var(--bnav-bg2); transform: translateY(-15px);
    box-shadow: 0 0 0 3.5px var(--bnav-active), 0 0 0 6px rgba(255, 255, 255, .55), 0 8px 16px rgba(0, 0, 0, .2);
    animation: wkBnavPop .6s cubic-bezier(.34, 1.56, .64, 1) both;
  }
  .wk-bnav-item.is-active .wk-bnav-ico img { transform: scale(1.12); }
  .wk-bnav-item.is-active .wk-bnav-label { transform: translateY(-2px); }
  .wk-bnav-item.is-active .wk-bnav-ico::before,
  .wk-bnav-item.is-active .wk-bnav-ico::after {
    content: ""; position: absolute; width: 9px; height: 9px; background: var(--bnav-active);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M5 0l1.3 3.7L10 5 6.3 6.3 5 10 3.7 6.3 0 5l3.7-1.3z'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M5 0l1.3 3.7L10 5 6.3 6.3 5 10 3.7 6.3 0 5l3.7-1.3z'/%3E%3C/svg%3E") center / contain no-repeat;
    animation: wkBnavTwinkle 2.4s ease-in-out infinite;
  }
  .wk-bnav-item.is-active .wk-bnav-ico::before { left: -11px; top: 2px; }
  .wk-bnav-item.is-active .wk-bnav-ico::after { right: -10px; top: 14px; width: 6px; height: 6px; animation-delay: 1.2s; }

  /* 點下去：先壓扁再彈起 */
  .wk-bnav-item:active .wk-bnav-ico img { transform: scale(.82); }
  .wk-bnav-item.is-tap .wk-bnav-ico img { animation: wkBnavJump .5s cubic-bezier(.34, 1.56, .64, 1); }

  /* 紅點：新套組、未讀通知、未使用的聯名優惠券 */
  .wk-bnav-dot {
    position: absolute; top: 3px; right: 3px; width: 11px; height: 11px; border-radius: 50%;
    background: #ff4d5e; box-shadow: 0 0 0 2px var(--bnav-bg); animation: wkBnavDot 2s ease-in-out infinite;
  }
  .wk-bnav-item.is-active .wk-bnav-dot { top: -1px; right: -1px; }

  /* 有底部選單時：頁尾、AI 客服、特效開關、主題預覽提示都往上讓出位置 */
  body.has-bnav footer.footer { padding-bottom: calc(var(--bnav-space, 58px) + 72px); }
  body.has-bnav #ai-chat-btn { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px); right: 14px; width: 52px; height: 52px; }
  body.has-bnav #ai-chat-btn img { width: 52px; height: 52px; }
  body.has-bnav #ai-chat-panel { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 76px); max-height: calc(100vh - 58px - env(safe-area-inset-bottom, 0px) - 150px); }
  body.has-bnav .wkfx-toggle { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px); }
  body.has-bnav .wkfx-count { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 19px); }
  body.has-bnav .wk-theme-preview { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 12px); }
  /* 有上緣裝飾（節慶彩旗）時再多讓 34px */
  body.has-bnav-deco footer.footer { padding-bottom: calc(var(--bnav-space, 58px) + 92px); }
  body.has-bnav-deco #ai-chat-btn, body.has-bnav-deco .wkfx-toggle { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 44px); }
  body.has-bnav-deco .wkfx-count { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 49px); }
  body.has-bnav-deco #ai-chat-panel { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 106px); max-height: calc(100vh - 58px - env(safe-area-inset-bottom, 0px) - 180px); }
  body.has-bnav-deco .wk-theme-preview { bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 42px); }
  .wk-bnav-deco { transition: opacity .2s; }
  body.wk-bsheet-open .wk-bnav-deco { opacity: 0; }
  body.wk-bsheet-open #ai-chat-btn, body.wk-bsheet-open #ai-chat-panel,
  body.wk-bsheet-open .wkfx-toggle, body.wk-bsheet-open .wkfx-count { visibility: hidden; }

  /* ── 「我的」面板：從底部選單上方彈出的卡片 ── */
  .wk-bsheet.is-open { display: block; position: fixed; inset: 0; z-index: 1024; }
  .wk-bsheet-backdrop { position: absolute; inset: 0; background: rgba(12, 40, 56, .42); opacity: 0; transition: opacity .25s; }
  .wk-bsheet.is-in .wk-bsheet-backdrop { opacity: 1; }
  .wk-bsheet-panel {
    position: absolute; left: 10px; right: 10px; bottom: calc(var(--bnav-space) + 16px);
    max-height: calc(100% - var(--bnav-space) - 80px); overflow: auto; overscroll-behavior: contain;
    background: #fff; border-radius: 22px; box-shadow: 0 14px 40px rgba(10, 40, 60, .3);
    transform: translateY(28px) scale(.94); transform-origin: 90% 100%; opacity: 0;
    transition: transform .38s cubic-bezier(.34, 1.56, .64, 1), opacity .2s;
    font-family: 'Noto Sans', 'Noto Sans TC', sans-serif;
  }
  .wk-bsheet.is-in .wk-bsheet-panel { transform: none; opacity: 1; }
  .wk-bsheet-head {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px;
    background: var(--bnav-head-bg); color: var(--bnav-head-text); border-radius: 22px 22px 0 0;
  }
  .wk-bsheet-head::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 10px; background: #fff;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='10'%3E%3Cpath d='M0 10Q8.5 0 17 10Q25.5 0 34 10Z'/%3E%3C/svg%3E") repeat-x left bottom / 34px 10px;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='10'%3E%3Cpath d='M0 10Q8.5 0 17 10Q25.5 0 34 10Z'/%3E%3C/svg%3E") repeat-x left bottom / 34px 10px;
  }
  .wk-bsheet-avatar { width: 50px; height: 50px; flex: none; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .7), 0 4px 10px rgba(0, 0, 0, .15); }
  .wk-bsheet-who { flex: 1 1 auto; min-width: 0; }
  .wk-bsheet-name { font-size: 17px; font-weight: 800; line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .wk-bsheet-role { font-size: 12px; opacity: .9; }
  .wk-bsheet-close {
    position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .25); color: inherit; font-size: 18px; line-height: 30px; text-align: center;
  }
  .wk-bsheet-coin {
    display: flex; align-items: center; gap: 10px; margin: 12px 14px 4px; padding: 8px 8px 8px 12px;
    background: #fff8d9; border-radius: 16px;
  }
  .wk-bsheet-coin img { width: 26px; height: 26px; }
  .wk-bsheet-coin .num { flex: 1 1 auto; font-size: 20px; font-weight: 800; color: #4d3636; font-variant-numeric: tabular-nums; }
  .wk-bsheet-coin .num small { font-size: 12px; font-weight: 600; color: #8a7a6a; margin-left: 4px; }
  .wk-bsheet-coin a {
    flex: none; padding: 7px 16px; border-radius: 999px; background: #ffcc02; color: #4d3636 !important;
    font-size: 14px; font-weight: 800; text-decoration: none; box-shadow: 0 3px 0 #e0a800;
  }
  .wk-bsheet-coin a:active { transform: translateY(2px); box-shadow: 0 1px 0 #e0a800; }
  .wk-bsheet-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 2px; padding: 10px 8px 6px; }
  .wk-bsheet-grid a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 2px;
    border-radius: 14px; color: #3d4f58 !important; text-decoration: none; font-size: 12px; font-weight: 600; text-align: center; line-height: 1.25;
  }
  .wk-bsheet-grid a:active { background: #f0f8fc; }
  .wk-bsheet-grid .tile {
    position: relative; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
    border-radius: 16px; background: #eef8fd; transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
  }
  .wk-bsheet-grid a:nth-child(4n+2) .tile { background: #fff4d6; }
  .wk-bsheet-grid a:nth-child(4n+3) .tile { background: #ffeef1; }
  .wk-bsheet-grid a:nth-child(4n+4) .tile { background: #eaf7ee; }
  .wk-bsheet-grid a:active .tile { transform: scale(.9); }
  .wk-bsheet-grid .tile img { width: 30px; height: 30px; object-fit: contain; }
  .wk-bsheet-grid .tile .wk-bnav-dot { top: -2px; right: -2px; box-shadow: 0 0 0 2px #fff; }
  .wk-bsheet-foot { display: flex; gap: 10px; padding: 6px 14px 16px; }
  .wk-bsheet-foot a, .wk-bsheet-foot button {
    flex: 1 1 0; padding: 10px; border-radius: 14px; border: 0; background: #f2f5f7; color: #3d4f58 !important;
    font-size: 14px; font-weight: 700; text-align: center; text-decoration: none;
  }
  .wk-bsheet-foot button { color: #c0392b !important; }
}

@keyframes wkBnavPop { 0% { transform: translateY(0) scale(.6); } 100% { transform: translateY(-15px) scale(1); } }
@keyframes wkBnavJump { 0% { transform: scale(.82); } 45% { transform: translateY(-7px) scale(1.15) rotate(-8deg); } 100% { transform: scale(1); } }
@keyframes wkBnavTwinkle { 0%, 100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1) rotate(20deg); } }
@keyframes wkBnavDot { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) {
  .wk-bnav-item.is-active .wk-bnav-ico, .wk-bnav-item.is-tap .wk-bnav-ico img,
  .wk-bnav-item.is-active .wk-bnav-ico::before, .wk-bnav-item.is-active .wk-bnav-ico::after, .wk-bnav-dot { animation: none; }
}
