/**
 * 天和国学主题 — 主样式（对齐 version1 uni-app H5 视觉）
 */

:root {
  --primary-color: #007aff;
  --tianhe-bg: #f5f5f5;
  --tianhe-bg-card: #ffffff;
  --tianhe-text: #333333;
  --tianhe-text-muted: #999999;
  --tianhe-border: #e5e5e5;
  --tianhe-search-bg: #000000;
  --tianhe-search-input-bg: #e0e0e0;
  --tianhe-tab-line: #cccccc;
  --tianhe-category-orange: #ff9500;
  --tianhe-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tianhe-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --tianhe-bottom-nav-h: 50px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  font-family: var(--tianhe-font);
  font-size: 16px;
  color: var(--tianhe-text);
  background: #ffffff;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
}

/* ── App Shell ── */
.tianhe-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
  background: var(--tianhe-bg);
  position: relative;
}

/* ── Header / Search（version1 黑底顶栏） ── */
.tianhe-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
}

.tianhe-header__search-wrap {
  width: 100%;
  background: var(--tianhe-search-bg);
}

.tianhe-header__search-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 60px;
  padding: 2px 15px 0;
  box-sizing: border-box;
}

.tianhe-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 52px);
  display: flex;
  justify-content: center;
}

.tianhe-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.tianhe-search__input {
  width: 70%;
  max-width: 70%;
  height: 28px;
  padding: 2px 12px 0;
  border: none;
  border-radius: 14px;
  background: var(--tianhe-search-input-bg);
  color: #000000;
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
  outline: none;
}

.tianhe-search__input::placeholder {
  color: var(--tianhe-text-muted);
}

/* ── Language Switcher（保留，适配黑顶栏） ── */
.tianhe-lang-switch {
  flex: 0 0 auto;
  position: relative;
}

.tianhe-lang-switch__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 44px;
  height: 28px;
  padding: 0 6px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

.tianhe-lang-switch__toggle:hover,
.tianhe-lang-switch__toggle:focus-visible {
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}

.tianhe-lang-switch__icon {
  font-size: 15px;
  line-height: 1;
}

.tianhe-lang-switch__current {
  display: none;
}

.tianhe-lang-switch__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 110px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--tianhe-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.tianhe-lang-switch__menu[hidden] {
  display: none !important;
}

.tianhe-lang-switch__option {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--tianhe-text);
  text-decoration: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.tianhe-lang-switch__option:disabled {
  cursor: default;
  opacity: 1;
}

.tianhe-lang-switch__option:hover,
.tianhe-lang-switch__option:focus {
  background: #f0f0f0;
  color: var(--tianhe-text);
}

.tianhe-lang-switch__option.is-current {
  color: var(--primary-color);
  font-weight: 600;
}

/* ── Tabs Area ── */
.tianhe-tabs {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.tianhe-subtabs {
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  height: 42px;
  padding: 0 8px;
  align-items: center;
}

.tianhe-subtabs::-webkit-scrollbar {
  display: none;
}

.tianhe-subtabs__item {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: #666666;
  font-size: 14px;
  font-family: var(--tianhe-font);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s;
  position: relative;
  line-height: 42px;
}

.tianhe-subtabs__item.is-active {
  color: var(--primary-color);
  font-weight: 500;
}

.tianhe-subtabs__indicator {
  flex: 0 0 auto;
  height: 2px;
  background: #ffffff;
  position: relative;
}

.tianhe-subtabs__indicator::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 2px;
  width: 40px;
  background: var(--primary-color);
  transition: transform 0.25s ease, width 0.25s ease;
  transform: translateX(0);
}

.tianhe-subtabs__line {
  flex: 0 0 auto;
  height: 1px;
  background: var(--tianhe-tab-line);
}

/* ── Content Panels ── */
.tianhe-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--tianhe-bg);
}

.tianhe-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tianhe-panel.is-active {
  visibility: visible;
  opacity: 1;
  z-index: 1;
}

.tianhe-panel__scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tianhe-bottom-nav-h) + var(--tianhe-safe-bottom) + 8px);
}

