/* ============================================================
   layout.css — Header / Bento Grid / Footer / 响应式断点
   [INPUT]: 依赖 base.css 的 CSS 变量
   [OUTPUT]: 页面骨架布局
   [POS]: 控制页面整体结构，不含具体卡片样式
   [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
   ============================================================ */

/* ============================================================
   Header
   ============================================================ */
header#main-header {
    padding: 24px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    background: transparent;
    transition: transform 0.3s ease;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--c1-text);
    transition: color 0.4s;
}

[data-theme="dark"] .logo { color: #fff; }

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================
   Theme Toggle
   ============================================================ */
.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    width: 140px;
    height: 44px;
    background: var(--toggle-bg);
    border-radius: 22px;
    padding: 4px;
    box-shadow: var(--toggle-shadow);
}

.theme-toggle .switch-indicator {
    position: absolute;
    top: 50%;
    left: 4px;
    width: calc((100% - 8px) / 3);
    height: 36px;
    background: var(--indicator-bg);
    border-radius: 18px;
    box-shadow: var(--indicator-shadow);
    transform: translateX(var(--indicator-x)) translateY(-50%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s ease;
    z-index: 1;
}

.theme-toggle .switch-icons {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
}

.theme-toggle .icon-btn {
    flex: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    font-size: 16px;
    transition: color 0.3s ease;
    outline: none;
}

/* Active state per theme */
[data-theme="light"]  .icon-btn[data-mode="light"]  { color: var(--icon-active); }
[data-theme="orange"] .icon-btn[data-mode="orange"] { color: var(--icon-active); }
[data-theme="dark"]   .icon-btn[data-mode="dark"]   { color: var(--icon-active); }

/* ============================================================
   Main Content
   ============================================================ */
#main-content {
    padding-top: 100px;
    padding-bottom: 60px;
    flex: none;
}

/* ============================================================
   Bento Grid
   ============================================================ */
.bento-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
}

/* --- 768px: 2 列 --- */
@media (min-width: 768px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: minmax(140px, auto);
    }

    .grid-stacked {
        grid-column: span 1;
        grid-row: span 2;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .grid-stacked > .bento-card,
    .grid-stacked > a.bento-card {
        flex: 1;
        min-height: 0;
    }
}

/* --- 1024px: 4 列完整布局 --- */
@media (min-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(2, minmax(160px, auto));
        gap: var(--gap);
    }

    .grid-hero   { grid-column: span 2; grid-row: span 2; }
    .grid-about  { grid-column: span 1; grid-row: span 2; }

    .grid-stacked {
        grid-column: span 1;
        grid-row: span 2;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .grid-stacked > .bento-card,
    .grid-stacked > a.bento-card {
        flex: 1;
        min-height: 0;
    }

    .grid-contact  { grid-column: span 1; }
    .grid-timezone { grid-column: span 2; }
    .grid-blog     { grid-column: span 1; }
}

/* --- 移动端 stacked 修正 --- */
@media (max-width: 768px) {
    .grid-stacked {
        grid-column: span 1;
        grid-row: span 1;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .grid-stacked > .bento-card,
    .grid-stacked > a.bento-card {
        flex: none;
        min-height: auto;
    }

    .card-content { padding: 16px; }
}

/* ============================================================
   Footer
   ============================================================ */
footer {
    margin-top: 80px;
    text-align: center;
    padding: 24px 0;
    opacity: 0.5;
    font-size: 0.9rem;
}

footer span { display: block; margin-bottom: 2px; }
