/*
Theme Name:   Piaoye Theme
Theme URI:    https://www.nicnie.com/
Description:  基于 Hello Elementor 的飘叶自定义主题，包含菜单优化、性能增强等功能
Author:       飘叶寻梦
Author URI:    https://www.nicnie.com/
Template:     hello-elementor
Version:      1.0.4
License:      GNU General Public License v2 or later
License URI:  http://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  piaoye-theme
*/

/**
 * 飘叶主题样式表
 *
 * 说明: 此文件会自动继承父主题(hello-elementor)的所有样式
 * 你可以在下面添加自定义CSS来覆盖父主题的样式
 *
 * @package Piaoye_Theme
 * @author 飘叶寻梦
 * @since 1.0.0
 */

/* ==================== 飘叶自定义样式区域 ==================== */

/* 修复子菜单宽度 - 让宽度自适应内容 */
.elementor-widget-nav-menu .sub-menu {
    width: auto !important;
    min-width: 190px !important;
}

/* 隐藏当前页面菜单项的默认下划线 */
.elementor-widget-nav-menu .current-menu-item > a::after,
.elementor-widget-nav-menu .current_page_item > a::after {
    opacity: 0 !important;
}

/* 但在hover时重新显示下划线 */
.elementor-widget-nav-menu .current-menu-item:hover > a::after,
.elementor-widget-nav-menu .current_page_item:hover > a::after {
    opacity: 1 !important;
}

/* 调整下划线位置,距离文字2px */
.elementor-widget-nav-menu a::after {
    bottom: 11px !important;
}

/* ==================== 搜索框样式 - 放大镜在输入框内部 ==================== */
/*
 * 使用通用自定义类 .piaoye-header-search，而非模板 ID
 * 需要在 Elementor 中给搜索框 widget 添加此类（Advanced → CSS Classes）
 * 所有语言的 Header 模板都使用相同的类，确保样式一致
 */

/* 🔧 限制小工具容器高度 - 解决多出空白的问题 */
.piaoye-header-search .elementor-widget-container {
    height: auto !important;
    min-height: auto !important;
}

/* 搜索表单设置为相对定位 */
.piaoye-header-search .e-search-form {
    position: relative !important;
    height: 38px !important;
}

/* 输入框容器占满宽度 */
.piaoye-header-search .e-search-input-wrapper {
    width: 100% !important;
    height: 38px !important;
    visibility: visible !important;
}

/* 输入框样式 */
.piaoye-header-search .e-search-input {
    width: 100% !important;
    height: 38px !important;
    min-height: 38px !important; /* 覆盖Elementor的calc()计算 */
    max-height: 38px !important; /* 防止被撑大 */
    padding: 8px 40px 8px 12px !important; /* 右侧留40px给图标 */
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
    background-color: #fff !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
}

/* 提交按钮绝对定位在输入框内部右侧 */
.piaoye-header-search .e-search-submit {
    position: absolute !important;
    right: 5px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: visible !important;
}

/* 隐藏LABEL */
.piaoye-header-search .e-search-label {
    display: none !important;
}

/* 按钮图标样式 */
.piaoye-header-search .e-search-submit svg {
    width: 18px !important;
    height: 18px !important;
    fill: #999 !important;
    transition: fill 0.3s ease !important;
}

/* Hover效果 */
.piaoye-header-search .e-search-submit:hover svg {
    fill: #333 !important;
}

.piaoye-header-search .e-search-input:focus {
    border-color: #999 !important;
    outline: none !important;
}

/* 搜索框样式结束 */

/* ==================== 修复页面水平滚动条 ==================== */

/* 全局防止水平滚动 */
 html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
} 

/* 移动端特定修复 */
@media (max-width: 767px) {
    /* 修复Elementor容器的margin问题 */
     .e-con-full {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    } 

    /* 修复轮播图溢出：默认限制，相关产品轮播除外 */
     .swiper-container,
    .swiper-wrapper,
    .swiper-slide {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    } 

    /* 相关产品轮播需要可滚动的wrapper */
     .section-carousel-slider.related-products .swiper-wrapper,
    .section-carousel-slider.related-products .swiper-slide {
        max-width: none !important;
        overflow: visible !important;
    }

    /* 产品主图/画廊轮播需要可见内容 */
     .single-product-gallery .swiper-wrapper,
    .single-product-gallery .swiper-slide,
    .elementor-widget-piaoye-gallery .swiper-wrapper,
    .elementor-widget-piaoye-gallery .swiper-slide {
        max-width: none !important;
        overflow: visible !important;
    }

    /* 首页轮播图需要正常显示 */
    .elementor-widget-slides .swiper-wrapper,
    .elementor-widget-slides .swiper-slide {
        max-width: none !important;
        overflow: visible !important;
    }

    /* 确保所有section不溢出 */
     .elementor-section {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    } 

    /* 确保所有widget和column不溢出 */
     .elementor-widget-wrap,
    .elementor-column {
        max-width: 100% !important;
        overflow-x: hidden !important;
    } 

    /* 确保图片响应式 */
     img {
        max-width: 100% !important;
        height: auto !important;
    } 
}

