/*
Theme Name:   Storefront York
Description:  Custom Storefront child theme with menu and branding adjustments
Author:       York
Template:     storefront
Version:      1.3.4
*/

/* 缩小头部空白区域 */
.site-header {
    padding-top: 0.5em !important;
    padding-bottom: 0.5em !important;
}

.site-header .col-full {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* site-branding占一整行 */
.site-header .site-branding {
    width: 100%;
    order: 1;
}

/* 隐藏secondary-navigation */
.site-header .secondary-navigation {
    display: none !important;
}

/* 搜索框靠右 */
.site-header .site-search {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto !important;
    max-width: 350px;
    width: 350px;
}

/* 缩小面包屑导航区域 */
.storefront-breadcrumb {
    padding-top: 0.5em !important;
    padding-bottom: 0.5em !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.storefront-breadcrumb .col-full {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Site Branding - 防止店名分行 */
.site-branding {
    min-width: 280px;
    width: auto;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.site-branding .site-title {
    white-space: nowrap;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.site-branding .site-title a {
    white-space: nowrap;
}

/* 如果使用 Logo */
.site-branding .custom-logo-link {
    white-space: nowrap;
}

/* 主导航菜单 - 不分行 + 减小高度 */
.main-navigation {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.main-navigation ul li {
    white-space: nowrap;
}

.main-navigation ul li a {
    white-space: nowrap;
    padding-top: 0.2em !important;
    padding-bottom: 0.2em !important;
    padding-left: 0.8em !important;
    padding-right: 0.8em !important;
}

/* 子菜单自动撑满宽度 + 减小高度 */
.main-navigation ul.sub-menu,
.main-navigation ul.submenu {
    width: max-content;
    min-width: 200px;
}

.main-navigation ul.sub-menu li,
.main-navigation ul.submenu li {
    width: 100%;
}

.main-navigation ul.sub-menu li a,
.main-navigation ul.submenu li a {
    width: 100%;
    white-space: nowrap;
    padding-top: 0.15em !important;
    padding-bottom: 0.15em !important;
    padding-left: 0.6em !important;
    padding-right: 0.6em !important;
}

/* 隐藏页脚信息 */
.site-info {
    display: none !important;
}

/* 响应式 - 移动端恢复正常 */
@media (max-width: 768px) {
    .site-branding {
        min-width: auto;
    }

    .site-branding .site-title {
        white-space: normal;
    }
}

/* ==========================================================================
   Latest Posts 区块样式优化
   ========================================================================== */

/* 覆盖母主题的 wp-post-image 间距 */
.wp-block-latest-posts .wp-post-image,
.wp-block-latest-posts .hentry .wp-post-image {
    margin-bottom: 0.4em !important; /* 缩小图片到标题的间距 */
    margin-left: auto;
    margin-right: auto;
}

/* 调整文章项的间距 */
.wp-block-latest-posts li,
.wp-block-latest-posts__list li {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* 图片容器 */
.wp-block-latest-posts .wp-block-latest-posts__featured-image,
.wp-block-latest-posts__list .wp-block-latest-posts__featured-image {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.wp-block-latest-posts .wp-block-latest-posts__featured-image img,
.wp-block-latest-posts__list .wp-block-latest-posts__featured-image img {
    display: block;
    margin-bottom: 0.4em !important; /* 缩小图片到标题的间距 */
    padding-bottom: 0 !important;
}

/* 标题链接 - 增大到下一篇文章的距离 */
.wp-block-latest-posts li > a,
.wp-block-latest-posts__list li > a,
.wp-block-latest-posts li a.wp-block-latest-posts__post-title,
.wp-block-latest-posts__list li a.wp-block-latest-posts__post-title {
    display: block;
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 2.5em !important; /* 增大标题到下一篇的间距 */
    padding-bottom: 0 !important;
}

/* Grid布局的情况 */
.wp-block-latest-posts.is-grid li {
    margin-bottom: 0 !important;
}

.wp-block-latest-posts.is-grid li > a {
    margin-bottom: 2.5em !important;
}

/* ==========================================================================
   产品页图片优化
   ========================================================================== */

/* 产品主图 - 缩小尺寸并添加空白边距 */
.single-product div.product .woocommerce-product-gallery {
    width: 38% !important;
    max-width: 360px;
    padding: 15px !important;
    box-sizing: border-box;
}

/* 重要：不限制wrapper宽度，让FlexSlider正常工作 */
.woocommerce-product-gallery__wrapper {
    max-width: none !important;
    /* FlexSlider会自动设置width为1400%等，不要覆盖 */
}

/* 限制每个图片项的显示大小 */
.woocommerce-product-gallery__image {
    /* FlexSlider会设置每个图片项的宽度，不要限制 */
    display: inline-block;
    vertical-align: top;
}

.woocommerce-product-gallery__image img {
    width: 100%;
    height: auto;
    display: block;
}

/* 确保FlexSlider图片正确显示 */
.woocommerce-product-gallery .flex-viewport {
    overflow: hidden !important;
    position: relative;
    max-width: none !important;
    width: 100% !important;
}

/* 确保zoom图标不遮挡 */
.woocommerce-product-gallery__trigger {
    z-index: 99;
}

/* 产品标题 - 缩小字体 */
.single-product div.product .product_title {
    font-size: 1.2em !important;
}

/* 产品缩略图 - 增大尺寸并减小间距 */
.flex-control-thumbs {
    margin-top: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
}

.flex-control-thumbs li {
    width: 23% !important;
    margin-right: 2.5% !important;
    margin-bottom: 8px !important;
    float: none !important;
}

.flex-control-thumbs li:nth-child(4n) {
    margin-right: 0 !important;
}

/* 确保每行开始时清除浮动 */
.flex-control-thumbs li:nth-child(4n+1) {
    clear: both;
}

.flex-control-thumbs li img {
    width: 100% !important;
    height: auto !important;
    cursor: pointer !important;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    display: block !important;
}

.flex-control-thumbs li img:hover,
.flex-control-thumbs li img.flex-active {
    opacity: 1 !important;
}

/* 确保缩略图可点击 */
.flex-control-thumbs li {
    pointer-events: auto !important;
}

.flex-control-thumbs li img {
    pointer-events: auto !important;
}

/* 相关产品 - 5列布局 */
.related.products ul.products li.product,
.upsells.products ul.products li.product {
    width: 19% !important;
    margin-right: 1.25% !important;
}

.related.products ul.products li.product:nth-child(5n),
.upsells.products ul.products li.product:nth-child(5n) {
    margin-right: 0 !important;
}

/* 响应式 - 产品页 */
@media (max-width: 768px) {
    .single-product div.product .woocommerce-product-gallery {
        width: 100% !important;
        max-width: 100%;
    }

    .flex-control-thumbs li {
        width: 23% !important;
        margin-right: 2.5% !important;
    }

    /* 移动端保持2列 */
    .related.products ul.products li.product,
    .upsells.products ul.products li.product {
        width: 48% !important;
        margin-right: 4% !important;
    }

    .related.products ul.products li.product:nth-child(2n),
    .upsells.products ul.products li.product:nth-child(2n) {
        margin-right: 0 !important;
    }
}

/* Woo product description table spacing */
.woocommerce-Tabs-panel--description table {
  margin: 0.6em 0;
  border-collapse: collapse;
}

.woocommerce-Tabs-panel--description th,
.woocommerce-Tabs-panel--description td {
  padding: 6px 10px;     /* 调小单元格内边距 */
  line-height: 1.35;     /* 调小行高 */
  vertical-align: top;
}

.woocommerce-Tabs-panel--description p {
  margin: 0 0 0.5em;     /* 防止表格里/周围的段落把间距撑大 */
}

/* 如果你表格里有很多 <br> 导致很松，也可加这条 */
.woocommerce-Tabs-panel--description br {
  line-height: 1.1;
}

/* 隐藏“Description”标签按钮（不影响其它标签） */
.woocommerce-tabs ul.tabs li.description_tab {
  display: none !important;
}

