/* ============================================================
 *  子比主题-笔记本文章框
 *  前端样式
 * ============================================================ */

.zibll-laptop-wrap {
    --zl-max-width: 720px;
    --zl-top: 5%;
    --zl-left: 14%;
    --zl-width: 72%;
    --zl-height: 42%;
    --zl-radius: 8px;
    --zl-bg: #000000;

    max-width: var(--zl-max-width);
    margin: 30px auto 40px;
    width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
    /* 防止主题/编辑器把整个 wrap 折叠 */
    height: auto !important;
    max-height: none !important;
    display: block !important;
    clear: both !important;
    position: relative !important;
    float: none !important;
    text-align: left;
    /* 防止被父级 zibll 卡片 overflow:hidden 裁切底座 */
    z-index: 1;
    isolation: isolate;
}

/* --- 笔记本舞台 --- */
.zibll-laptop-stage {
    position: relative;
    width: 100%;
    line-height: 0;
    overflow: visible !important;
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent;
    /* 默认：单篇文章页用 3/2 比例（覆盖宽度决定高度） */
    aspect-ratio: 3 / 2;
}

/* archive 卡片模式：让 stage 完全填满父容器，不再固定比例 */
.zibll-laptop-stage.zibll-laptop-archive-stage,
.zibll-laptop-wrap.zibll-laptop-archive .zibll-laptop-stage {
    aspect-ratio: auto;
    height: 100% !important;
    min-height: 0;
}

.zibll-laptop-stage::after {
    content: "";
    display: block;
    clear: both;
}

.zibll-laptop-image {
    /* 用 object-fit:cover 强制图片填满整个 stage 区域。
       配合 object-position: center bottom 让底座永远对齐 stage 底边。
       这样无论 stage 实际比例如何，底座都不会被裁切，
       屏幕顶部即使有少量裁切也可接受（屏幕区域占主体）。 */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: block !important;
    object-fit: cover !important;
    object-position: center bottom !important;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    z-index: 1;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    transform: none !important;
}

/* --- 屏幕区域（覆盖在笔记本图片上） --- */
.zibll-laptop-screen {
    position: absolute !important;
    top: var(--zl-top) !important;
    left: var(--zl-left) !important;
    width: var(--zl-width) !important;
    height: var(--zl-height) !important;
    max-width: 100% !important;
    max-height: 100% !important;
    background: var(--zl-bg) !important;
    border-radius: var(--zl-radius) !important;
    /* 关键：黑框必须严格裁切，超出部分不可见 */
    overflow: hidden !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    z-index: 2 !important;
    pointer-events: none !important;
    /* 防止任何子元素溢出黑框 */
    contain: layout paint;
}

.zibll-laptop-screen img,
.zibll-screen-cell img {
    pointer-events: auto;
}

