/* ============================================================
   visual.css — 4 种视觉风格增强
   风格 1：Sketch and Scribble（手绘涂鸦感）
   风格 2：Digital Impressionism（数字印象派）
   风格 3：Morphing Objects（形变物体）
   风格 4：Generative Art（生成艺术）
   ============================================================ */

/* ---------- 自托管手写字体 ---------- */

@font-face {
  font-family: 'Caveat';
  src: url('../../assets/fonts/caveat.woff2') format('woff2');
  font-display: swap;
  font-weight: 400 700;
}

/* Ma Shan Zheng 中文子集：自托管 latin 子集 + CDN 中文备选 */
@font-face {
  font-family: 'Ma Shan Zheng';
  src: url('../../assets/fonts/ma-shan-zheng.woff2') format('woff2');
  font-display: swap;
  font-weight: 400;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* CDN 备选：中文汉字子集（离线时回退到系统手写字体） */
@font-face {
  font-family: 'Ma Shan Zheng';
  src: url('https://fonts.gstatic.com/s/mashanzheng/v18/NaPecZTRCLxvwo41b4gvzkXaRMGEFoZJFdX0wQ5Xo5Hr21L9zCcRFhbSe5Nk0pIMuUkHEA.119.woff2') format('woff2');
  font-display: swap;
  font-weight: 400;
  unicode-range: U+4E00-9FFF, U+3000-303F, U+FF00-FFEF;
}

:root {
  --font-hand: 'Caveat', 'Ma Shan Zheng', cursive;
}

/* ============================================================
   风格 1：Sketch and Scribble（手绘涂鸦感）
   ============================================================ */

/* 手写字体类 */
.font-hand {
  font-family: var(--font-hand);
}

/* 支线大标题手写体（用更高特异性，不覆盖 app.css 原类） */
.hand-title {
  font-family: var(--font-hand);
  font-weight: 600;
}

/* 手绘按钮边框：不规则圆角模拟手绘线条 */
.btn-sketch {
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  border: 1.5px solid var(--ink);
  position: relative;
  transition: border-radius 0.2s ease;
}
.btn-sketch:active {
  border-radius: 15px 225px 15px 255px / 255px 15px 225px 15px;
}

/* 手绘下划线：SVG path 背景 + dasharray 动画 */
.hand-underline {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none'%3E%3Cpath d='M2 5 Q 15 2, 30 5 T 60 5 T 98 4' fill='none' stroke='%23c49a4f' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.3em;
  padding-bottom: 0.15em;
}

/* 票根撕裂边缘：clip-path 锯齿 */
.ticket-sketch {
  clip-path: polygon(
    0% 2%, 3% 0%, 7% 3%, 12% 1%, 18% 3%, 25% 0%, 33% 2%, 42% 1%, 50% 3%,
    58% 1%, 67% 2%, 75% 0%, 82% 3%, 88% 1%, 93% 3%, 97% 0%, 100% 2%,
    99% 10%, 100% 20%, 98% 35%, 100% 50%, 99% 65%, 100% 80%, 98% 95%, 100% 100%,
    90% 98%, 80% 100%, 70% 99%, 60% 100%, 50% 98%, 40% 100%, 30% 99%, 20% 100%, 10% 98%, 0% 100%,
    1% 85%, 0% 70%, 1% 55%, 0% 40%, 1% 25%, 0% 10%
  );
}

/* 手绘分隔线：SVG 波浪线 */
.divider-sketch {
  height: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4 Q 12 1, 25 4 T 50 4 T 75 4 T 100 4' fill='none' stroke='%231f2b24' stroke-opacity='0.15' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

/* 手绘图标：圆角线稿 */
[data-icon="sketch"] {
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke: currentColor;
}

/* 纸张纹理增强：body 叠加噪点 */
body.visual-paper-enhanced::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url('../assets/tex/paper-grain.png');
  opacity: 0.06;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* ============================================================
   风格 2：Digital Impressionism（数字印象派）
   ============================================================ */

/* 场景族配色变量 */
:root {
  --family-rest: #e8a87c;      /* 暖橙 */
  --family-sport: #5b9bd5;     /* 活力蓝 */
  --family-nature: #7cb342;    /* 草绿 */
  --family-market: #f0c040;    /* 暖黄 */
  --family-culture: #5c6bc0;   /* 靛蓝 */
  --family-social: #ec407a;    /* 玫红 */
  --family-digital: #78909c;   /* 灰蓝 */
  --family-street: #8d6e63;    /* 棕褐 */
  --family-night: #7e57c2;     /* 深紫 */
  --family-cozy: #d7ccc8;      /* 米白 */
  --family-explore: #ff7043;   /* 橙红 */
}

/* 印象派背景：多层 radial-gradient 叠加 */
.bg-impressionist {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(196, 154, 79, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, rgba(200, 84, 58, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(47, 79, 71, 0.05) 0%, transparent 50%),
    var(--paper);
}

/* 水雾光斑：彩色模糊块 */
.mist-impressionist {
  position: relative;
  overflow: hidden;
}
.mist-impressionist::before {
  content: '';
  position: absolute;
  inset: -20px;
  background:
    radial-gradient(circle at 30% 40%, rgba(196, 154, 79, 0.12), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(200, 84, 58, 0.08), transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(126, 87, 198, 0.06), transparent 40%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}
.mist-impressionist > * {
  position: relative;
  z-index: 1;
}

/* 完成动画光晕增强：印象派多层渐变 */
.completion-overlay.visual-impressionist .completion-glow {
  filter: blur(8px);
}

/* ============================================================
   风格 3：Morphing Objects（形变物体）
   ============================================================ */

/* 形变 SVG 容器 */
.morph-icon {
  will-change: d;
  overflow: visible;
}
.morph-icon path {
  transition: none; /* 形变由 JS 驱动，不用 CSS transition */
}

/* 底部导航图标形变样式 */
.tab .morph-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* 心情图标形变样式 */
.mood-morph-icon {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* 完成对勾形变：圆圈→对勾 */
.check-morph {
  width: 48px;
  height: 48px;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  will-change: d;
}

/* ============================================================
   风格 4：Generative Art（生成艺术）
   ============================================================ */

/* 流动场 Canvas 背景 */
.flow-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* 粒子 Canvas（完成动画用） */
.particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* 完成动画粒子 Canvas */
.completion-particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* 票根生成艺术装饰 */
.ticket-gen-art {
  position: relative;
  overflow: hidden;
}
.ticket-gen-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(196, 154, 79, 0.05) 0%, transparent 50%),
    linear-gradient(315deg, rgba(200, 84, 58, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

/* ============================================================
   全局：prefers-reduced-motion 降级
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  /* 关闭粒子动画 */
  .flow-canvas,
  .particle-canvas,
  .completion-particle-canvas {
    animation: none !important;
  }

  /* 形变改为瞬时切换 */
  .morph-icon,
  .check-morph {
    transition: none !important;
    animation: none !important;
  }

  /* 手绘下划线动画停止 */
  .hand-underline {
    animation: none !important;
  }

  /* 去除所有 blur 滤镜 */
  .mist-impressionist::before,
  .completion-overlay.visual-impressionist .completion-glow {
    filter: none !important;
  }
}
