/* ==========================================================================
   Drift — 设计系统
   深色优先 · 低饱和 · 柔和 · WCAG AA
   配色与字号严格遵循 req.txt「配色 + 字体规范」
   ========================================================================== */

:root {
  /* 色彩系统 */
  --bg: #12141C;
  --surface: #1A1D29;
  --surface-soft: #202433;
  --accent: #A8B4D9;
  --accent-hover: #B9C4E8;
  --accent-2: #B8A8D9;
  --text: #E9EBF2;
  --text-dim: #9AA3BD;
  --border: #2A2F42;
  --danger: #E88A8A;
  --success: #99C7B8;

  /* 圆角 / 阴影 / 间距 */
  --r-card: 14px;
  --r-btn: 20px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --sp: 8px;

  /* 动效：柔和不刺眼 */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 300ms;
  --t-mid: 500ms;
  --t-slow: 800ms;

  /* 字体 */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* 布局 */
  --footer-h: 92px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom));
}

/* 背景星空：固定在最底层，不接收事件 */
#bg-stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.75;
}

.noscript-note {
  padding: 24px;
  text-align: center;
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   顶部栏
   -------------------------------------------------------------------------- */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 0;
}

.topbar[hidden] { display: none; }

.topbar-left { display: flex; align-items: center; gap: 14px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 300;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.brand-mark { flex: none; opacity: 0.9; }
.brand-name { color: var(--accent); font-weight: 300; }
.brand:hover .brand-name { color: var(--accent-hover); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.icon-btn:hover,
.icon-btn:focus-visible {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}

/* --------------------------------------------------------------------------
   主内容区
   -------------------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  min-height: calc(100vh - var(--footer-h));
  padding: 48px 24px 72px;
}
.app:focus { outline: none; }

/* 视图淡入 */
.view {
  animation: view-in var(--t-mid) var(--ease) both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   排版
   -------------------------------------------------------------------------- */
h1, h2, h3, p { margin: 0; }

.h1 {
  font-weight: 300;
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.h2 {
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.body { font-size: 1rem; line-height: 1.6; }

.small {
  font-weight: 300;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.text-dim { color: var(--text-dim); }
.center { text-align: center; }

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  padding: 18px 28px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: var(--surface); }

.btn-block { width: 100%; }
.btn-sm { padding: 12px 20px; font-size: 0.9rem; border-radius: 16px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* --------------------------------------------------------------------------
   首页
   -------------------------------------------------------------------------- */
.home {
  min-height: calc(100vh - var(--footer-h) - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}
.home .home-sub {
  max-width: 30ch;
  margin: 0 auto;
}
.home .home-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 340px;
  margin-top: 32px;
}
.home .home-actions .btn { min-height: 62px; }
.home .home-hint { margin-top: 12px; }

/* --------------------------------------------------------------------------
   通用页面头
   -------------------------------------------------------------------------- */
.page-head { text-align: center; margin-bottom: 40px; }
.page-head .h2 { margin-bottom: 10px; }
.page-head .lead { max-width: 42ch; margin: 0 auto; }

/* --------------------------------------------------------------------------
   倾诉页
   -------------------------------------------------------------------------- */
.release-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  box-shadow: var(--shadow);
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.thought-input {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  padding: 18px;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  transition: border-color var(--t-fast) var(--ease);
}
.thought-input::placeholder { color: #5F6880; }
.thought-input:focus { outline: none; border-color: var(--accent); }

.counter {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-dim);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.counter.over { color: var(--danger); }

.field-group { margin-top: 28px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--accent-2);
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--accent-2); }
.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent-2);
}
.chip:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* 投递模式单选 */
.modes { display: flex; flex-direction: column; gap: 12px; }
.mode {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.mode:has(input:checked) { border-color: var(--accent); background: var(--surface-soft); }
.mode:hover { border-color: var(--accent); }
.mode input {
  margin-top: 4px;
  accent-color: var(--accent);
  width: 18px; height: 18px;
  flex: none;
}
.mode-body strong {
  display: block;
  font-weight: 500;
  font-size: 0.98rem;
  color: var(--text);
  margin-bottom: 3px;
}
.mode-body span {
  display: block;
  font-size: 0.85rem;
  font-weight: 300;
  line-height: 1.5;
  color: var(--text-dim);
}

.release-actions { margin-top: 32px; }

.block-note {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--danger);
  border-radius: var(--r-card);
  background: rgba(232, 138, 138, 0.07);
  color: var(--danger);
  font-size: 0.9rem;
  line-height: 1.6;
}
.block-note a { color: var(--danger); }

/* --------------------------------------------------------------------------
   释放动画页
   -------------------------------------------------------------------------- */
#release-canvas-wrap {
  position: relative;
  width: 100%;
  height: 44vh;
  min-height: 280px;
  margin: 0 auto;
}
#release-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.animation-copy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  pointer-events: none;
  padding: 0 24px;
}
.animation-copy .line {
  font-weight: 300;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  line-height: 1.45;
  opacity: 0;
}
.animation-copy .line.show { animation: gentle-in var(--t-slow) var(--ease) forwards; }
.animation-copy .line.delay-1 { animation-delay: 1.1s; }
@keyframes gentle-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animation-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 340px;
  margin: 8px auto 0;
}