.zibll-screen-inner {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* 在黑框内为文章首图留出明显的边距（后台可调） */
    padding: var(--zl-padding, 24px) !important;
    box-sizing: border-box !important;
    /* 关键：内层也严格裁切 */
    overflow: hidden !important;
    background: var(--zl-bg, #000000) !important;
    border-radius: var(--zl-radius, 8px) !important;
    /* 防止任何子元素溢出 */
    contain: layout paint;
}
/* --- 图片网格 --- */
.zibll-screen-grid {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: grid !important;
    gap: 4px;
    align-items: center !important;
    justify-items: center !important;
    overflow: hidden !important;
}

/* 1张图：占满（缩进留边） */
.zibll-screen-grid[data-count="1"] {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}
.zibll-screen-grid[data-count="1"] .zibll-screen-cell {
    /* 关键：让 cell 主动收缩四周留出可见的"黑边" */
    margin: var(--zl-padding, 24px) !important;
    width: calc(100% - 2 * var(--zl-padding, 24px)) !important;
    height: calc(100% - 2 * var(--zl-padding, 24px)) !important;
    max-width: calc(100% - 2 * var(--zl-padding, 24px)) !important;
    max-height: calc(100% - 2 * var(--zl-padding, 24px)) !important;
    overflow: hidden !important;
    min-width: 0 !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}
.zibll-screen-grid[data-count="1"] .zibll-screen-cell img {
    /* 严格约束图片在黑框内，绝不超出 */
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    object-fit: contain !important;
    /* 覆盖 WordPress 自动注入的 width/height HTML 属性 */
    display: block !important;
}

/* 2张：左右 */
.zibll-screen-grid[data-count="2"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}
.zibll-screen-grid[data-count="2"] .zibll-screen-cell {
    width: 100%;
    height: 100%;
}
.zibll-screen-grid[data-count="2"] .zibll-screen-cell img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* 3-4张：2x2 */
.zibll-screen-grid[data-count="3"],
.zibll-screen-grid[data-count="4"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.zibll-screen-grid[data-count="3"] .zibll-screen-cell:nth-child(3),
.zibll-screen-grid[data-count="4"] .zibll-screen-cell:nth-child(3) {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}
.zibll-screen-grid[data-count="3"] .zibll-screen-cell:nth-child(4) {
    display: none;
}
.zibll-screen-grid[data-count="3"] .zibll-screen-cell:nth-child(2) {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
}

/* 5张及以上：3列网格 */
.zibll-screen-grid:not([data-count="1"]):not([data-count="2"]):not([data-count="3"]):not([data-count="4"]) {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
}

.zibll-screen-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    border-radius: 2px;
    box-sizing: border-box;
}

.zibll-screen-cell img {
    max-width: 100% !important;
    max-height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* --- 屏幕空白占位 --- */
.zibll-screen-empty {
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.zibll-screen-empty .dashicons {
    font-size: 28px;
    line-height: 1;
}
.zibll-screen-empty p {
    margin: 0;
}

/* --- 文字区域 --- */
.zibll-laptop-text {
    margin-top: 28px;
    line-height: 1.85;
    color: #333;
    font-size: 15px;
    word-break: break-word;
}

.zibll-laptop-text p {
    margin: 0 0 1em;
}

.zibll-laptop-text h1,
.zibll-laptop-text h2,
.zibll-laptop-text h3,
.zibll-laptop-text h4,
.zibll-laptop-text h5,
.zibll-laptop-text h6 {
    margin: 1.4em 0 0.6em;
    line-height: 1.3;
    color: #222;
    font-weight: 700;
}

.zibll-laptop-text h2 { font-size: 1.6em; }
.zibll-laptop-text h3 { font-size: 1.35em; }
.zibll-laptop-text h4 { font-size: 1.15em; }

.zibll-laptop-text a {
    color: #2271b1;
    text-decoration: none;
    border-bottom: 1px solid rgba(34, 113, 177, 0.3);
    transition: all 0.2s ease;
}
.zibll-laptop-text a:hover {
    color: #135e96;
    border-bottom-color: #135e96;
}

.zibll-laptop-text blockquote {
    margin: 1.2em 0;
    padding: 0.6em 1.2em;
    border-left: 4px solid #2271b1;
    background: rgba(34, 113, 177, 0.06);
    color: #555;
    border-radius: 0 4px 4px 0;
}

.zibll-laptop-text pre,
.zibll-laptop-text code {
    font-family: Consolas, Monaco, "Courier New", monospace;
}
.zibll-laptop-text code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.92em;
    color: #c7254e;
}
.zibll-laptop-text pre {
    background: #1e1e1e;
    color: #f8f8f2;
    padding: 14px 18px;
    border-radius: 6px;
    overflow-x: auto;
    line-height: 1.6;
    margin: 1.2em 0;
}
.zibll-laptop-text pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    border-radius: 0;
}

.zibll-laptop-text ul,
.zibll-laptop-text ol {
    margin: 1em 0;
    padding-left: 1.6em;
}
.zibll-laptop-text li {
    margin: 0.3em 0;
}

.zibll-laptop-text img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.zibll-laptop-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: 0.95em;
}
.zibll-laptop-text th,
.zibll-laptop-text td {
    border: 1px solid #e5e5e5;
    padding: 8px 12px;
    text-align: left;
}
.zibll-laptop-text th {
    background: #f7f7f7;
    font-weight: 600;
}

/* --- 移动端适配 --- */
@media (max-width: 600px) {
    .zibll-laptop-wrap {
        --zl-top: 4%;
        --zl-left: 8%;
        --zl-width: 84%;
        --zl-height: 40%;
        --zl-radius: 5px;
    }
    .zibll-laptop-text {
        font-size: 14px;
    }
    .zibll-laptop-text h2 { font-size: 1.4em; }
    .zibll-laptop-text h3 { font-size: 1.2em; }
}

/* ============================================================
 *  archive / 首页 / 最新文章模块 专用样式
 *  让特色图卡片用更紧凑的笔记本框
 *  关键：zibll 卡片图区用 padding-bottom 百分比实现固定宽高比，
 *       height:0 + overflow:hidden，导致常规 max-height 失效。
 *       必须用 position:absolute 让 wrap 完全填满父容器。
 * ============================================================ */
.zibll-laptop-wrap.zibll-laptop-archive {
    max-width: 100% !important;
    margin: 0 !important;
    /* 用 absolute 填满父级 zibll 卡片图区，绕开 height:0 限制 */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    overflow: visible !important;
}

.zibll-laptop-wrap.zibll-laptop-archive .zibll-laptop-stage {
    /* stage 跟随 wrap（已填满父容器） */
    aspect-ratio: auto !important;
    height: 100% !important;
    min-height: 0;
}

.zibll-laptop-wrap.zibll-laptop-archive .zibll-laptop-image {
    object-position: center bottom !important;
}

/* 给 zibll 卡片图区添加定位上下文（让 absolute 的 wrap 能正确填满） */
.post-thumb,
.entry-media,
.thumbnail,
.post-cover,
.post-media,
.cat-post-thumb {
    position: relative !important;
}

/* 防止 zibll 主题卡片容器（通常有 overflow:hidden）裁切底座 */
.post-thumb .zibll-laptop-wrap,
.entry-media .zibll-laptop-wrap,
.thumbnail .zibll-laptop-wrap,
.post-cover .zibll-laptop-wrap,
.cat-post-thumb .zibll-laptop-wrap,
.posts-item .zibll-laptop-wrap,
article .zibll-laptop-wrap,
.entry-thumb .zibll-laptop-wrap,
.posts-item .thumb .zibll-laptop-wrap {
    overflow: visible !important;
}

.zibll-laptop-wrap.zibll-laptop-archive .zibll-screen-grid[data-count="1"] .zibll-screen-cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zibll-laptop-wrap.zibll-laptop-archive .zibll-screen-cell img,
.zibll-laptop-wrap.zibll-laptop-archive .zibll-screen-featured {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    margin: 0 auto !important;
    display: block !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    vertical-align: middle !important;
}
