/* ========================================
   BirdChain 多语言排版支持样式
   支持LTR和RTL语言，自适应不同文本长度
   ======================================== */

/* ----------------------------------------
   基础多语言支持
   ---------------------------------------- */

/* 确保文字方向正确应用 */
[dir="rtl"] {
  text-align: right;
}

[dir="ltr"] {
  text-align: left;
}

/* 但某些元素保持居中 */
[dir="rtl"] .text-center,
[dir="ltr"] .text-center {
  text-align: center;
}

/* ----------------------------------------
   RTL 语言特定样式
   ---------------------------------------- */

.rtl .bc-header {
  direction: rtl;
}

.rtl .bc-footer {
  direction: rtl;
}

.rtl .bc-nav {
  flex-direction: row-reverse;
}

.rtl .bc-header-actions {
  flex-direction: row-reverse;
}

/* 语言下拉菜单在RTL中从左侧展开 */
.rtl .bc-lang-menu {
  right: auto;
  left: 0;
}

/* 调整RTL模式下的图标位置 */
.rtl .bc-lang-item {
  flex-direction: row-reverse;
}

.rtl .bc-lang-flag {
  margin-left: 12px;
  margin-right: 0;
}

/* 移动端菜单RTL支持 */
.rtl .bc-mobile-menu {
  right: -100%;
  left: auto;
}

.rtl .bc-mobile-menu.open {
  right: 0;
}

.rtl .bc-mobile-overlay {
  right: 0;
  left: auto;
}

/* 面包屑导航RTL */
.rtl .bc-breadcrumb {
  flex-direction: row-reverse;
}

.rtl .bc-breadcrumb .sep {
  transform: scaleX(-1);
}

/* ----------------------------------------
   自适应文本长度 - 导航和按钮
   ---------------------------------------- */

/* 导航项自适应宽度 */
.bc-nav-item {
  white-space: nowrap;
  min-width: max-content;
  padding: 8px 14px;
}

/* 为长文本添加灵活的间距 */
.bc-nav {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 按钮自适应文本长度 */
.btn {
  padding: 10px 18px;
  white-space: nowrap;
  min-width: max-content;
}

.btn-sm {
  padding: 6px 12px;
}

.btn-lg {
  padding: 14px 28px;
}

/* ----------------------------------------
   弹性布局容器
   ---------------------------------------- */

/* 使用Flexbox确保内容自适应 */
.flex-wrap-responsive {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* 网格布局自适应 */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

/* ----------------------------------------
   文本处理
   ---------------------------------------- */

/* 防止文本溢出，添加省略号 */
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 允许文本换行但限制行数 */
.text-limit-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  max-height: 2.8em;
}

.text-limit-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  max-height: 4.2em;
}

/* 允许文本正常换行 */
.text-break {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* ----------------------------------------
   多语言字体优化
   ---------------------------------------- */

/* 为不同语言优化字体渲染 */
html[lang="zh"] body,
html[lang="zh-CN"] body,
html[lang="zh-TW"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

html[lang="ja"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic Pro", "Yu Gothic", sans-serif;
}

html[lang="ko"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
}

html[lang="ar"] body,
html[lang="he"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Tahoma", "Arial", sans-serif;
}

/* ----------------------------------------
   响应式间距调整
   ---------------------------------------- */

/* 根据屏幕尺寸调整内边距 */
.responsive-padding {
  padding: clamp(10px, 2vw, 20px);
}

/* 导航在小屏幕下调整 */
@media (max-width: 1024px) {
  .bc-nav {
    gap: 4px;
  }
  
  .bc-nav-item {
    padding: 6px 10px;
    font-size: 0.9rem;
  }
}

@media (max-width: 768px) {
  /* 移动端隐藏部分导航项或调整 */
  .hide-mobile {
    display: none !important;
  }
}

/* ----------------------------------------
   卡片和容器自适应
   ---------------------------------------- */

/* 卡片内容自适应 */
.bc-work-card,
.bc-product-card,
.bc-creator-card {
  overflow: hidden;
}

/* 卡片标题自适应 */
.bc-work-card-title,
.bc-product-card-title {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* 元数据自适应 */
.bc-work-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ----------------------------------------
   语言菜单优化
   ---------------------------------------- */

.bc-lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px 0;
  margin-top: 4px;
  z-index: 1003;
  min-width: 180px;
  max-width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.bc-lang-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.bc-lang-dropdown:hover .bc-lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.bc-lang-item {
  padding: 12px 16px;
  gap: 10px;
  display: flex;
  align-items: center;
}

.bc-lang-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------
   页脚自适应
   ---------------------------------------- */

.bc-footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 24px;
}

.bc-footer-col h4 {
  margin-bottom: 12px;
  font-size: 1rem;
  white-space: nowrap;
}

.bc-footer-col a {
  display: block;
  padding: 6px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------
   搜索框和表单自适应
   ---------------------------------------- */

.bc-search-box {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.bc-search-box input {
  width: 100%;
  padding: 8px 14px;
}

/* 表单元素自适应 */
form [data-action="newsletter-form"] {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

form [data-action="newsletter-form"] input {
  flex: 1;
  min-width: 200px;
}

/* ----------------------------------------
   Toast 提示自适应
   ---------------------------------------- */

.bc-toast {
  max-width: 340px;
  word-wrap: break-word;
}

/* ----------------------------------------
   印刷样式优化
   ---------------------------------------- */

/* 改善行长可读性 */
.prose-content {
  max-width: 70ch;
}

/* 为长文本添加更好的行高 */
.long-text {
  line-height: 1.7;
  letter-spacing: 0.01em;
}

/* ----------------------------------------
   调试和开发辅助
   ---------------------------------------- */

/* 在开发时可以用来查看语言相关的类 */
.lang-debug [dir]::before {
  content: "dir=" attr(dir);
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 4px 8px;
  font-size: 12px;
  z-index: 99999;
  border-radius: 4px;
}

/* ========================================
   导航栏样式修复 - 防止重叠和溢出
   ======================================== */

/* Header主容器防止子元素溢出 */
.bc-header .container {
  overflow: visible;
  gap: 12px;
}

/* 导航容器自适应 */
.bc-nav {
  flex: 1;
  min-width: 0;
  overflow: visible;
  gap: 2px;
}

.bc-nav-item {
  padding: 6px 10px;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* "更多"下拉菜单定位，防止被右侧按钮遮挡 */
.bc-nav-item:last-child {
  position: relative;
}

.bc-nav-dropdown {
  z-index: 1002;
  min-width: 160px;
}

/* 修复"更多"下拉在右侧时被裁剪的问题 */
.bc-nav-item:last-child .bc-nav-dropdown {
  left: auto;
  right: 0;
}

/* 语言下拉菜单z-index确保在导航之上 */
.bc-lang-dropdown {
  position: relative;
  z-index: 1003;
}

/* Header actions不换行，保持在一行 */
.bc-header-actions {
  flex-shrink: 0;
  flex-wrap: nowrap;
}

/* 搜索框宽度自适应 */
.bc-search-box {
  min-width: 140px;
  max-width: 240px;
  width: auto;
}

/* 中等屏幕适配 */
@media (max-width: 1199px) {
  .bc-search-box {
    min-width: 100px;
    max-width: 180px;
  }
  .bc-nav-item {
    padding: 6px 8px;
    font-size: 0.82rem;
  }
  .bc-header .container {
    gap: 8px;
  }
}