/* ── Banner Carousel（version1 banner-swiper） ── */
.tianhe-banner {
  position: relative;
  margin: 10px 15px 0;
  border-radius: 20px;
  overflow: hidden;
  background: #eeeeee;
  height: clamp(160px, 45vw, 320px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.tianhe-banner__track {
  position: relative;
  width: 100%;
  height: 100%;
}

.tianhe-banner__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  cursor: pointer;
}

.tianhe-banner__slide.is-active {
  opacity: 1;
  z-index: 1;
}

.tianhe-banner__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tianhe-banner__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  font-size: 1.1rem;
}

.tianhe-banner__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: flex-end;
  padding: 0 16px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
}

.tianhe-banner__dots {
  position: absolute;
  bottom: 10px;
  right: 14px;
  display: flex;
  gap: 5px;
  z-index: 2;
}

.tianhe-banner__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: background 0.2s, transform 0.2s;
}

.tianhe-banner__dot.is-active {
  background: #ffffff;
  transform: scale(1.15);
}

/* ── Category Items（version1 category-item） ── */
.tianhe-categories {
  margin: 12px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tianhe-categories::-webkit-scrollbar {
  display: none;
}

.tianhe-categories__track {
  display: flex;
  gap: 8px;
  padding: 4px 15px;
}

.tianhe-category-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 80px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  outline: none;
}

.tianhe-category-chip__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tianhe-category-orange);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 6px;
}

.tianhe-panel[data-section-slug="sky-shanggu"] .tianhe-category-chip__icon {
  background: var(--tianhe-category-orange);
}

.tianhe-panel:not([data-section-slug="sky-shanggu"]) .tianhe-category-chip__icon {
  background: linear-gradient(135deg, #8a2be2 0%, #4b0082 100%);
}

.tianhe-category-chip__name {
  font-size: 12px;
  color: var(--tianhe-text);
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
}

/* ── Section Titles ── */
.tianhe-section {
  padding: 12px 15px 8px;
}

.tianhe-section__header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  width: 100%;
}

.tianhe-section__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--tianhe-text);
  padding: 0;
  border: none;
}

.tianhe-section__more {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tianhe-text);
  cursor: pointer;
  flex-shrink: 0;
}

.tianhe-section__more:active {
  opacity: 0.7;
}

/* ── Hot Grid（version1 双列卡片） ── */
.tianhe-hot-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 0;
}

.tianhe-hot-card {
  width: 48%;
  border: 1px solid var(--tianhe-border);
  background: var(--tianhe-bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: opacity 0.15s;
}

.tianhe-hot-card:active {
  opacity: 0.85;
}

.tianhe-hot-card__img,
.tianhe-hot-card__placeholder {
  width: 100%;
  height: clamp(100px, 28vw, 180px);
  object-fit: cover;
  display: block;
}

.tianhe-hot-card__placeholder {
  background: #eeeeee;
}

.tianhe-hot-card__title {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--tianhe-text);
  line-height: 1.35;
}

/* ── Content Grid（version1 content-grid） ── */
.tianhe-content-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 0;
}

.tianhe-content-grid.is-collapsed .tianhe-grid-card:nth-child(n + 5) {
  display: none;
}

.tianhe-grid-card {
  width: 48%;
  border: 1px solid var(--tianhe-border);
  background: var(--tianhe-bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: opacity 0.15s;
}

.tianhe-grid-card:active {
  opacity: 0.85;
}

.tianhe-grid-card__img,
.tianhe-grid-card__placeholder {
  width: 100%;
  height: clamp(100px, 28vw, 180px);
  object-fit: cover;
  display: block;
}

.tianhe-grid-card__placeholder {
  background: #eeeeee;
}

.tianhe-grid-card__title {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--tianhe-text);
  line-height: 1.35;
}

/* ── Post List ── */
.tianhe-post-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tianhe-post-item {
  display: block;
  padding: 12px 14px;
  background: var(--tianhe-bg-card);
  border-radius: 12px;
  border: 1px solid var(--tianhe-border);
  text-decoration: none;
  color: var(--tianhe-text);
}

.tianhe-post-item:active {
  background: #f9f9f9;
}

.tianhe-post-item__title {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 4px;
  line-height: 1.4;
}

