/* ============================
   QIWI THEME - ENHANCED FEATURES
   浮动导航栏 + 背景图片 + 左右布局头图
   ============================ */

/* ===== 全局背景图片功能 ===== */
body.has-background {
  position: relative;
  overflow-x: hidden;
}

.global-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  transition: opacity 0.5s ease;
}

.global-background::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, var(--bg-mask-opacity, 0.5));
  z-index: 1;
}

/* 背景图片遮罩变量 */
:root {
  --bg-mask-opacity: 0.5;
}

/* 有背景图时调整主要内容区域 */
body.has-background .site-main,
body.has-background .site-header,
body.has-background .site-footer {
  position: relative;
  z-index: 1;
}

/* ===== 浮动导航栏 ===== */
.floating-nav {
  position: fixed;
  top: -80px;
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.floating-nav.show {
  top: 0;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.floating-nav .nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  height: 100%;
}

.floating-nav .nav-brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.floating-nav .nav-brand:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.floating-nav .nav-links {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.floating-nav .nav-links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
  position: relative;
}

.floating-nav .nav-links a:hover,
.floating-nav .nav-links a.current {
  color: var(--color-accent);
  background-color: rgba(217, 159, 0, 0.1);
  transform: translateY(-1px);
  text-decoration: none;
}

.floating-nav .nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: all 0.2s ease;
  transform: translateX(-50%);
}

.floating-nav .nav-links a:hover::after,
.floating-nav .nav-links a.current::after {
  width: 80%;
}

.floating-nav .nav-search {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xs);
  transition: all 0.2s ease;
}

.floating-nav .nav-search:focus-within {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(217, 159, 0, 0.2);
}

.floating-nav .nav-search input {
  background: none;
  border: none;
  color: var(--color-text-primary);
  padding: 4px var(--spacing-sm);
  font-size: var(--font-size-sm);
  width: 150px;
  transition: width 0.2s ease;
}

.floating-nav .nav-search input::placeholder {
  color: var(--color-text-muted);
}

.floating-nav .nav-search input:focus {
  outline: none;
  width: 200px;
}

.floating-nav .nav-search button {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--border-radius-sm);
  transition: color 0.2s ease;
}

.floating-nav .nav-search button:hover {
  color: var(--color-accent);
}

/* ===== 左右布局头图样式 ===== */
.post-card.layout-side {
  display: flex;
  align-items: stretch;
  gap: var(--spacing-lg);
  min-height: 180px;
}

.post-card.layout-side .post-thumbnail {
  flex: 0 0 280px;
  width: 280px;
  margin-bottom: 0;
  align-self: stretch;
}

.post-card.layout-side .post-thumbnail img {
  height: 100%;
  min-height: 180px;
  width: 100%;
  object-fit: cover;
}

.post-card.layout-side .post-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}

.post-card.layout-side .post-preview-header {
  margin-bottom: var(--spacing-sm);
}

.post-card.layout-side .post-title {
  font-size: 1.3rem;
  line-height: 1.4;
  margin-bottom: var(--spacing-sm);
}

.post-card.layout-side .post-meta {
  margin-bottom: var(--spacing-sm);
  gap: var(--spacing-sm);
}

.post-card.layout-side .post-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.6;
  margin-bottom: var(--spacing-sm);
  flex-grow: 1;
}

/* 左右布局时的小优化 */
.post-card.layout-side .post-meta span {
  font-size: var(--font-size-xs);
}

.post-card.layout-side .post-meta svg {
  width: 12px;
  height: 12px;
}

/* ===== 响应式设计 ===== */

/* 平板端 */
@media (max-width: 1024px) {
  .floating-nav .nav-search input {
    width: 120px;
  }
  
  .floating-nav .nav-search input:focus {
    width: 160px;
  }
  
  .post-card.layout-side .post-thumbnail {
    flex: 0 0 240px;
    width: 240px;
  }
}

