/* ========================================
   StoryWeb - Global Navigation Bar
   手機版：固定底部 Tab Bar
   桌面版：Header Sub-Nav Bar
   ======================================== */

/* ========================================
   桌面版 Sub-Nav Bar（>= 768px）
   ======================================== */

.site-subnav {
    display: none;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    z-index: 90;
    width: 100%;
    flex-shrink: 0; /* 在 body flex column 佈局中，不被壓縮 */
}

@media (min-width: 768px) {
    .site-subnav {
        display: block;
    }
}

.site-subnav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-subnav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.site-subnav-link:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

.site-subnav-link.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: rgba(201, 169, 98, 0.08);
}

.site-subnav-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ========================================
   手機版底部 Tab Bar（< 768px）
   ======================================== */

.site-tabbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--color-border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@media (max-width: 767px) {
    .site-tabbar {
        display: flex;
    }

    /* =====================================================
       手機版 padding-bottom 策略：

       問題根源：
         index.html 使用 body { height: 100vh; overflow: hidden } + flex 雙欄佈局。
         在 box-sizing: border-box 下，對 body 加 padding-bottom 會縮小 content 區域
         （height: 100vh 包含 padding），導致 .main-layout（flex: 1）高度減少，
         且 overflow: hidden 阻止 touch scroll，手機滾動完全失效。

       修復方向：
         不對 body 加 padding-bottom，改對各頁面的實際捲動容器加 padding-bottom：

         - index.html：.story-list-panel / .detail-panel-content（flex 佈局內的捲動容器）
         - 其他頁面（body 可正常捲動，overflow visible）：加 body padding-bottom 安全，
           但 index.html 的 body 有 overflow: hidden，style.css 覆蓋了 padding-bottom 為 0
       ===================================================== */

    /* 一般頁面（body 可正常捲動）：加 padding-bottom 避免 tab bar 遮住內容 */
    /* 注意：index.html 的 body 有 height: 100vh + overflow: hidden，
       style.css 會用 padding-bottom: 0 覆蓋此規則，避免壓縮雙欄佈局高度 */
    body {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    }

    /* index.html 雙欄佈局：對捲動容器加 padding-bottom（替代 body padding） */
    .story-list-panel {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    }

    .detail-panel-content {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    }
}

.site-tabbar-inner {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: stretch;
}

.site-tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.3rem 0;
    transition: all var(--transition-fast);
    position: relative;
}

.site-tabbar-item:hover {
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.site-tabbar-item.active {
    color: var(--color-primary);
}

.site-tabbar-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 0 0 2px 2px;
}

.site-tabbar-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.site-tabbar-label {
    line-height: 1;
    letter-spacing: 0.02em;
}
