/* caprix.jp — 動きのある案。html[data-motion] で案を切り替え、JS が動くときだけ .motion-ready が付く */

/* ───────── 共通 ───────── */

/* 見出しを1文字ずつ持ち上げる */
.hero-chars .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.1em;
  margin-bottom: -0.1em;
}

.hero-chars .ch {
  display: inline-block;
}

.motion-ready .hero-chars .ch {
  transform: translateY(112%);
  animation: ch-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(160ms + var(--i, 0) * 36ms);
}

@keyframes ch-in {
  to {
    transform: none;
  }
}

.motion-ready .site-header {
  animation: fade-down 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.motion-ready .hero .mono,
.motion-ready .hero-lead {
  animation: fade-up 1s 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.motion-ready .waves {
  animation: fade-in 1.6s 0.5s ease both;
}

@keyframes fade-down {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* 画面に入ったら出てくる */
.motion-ready .rv {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--d, 0) * 90ms);
}

.motion-ready .rv.is-in {
  opacity: 1;
  transform: none;
}

/* ───────── 1 弦（strings） ───────── */

[data-motion="strings"] .waves {
  height: 170px;
}

.strings-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

.strings-on .waves-svg {
  visibility: hidden;
}

[data-motion="strings"].motion-ready .service:not(.is-next) .svc-row {
  position: relative;
  border-top-color: transparent;
}

.row-string {
  position: absolute;
  left: 0;
  top: -20px;
  width: 100%;
  height: 40px;
  overflow: visible;
  pointer-events: none;
}

.row-string path {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke 240ms ease;
}

.svc-row:hover .row-string path {
  stroke: var(--ink-3);
}

/* ───────── 2 文字（kinetic） ───────── */

[data-motion="kinetic"] .hero-chars .ch {
  font-weight: var(--w, 300);
}

[data-motion="kinetic"] .waves {
  height: 110px;
  margin-top: 56px;
}

.marquee {
  margin-top: 24px;
  overflow: hidden;
  border-block: 1px solid var(--rule);
  padding-block: 20px;
}

.marquee-track {
  display: flex;
  width: max-content;
  will-change: transform;
}

.marquee-item {
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
  padding-right: 0.34em;
  font-size: clamp(56px, 9.5vw, 148px);
  font-weight: 200;
  letter-spacing: -0.045em;
  line-height: 1;
  white-space: nowrap;
}

.marquee-item.is-outline {
  color: transparent;
  -webkit-text-stroke: 1px var(--ink);
}

.marquee-sep {
  display: inline-block;
  width: 0.14em;
  height: 0.14em;
  border-radius: 50%;
  background: var(--ink);
}

/* 行にカーソルを乗せると、墨色が下から満ちる */
[data-motion="kinetic"] .svc-row.is-link {
  position: relative;
  isolation: isolate;
  transition: color 0.5s cubic-bezier(0.7, 0, 0.2, 1);
}

[data-motion="kinetic"] .svc-row.is-link::before {
  content: "";
  position: absolute;
  inset: -1px calc(var(--pad) * -0.5) 0;
  z-index: -1;
  border-radius: 4px;
  background: var(--ink);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform 0.55s cubic-bezier(0.7, 0, 0.2, 1);
}

[data-motion="kinetic"] .svc-row.is-link:hover::before,
[data-motion="kinetic"] .svc-row.is-link:focus-visible::before {
  transform: scaleY(1);
}

[data-motion="kinetic"] .svc-row.is-link:hover,
[data-motion="kinetic"] .svc-row.is-link:focus-visible {
  color: var(--bg);
}

[data-motion="kinetic"] .svc-row.is-link:hover :is(.svc-desc, .svc-sub, .svc-no),
[data-motion="kinetic"] .svc-row.is-link:focus-visible :is(.svc-desc, .svc-sub, .svc-no) {
  color: rgba(246, 246, 243, 0.72);
}

[data-motion="kinetic"] .svc-row.is-link :is(.svc-desc, .svc-sub, .svc-no) {
  transition: color 0.5s cubic-bezier(0.7, 0, 0.2, 1);
}

[data-motion="kinetic"] .svc-row.is-link:hover .svc-domain {
  transform: translateX(16px);
}

/* 自前のカーソル */
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.cursor.is-hidden {
  opacity: 0;
}

.cursor-dot,
.cursor-ring {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--ink);
}

.cursor-ring {
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(20, 20, 20, 0.5);
  border-radius: 50%;
  transition:
    width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    height 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    margin 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.35s ease,
    border-color 0.35s ease;
}

.cursor-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cursor.is-link .cursor-ring {
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-color: var(--ink);
}

.cursor.is-open .cursor-ring {
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border-color: var(--bg);
  background: var(--bg);
}

.cursor.is-open .cursor-label {
  opacity: 1;
}

