/* 兰亭序 · 多版本逐字对比
 *
 * 双主题：
 *   [data-theme="dark"]  夜帖古卷
 *   [data-theme="light"] 兰亭春色
 *
 * 布局：两页共享，响应式断点 768px
 */

/* ============================================
   主题变量
   ============================================ */

[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-elevated: #2a2520;
  --text: #c8b88a;
  --text-secondary: #999;
  --accent: #7a9e7e;
  --accent-dim: rgba(122, 158, 126, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --panel-bg: #222;
  --char-bg: #2a2520;
  --char-active: #3a3228;
  --img-border: transparent;
  --scrollbar-thumb: #555;
  --missing-bg: #333;
  --missing-text: #666;
}

[data-theme="light"] {
  --bg: #f0ebe3;
  --bg-elevated: rgba(255, 255, 255, 0.6);
  --text: #4a4540;
  --text-secondary: #777;
  --accent: #6b8e6b;
  --accent-dim: rgba(107, 142, 107, 0.12);
  --border: rgba(0, 0, 0, 0.08);
  --panel-bg: #faf7f2;
  --char-bg: #e8e4dd;
  --char-active: #d8d0c4;
  --img-border: rgba(0, 0, 0, 0.08);
  --scrollbar-thumb: #c0b8a8;
  --missing-bg: #e0dbd2;
  --missing-text: #aaa;
}

/* ============================================
   基础重置
   ============================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  font-feature-settings: "palt", "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow-wrap: break-word;
  overflow-x: hidden;
  transition: background 0.15s ease, color 0.15s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ============================================
   顶栏
   ============================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px clamp(20px, 5vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__title {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.topbar__theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.15s ease;
}
.topbar__theme-btn:hover {
  border-color: var(--accent);
}

/* 主题图标：dark 时显示 ☀，light 时显示 🌙 */
[data-theme="dark"] .topbar__theme-icon::before { content: "☀"; }
[data-theme="light"] .topbar__theme-icon::before { content: "🌙"; }

/* ============================================
   着陆页
   ============================================ */

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(48px, 8vw, 96px) clamp(20px, 5vw, 48px) 96px;
}

.landing-hero {
  text-align: center;
  margin-bottom: clamp(48px, 8vh, 96px);
}

.landing-hero__title {
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0 0 12px;
  line-height: 1.2;
}

.landing-hero__subtitle {
  font-size: clamp(14px, 1.8vw, 18px);
  color: var(--text-secondary);
  margin: 0 0 24px;
  letter-spacing: 0.2em;
}

.landing-hero__desc {
  font-size: clamp(15px, 1.8vw, 18px);
  line-height: 1.85;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  text-align: justify;
}

/* 版本卡片 */
.versions {
  margin-bottom: clamp(48px, 8vh, 96px);
}

.versions__heading {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  text-align: center;
  margin: 0 0 clamp(24px, 4vh, 48px);
  letter-spacing: 0.1em;
}

.versions__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(16px, 2.5vw, 24px);
}

.version-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(20px, 3vw, 32px);
  transition: border-color 0.15s ease;
}
.version-card:hover {
  border-color: var(--accent);
}

.version-card__name {
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 700;
  margin: 0 0 8px;
}

.version-card__attr {
  font-size: 14px;
  color: var(--accent);
  margin: 0 0 4px;
}

