/* ============================================================
   Shiro Core Design System — 自定义样式
   基于 Shiro Core Design Specification
   ============================================================ */

/* --- 2. CSS 自定义属性 (色彩系统) --- */
:root {
  --color-primary: #33a6b8;
  --color-accent: #33a6b8;
  --color-base-100: #ffffff;
  --color-base-content: #000000;
  --color-info: #007aff;
  --color-success: #34c759;
  --color-warning: #ff9500;
  --color-error: #ff3b30;
  --bg-opacity: rgba(255, 255, 255, 0.72);
  --color-border: rgba(24, 24, 27, 0.1);
  --noise-opacity: 0.04;
  --color-muted-500: #737373;

  --app-font-sans: 'Manrope', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Roboto, Helvetica, 'Hiragino Sans GB', sans-serif;
  --app-font-serif: 'Noto Serif SC', 'Noto Serif CJK SC', 'Source Han Serif SC', 'Source Han Serif', SongTi SC, SimSun, 'Hiragino Sans GB', serif;
  --app-font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code PL', Consolas, Monaco, monospace;
}

[data-theme="dark"] {
  --color-primary: #f596aa;
  --color-accent: #f596aa;
  --color-base-100: #1c1c1e;
  --color-base-content: #ffffff;
  --color-info: #0a84ff;
  --color-success: #30d158;
  --color-warning: #ff9f0a;
  --color-error: #ff453a;
  --bg-opacity: rgba(29, 29, 31, 0.72);
  --color-border: #3f3f46;
  --noise-opacity: 0.01;
  --color-muted-500: #525252;
}

/* --- View Transitions 主题切换过渡 --- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

[data-theme="dark"]::view-transition-old(root) {
  z-index: 1;
}
[data-theme="dark"]::view-transition-new(root) {
  z-index: 999;
}

::view-transition-old(root) {
  animation: turnOff 800ms ease-in-out forwards;
}
::view-transition-new(root) {
  animation: turnOn 800ms ease-in-out forwards;
}

@keyframes turnOff {
  0% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(100% 0 0 0); }
}
@keyframes turnOn {
  0% { clip-path: inset(0 0 100% 0); }
  100% { clip-path: inset(0 0 0 0); }
}

/* --- 1. 全局基础 --- */
html {
  font-size: 14px;
  line-height: 1.5;
  scroll-behavior: smooth;
}

body {
  font-family: var(--app-font-sans);
  background-color: var(--color-base-100);
  color: var(--color-base-content);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- 1.5 微噪纹理 --- */
html.noise::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- 5.1 按钮 --- */
.btn-primary {
  background-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  border: none;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}
.btn-primary:hover {
  filter: contrast(1.1);
}
.btn-primary:active {
  filter: contrast(1.25);
  transform: scale(0.95);
}
.btn-primary:disabled {
  background-color: rgba(51, 166, 184, 0.4);
  opacity: 0.8;
  cursor: not-allowed;
  filter: none;
  transform: none;
}
[data-theme="dark"] .btn-primary {
  color: #1c1c1e;
}
[data-theme="dark"] .btn-primary:disabled {
  background-color: rgba(245, 150, 170, 0.4);
}

.btn-secondary {
  border-radius: 9999px;
  background: var(--bg-opacity);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 0 0 1px rgba(24,24,27,0.05);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: box-shadow 200ms ease;
}
[data-theme="dark"] .btn-secondary {
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.1);
}
.btn-secondary:hover {
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 0 0 1px rgba(255,255,255,0.2);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background-color: var(--color-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 150ms ease;
}
.btn-icon:hover {
  opacity: 0.9;
}

/* --- 5.7 链接下划线动画 --- */
.link-underline {
  position: relative;
  color: var(--color-accent);
  text-decoration: none;
  background-image: linear-gradient(var(--color-accent), var(--color-accent));
  background-size: 0% 1.5px;
  background-repeat: no-repeat;
  background-position: left 1.2em;
  transition: background-size 500ms ease;
  text-underline-offset: 3px;
}
.link-underline:hover {
  background-size: 100% 1.5px;
  transition: background-size 250ms ease;
}

/* --- 5.8 引用块 --- */
blockquote.sh-blockquote {
  position: relative;
  border: 0;
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-opacity);
  border-radius: 0.5rem;
  font-style: italic;
}
blockquote.sh-blockquote::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  border-radius: 1em;
  background-color: var(--color-accent);
}