.tianhe-post-item__excerpt {
  font-size: 13px;
  color: var(--tianhe-text-muted);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tianhe-post-list__loading,
.tianhe-post-list__empty {
  text-align: center;
  padding: 20px;
  color: var(--tianhe-text-muted);
  font-size: 14px;
}

/* ── Bottom Navigation（version1 uni-tabbar-bottom：fixed 贴底） ── */
.tianhe-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #ffffff;
  border-top: 1px solid var(--tianhe-border);
  padding-bottom: var(--tianhe-safe-bottom);
  z-index: 998;
  min-height: var(--tianhe-bottom-nav-h);
  box-sizing: border-box;
}

.tianhe-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 0 2px;
  border: none;
  background: transparent;
  color: #999999;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.2;
}

.tianhe-bottom-nav__item.is-active {
  color: var(--primary-color);
}

.tianhe-bottom-nav__icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tianhe-bottom-nav__img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.tianhe-bottom-nav__label {
  line-height: 1.2;
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── ICP Footer ── */
.tianhe-icp-footer {
  text-align: center;
  padding: 20px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #888888;
  background: transparent;
}

.tianhe-icp-footer__nav {
  margin: 0 0 4px;
}

.tianhe-icp-footer a {
  color: #888888;
  text-decoration: none;
}

.tianhe-icp-footer a:hover {
  text-decoration: underline;
}

.tianhe-icp-footer__sep {
  margin: 0 4px;
  opacity: 0.6;
}

/* ── Search Overlay ── */
.tianhe-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--tianhe-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tianhe-search-overlay[hidden] {
  display: none !important;
}

.tianhe-search-overlay__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  background: #ffffff;
  border-bottom: 1px solid var(--tianhe-border);
  color: var(--tianhe-text);
}

.tianhe-search-overlay__back {
  border: none;
  background: transparent;
  color: var(--primary-color);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.tianhe-search-overlay__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.tianhe-search-overlay__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 15px;
  padding-bottom: calc(20px + var(--tianhe-safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.tianhe-search-result {
  display: block;
  padding: 14px;
  margin-bottom: 8px;
  background: var(--tianhe-bg-card);
  border-radius: 12px;
  border: 1px solid var(--tianhe-border);
  text-decoration: none;
  color: var(--tianhe-text);
}

.tianhe-search-result:active {
  background: #f9f9f9;
}

.tianhe-search-result__title {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 4px;
}

.tianhe-search-result__desc {
  font-size: 13px;
  color: var(--tianhe-text-muted);
  margin: 0;
  line-height: 1.4;
}

/* ── Single Post Page ── */
.tianhe-single {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  background: var(--tianhe-bg);
}

.tianhe-single__header {
  margin-bottom: 16px;
}

.tianhe-single__back {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
}

.tianhe-single__back:hover {
  text-decoration: underline;
}

.tianhe-single__article {
  background: var(--tianhe-bg-card);
  border-radius: 12px;
  padding: 24px 20px;
  border: 1px solid var(--tianhe-border);
}

.tianhe-single__title {
  font-size: 1.5rem;
  line-height: 1.4;
  margin: 0 0 8px;
  color: var(--tianhe-text);
}

.tianhe-single__date {
  font-size: 13px;
  color: var(--tianhe-text-muted);
}

.tianhe-single__content {
  margin-top: 20px;
  line-height: 1.8;
  font-size: 16px;
}

.tianhe-single__content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.tianhe-single__content p {
  margin: 0 0 1em;
}

/* ── Fallback / No Data ── */
.tianhe-fallback {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.tianhe-no-data {
  text-align: center;
  padding: 40px 20px;
  color: var(--tianhe-text-muted);
}

/* ── Landscape ── */
@media (orientation: landscape) and (min-width: 568px) {
  .tianhe-hot-grid .tianhe-hot-card,
  .tianhe-content-grid .tianhe-grid-card {
    width: 23%;
  }
}

/* ── 启动页（首页内嵌，无服务端重定向） ── */
html.tianhe-splash-active,
html.tianhe-splash-active body {
  overflow: hidden;
}

.tianhe-splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.tianhe-splash-overlay[hidden] {
  display: none !important;
}

.tianhe-splash-overlay__text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: clamp(36px, 8vw, 60px);
  font-weight: 700;
  color: #333333;
  letter-spacing: 15px;
  opacity: 0;
  animation: tianhe-splash-fade-in 1s ease forwards;
  font-family: "STKaiti", "KaiTi", "楷体", serif;
}

@keyframes tianhe-splash-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