/* --------------------------------------------------------------------------
   公共墙
   -------------------------------------------------------------------------- */
.wall-intro { max-width: 46ch; margin: 0 auto 28px; }

.wall-viewport {
  position: relative;
  height: 56vh;
  min-height: 340px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
}
.wall-track {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: wall-scroll 48s linear infinite;
}
.wall-viewport:hover .wall-track { animation-play-state: paused; }
@keyframes wall-scroll {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }
}
.wall-card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 400;
  color: var(--text);
}
.wall-card .mood {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--accent-2);
}

.wall-off {
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.wall-off .h2 { margin-bottom: 14px; }

/* --------------------------------------------------------------------------
   放松页
   -------------------------------------------------------------------------- */
.relax-section { margin-top: 44px; }
.relax-section .h2 { text-align: center; margin-bottom: 8px; }
.relax-section .section-sub { text-align: center; margin-bottom: 24px; }

/* 呼吸圆环 */
.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 12px 0 4px;
}
.breath-ring {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(168, 180, 217, 0.16), rgba(168, 180, 217, 0.03) 62%, transparent 70%);
  border: 1px solid rgba(168, 180, 217, 0.4);
  box-shadow: 0 0 60px rgba(168, 180, 217, 0.12), inset 0 0 40px rgba(168, 180, 217, 0.06);
  transform: scale(0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}
.breath-ring::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(168, 180, 217, 0.18);
}
.breath-label {
  font-weight: 300;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  z-index: 1;
}
.breath-count {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-height: 1.3em;
}
.breath-controls { display: flex; gap: 12px; }

/* 声景 */
.sound-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.sound-btn svg { width: 26px; height: 26px; }
.sound-btn:hover { border-color: var(--accent); color: var(--text); }
.sound-btn[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}
.sound-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.volume-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}
.volume-row label { font-size: 0.85rem; font-weight: 300; color: var(--text-dim); white-space: nowrap; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* --------------------------------------------------------------------------
   隐私页 / 通用信息页
   -------------------------------------------------------------------------- */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 28px;
  line-height: 1.7;
}
.info-card h2 { margin-bottom: 16px; }
.info-card p { margin-bottom: 14px; }
.info-card a { color: var(--accent); }

/* --------------------------------------------------------------------------
   页脚
   -------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  z-index: 3;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 24px calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--border);
}
.footer-disclaimer {
  font-weight: 300;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 60ch;
  margin: 0 auto 10px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 300;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.footer-links a {
  color: var(--danger);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.footer-links a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Toast 轻提示
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 16px);
  transform: translate(-50%, 20px);
  z-index: 50;
  padding: 12px 22px;
  font-size: 0.9rem;
  color: var(--bg);
  background: var(--success);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: var(--bg); }

/* --------------------------------------------------------------------------
   分享弹窗
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 9, 14, 0.72);
  backdrop-filter: blur(4px);
  animation: view-in var(--t-fast) var(--ease) both;
}
.modal {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  text-align: center;
}
.modal .h2 { margin-bottom: 10px; }
.modal .btn { margin-top: 22px; }

/* --------------------------------------------------------------------------
   响应式 & 无障碍
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .app { padding: 32px 20px 64px; }
  .topbar { padding: 16px 20px 0; }
  .site-footer { padding-left: 20px; padding-right: 20px; }
  .sound-grid { gap: 8px; }
  .sound-btn { padding: 16px 4px; font-size: 0.8rem; }
}

@media (max-height: 640px) {
  .home { gap: 12px; }
  .home .home-actions { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .wall-track { animation: none; }
}
