/* 现代化主题系统 - 使用 CSS 变量 + 媒体查询 */

:root {
  /* 声明支持的颜色方案 */
  color-scheme: light dark;

  /* 全局变量 */
  --transition-duration: 0.3s;

  /* 亮色模式默认 */
  --primary: #4285f4;
  --primary-rgb: 66 133 244;
  --primary-light: #4285f433;
  --primary-dark: #3367d6;

  --secondary: #ea580c;
  --secondary-rgb: 234 88 12;
  --secondary-light: #ea580c33;

  --bg: #f3f4f6;
  --bg-rgb: 243 244 246;
  --bg-secondary: #e5e7eb;
  --bg-tertiary: #d1d5db;
  --terminal-bg: #ffffff;

  --text: #1a1a1a;
  --text-rgb: 26 26 26;
  --text-secondary: #9ca3af;
  --text-tertiary: #cbd5e1;
  --terminal-text: #1a1a1a;
  --title-color: #1a1a1a;
  --button-text: #1a1a1a;

  --border-color: #e5e7eb;
  --border-color-rgb: 229 231 235;
  --terminal-border: #e5e7eb;

  --tag-bg: #f3f4f6;
  --tag-text: #1a1a1a;

  --header-bg: #f9fafb;
  --code-bg: #f3f4f6;

  /* 终端窗口控制按钮 */
  --btn-close: #ff5f56;
  --btn-minimize: #ffbd2e;
  --btn-expand: #27c93f;

  /* 状态颜色 */
  --success: #10b981;
  --success-rgb: 16 185 129;
  --success-light: #d1fae5;
  --success-dark: #065f46;

  --warning: #f59e0b;
  --warning-rgb: 245 158 11;
  --warning-light: #fef3c7;
  --warning-dark: #92400e;

  --danger: #ef4444;
  --danger-rgb: 239 68 68;
  --danger-light: #fee2e2;
  --danger-dark: #991b1b;

  --gray-light: #f3f4f6;
  --gray-dark: #374151;

  /* 全局样式变量 */
  --border-radius: 0.5rem;
  --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #00ff9d;
    --primary-rgb: 0 255 157;
    --primary-light: #00ff9d33;
    --primary-dark: #00b8ff;

    --secondary: #00b8ff;
    --secondary-rgb: 0 184 255;
    --secondary-light: #00b8ff33;

    --bg: #0a0e17;
    --bg-rgb: 10 14 23;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --terminal-bg: #0d1117;

    --text: #e6e6e6;
    --text-rgb: 230 230 230;
    --text-secondary: #d1d5db;
    --text-tertiary: #6b7280;
    --terminal-text: #e6e6e6;
    --title-color: #ffffff;
    --button-text: #e6e6e6;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-rgb: 255 255 255;
    --terminal-border: rgba(255, 255, 255, 0.1);

    --tag-bg: #161b22;
    --tag-text: #e6e6e6;

    --header-bg: #161b22;
    --code-bg: #161b22;

    --success-light: #064e3b;
    --success-dark: #d1fae5;

    --warning-light: #78350f;
    --warning-dark: #fef3c7;

    --danger-light: #7f1d1d;
    --danger-dark: #fee2e2;

    --gray-light: #1f2937;
    --gray-dark: #e5e7eb;
  }
}

/* 手动暗色模式覆盖 - 使用 html.dark */
html.dark {
  --primary: #00ff9d;
  --primary-rgb: 0 255 157;
  --primary-light: #00ff9d33;
  --primary-dark: #00b8ff;

  --secondary: #00b8ff;
  --secondary-rgb: 0 184 255;
  --secondary-light: #00b8ff33;

  --bg: #0a0e17;
  --bg-rgb: 10 14 23;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --terminal-bg: #0d1117;

  --text: #e6e6e6;
  --text-rgb: 230 230 230;
  --text-secondary: #d1d5db;
  --text-tertiary: #6b7280;
  --terminal-text: #e6e6e6;
  --title-color: #ffffff;
  --button-text: #e6e6e6;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-color-rgb: 255 255 255;
  --terminal-border: rgba(255, 255, 255, 0.1);

  --tag-bg: #161b22;
  --tag-text: #e6e6e6;

  --header-bg: #161b22;
  --code-bg: #161b22;

  --success-light: #064e3b;
  --success-dark: #d1fae5;

  --warning-light: #78350f;
  --warning-dark: #fef3c7;

  --danger-light: #7f1d1d;
  --danger-dark: #fee2e2;

  --gray-light: #1f2937;
  --gray-dark: #e5e7eb;
}