.version-card__loc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.version-card__note {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* CTA 按钮 */
.landing-cta {
  text-align: center;
}

.landing-cta__btn {
  display: inline-block;
  padding: 14px 48px;
  background: var(--accent);
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.15em;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.landing-cta__btn:hover {
  opacity: 0.85;
  text-decoration: none;
}

/* ============================================
   响应式 · 着陆页
   ============================================ */

@media (max-width: 768px) {
  .versions__grid {
    grid-template-columns: 1fr;
  }
}

/* 顶栏 · 返回链接 */
.topbar__back {
  font-size: clamp(14px, 1.6vw, 16px);
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.05em;
}
.topbar__back:hover {
  color: var(--accent);
}

.topbar__page-title {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
}

/* ============================================
   搜索栏
   ============================================ */

.lt-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px clamp(16px, 3vw, 24px);
  background: var(--char-bg);
  border-bottom: 1px solid var(--border);
}

.lt-search__input {
  width: 120px;
  padding: 5px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.15em;
  outline: none;
  transition: border-color 0.2s ease;
}
.lt-search__input:focus {
  border-bottom-color: var(--accent);
}
.lt-search__input::placeholder {
  color: var(--text-secondary);
  opacity: 0.4;
  letter-spacing: 0.15em;
}

.lt-search__count {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 48px;
  text-align: center;
  letter-spacing: 0.05em;
}

.lt-search__btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.lt-search__btn:hover:not(:disabled) {
  opacity: 1;
  color: var(--accent);
}
.lt-search__btn:disabled {
  opacity: 0.2;
  cursor: default;
}
.lt-search__btn--clear {
  font-size: 15px;
  padding: 2px 4px;
}

/* 搜索高亮 */
.lt-ch--match {
  background: var(--accent-dim);
  border-radius: 2px;
}

.lt-ch--current {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 2px;
}

/* ============================================
   卷轴区：竖排横滚
   ============================================ */

.lt-scroll {
  position: relative;
  background: var(--char-bg);
  padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 40px);
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  height: clamp(440px, 60vh, 640px);
  max-width: 100vw;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.lt-scroll::-webkit-scrollbar { height: 6px; }
.lt-scroll::-webkit-scrollbar-track { background: transparent; }
.lt-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* 一句一列 */
.lt-col {
  display: block;
  margin-left: clamp(8px, 1.4vw, 18px);
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.65;
  letter-spacing: 0.05em;
}

/* 可点击的字 */
.lt-ch {
  display: inline;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
  border-radius: 2px;
  padding: 4px 2px;
}
.lt-ch:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.lt-ch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lt-ch--active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 700;
}

/* 标点 */
.lt-pun {
  display: inline;
  color: var(--text-secondary);
}

/* ============================================
   对比面板
   ============================================ */

.lt-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  padding: 0;
  max-height: 35vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.2s ease-out;
}
.lt-panel--open {
  transform: translateY(0);
}

.lt-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(16px, 3vw, 24px);
  border-bottom: 1px solid var(--border);
}

.lt-panel__char {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 700;
}

.lt-panel__pos {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

.lt-panel__close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.lt-panel__close:hover {
  color: var(--text);
}

/* 版本并列网格 */
.lt-panel__grid {
  display: flex;
  gap: clamp(12px, 2vw, 24px);
  padding: clamp(12px, 2vw, 20px) clamp(16px, 3vw, 24px);
  overflow-x: auto;
  justify-content: center;
}

.lt-panel__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lt-panel__img-wrap {
  width: 120px;
  height: 120px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--char-bg);
  border: 1px solid var(--img-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lt-panel__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}

.lt-panel__img-wrap--missing {
  background: var(--missing-bg);
}

.lt-panel__missing {
  font-size: 24px;
  color: var(--missing-text);
}

.lt-panel__ver-name {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.1em;
}

/* ============================================
   响应式 · 对比页
   ============================================ */

@media (max-width: 768px) {
  .lt-scroll {
    height: 70vh;
    font-size: clamp(18px, 5vw, 24px);
  }

  .lt-panel {
    max-height: 45vh;
  }

  .lt-panel__img-wrap {
    width: 80px;
    height: 80px;
  }

  .lt-panel__grid {
    justify-content: flex-start;
  }
}

/* ============================================
   面板内说明
   ============================================ */

.lt-panel__footnote {
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-secondary);
  padding: 8px clamp(16px, 3vw, 24px) 12px;
  border-top: 1px solid var(--border);
}

.lt-panel__note-link {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-size: 12px;
}
.lt-panel__note-link:hover {
  text-decoration: underline;
}

.lt-panel__head-note-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-right: 8px;
}

.lt-panel__head-note {
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  opacity: 0.6;
  white-space: nowrap;
}
.lt-panel__head-note:hover {
  color: var(--accent);
  opacity: 1;
}

/* ============================================
   Lightbox
   ============================================ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lightbox--open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  padding: 4px 12px;
  line-height: 1;
}
.lightbox__close:hover {
  opacity: 0.7;
}

.lightbox__caption {
  color: #ccc;
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  letter-spacing: 0.1em;
}
