/* 「CSS と SVG だけでできるリッチな表現」記事のデモ用スタイル。.rx の共通部分は JS 版の記事でも使う */
.rx {
  position: relative;
  margin: 0 0 .7em;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--code-bg);
  color: var(--text);
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
}
.rx * { box-sizing: border-box; }
.rx p { margin: 0; }

/* ---------- 1. リキッドグラス ----------
   構成は lucasromerodb/liquid-glass-effect-macos を参考にした。
   ぼかした背景（backdrop-filter）を、さらに SVG フィルタ（filter: url()）で歪ませる。JS 版の記事ではドラッグできる */
.rx-lg {
  min-height: 380px; touch-action: none;
  background-color: #f3e6cf;
  background-image:
    radial-gradient(circle at 25% 25%, #e63946 0 10%, transparent 10.5%),
    radial-gradient(circle at 75% 75%, #2a9d8f 0 10%, transparent 10.5%),
    radial-gradient(circle at 75% 25%, #f4a261 0 6%, transparent 6.5%),
    radial-gradient(circle at 25% 75%, #264653 0 6%, transparent 6.5%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.12) 0 2px, transparent 2px 11px);
  background-size: 90px 90px;
  animation: rx-lg-move 40s linear infinite;
}
@keyframes rx-lg-move { to { background-position: 0 -900px; } }
.rx-lgw {
  position: absolute; z-index: 2; display: flex; overflow: hidden;
  font-weight: 600; color: #fff;
  box-shadow: 0 6px 6px rgba(0,0,0,.2), 0 0 20px rgba(0,0,0,.1);
  transition: padding .4s cubic-bezier(.175, .885, .32, 2.2), border-radius .4s cubic-bezier(.175, .885, .32, 2.2);
}
.rx-lgw > * { border-radius: inherit; }
.rx-lgw .fx {
  position: absolute; inset: 0; z-index: 0; overflow: hidden; isolation: isolate;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  filter: url(#rx-glass);
}
.rx-lgw .tint { position: absolute; inset: 0; z-index: 1; background: rgba(255,255,255,.25); }
.rx-lgw .shine {
  position: absolute; inset: 0; z-index: 2; overflow: hidden;
  box-shadow: inset 2px 2px 1px 0 rgba(255,255,255,.5), inset -1px -1px 1px 1px rgba(255,255,255,.5);
}
.rx-lgw .txt { position: relative; z-index: 3; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
/* メニュー */
.rx-lg-menu { left: 6%; top: 8%; padding: .4rem; border-radius: 1.6rem; }
.rx-lg-menu:hover { padding: .6rem; }
.rx-lg-menu .txt div { font-size: 16px; padding: .3rem .7rem; border-radius: .8rem; transition: background .1s; }
.rx-lg-menu .txt div:hover { background: rgba(255,255,255,.45); }
/* ドック */
.rx-lg-dock { left: 50%; bottom: 7%; margin-left: -150px; padding: .5rem; border-radius: 1.8rem; }
.rx-lg-dock:hover { padding: .7rem; border-radius: 2.2rem; }
.rx-lg-dock .txt { display: flex; gap: 6px; font-size: 34px; line-height: 1; }
.rx-lg-dock .txt span { width: 44px; height: 44px; display: grid; place-items: center; transition: transform .4s cubic-bezier(.175, .885, .32, 2.2); }
.rx-lg-dock .txt span:hover { transform: scale(.9); }
/* ボタン */
.rx-lg-btn { right: 7%; top: 18%; padding: 1.1rem 1.8rem; border-radius: 3rem; }
.rx-lg-btn:hover { padding: 1.3rem 2.1rem; border-radius: 4rem; }
.rx-lg-btn .txt { font-size: 20px; letter-spacing: .02em; }
@media (max-width: 520px) {
  .rx-lg-btn { right: 5%; top: 50%; }
}

/* ---------- 2. オーロラ ---------- */
.rx-aurora { background: #05060a; min-height: 260px; }
.rx-aurora i { position: absolute; width: 70%; height: 70%; border-radius: 50%; filter: blur(50px); opacity: .75; mix-blend-mode: screen; animation: rx-aurora 16s ease-in-out infinite alternate; }
.rx-aurora i:nth-child(1) { background: #00f5a0; left: -10%; top: -20%; }
.rx-aurora i:nth-child(2) { background: #00b4ff; right: -15%; top: 10%; animation-duration: 13s; animation-delay: -5s; }
.rx-aurora i:nth-child(3) { background: #b14dff; left: 20%; bottom: -35%; animation-duration: 19s; animation-delay: -9s; }
.rx-aurora p { position: relative; color: #fff; font-size: 26px; font-weight: 700; letter-spacing: .1em; }
@keyframes rx-aurora {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { transform: translate(15%, 10%) rotate(40deg) scale(1.25); }
}

/* ---------- 3. 光が走る文字 ---------- */
.rx-shine p {
  font-size: clamp(30px, 8vw, 54px); font-weight: 900; letter-spacing: .04em;
  background: linear-gradient(110deg, var(--muted) 0 40%, var(--text) 48%, var(--bg) 50%, var(--text) 52%, var(--muted) 60% 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rx-shine 3.2s linear infinite;
}
@keyframes rx-shine { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* ---------- 6. 形が変わる塊 ---------- */
.rx-blob div {
  width: 170px; height: 170px;
  border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
  background: linear-gradient(135deg, var(--text), var(--muted));
  animation: rx-morph 8s ease-in-out infinite, rx-spin 20s linear infinite;
}
@keyframes rx-morph {
  0%, 100% { border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%; }
  33% { border-radius: 70% 30% 46% 54% / 30% 29% 71% 70%; }
  66% { border-radius: 28% 72% 34% 66% / 63% 46% 54% 37%; }
}
@keyframes rx-spin { to { rotate: 360deg; } }

/* ---------- 7. 線で描かれる太極図（描く→塗る→消す を繰り返す） ---------- */
.rx-yy { min-height: 280px; }
.rx-yy svg { width: 200px; height: 200px; overflow: visible; }
.rx-yy .ln { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 1; stroke-dashoffset: 1; animation: rx-draw 9s ease infinite; }
.rx-yy .ln2 { animation-name: rx-draw2; }
.rx-yy .fl { fill: var(--text); opacity: 0; animation: rx-fill 9s ease infinite; }
.rx-yy .fl2 { fill: var(--code-bg); }
@keyframes rx-draw { 0% { stroke-dashoffset: 1; opacity: 1; } 28%, 85% { stroke-dashoffset: 0; opacity: 1; } 95%, 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes rx-draw2 { 0%, 9% { stroke-dashoffset: 1; opacity: 1; } 36%, 85% { stroke-dashoffset: 0; opacity: 1; } 95%, 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes rx-fill { 0%, 38% { opacity: 0; } 48%, 85% { opacity: 1; } 95%, 100% { opacity: 0; } }

/* ---------- 8. タイプライター（steps() で1文字ずつ幅を広げる） ---------- */
.rx-type p { font-family: var(--mono); font-size: clamp(18px, 5vw, 26px); white-space: nowrap; }
.rx-type p span { display: inline-block; vertical-align: bottom; overflow: hidden; width: 0; animation: rx-typing 5s steps(13, end) infinite alternate; }
.rx-type p::after { content: ""; display: inline-block; width: .55em; height: 1.1em; margin-left: 2px; vertical-align: -.15em; background: var(--text); animation: rx-blink 1s steps(1) infinite; }
@keyframes rx-typing { 0%, 15% { width: 0; } 70%, 100% { width: 13ch; } }
@keyframes rx-blink { 50% { opacity: 0; } }

/* ---------- 9. グリッチ ---------- */
.rx-glitch { background: #0b0b0b; }
.rx-glitch p { position: relative; font: 900 clamp(34px, 9vw, 60px)/1 var(--sans); color: #f2f2f2; letter-spacing: .06em; }
.rx-glitch p::before, .rx-glitch p::after { content: attr(data-text); position: absolute; inset: 0; }
.rx-glitch p::before { color: #ff2b6b; transform: translate(-2px, 0); mix-blend-mode: screen; animation: rx-gl1 2.4s infinite steps(1); }
.rx-glitch p::after { color: #22e6ff; transform: translate(2px, 0); mix-blend-mode: screen; animation: rx-gl2 2.4s infinite steps(1); }
@keyframes rx-gl1 {
  0%, 100% { clip-path: inset(0 0 100% 0); }
  10% { clip-path: inset(10% 0 60% 0); transform: translate(-5px, 0); }
  12% { clip-path: inset(70% 0 5% 0); transform: translate(4px, 0); }
  14% { clip-path: inset(0 0 100% 0); }
  60% { clip-path: inset(40% 0 40% 0); transform: translate(-3px, 0); }
  62% { clip-path: inset(0 0 100% 0); }
}
@keyframes rx-gl2 {
  0%, 100% { clip-path: inset(0 0 100% 0); }
  11% { clip-path: inset(50% 0 20% 0); transform: translate(5px, 0); }
  13% { clip-path: inset(5% 0 80% 0); transform: translate(-4px, 0); }
  15% { clip-path: inset(0 0 100% 0); }
  61% { clip-path: inset(20% 0 65% 0); transform: translate(3px, 0); }
  63% { clip-path: inset(0 0 100% 0); }
}

/* ---------- 10. ニューモーフィズム（チェックボックスの状態で凹ませる） ---------- */
.rx-neu { background: var(--bg); gap: 26px; grid-auto-flow: column; justify-content: center; }
.rx-neu label { position: relative; cursor: pointer; }
.rx-neu input { position: absolute; opacity: 0; pointer-events: none; }
.rx-neu span {
  width: 82px; height: 82px; border-radius: 22px; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); font-size: 26px;
  --neu-lo: light-dark(color-mix(in srgb, var(--bg), #000 22%), color-mix(in srgb, var(--bg), #000 55%));
  --neu-hi: light-dark(color-mix(in srgb, var(--bg), #fff 45%), color-mix(in srgb, var(--bg), #fff 7%));
  box-shadow: 8px 8px 16px var(--neu-lo), -8px -8px 16px var(--neu-hi);
  transition: box-shadow .2s, color .2s;
}
.rx-neu input:checked + span {
  color: var(--text);
  box-shadow: inset 6px 6px 12px var(--neu-lo), inset -6px -6px 12px var(--neu-hi);
}
.rx-neu input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 4px; }

/* ---------- 11. 進捗リング ---------- */
@property --rx-p { syntax: "<integer>"; inherits: true; initial-value: 0; }
.rx-ring { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 24px; padding: 20px; }
.rx-ring div {
  width: 110px; height: 110px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--text) calc(var(--rx-p) * 1%), var(--line) 0);
  -webkit-mask: radial-gradient(circle, transparent 43px, #000 44px);
  mask: radial-gradient(circle, transparent 43px, #000 44px);
}
.rx-ring figure { position: relative; margin: 0; display: grid; place-items: center; --rx-p: var(--to); animation: rx-ring 2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rx-ring { from { --rx-p: 0; } to { --rx-p: var(--to); } }
@supports (animation-timeline: view()) {
  .rx-ring figure { animation-timeline: view(); animation-range: entry 30% cover 50%; animation-timing-function: linear; }
}
.rx-ring figure span { position: absolute; counter-reset: p var(--rx-p); font: 700 22px var(--mono); }
.rx-ring figure span::after { content: counter(p) "%"; }
.rx-ring figure:nth-child(1) { --to: 72; }
.rx-ring figure:nth-child(2) { --to: 38; }
.rx-ring figure:nth-child(3) { --to: 91; }

/* ---------- 13. スクロールで現れる（animation-timeline: view()） ---------- */
.rx-reveal { display: block; place-items: normal; padding: 22px; min-height: 0; }
.rx-reveal div { padding: 14px 16px; margin: 0 0 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.rx-reveal div:last-child { margin-bottom: 0; }
@supports (animation-timeline: view()) {
  .rx-reveal div { animation: rx-reveal linear both; animation-timeline: view(); animation-range: entry 0% cover 35%; }
}
@keyframes rx-reveal { from { opacity: 0; transform: translateY(30px) scale(.97); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }

/* ---------- 14. 流れる帯 ---------- */
.rx-marquee { min-height: 0; padding: 18px 0; display: block; place-items: normal; }
.rx-marquee .track { display: flex; width: max-content; animation: rx-marq 22s linear infinite; }
.rx-marquee .track span { padding: 0 22px; font-size: 22px; font-weight: 700; white-space: nowrap; color: var(--muted); }
.rx-marquee .track span:nth-child(odd) { color: var(--text); }
.rx-marquee:hover .track { animation-play-state: paused; }
.rx-marquee { -webkit-mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
@keyframes rx-marq { to { transform: translateX(-50%); } }

/* ---------- 15. 波 ---------- */
.rx-wave { min-height: 220px; place-items: end stretch; }
.rx-wave svg { width: 100%; height: 140px; display: block; }
.rx-wave use { animation: rx-wave 7s cubic-bezier(.55, .5, .45, .5) infinite; }
.rx-wave use:nth-of-type(1) { animation-duration: 7s; animation-delay: -2s; fill: color-mix(in srgb, var(--text) 25%, transparent); }
.rx-wave use:nth-of-type(2) { animation-duration: 10s; animation-delay: -3s; fill: color-mix(in srgb, var(--text) 45%, transparent); }
.rx-wave use:nth-of-type(3) { animation-duration: 13s; animation-delay: -4s; fill: color-mix(in srgb, var(--text) 70%, transparent); }
.rx-wave p { position: absolute; top: 34px; left: 0; right: 0; text-align: center; font-size: 20px; font-weight: 700; }
@keyframes rx-wave { 0% { transform: translateX(-90px); } 100% { transform: translateX(85px); } }

/* ---------- 16. 一文字ずつ跳ねる ---------- */
.rx-bounce p { font-size: clamp(26px, 6vw, 40px); font-weight: 800; }
.rx-bounce p span { display: inline-block; animation: rx-bounce 4s cubic-bezier(.3, 1.6, .5, 1) infinite both; animation-delay: calc(var(--i) * 70ms); }
@keyframes rx-bounce {
  0% { transform: translateY(-40px) scale(.6); opacity: 0; }
  15% { transform: translateY(4px) scale(1.05); opacity: 1; }
  25%, 85% { transform: none; opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}

/* 共通: 動きを減らす設定のときは止める */
@media (prefers-reduced-motion: reduce) {
  .rx *, .rx *::before, .rx *::after { animation: none !important; transition: none !important; }
  .rx-yy .ln { stroke-dashoffset: 0; }
  .rx-yy .fl { opacity: 1; }
  .rx-type p span { width: 13ch; }
}
