/* ============================================================
 * Widgets — 侧边栏统一 UI（文章 / 产品 / 分类三套合一）
 * ------------------------------------------------------------
 * 从 polish.css 按所有权迁移（严格视觉不变）。
 * 加载层级：priority 25，依赖 eth-utilities，页面 css 之前。
 * ============================================================ */
/* 0.7.5：分类侧边栏不再包裹卡片（内部 .eth-widget 已是卡片），
   避免双重边框/背景。文章/产品侧边栏仍是卡片容器。 */
.eth-article-widget,
.eth-product-sidebar > * {
    padding: var(--eth-space-xs);
    border: 1px solid var(--eth-premium-border);
    border-radius: var(--eth-radius-m);
    background: var(--eth-bg-surface);
    box-shadow: var(--eth-premium-shadow-sm);
}

.eth-widget__title,
.eth-article-widget__title {
    padding-bottom: var(--eth-space-2xs);
    border-bottom: 1px solid var(--eth-premium-border);
    font-size: var(--eth-fs-xs);
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.eth-widget li + li {
    margin-top: var(--eth-space-2xs);
}

/* =========================================================
 * 0.7.4 — 侧边栏统一 UI（文章 / 产品 / 分类三套合一）
 * ----------------------------------------------------
 * 统一卡片语言 + 链接样式 + 产品图片右对齐。
 * ========================================================= */

/* --- 1. 统一 widget 卡片语言 --- */
.eth-article-content__sidebar,
.eth-product-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--eth-space-xs);
}

/* 三种 widget 统一为同一套卡片 */
.eth-article-widget,
.eth-product-widget,
.eth-widget {
    position: relative;
    padding: clamp(1.1rem, 2vw, 1.5rem);
    border: 1px solid var(--eth-premium-border);
    border-radius: var(--eth-radius-l);
    background:
        radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--eth-primary) 4%, transparent), transparent 55%),
        var(--eth-bg-surface);
    box-shadow: var(--eth-premium-shadow-sm);
    transition: box-shadow 280ms var(--eth-premium-ease), border-color 280ms ease;
}

.eth-article-widget:hover,
.eth-product-widget:hover,
.eth-widget:hover {
    border-color: color-mix(in srgb, var(--eth-primary) 22%, var(--eth-border));
    box-shadow: var(--eth-premium-shadow-md);
}

.eth-article-widget + .eth-article-widget,
.eth-product-widget + .eth-product-widget {
    margin-top: 0;
}

/* 标题统一 eyebrow 风格 */
.eth-article-widget__title,
.eth-product-widget__title,
.eth-widget__title {
    position: relative;
    margin: 0 0 var(--eth-space-xs);
    padding: 0 0 var(--eth-space-2xs);
    border-bottom: 1px solid var(--eth-premium-border);
    font-size: var(--eth-fs-xs);
    font-weight: var(--eth-fw-bold);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--eth-text-title);
}

/* 标题左侧品牌色小标（延续 TOC 语言） */
.eth-article-widget__title::before,
.eth-product-widget__title::before,
.eth-widget__title::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-right: var(--eth-space-3xs);
    border-radius: 2px;
    background: linear-gradient(135deg, var(--eth-primary), var(--eth-tertiary));
    vertical-align: middle;
}

/* --- 2. 侧边栏链接样式（li / a） --- */
.eth-article-widget ul,
.eth-product-widget ul,
.eth-widget ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.eth-article-widget li,
.eth-product-widget li,
.eth-widget li {
    margin: 0;
}

.eth-article-widget li + li,
.eth-product-widget li + li,
.eth-widget li + li {
    margin-top: 0.3rem;
}

.eth-article-widget li a,
.eth-product-widget li a,
.eth-widget li a,
.eth-article-widget li > a,
.eth-product-widget li > a,
.eth-widget li > a {
    display: block;
    padding: var(--eth-space-3xs) var(--eth-space-2xs);
    border-radius: var(--eth-radius-s);
    color: var(--eth-text-body);
    font-size: var(--eth-fs-small);
    font-weight: var(--eth-fw-medium);
    line-height: 1.5;
    text-decoration: none;
    transition: color 200ms ease, background-color 200ms ease, padding-left 260ms var(--eth-premium-ease);
}

.eth-article-widget li a:hover,
.eth-product-widget li a:hover,
.eth-widget li a:hover,
.eth-article-widget li.current-menu-item > a,
.eth-product-widget li.current-menu-item > a,
.eth-widget li.current-menu-item > a {
    color: var(--eth-primary);
    background: color-mix(in srgb, var(--eth-primary) 7%, transparent);
    padding-left: var(--eth-space-xs);
}

/* 分类/标签云：小胶囊 */
.eth-article-widget .tagcloud,
.eth-product-widget .tagcloud,
.eth-widget .tagcloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--eth-space-3xs);
}
.eth-article-widget .tagcloud a,
.eth-product-widget .tagcloud a,
.eth-widget .tagcloud a {
    display: inline-flex;
    padding: 0.3rem var(--eth-space-2xs);
    border: 1px solid var(--eth-premium-border);
    border-radius: var(--eth-radius-full);
    font-size: var(--eth-fs-xs);
    font-weight: var(--eth-fw-semibold);
    color: var(--eth-text-muted);
    background: color-mix(in srgb, var(--eth-bg-surface) 90%, transparent);
    transition: color 200ms ease, border-color 200ms ease, background-color 200ms ease;
}
.eth-article-widget .tagcloud a:hover,
.eth-product-widget .tagcloud a:hover,
.eth-widget .tagcloud a:hover {
    color: #fff;
    background: var(--eth-primary);
    border-color: var(--eth-primary);
}