/* --- 5.9 毛玻璃层级 --- */
.glass-thick {
  background: rgba(153,153,153,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
[data-theme="dark"] .glass-thick,
.glass-thick[data-theme="dark"] {
  background: rgba(37,37,37,0.9);
}

.glass-default,
.glass {
  background: var(--bg-opacity);
  backdrop-filter: blur(17.5px);
  -webkit-backdrop-filter: blur(17.5px);
}

.glass-thin {
  background: rgba(166,166,166,0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}
[data-theme="dark"] .glass-thin {
  background: rgba(37,37,37,0.7);
}

/* --- 5.10 滚动条 --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-muted-500);
  border-radius: 0.75rem;
}
::-webkit-scrollbar-thumb:hover {
  background: oklch(from var(--color-muted-500) l c h / 0.8);
}

* {
  scrollbar-color: var(--color-muted-500) transparent;
  scrollbar-width: thin;
}

/* --- 卡片阴影 --- */
.card {
  border-radius: 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-base-100);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.card-hover:hover {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.08),
    0 6px 14px rgba(0,0,0,0.08);
}

/* --- 6.2 入场动画 --- */
@keyframes scale-in {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.animate-scale-in {
  animation: scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes fade-up {
  0% { transform: translateY(30px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.animate-fade-up {
  animation: fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
.animate-fade-in {
  animation: fade-in 0.4s ease both;
}

/* --- 6.3 装饰动效 --- */
@keyframes ping-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}
.animate-ping-pulse {
  animation: ping-pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes bounce-arrow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-25%); }
}
.animate-bounce-arrow {
  animation: bounce-arrow 2s ease-in-out infinite;
}

/* --- 6.1 Spring 模拟 (CSS 最佳逼近) --- */
.spring-bounce {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1.5);
}
.spring-soft {
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.spring-rebound {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.spring-micro {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- 主题切换器 --- */
.theme-switcher {
  display: inline-flex;
  gap: 2px;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  padding: 3px;
  position: relative;
}
.theme-switcher-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.2s ease;
  color: var(--color-base-content);
  opacity: 0.5;
}
.theme-switcher-btn.active {
  opacity: 1;
}
.theme-switcher-indicator {
  position: absolute;
  top: 3px;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background-color: var(--color-base-100);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: left 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 0;
}

/* --- 表单元素 --- */
.sh-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  outline: none;
  background: var(--color-base-100);
  border: 1px solid var(--color-border);
  color: var(--color-base-content);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.sh-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(from var(--color-accent) r g b / 0.15);
}
.sh-input::placeholder {
  color: var(--color-base-content);
  opacity: 0.35;
}

.sh-textarea {
  resize: vertical;
  min-height: 80px;
}

/* --- 搜索结果卡片 --- */
.result-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
  cursor: default;
  transition: opacity 0.3s ease;
}
.result-card:last-child {
  border-bottom: none;
}
.result-card:hover .result-card-title {
  color: var(--color-accent);
}
.result-card-title {
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.25s ease;
}
.result-card-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  opacity: 0.5;
}
.result-card-desc {
  margin-top: 0.625rem;
  padding: 0.625rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.625;
  background: var(--bg-opacity);
  border: 1px solid var(--color-border);
  color: var(--color-base-content);
  opacity: 0.85;
}

/* --- 搜索高亮 --- */
.search-highlight {
  background-color: var(--color-accent);
  color: #fff;
  padding: 0.125em 0.25em;
  border-radius: 0.25em;
}
[data-theme="dark"] .search-highlight {
  color: #1c1c1e;
}

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  opacity: 0.5;
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

/* --- 加载动画 --- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-spin {
  animation: spin 1s linear infinite;
}

/* --- Toast 提示 --- */
.toast {
  position: fixed;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 9999;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--color-base-100);
  color: var(--color-base-content);
  border: 1px solid var(--color-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  border-color: var(--color-success);
  color: var(--color-success);
}
.toast.error {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* --- 管理后台表格 --- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  opacity: 0.7;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.admin-table tr:hover td {
  background: var(--bg-opacity);
}

/* --- 模态框 --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: var(--color-base-100);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 48px rgba(0,0,0,0.12);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal-content {
  transform: scale(1);
}

/* --- 分页 --- */
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-base-100);
  color: var(--color-base-content);
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0.6;
}
.page-btn:hover { opacity: 1; background: var(--bg-opacity); }
.page-btn.active { opacity: 1; background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.page-btn:disabled { opacity: 0.25; cursor: default; background: transparent; }
.page-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 0.75rem;
  opacity: 0.35;
  user-select: none;
}

/* --- 响应式 --- */
@media (max-width: 640px) {
  .admin-table {
    font-size: 0.75rem;
  }
  .admin-table th,
  .admin-table td {
    padding: 0.5rem 0.5rem;
  }
}
