/**
 * [INPUT]: 依赖 index.html 的稳定语义结构与主题类名
 * [OUTPUT]: 对外提供下载页双主题、响应式布局与语言控制区的视觉样式
 * [POS]: 独立下载站的唯一样式层，保持中英文版本共享同一视觉系统
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */
:root {
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --ui-accent: #ff8a1f;
  --brand-orange: #ff7a1a;
  --download-surface: rgba(4, 12, 28, 0.52);
  --download-surface-strong: rgba(255, 255, 255, 0.08);
  --download-border: rgba(255, 255, 255, 0.18);
  --download-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  --download-glow: 0 0 42px rgba(255, 138, 31, 0.2);
  --secondary-button-bg: rgba(255, 255, 255, 0.035);
  --control-surface: rgba(3, 13, 34, 0.32);
  --control-border: rgba(255, 255, 255, 0.16);
  --control-active-surface: rgba(255, 138, 31, 0.16);
  --control-active-border: rgba(255, 138, 31, 0.42);
  --font-hero: "Instrument Serif", serif;
  --font-ui: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --pad: 3vw;
}

body.theme-light {
  --text-primary: #1a1614;
  --text-secondary: rgba(26, 22, 20, 0.6);
  --ui-accent: #ff7a1a;
  --download-surface: rgba(255, 250, 244, 0.72);
  --download-surface-strong: rgba(255, 255, 255, 0.62);
  --download-border: rgba(93, 34, 21, 0.18);
  --download-shadow: 0 28px 90px rgba(67, 20, 12, 0.18);
  --download-glow: 0 0 48px rgba(255, 122, 26, 0.2);
  --secondary-button-bg: rgba(26, 22, 20, 0.035);
  --control-surface: rgba(255, 250, 244, 0.42);
  --control-border: rgba(93, 34, 21, 0.16);
  --control-active-surface: rgba(255, 122, 26, 0.14);
  --control-active-border: rgba(185, 71, 24, 0.34);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  font-family: var(--font-ui);
  color: var(--text-primary);
  transition: color 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(143, 217, 182, 0.18), transparent 30%),
    linear-gradient(135deg, #050714 0%, #083465 50%, #0a7dcc 74%, #8fd9b6 100%);
}

body.theme-light #canvas-container {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.42), transparent 34%),
    linear-gradient(135deg, #f5f0e6 0%, #d97b56 58%, #8c2b19 100%);
}

#ui-layer {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  padding: var(--pad);
  pointer-events: none;
}

.interact {
  pointer-events: auto;
}

header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  mix-blend-mode: normal;
}

.logo {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

button,
.download-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: color 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
}

button:hover {
  color: var(--text-primary);
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 30px 1px 34px;
  align-items: center;
  min-height: 34px;
  padding: 3px;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 58%),
    var(--control-surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 26px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  transition:
    border-color 0.25s ease,
    background-color 0.25s ease,
    transform 0.2s ease;
}

.language-switch:hover {
  border-color: var(--control-active-border);
  transform: translateY(-1px);
}

.language-switch:active {
  transform: scale(0.97);
}

.language-switch:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 3px;
}

.language-option {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
  transition:
    color 0.25s ease,
    background-color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.language-option.is-active {
  border-color: var(--control-active-border);
  background: var(--control-active-surface);
  box-shadow: 0 0 18px rgba(255, 122, 26, 0.12);
  color: var(--text-primary);
}

.language-divider {
  width: 1px;
  height: 12px;
  background: var(--control-border);
}

.definition-block {
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  width: min(100%, 420px);
  max-width: 420px;
  border: 1px solid var(--download-border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09), transparent 38%),
    var(--download-surface);
  box-shadow:
    var(--download-shadow),
    var(--download-glow);
  padding: clamp(18px, 2vw, 24px);
  font-size: 0.82rem;
  line-height: 1.45;
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  position: relative;
  overflow: hidden;
}

.definition-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-orange), transparent 64%);
}

.def-word {
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.05;
  margin-bottom: 0.45rem;
  color: var(--text-primary);
}

.def-meta {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.def-phonetic {
  font-style: italic;
  color: var(--text-primary);
  opacity: 0.82;
}

.def-text {
  color: var(--text-primary);
  opacity: 0.9;
  max-width: 34rem;
}

.hero {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
}

h1 {
  font-family: var(--font-hero);
  font-size: clamp(4.6rem, 10.5vw, 12.5rem);
  font-weight: 400;
  line-height: 0.78;
  letter-spacing: 0;
  margin-bottom: 1.1rem;
  transform: translateX(-1vw);
}

.brand-word {
  display: block;
}

.brand-word {
  line-height: 0.78;
}

.brand-x {
  display: inline-block;
  font-size: 1.02em;
  margin-left: 0.015em;
  color: var(--brand-orange);
  text-shadow: 0 0 18px rgba(255, 122, 26, 0.22);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  transform: translateX(5vw);
}

.footer-info {
  grid-column: 2;
  grid-row: 3;
  align-self: end;
  justify-self: end;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.footer-info a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-info a:hover {
  color: var(--text-primary);
}

.theme-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-indicator {
  width: 4px;
  height: 4px;
  background-color: var(--ui-accent);
  border-radius: 50%;
  transition: background-color 1.5s ease;
}

.download-actions {
  margin-top: 1.35rem;
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.download-actions .download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 46px;
  border-radius: 4px;
  padding: 0.8rem 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1;
  flex: 1 1 142px;
  white-space: nowrap;
  transition:
    transform 0.2s ease,
    filter 0.2s ease,
    opacity 0.2s ease;
}

.download-actions .download-btn.primary {
  background: var(--ui-accent);
  color: #03080a;
  border: none;
}

.download-actions .download-btn.secondary {
  background: var(--secondary-button-bg);
  color: var(--text-primary);
  border: 1px solid var(--text-secondary);
}

body.theme-light .download-actions .download-btn.primary {
  color: #fff8f4;
}

.download-actions .download-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.download-actions .download-btn:active {
  transform: scale(0.97);
}

.download-actions .download-btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.download-actions .download-btn.is-disabled:hover {
  filter: none;
  transform: none;
}

.download-requirements {
  margin-top: 1rem;
  border-top: 1px solid var(--download-border);
  padding-top: 0.9rem;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.35;
}

@media (max-width: 768px) {
  #ui-layer {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
  }

  h1 {
    transform: none;
  }

  .hero-sub {
    transform: none;
    margin-top: 1rem;
  }

  .footer-info {
    display: none;
  }

  .definition-block {
    margin-bottom: 2rem;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .controls {
    gap: 0.75rem;
    font-size: 0.68rem;
  }

  .language-switch {
    grid-template-columns: 28px 1px 31px;
    min-height: 32px;
  }

  .download-actions .download-btn {
    padding-inline: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
