/* =========================================================
   SirenGirl — layout.css
   App shell · sidebar · topbar · page grid · responsive
   Breakpoints: 480 / 768 / 1024 / 1280
   ========================================================= */

/* ---------- App shell ---------- */
.app-shell {
    min-height: 100dvh;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    min-width: 0;
}

/* ---------- Sidebar (mobile: off-canvas drawer) ----------
   Phase 28：尺寸与「微透明感」对齐 onlykiss 的抽屉。
   实测 onlykiss（390×844 视口，2026-10-25）：
     · 宽 210px，满高，padding 18px 12px
     · 底色 rgba(8,9,12,.72) + 左上角一层 rgba(255,255,255,.10) 高光
     · backdrop-filter: blur(20px) saturate(1.45) → 透出后面页面内容
     · border-e 1px rgba(255,255,255,.15)
     · box-shadow: 0 26px 70px rgba(0,0,0,.48), 0 6px 34px rgba(255,255,255,.08)
   ⚠ 这里只改「抽屉外壳」，导航项（.nav__item）保持站内原有尺寸与选中样式。 */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(210px, 88vw);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding: 18px 12px;
    background-color: rgba(8, 9, 12, .72);
    background-image: radial-gradient(120% 90% at 15% -22%, rgba(255, 255, 255, .10), rgba(0, 0, 0, 0) 70%);
    -webkit-backdrop-filter: blur(20px) saturate(1.45);
    backdrop-filter: blur(20px) saturate(1.45);
    border-right: 1px solid rgba(255, 255, 255, .15);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .48), 0 6px 34px rgba(255, 255, 255, .08);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-102%);
    transition: transform var(--t-slow);
    will-change: transform;
}

.sidebar.is-open { transform: translateX(0); }

.sidebar__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-2);
}

.sidebar__spacer { flex: 1 1 auto; min-height: var(--sp-3); }

/* Phase 27：.sidebar__card* 与 .sidebar__foot* 已随侧边栏底部两个信息块
   一并删除（模板里再无对应元素），不留死规则。 */

/* ---------- Drawer overlay ---------- */
.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(4, 6, 11, .68);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: overlay-in var(--t-fast) both;
}

@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    height: var(--topbar-h);
    padding: 0 var(--sp-3);
    /* Phase 10：对齐 OnlyKiss 的实测值 —— 更透的底色 + 更强的背景模糊 */
    background: rgba(0, 0, 0, .32);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    backdrop-filter: blur(22px) saturate(1.5);
    border-bottom: 1px solid var(--border);
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 0 0 auto;
    /* Phase 11：搜索框移走后页眉里没有弹性元素了，
       必须显式把账号区推到右侧，否则全部挤在左边。 */
    margin-left: auto;
}

/* Phase 11：页眉导航（对齐 OnlyKiss 的居中三段式）。
   <1024px 隐藏 —— 该断点下导航由底部 tab bar 承担，避免同屏两份导航。 */
.topbar__nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 2px;
}

.topbar__nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: var(--r-pill);
    color: var(--text-dim);
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: color var(--t-fast), background var(--t-fast);
}

.topbar__nav-link:hover { color: var(--text); background: var(--surface-2); }

/* 选中态：底色 + 文字提亮，且 aria-current 已标示语义 */
.topbar__nav-link.is-active {
    color: var(--text);
    background: var(--surface-2);
}

/* Phase 32：`.topbar .topbar__signin { display: none }` 已删 ——
   ≠<480px 隐藏登录入口的旧逻辑早就不成立（components.css 全局覆盖成 inline-flex），
   留着只会让人误以为移动端看不到 Sign in。.btn 本身就是 inline-flex，
   下面的 768px 规则也无需再重复声明。 */

/* ---------- Mobile tab bar（Phase 9）----------
   <1024px 固定贴底；与侧边栏同源（都读 $config['nav']）。
   padding-bottom 用 env() 适配 iPhone 底部横条（无该变量时回退 0）。 */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    align-items: stretch;
    background: rgba(11, 13, 18, .9);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar__item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--text-mute);
    font-size: .68rem;
    font-weight: 650;
    letter-spacing: .01em;
    text-decoration: none;
    transition: color var(--t-fast);
}

.tabbar__item:hover { color: var(--text); }

/* 选中态：颜色 + 图标同上，且 aria-current 已标示语义 */
.tabbar__item.is-active { color: var(--brand); }