.cursor.is-open .cursor-dot {
  opacity: 0;
}

@media (pointer: fine) {
  .has-cursor,
  .has-cursor a,
  .has-cursor button {
    cursor: none;
  }

  .has-cursor :is(input, textarea, select) {
    cursor: auto;
  }
}

/* ───────── 3 重なり（stack） ───────── */

/* 見出しはスクロールでゆっくり沈み、五本の線は広がる */
[data-motion="stack"].motion-ready .hero {
  transform: translateY(calc(var(--sy, 0) * 0.32px));
  opacity: calc(1 - var(--sy, 0) / 620);
}

[data-motion="stack"] .waves {
  height: 190px;
}

[data-motion="stack"] .waves-svg {
  top: 20px;
  transform: scaleY(calc(1 + min(var(--sy, 0), 360) / 420));
  transform-origin: 50% 75px;
}

[data-motion="stack"] .w {
  vector-effect: non-scaling-stroke;
}

/* サービスは重なっていくカード */
[data-motion="stack"] .service-list {
  border-bottom: 0;
  padding-bottom: 8vh;
}

[data-motion="stack"] .service {
  position: sticky;
  top: calc(88px + var(--i, 0) * 18px);
  margin-bottom: 24vh;
}

[data-motion="stack"] .service:last-child {
  margin-bottom: 0;
}

[data-motion="stack"].motion-ready .service.rv {
  opacity: 1;
  transform: none;
}

[data-motion="stack"] .svc-row {
  position: relative;
  min-height: min(62vh, 560px);
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "no status"
    "name name"
    "desc arrow";
  row-gap: 28px;
  align-items: end;
  padding: 40px 48px 44px;
  border: 1px solid var(--rule);
  border-radius: 28px;
  background: var(--field);
  box-shadow: 0 40px 80px -60px rgba(20, 20, 20, 0.45);
  transform: scale(calc(1 - var(--p, 0) * 0.06));
  transform-origin: 50% 0;
  overflow: hidden;
}

[data-motion="stack"] .svc-row::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: calc(var(--p, 0) * 0.6);
  pointer-events: none;
}

[data-motion="stack"] .svc-no,
[data-motion="stack"] .svc-row .status {
  align-self: start;
}

[data-motion="stack"] .svc-domain {
  font-size: clamp(64px, 11vw, 176px);
  font-weight: 200;
  letter-spacing: -0.05em;
}

[data-motion="stack"] .svc-sub {
  font-size: 16px;
}

[data-motion="stack"] .svc-desc {
  max-width: 560px;
  font-size: 16px;
}

[data-motion="stack"] .svc-next {
  font-size: clamp(40px, 6vw, 88px);
  align-self: end;
}

[data-motion="stack"] .is-next .svc-row {
  border-style: dashed;
  border-color: var(--rule-2);
  background: var(--bg);
  box-shadow: none;
}

[data-motion="stack"] .svc-row .arrow {
  width: 56px;
  height: 56px;
  opacity: 0.4;
}

/* 見出しは左から拭うように出る */
[data-motion="stack"].motion-ready .section-head.rv,
[data-motion="stack"].motion-ready .split-head.rv {
  opacity: 1;
  transform: none;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.1s cubic-bezier(0.7, 0, 0.2, 1);
}

[data-motion="stack"].motion-ready .section-head.rv.is-in,
[data-motion="stack"].motion-ready .split-head.rv.is-in {
  clip-path: inset(0 0 0 0);
}

/* うっすらフィルムの粒子 */
[data-motion="stack"].motion-ready body::after {
  content: "";
  position: fixed;
  inset: -120px;
  z-index: 80;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(5) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-40px, 24px); }
  40% { transform: translate(28px, -46px); }
  60% { transform: translate(-58px, -12px); }
  80% { transform: translate(46px, 34px); }
  100% { transform: translate(0, 0); }
}

/* ───────── スマートフォン ───────── */

@media (max-width: 720px) {
  [data-motion="strings"] .waves {
    height: 130px;
  }

  .marquee {
    padding-block: 14px;
  }

  [data-motion="stack"] .service {
    top: calc(76px + var(--i, 0) * 12px);
    margin-bottom: 18vh;
  }

  [data-motion="stack"] .svc-row {
    min-height: 58vh;
    padding: 28px 24px 30px;
    border-radius: 22px;
    grid-template-areas:
      "no status"
      "name name"
      "desc desc";
  }

  [data-motion="stack"] .svc-row .arrow {
    display: none;
  }

  [data-motion="stack"] .svc-domain {
    font-size: clamp(48px, 15vw, 72px);
  }
}

/* 動きを減らす設定では、何も動かさない */
@media (prefers-reduced-motion: reduce) {
  .hero-chars .ch,
  .rv,
  .marquee-track,
  body::after {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