/* 限制轮播图Section内容不溢出 (保留旧代码作为参考) */
 .elementor-element-3b4931f { 
     overflow: hidden !important; 
 } 

/* 修复页面水平滚动条结束 */
/* ==================== 修复菜单小箭头 ==================== */
.elementor-nav-menu .sub-arrow {
    padding: 0px 0px 5px 0px  !important;
}

/* 缩小菜单下拉箭头图标并垂直居中 */
.elementor-nav-menu .sub-arrow .icon-piaoye_zhedie {
    font-size: 12px !important;
    transform: translateY(4px) !important;
    font-weight: bold !important;
    -webkit-text-stroke: 0px currentColor;
}
/* 子菜单中有下级菜单的箭头朝右（因为三级菜单向右飞出） */
.elementor-nav-menu .sub-menu .menu-item-has-children > a .sub-arrow .icon-piaoye_zhedie {
    transform: translateY(4px) rotate(-90deg) !important;
}

/* 单小箭头修复结束 */

/* ==================== 菜单换行时下拉不被第二行干扰 ==================== */
.elementor-nav-menu > li.menu-item-has-children:hover {
    position: relative;
    z-index: 100;
}

/* ==================== 三级菜单向右飞出 ==================== */
.elementor-nav-menu .sub-menu .menu-item-has-children > .sub-menu {
    top: 0 !important;
    left: 100% !important;
}


/* ==================== 优雅的CSS细线箭头设计 ==================== */
/* 使用纯CSS绘制细线条箭头，更加优雅美观 */
/* .elementor-nav-menu .sub-arrow svg { */
    /* display: none !important; */
/* } */

/* .elementor-nav-menu .sub-arrow::after { */
    /* content: ""; */
    /* display: inline-block; */
    /* width: 5px; */
    /* height: 5px; */
    /* border-right: 1.5px solid #666; */
    /* border-bottom: 1.5px solid #666; */
    /* transform: rotate(45deg); */
    /* margin-left: 3px; */
    /* margin-right: 5px; */
    /* margin-bottom: 2px; */
    /* vertical-align: middle; */
    /* transition: border-color 0.3s ease; */
/* } */

/* 悬停时箭头颜色加深 */
/* .elementor-nav-menu .menu-item:hover .sub-arrow::after { */
    /* border-color: #333; */
/* } */

/* CSS细线箭头设计结束 */

/* ==================== 修复小语种header padding ==================== */
/* 小语种header模板缺少padding重置，导致导航条偏高 */
/* ES:32896, FR:34301, AR:34920, PT:34978, DE:35039, IT:35292 */
.elementor-32896 .e-con-inner,
.elementor-34301 .e-con-inner,
.elementor-34920 .e-con-inner,
.elementor-34978 .e-con-inner,
.elementor-35039 .e-con-inner,
.elementor-35292 .e-con-inner {
    /* padding-top: 0 !important;
    padding-bottom: 0 !important; */
}
/* 小语种header padding修复结束-在elementor修复了 */

/* ==================== 修复 Posts / Archive Posts 图片 CLS ==================== */
/*
 * Elementor 会提前给缩略图容器预留图片比例空间。
 * 在 Elementor JS 初始化前，图片如果仍处于普通文档流，
 * 就会出现“图片高度 + 比例预留高度”的双重高度。
 *
 * 同时兼容：
 * 1. 普通 Posts 小工具
 * 2. Archive Posts 归档文章小工具
 */

/* 缩略图比例容器 */
.elementor-widget-posts
.elementor-posts-container
.elementor-post__thumbnail,

.elementor-widget-archive-posts
.elementor-posts-container
.elementor-post__thumbnail {
    position: relative !important;
    overflow: hidden !important;
}

/* 图片链接保持块级布局 */
.elementor-widget-posts
.elementor-post__thumbnail__link,

.elementor-widget-archive-posts
.elementor-post__thumbnail__link {
    display: block !important;
}

/* 图片立即绝对定位，不等待 Elementor JS 初始化 */
.elementor-widget-posts
.elementor-posts-container
.elementor-post__thumbnail img,

.elementor-widget-archive-posts
.elementor-posts-container
.elementor-post__thumbnail img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;

    width: calc(100% + 1px) !important;
    height: calc(100% + 1px) !important;

    transform: translate(-50%, -50%) !important;
    object-fit: cover !important;
    display: block !important;
}