/* 表单/搜索 widget 输入框 */
:where(.eth-article-widget, .eth-product-widget, .eth-widget) :where(input[type="text"], input[type="search"], input[type="email"], select, textarea):not(.eth-search-form__input, .eth-search-form__type) {
    width: 100%;
    padding: var(--eth-space-2xs);
    border: 1px solid var(--eth-premium-border);
    border-radius: var(--eth-radius-s);
    background: var(--eth-bg-surface);
    color: var(--eth-text-title);
    font: inherit;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}
:where(.eth-article-widget, .eth-product-widget, .eth-widget) :where(input, select, textarea):not(.eth-search-form__input, .eth-search-form__type):focus {
    border-color: var(--eth-primary);
    outline: none;
    box-shadow: var(--eth-focus-ring);
}

/* --- 3. 产品侧边栏：图片右对齐 + 边距优化 --- */
.eth-product-widget img,
.eth-product-widget .wp-block-image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: var(--eth-space-2xs) 0 0 auto;   /* 右对齐 */
    border-radius: var(--eth-radius-s);
    border: 1px solid var(--eth-premium-border);
}

/* 侧边栏内的小图（缩略图/头像等）右对齐 */
.eth-product-widget :is(.wp-block-image, figure) img {
    margin-left: auto;
}

/* --- 4. 正文链接（文章/页面内容）--- */
.eth-article-entry a,
.eth-product-entry a,
.entry-content a {
   /*  color: var(--eth-link); */
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 0 1px;
    transition: color 220ms ease, background-size 320ms var(--eth-premium-ease);
}
.eth-article-entry a:hover,
.eth-product-entry a:hover{
    color: var(--eth-primary);
    background-size: 100% 1px;
}
/* 正文内的按钮/图片链接不去下划线 */
.eth-article-entry a:has(img),
.eth-product-entry a:has(img),
.entry-content a:has(img) {
    background-image: none;
}

/* --- 5. 响应式 --- */
@media (max-width: 992px) {
    .eth-article-content__sidebar,
    .eth-product-sidebar {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: var(--eth-space-xs);
    }
}

/* ==========================================================================
   6. Sidebar collapsible nav (1.3.10: migrated from category.css)
   Multi-level sidebar menu expand/collapse, applied to category/search (.eth-loop-layout__sidebar),
   product (.eth-product-sidebar) and article (.eth-article-content__sidebar) sidebars.
   ========================================================================== */
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible > ul.children,
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible > ul.sub-menu {
    display: none;
    margin-top: var(--eth-space-2xs);
    padding-left: var(--eth-space-s);
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible.eth-open > ul.children,
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible.eth-open > ul.sub-menu {
    display: block;
}

/* 独立展开按钮：行内右侧，点击展开/收起子菜单。
   1.2.11 修正：按钮插入 a 之后（非 li 末尾），子菜单展开时不被挤到底部。 */
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible .eth-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    margin-left: var(--eth-space-3xs);   /* 与文字拉开间距 */
    padding: 0;
    border: 1px solid var(--eth-border);
    border-radius: var(--eth-radius-xs);
    background: var(--eth-bg-surface);
    color: var(--eth-text-muted);
    cursor: pointer;
    vertical-align: middle;
    transition: transform var(--eth-transition-s), background var(--eth-transition-s), color var(--eth-transition-s);
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible .eth-sidebar-toggle svg {
    width: 0.85rem;
    height: 0.85rem;
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible .eth-sidebar-toggle:hover {
    background: var(--eth-primary-10);
    color: var(--eth-primary);
    border-color: var(--eth-primary-40);
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible .eth-sidebar-toggle--open {
    transform: rotate(180deg);
    background: var(--eth-primary-10);
    color: var(--eth-primary);
    border-color: var(--eth-primary-40);
}

/* 0.7.5：折叠项 li 横向排布，链接占左侧、按钮靠右 */
/* 0.8.4：加 flex-wrap:wrap，子菜单 flex-basis:100% 独占一行，
   避免展开后子菜单被 flex 行挤压导致竖向排列+溢出 */
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible > a {
    flex: 1;
    display: block;
    min-width: 0;
}
/* 0.8.4：子菜单独占一行、完整宽度，保留缩进层级（支持多级嵌套） */
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible > ul.children,
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-collapsible > ul.sub-menu {
    flex-basis: 100%;
    width: 100%;
    padding-left: var(--eth-space-s);
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li {
    padding: var(--eth-space-3xs) 0;
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li.eth-collapsible > ul.children li,
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li.eth-collapsible > ul.sub-menu li {
    padding: var(--eth-space-3xs) 0;
}

/* 1.3：收紧侧边栏菜单间距——归零 category.css 的 margin-bottom（与 polish 的
   margin-top 叠加导致过空），统一用 0.25rem 控制相邻项间距；链接内边距收紧。 */
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li {
    margin-bottom: 0;
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li + li {
    margin-top: 0.25rem;
}
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li a,
:is(.eth-loop-layout__sidebar, .eth-product-sidebar, .eth-article-content__sidebar) .eth-widget li > a {
    padding: 0.3rem var(--eth-space-2xs);
}