@media (max-width: 768px) {
  /* 浮动导航栏移动端适配 */
  .floating-nav {
    height: 50px;
  }
  
  .floating-nav .nav-content {
    padding: 0 var(--spacing-sm);
  }
  
  .floating-nav .nav-brand {
    font-size: var(--font-size-sm);
  }
  
  .floating-nav .nav-links {
    gap: var(--spacing-sm);
  }
  
  .floating-nav .nav-links a {
    font-size: var(--font-size-xs);
    padding: 4px var(--spacing-xs);
  }
  
  .floating-nav .nav-search {
    display: none; /* 移动端隐藏搜索框 */
  }
  
  /* 左右布局改为上下布局 */
  .post-card.layout-side {
    flex-direction: column;
    min-height: auto;
  }
  
  .post-card.layout-side .post-thumbnail {
    flex: none;
    width: 100%;
    margin-bottom: var(--spacing-md);
  }
  
  .post-card.layout-side .post-thumbnail img {
    height: 160px;
    min-height: 160px;
  }
  
  .post-card.layout-side .post-content-wrapper {
    min-height: auto;
  }
  
  .post-card.layout-side .post-excerpt {
    -webkit-line-clamp: 2;
  }
}

@media (max-width: 480px) {
  .floating-nav .nav-links {
    gap: 8px;
  }
  
  .floating-nav .nav-links a {
    padding: 2px 4px;
  }
  
  .post-card.layout-side .post-thumbnail img {
    height: 140px;
    min-height: 140px;
  }
  
  .post-card.layout-side .post-title {
    font-size: 1.1rem;
  }
}

/* ===== 浮动导航栏显示逻辑相关样式 ===== */
.nav-trigger {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200px;
  pointer-events: none;
  z-index: -1;
}

/* ===== 加载动画 ===== */
.floating-nav .loading {
  opacity: 0.6;
}

/* ===== 增强的视觉效果 ===== */
.post-card.layout-side:hover .post-thumbnail img {
  transform: scale(1.05);
}

.post-card.layout-side .post-thumbnail {
  overflow: hidden;
  border-radius: var(--border-radius-md);
}

/* ===== 辅助功能支持 ===== */
@media (prefers-reduced-motion: reduce) {
  .floating-nav,
  .floating-nav.show,
  .post-card.layout-side .post-thumbnail img,
  .global-background {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== 高对比度模式 ===== */
@media (prefers-contrast: high) {
  .floating-nav {
    background: rgba(0, 0, 0, 0.98);
    border-bottom: 2px solid var(--color-accent);
  }
  
  .floating-nav .nav-search {
    border-color: var(--color-text-secondary);
  }
}

/* ===== 暗色主题优化 ===== */
@media (prefers-color-scheme: dark) {
  .floating-nav {
    background: rgba(10, 10, 10, 0.98);
  }
  
  .global-background::after {
    background-color: rgba(0, 0, 0, calc(var(--bg-mask-opacity) + 0.1));
  }
}

/* ===== 打印样式 ===== */
@media print {
  .floating-nav,
  .global-background {
    display: none !important;
  }
  
  .post-card.layout-side {
    flex-direction: column;
  }
  
  .post-card.layout-side .post-thumbnail {
    width: 100%;
    max-height: 200px;
  }
}

/* ===== 超大屏幕优化 ===== */
@media (min-width: 1440px) {
  .post-card.layout-side .post-thumbnail {
    /* flex: 0 0 320px; */
    /* width: 320px; */
  }
  
  .floating-nav .nav-search input {
    width: 180px;
  }
  
  .floating-nav .nav-search input:focus {
    width: 240px;
  }
}

/* ===== 浮动导航栏激活时的布局调整 ===== */
body.floating-nav-active .sidebar {
  top: calc(var(--spacing-lg) + 60px); /* 原来的top值 + 浮动导航栏高度 */
}

/* 移动端适配 */
@media (max-width: 768px) {
  body.floating-nav-active .sidebar {
    top: calc(var(--spacing-lg) + 50px); /* 移动端浮动导航栏高度是50px */
  }
}