.tabbar__label {
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Page ---------- */
.page {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: var(--sp-4) var(--sp-3) var(--sp-7);
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}

/* ---------- Sections ---------- */
.section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
    scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
}

.section__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.section__heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.section__title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.section__subtitle {
    font-size: .78rem;
    color: var(--text-mute);
}

/* =========================================================
   Breakpoint: 480px
   ========================================================= */
@media (min-width: 480px) {
    .topbar { padding-inline: var(--sp-4); }
    .page   { padding-inline: var(--sp-4); }
}

/* =========================================================
   Phase 10：<480px 的「顶栏两行」规则已删除。
   它原本存在的原因是搜索框要独占一行（--topbar-h: 104px）；
   搜索框移出页眉后，页眉在任何宽度下都是单行，不再需要换行。
   ========================================================= */

/* =========================================================
   Phase 12：<640px 页眉改两行 —— 站标与站名独占第一行并居中
   （对齐 OnlyKiss 的移动端页眉）

   OnlyKiss 移动端页眉实测 98px，正是两行：
     row 1  y=12 h=30   logo 水平居中（绝对定位）
     row 2  y=48 h=38   ☰ 在左，语言/宝石/头像在右
   本实现的差异：用 flex-wrap 换行而非绝对定位，
   因此页眉高度自适应、不会与内容重叠。
   ========================================================= */
@media (max-width: 639px) {
    /* 两行页眉更高，滚动定位需要同步（.section 的 scroll-margin-top 依赖它） */
    :root { --topbar-h: 96px; }

    .topbar {
        height: auto;
        flex-wrap: wrap;
        align-items: center;
        row-gap: 8px;
        padding: 10px var(--sp-3);
    }

    /* 第一行：站标 + 站名独占整行并居中 */
    .topbar .brand {
        order: 1;
        flex: 1 1 100%;
        display: flex;
        justify-content: center;
    }

    /* 第二行：☰ 靠左，账号按钮靠右（.topbar__actions 已带 margin-left:auto） */
    .topbar__menu    { order: 2; }
    .topbar__actions { order: 3; }
}

/* =========================================================
   Breakpoint: 768px
   ========================================================= */
@media (min-width: 768px) {
    body { font-size: 15.5px; }

    /* Phase 10：桌面页眉加高到 OnlyKiss 的 75px */
    :root   { --topbar-h: 75px; }
    .topbar { gap: var(--sp-3); }

    .page {
        padding: var(--sp-5) var(--sp-5) var(--sp-7);
        gap: var(--sp-7);
    }

    .section__title { font-size: 1.18rem; }
    /* Phase 32：.section__link 已删 —— 模板中从无此类名（无“查看全部”类链接）。 */
    .section__subtitle { font-size: .82rem; }
}

/* =========================================================
   Breakpoint: 1024px — sidebar becomes permanent column
   ========================================================= */
@media (min-width: 1024px) {
    /* Phase 11：常驻侧边栏已移除 —— 导航改由页眉承载（对齐 OnlyKiss）。
       侧边栏现在在**所有宽度**下都是 ☰ 打开的抽屉，因此：
         · 不再有"侧边栏 + 主区"的 grid 布局
         · 不再隐藏 ☰ 与品牌（它们现在在桌面也有用）
       ── 副作用：主内容区宽 278px（原侧边栏宽度），
          1024px 下的 5 列卡片从 126px 回到约 183px。 */
    .topbar { gap: var(--sp-4); }

    /* 页眉导航在桌面显示（真居中：相对整个页眉，与 OnlyKiss 一致） */
    .topbar__nav { display: flex; }
}

/* =========================================================
   Breakpoint: 1280px
   ========================================================= */
@media (min-width: 1280px) {
    .page { padding-inline: var(--sp-7); gap: var(--sp-7); }
}

/* =========================================================
   Phase 9：底部导航只在侧边栏隐藏时出现
   ========================================================= */
@media (min-width: 1024px) {
    /* 该断点起侧边栏常驻，底栏冗余 → 整体隐藏 */
    .tabbar { display: none; }
}

@media (max-width: 1023px) {
    /* 内容必须给底栏让位，否则最后一行卡片会被永久遮住 */
    .page {
        padding-bottom: calc(var(--sp-7) + 64px + env(safe-area-inset-bottom, 0px));
    }

    /* Toast 也必须抬高，否则会被底栏盖住 */
    .toast-stack {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}
