/**
 * ============================================================
 *  Global Styles — Agent Dashboard
 * ============================================================
 */

@import './variables/tokens.css';
@import './skin.css';
@import './components/tradewind.css';
@import './components/tradewind-panels.css';
@import './components/markdown.css';

/* ─── Fonts ─────────────────────────────────────────────── */
/* Orbitron — 本地字体，仅用于徽标。变量字体单文件覆盖 700-900 字重 */
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/fonts/orbitron.woff2') format('woff2');
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  overflow: hidden;
  position: relative;
}

/* 环境光晕 — 仅顶部主光（随皮肤氛围色变化）。
 * 右下点缀与底中辅光已删除：背景留白，便于上层 UI / 自定义底纹
 * 主导氛围。 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 140% 80% at 10% 15%, var(--ambient-glow-1) 0%, transparent 60%);
}

/* 底纹层 — 支持模糊和混合模式 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--texture-opacity);
  background-image: var(--texture);
  background-repeat: var(--texture-repeat, repeat);
  background-size: var(--texture-size, auto);
  background-position: center;
  filter: blur(var(--texture-blur));
  mix-blend-mode: var(--texture-blend);
  transition: opacity var(--duration-slow) var(--ease-out-expo);
}

#root {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-bg-elevated);
  border-radius: var(--border-radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ─── Selection ─────────────────────────────────────────── */
::selection {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

/* ─── Utility ───────────────────────────────────────────── */
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }
.text-mono      { font-family: var(--font-mono); }
.text-truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 统一的「+」图标按钮（季风/对流/气旋/潮汐等各功能区共用）。
 * 中性配色——不跟随主色；hover 动效取自对流原 .conv__new-btn 的手感：放大 + 过渡。 */
.icon-add-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-out-expo);
}
.icon-add-btn:hover {
  border-color: var(--border-color-hover);
  color: var(--color-text-primary);
  background: var(--color-bg-elevated);
  transform: scale(1.08);
}
.icon-add-btn:active {
  transform: scale(0.94);
}
/* 紧凑尺寸（侧栏小标题旁的 +，如气旋/潮汐） */
.icon-add-btn--sm {
  width: 24px;
  height: 24px;
}

/* ─── Entrance Animations ───────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

.animate-in {
  animation: fadeInUp 0.3s var(--ease-out-expo) both;
}

.animate-in--fast {
  animation: fadeIn 0.15s var(--ease-out-expo) both;
}

/* 页面切换过渡 — 通过 JS 在 page 变化时重新挂上 .page-panel--enter 触发 */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-panel--enter {
  animation: pageEnter var(--duration-normal) var(--ease-out-expo) both;
}

/* stagger 辅助 — 每项延时 40ms */
.stagger > * { animation: fadeInUp 0.3s var(--ease-out-expo) both; }
.stagger > *:nth-child(1)  { animation-delay: 0ms; }
.stagger > *:nth-child(2)  { animation-delay: 40ms; }
.stagger > *:nth-child(3)  { animation-delay: 80ms; }
.stagger > *:nth-child(4)  { animation-delay: 120ms; }
.stagger > *:nth-child(5)  { animation-delay: 160ms; }
.stagger > *:nth-child(6)  { animation-delay: 200ms; }
.stagger > *:nth-child(7)  { animation-delay: 240ms; }
.stagger > *:nth-child(8)  { animation-delay: 280ms; }
.stagger > *:nth-child(9)  { animation-delay: 320ms; }
.stagger > *:nth-child(10) { animation-delay: 360ms; }

/* ─── Focus ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

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