/* ═══════════════════════════════════════════════════════════════
   Immersive v8.1 — 動態升級包（精緻調整版）
   原則：dynamics 應該是「輔助」不是「主角」— 低調但有層次
   ═══════════════════════════════════════════════════════════════ */

/* ───── 1) 進場淡入（更柔和 + 順序更明顯）───── */
@keyframes v8-fadein {
  from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
header, main, footer, article, .entry-content {
  animation: v8-fadein 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
main { animation-delay: 0.05s; }
.entry-content > *:nth-child(1) { animation-delay: 0.1s; }
.entry-content > *:nth-child(2) { animation-delay: 0.15s; }
.entry-content > *:nth-child(3) { animation-delay: 0.2s; }
.entry-content > *:nth-child(4) { animation-delay: 0.25s; }
.entry-content > *:nth-child(5) { animation-delay: 0.3s; }

/* ───── 2) 微妙網格背景（更大格，更淡）───── */
.v8-mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 96px 96px;
  background-position: 0 0;
  opacity: 1;
  animation: v8-mesh-drift 80s linear infinite;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 90%);
}
@keyframes v8-mesh-drift {
  0% { background-position: 0 0; }
  100% { background-position: 96px 96px; }
}

/* ───── 3) 滑鼠追蹤輝光（用 vw 適應，更低調）───── */
.v8-spot {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  width: 22vw;
  height: 22vw;
  max-width: 320px;
  max-height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--v7-blob-1, rgba(168,85,247,0.35)) 0%, transparent 65%);
  filter: blur(50px);
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}
.v8-spot.active { opacity: 0.4; }

/* ───── 4) 卡片懸停（更克制的 lift + 漸進陰影）───── */
article, .post, [class*="post-"], .card, [class*="-card"] {
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.5s ease;
}
article:hover, .post:hover, [class*="post-"]:hover, .card:hover, [class*="-card"]:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 48px -20px rgba(0,0,0,0.28), 0 2px 4px rgba(0,0,0,0.05);
}

/* ───── 5) 連結微互動 ───── */
a:not([class*="button"]):not([class*="btn"]):not(.elementor-button) {
  position: relative;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0 1px;
  transition: background-size 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
a:not([class*="button"]):not([class*="btn"]):not(.elementor-button):hover {
  background-size: 100% 1px;
}

/* ───── 6) 章節標題（更精緻的下劃線）───── */
.entry-content h2, .entry-content h3,
article h2, article h3 {
  position: relative;
}
.entry-content h2::after, .entry-content h3::after,
article h2::after, article h3::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg,
    var(--v7-blob-1, #a855f7),
    var(--v7-blob-2, #ec4899) 60%,
    transparent);
  border-radius: 2px;
  animation: v8-underline-draw 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}
@keyframes v8-underline-draw {
  to { width: 60px; }
}
.entry-content h2:hover::after, article h2:hover::after {
  width: 120px;
  transition: width 0.4s ease;
}

/* ───── 7) Scroll-driven reveal（漸進元素）───── */
@supports (animation-timeline: view()) {
  .entry-content > p,
  .entry-content > figure,
  .entry-content > blockquote,
  article {
    animation: v8-reveal linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 25%;
  }
  @keyframes v8-reveal {
    from { opacity: 0.4; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

/* ───── 8) 按鈕磁吸感（不需 JS）───── */
button, .button, .btn, [class*="-button"], input[type="submit"] {
  position: relative;
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    background-color 0.3s ease;
}
button::before, .button::before, .btn::before,
[class*="-button"]::before, input[type="submit"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255,255,255,0.25) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
button:hover, .button:hover, .btn:hover,
[class*="-button"]:hover, input[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px -10px rgba(0,0,0,0.4);
}
button:hover::before, .button:hover::before, .btn:hover::before,
[class*="-button"]:hover::before, input[type="submit"]:hover::before {
  opacity: 1;
}

/* ───── 9) 圖片精緻邊框（微弱 inset）───── */
.entry-content img, article img {
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

/* ───── 10) 圖片載入骨架 ───── */
img:not([src]), img[src=""] {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 100%);
  background-size: 200% 100%;
  animation: v8-skeleton 1.5s ease-in-out infinite;
}
@keyframes v8-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ───── 11) 滾動條（更細緻）───── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--v7-blob-1, #a855f7), var(--v7-blob-2, #ec4899));
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--v7-blob-1, #a855f7);
  background-clip: padding-box;
}

/* ───── 12) 選取文字 ───── */
::selection {
  background: var(--v7-blob-1, #a855f7);
  color: white;
}

/* ───── 13) Focus visible（Accessibility）───── */
*:focus-visible {
  outline: 2px solid var(--v7-blob-1, #a855f7);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ───── 14) Reduced motion fallback ───── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .v8-mesh { animation: none !important; opacity: 0.3 !important; }
  .v8-spot { display: none !important; }
  .entry-content h2::after, article h2::after { width: 60px !important; }
}

/* ───── 16) Widget readability — 半透明白底讓 v7 浪漫的同時文字清晰 ───── */
.widget, .wp-block-group, .entry-content > p,
aside .widget, .sidebar .widget,
.elementor-widget-wrap > div,
.wp-block-latest-posts, .wp-block-search,
ul.wp-block-latest-posts__list,
.recent-posts, .widget_recent_entries,
.widget_recent_comments,
.widget_categories,
.widget_archive,
.widget_tag_cloud,
.widget_meta {
  background-color: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border-radius: 14px;
  padding: 20px 24px !important;
  box-shadow: 0 4px 24px -8px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(255,255,255,0.6);
  margin-bottom: 24px;
}
.widget a, .recent-posts a, .wp-block-latest-posts__list a,
.widget_recent_entries a, .widget_categories a, .widget_archive a {
  color: #1a1a1a !important;
  font-weight: 500;
}
.widget a:hover, .recent-posts a:hover,
.widget_recent_entries a:hover, .widget_categories a:hover {
  color: var(--v7-blob-1, #a855f7) !important;
}
.widget-title, .widgettitle, .wp-block-heading {
  color: #0f0f0f !important;
}

/* article 內文若處於浮空狀態，加白底 */
main article, .entry-content article, .post {
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: 0 6px 30px -10px rgba(0,0,0,0.15);
}

/* ───── 17) Hero / Page title 強化 ───── */
.entry-title, .post-title, h1.entry-title {
  color: white !important;
  text-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 1px 0 rgba(0,0,0,0.2);
  font-weight: 800;
}

/* ───── 15) Print fallback ───── */
@media print {
  .v8-mesh, .v8-spot, .niche-float, .v7-blob, .v7-grain, .v7-progress, .v7-cursor, .cafe-scene { display: none !important; }
  * { background: white !important; color: black !important; box-shadow: none !important; }
}