/* 优化的平滑过渡 - 只应用到需要的元素 */
body,
button,
input,
select,
textarea,
a {
  transition: background-color var(--transition-duration) ease,
              color var(--transition-duration) ease,
              border-color var(--transition-duration) ease;
}

/* 主题切换按钮动画 */
.theme-toggle {
  transition: all 0.3s ease;
}

.theme-toggle i {
  transition: transform 0.3s ease;
}

.theme-toggle:hover i {
  transform: rotate(30deg);
}

.terminal-input {
  width: 100%;
  background-color: color-mix(in oklab, var(--terminal-bg) 84%, var(--bg-secondary)) !important;
  background-image:
    linear-gradient(to bottom, rgba(var(--primary-rgb), 0.04), rgba(var(--primary-rgb), 0.0));
  border: 1px solid rgba(var(--primary-rgb), 0.42) !important;
  outline: 1px solid rgba(var(--primary-rgb), 0.22);
  outline-offset: -1px;
  color: var(--text) !important;
  font-family: var(--font-mono);
  padding: 0.55rem 0.7rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  line-height: 1.25;
  letter-spacing: 0.01em;
  caret-color: var(--primary);
  appearance: none;
  display: block;
  box-shadow:
    inset 0 0 0 1px rgba(var(--primary-rgb), 0.16),
    inset 0 10px 20px rgba(0, 0, 0, 0.10),
    inset 0 0 26px rgba(var(--primary-rgb), 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.14);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .terminal-input {
    background-color: color-mix(in oklab, var(--bg-tertiary) 88%, var(--terminal-bg)) !important;
    background-image:
      linear-gradient(to bottom, rgba(var(--primary-rgb), 0.06), rgba(var(--primary-rgb), 0.0)),
      repeating-linear-gradient(
        to bottom,
        rgba(var(--primary-rgb), 0.06) 0px,
        rgba(var(--primary-rgb), 0.06) 1px,
        transparent 1px,
        transparent 6px
      );
    border: 1px solid rgba(var(--primary-rgb), 0.48) !important;
    outline: 1px solid rgba(var(--primary-rgb), 0.22);
    box-shadow:
      inset 0 0 0 1px rgba(var(--primary-rgb), 0.16),
      inset 0 10px 20px rgba(0, 0, 0, 0.32),
      inset 0 0 26px rgba(var(--primary-rgb), 0.12),
      0 0 0 1px rgba(0, 0, 0, 0.26);
  }
}

html.dark .terminal-input {
  background-color: color-mix(in oklab, var(--bg-tertiary) 88%, var(--terminal-bg)) !important;
  background-image:
    linear-gradient(to bottom, rgba(var(--primary-rgb), 0.06), rgba(var(--primary-rgb), 0.0)),
    repeating-linear-gradient(
      to bottom,
      rgba(var(--primary-rgb), 0.06) 0px,
      rgba(var(--primary-rgb), 0.06) 1px,
      transparent 1px,
      transparent 6px
    );
  border: 1px solid rgba(var(--primary-rgb), 0.48) !important;
  outline: 1px solid rgba(var(--primary-rgb), 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(var(--primary-rgb), 0.16),
    inset 0 10px 20px rgba(0, 0, 0, 0.32),
    inset 0 0 26px rgba(var(--primary-rgb), 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.26);
}

.terminal-input::placeholder {
  color: rgba(0, 0, 0, 0.45);
  letter-spacing: 0.02em;
}

@media (prefers-color-scheme: dark) {
  .terminal-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
  }
}