/* Posts / Archive Posts CLS 修复结束 */

 /* ==================== WordPress 经典文章图集 ==================== */
  /*
   * 根因：
   * Hello Elementor 声明了 HTML5 gallery 支持，因此 WordPress 的
   * gallery_shortcode() 不再输出旧式 float/width 内联布局。
   * 父主题又没有提供 .gallery-columns-* 布局，导致每个 figure
   * 作为块级元素单独占据一行。
   *
   * 本规则仅处理：
   * 1. Elementor Theme Post Content 直接输出的经典 [gallery]；
   * 2. Hello Elementor 默认 page-content 直接输出的经典 [gallery]。
   *
   * 不影响 Elementor Image Gallery、产品画廊和 Swiper。
   */

  /* 基础网格：未识别列数时 fallback 为 3 列 */
  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery[class*="gallery-columns-"] {
      display: grid;
      grid-template-columns:
          repeat(var(--pyt-gallery-columns, 3), minmax(0, 1fr));
      gap: clamp(8px, 1vw, 16px);
      align-items: start;
      margin: 1.5em 0;
  }

  /* WordPress 后台列数映射 */
  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-1 {
      --pyt-gallery-columns: 1;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-2 {
      --pyt-gallery-columns: 2;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-3 {
      --pyt-gallery-columns: 3;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-4 {
      --pyt-gallery-columns: 4;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-5 {
      --pyt-gallery-columns: 5;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-6 {
      --pyt-gallery-columns: 6;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-7 {
      --pyt-gallery-columns: 7;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-8 {
      --pyt-gallery-columns: 8;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery.gallery-columns-9 {
      --pyt-gallery-columns: 9;
  }

  /* 清除 figure 的浏览器默认边距 */
  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery[class*="gallery-columns-"] > .gallery-item {
      min-width: 0;
      margin: 0;
      text-align: center;
  }

  /* 图片链接使用块级布局 */
  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery[class*="gallery-columns-"] .gallery-icon {
      margin: 0;
  }

  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery[class*="gallery-columns-"] .gallery-icon > a {
      display: block;
  }

  /*
   * 保留后台选择的图片尺寸和原始比例：
   * - 图片大于格子时自动缩小；
   * - 图片小于格子时不强制放大；
   * - 不裁切雕塑主体；
   * - 不在本次结构修复中引入正方形视觉策略。
   */
  :where(
      .elementor-widget-theme-post-content > .elementor-widget-container,
      .page-content
  ) > .gallery[class*="gallery-columns-"] .gallery-item img {
      display: block;
      width: auto;
      max-width: 100%;
      height: auto;
      margin-inline: auto;
  }

  /* 平板：后台设置 4～9 列时收敛为 3 列 */
  @media (max-width: 1024px) {
      :where(
          .elementor-widget-theme-post-content > .elementor-widget-container,
          .page-content
      ) > .gallery:is(
          .gallery-columns-4,
          .gallery-columns-5,
          .gallery-columns-6,
          .gallery-columns-7,
          .gallery-columns-8,
          .gallery-columns-9
      ) {
          --pyt-gallery-columns: 3;
      }
  }

  /* 手机：后台设置 3～9 列时收敛为 2 列 */
  @media (max-width: 767px) {
      :where(
          .elementor-widget-theme-post-content > .elementor-widget-container,
          .page-content
      ) > .gallery:is(
          .gallery-columns-3,
          .gallery-columns-4,
          .gallery-columns-5,
          .gallery-columns-6,
          .gallery-columns-7,
          .gallery-columns-8,
          .gallery-columns-9
      ) {
          --pyt-gallery-columns: 2;
      }
  }

  /* 小屏手机：统一为 1 列 */
  @media (max-width: 479px) {
      :where(
          .elementor-widget-theme-post-content > .elementor-widget-container,
          .page-content
      ) > .gallery[class*="gallery-columns-"] {
          --pyt-gallery-columns: 1;
      }
  }

  /* WordPress 经典文章图集结束 */

/* ==================== 阿语博客正文与目录对齐 ==================== */
/*
 * 阿语页面已使用 RTL 阅读方向，但 Elementor 正文组件可能仍指定左对齐，
 * Easy Table of Contents 也会显式指定 LTR 及目录标题左对齐。
 * 仅覆盖阿语单篇博客的正文组件和目录，避免改动其它语言及产品页面。
 * start 跟随元素的阅读方向；正文继承页面 RTL，目录显式使用 RTL。
 * 正文子元素仍可保留各自明确设置的居中、两端对齐等排版。
 */
html:lang(ar) .single-post .elementor-location-single .elementor-widget-theme-post-content {
    text-align: start;
}

html:lang(ar) .single-post #ez-toc-container {
    direction: rtl;
    text-align: start;
}

html:lang(ar) .single-post #ez-toc-container .ez-toc-title {
    text-align: start;
}