html.dark .terminal-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.terminal-input:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow:
    inset 0 0 0 1px rgba(var(--primary-rgb), 0.22),
    inset 0 0 26px rgba(var(--primary-rgb), 0.14),
    0 0 0 2px rgba(var(--primary-rgb), 0.22),
    0 0 28px rgba(var(--primary-rgb), 0.24);
}

.terminal-input.textarea {
  resize: vertical;
  min-height: 4.5rem;
}

/* Terminal Window Glow Effects */
.terminal-window {
  background-color: var(--terminal-bg);
  border-radius: 8px !important;
  border: 1px solid var(--primary) !important;
  box-shadow:
    0 0 8px rgba(var(--primary-rgb), 0.4),
    0 0 20px rgba(var(--primary-rgb), 0.2),
    0 10px 30px rgba(var(--primary-rgb), 0.2) !important;
  overflow: hidden;
  position: relative;
  animation: terminal-glow 4s ease-in-out infinite alternate !important;
}

@keyframes terminal-glow {
  0% {
    box-shadow:
      0 0 8px rgba(var(--primary-rgb), 0.4),
      0 0 20px rgba(var(--primary-rgb), 0.2),
      0 10px 30px rgba(var(--primary-rgb), 0.2);
  }
  100% {
    box-shadow:
      0 0 12px rgba(var(--primary-rgb), 0.5),
      0 0 25px rgba(var(--primary-rgb), 0.3),
      0 10px 30px rgba(var(--primary-rgb), 0.2);
  }
}

/* Dark mode glow adjustments */
@media (prefers-color-scheme: dark) {
  .terminal-window {
    animation: terminal-glow-dark 4s ease-in-out infinite alternate !important;
  }

  @keyframes terminal-glow-dark {
    0% {
      box-shadow:
        0 0 8px rgba(var(--primary-rgb), 0.3),
        0 0 20px rgba(var(--primary-rgb), 0.15),
        0 10px 40px rgba(var(--primary-rgb), 0.1);
      border-color: rgba(var(--primary-rgb), 0.5) !important;
    }
    100% {
      box-shadow:
        0 0 15px rgba(var(--primary-rgb), 0.5),
        0 0 30px rgba(var(--primary-rgb), 0.25),
        0 10px 50px rgba(var(--primary-rgb), 0.15);
      border-color: rgba(var(--primary-rgb), 0.8) !important;
    }
  }
}

html.dark .terminal-window {
  animation: terminal-glow-dark 4s ease-in-out infinite alternate !important;
}

/* Terminal Header */
.terminal-header {
  border-bottom: 1px solid var(--primary) !important;
  box-shadow: 0 1px 5px rgba(var(--primary-rgb), 0.2) !important;
}

/* Glow Text Effect */
.glow-text {
  text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

/* Post Card Hover Effects */
.post-card {
  position: relative;
  transition: all 0.3s ease;
}

.post-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
  background-color: var(--post-border-color, var(--primary));
}

.post-card:hover {
  transform: translateX(8px);
}

.post-card:hover::before {
  opacity: 1;
}

/* Cursor Blink Animation */
.cursor {
  display: inline-block;
  width: 10px;
  height: 18px;
  background-color: var(--primary);
  animation: blink 1s infinite;
  vertical-align: middle;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ASCII Art Styling */
.ascii-art {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.2;
  color: var(--primary);
  white-space: pre;
  margin: 0;
  padding: 0;
  text-align: left;
  letter-spacing: 0;
  overflow-x: auto;
}

@media (max-width: 640px) {
  .ascii-art {
    font-size: 0.625rem;
  }
}

/* Link Hover Effects */
a {
  transition: all 0.3s ease;
}

/* Button Hover Glow */
button:hover,
a:hover {
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.3);
}
