/* Springy Input: 打った文字が跳ねて着地し、キャレットは移動中に伸びる
   designbookmark.com の Motion Studies より。色・書体・角丸はこのツールのもの。 */

:root {
  --input-caret: 700 32; /* キャレットの移動。速さで伸びる */
  --input-morph: 300 20; /* 欄 <-> 受信済みピル */
}

.sfield {
  position: relative;
  width: 100%;
  height: 60px;
  border-radius: var(--g-radius);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  transition: box-shadow 0.25s, background 0.3s, border-radius 0.4s;
  overflow: hidden;
  will-change: width, transform;
  justify-self: center;
}
.sfield.focus { box-shadow: 0 0 0 1.5px var(--g-gold) inset; }
.sfield.err { box-shadow: 0 0 0 1.5px var(--g-red) inset; }
.sfield.ok {
  background: linear-gradient(180deg, #ffe08a 0%, var(--g-gold) 55%, var(--g-gold-2) 100%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 6px 18px rgba(0, 0, 0, 0.35);
  border-radius: 30px;
}

.slabel {
  position: absolute;
  left: 20px;
  top: 18px;
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  transform-origin: left top;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.sbox { position: absolute; left: 20px; right: 62px; top: 26px; height: 26px; }
.slayer { position: absolute; inset: 0; overflow: hidden; white-space: pre; pointer-events: none; }
.slayer-in { position: absolute; left: 0; top: 0; height: 26px; line-height: 26px; white-space: pre; }
.ch {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 26px;
  font-kerning: none;
  transform-origin: 50% 80%;
}
.ch.comp { text-decoration: underline dotted rgba(255, 255, 255, 0.6); text-underline-offset: 4px; }
.ch.in { animation: ch-drop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d, 0ms); }
.ch.out { position: absolute; top: 0; animation: ch-out 0.34s cubic-bezier(0.5, 0, 0.75, 0) forwards; }
.ch.nope { animation: ch-nope 0.46s ease both; animation-delay: var(--d, 0ms); }
.ch.fly { animation: ch-fly 0.42s cubic-bezier(0.5, 0, 0.75, 0) forwards; animation-delay: var(--d, 0ms); }
@keyframes ch-drop {
  0% { transform: translateY(14px) rotate(-16deg) scale(0.5); opacity: 0; filter: blur(3px); }
  55% { transform: translateY(-3px) rotate(4deg) scale(1.1); opacity: 1; filter: none; }
  80% { transform: translateY(1px) rotate(-1deg) scale(0.98); }
  100% { transform: none; }
}
@keyframes ch-out { to { transform: translateY(-18px) rotate(20deg) scale(0.5); opacity: 0; filter: blur(3px); } }
@keyframes ch-nope {
  0%, 100% { transform: none; }
  20% { transform: translateX(-4px) rotate(-8deg); }
  40% { transform: translateX(4px) rotate(6deg); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(1px); }
}
@keyframes ch-fly { to { transform: translateY(-28px) scale(0.6); opacity: 0; filter: blur(4px); } }

.sinput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  background: none;
  padding: 0;
  margin: 0;
  font: 700 18px "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 26px;
  font-kerning: none;
  letter-spacing: 0;
  text-align: left;
  color: transparent;
  caret-color: transparent;
  border-radius: 0;
}
.sinput::selection { background: rgba(255, 255, 255, 0.2); color: transparent; }
.scaret {
  position: absolute;
  left: 0;
  top: 3px;
  width: 2px;
  height: 20px;
  border-radius: 2px;
  background: var(--g-gold);
  opacity: 0;
  pointer-events: none;
  transform-origin: left center;
}
.scaret.blink { animation: scaret-blink 1s steps(1) infinite; }
@keyframes scaret-blink { 50% { opacity: 0; } }

/* 送信ボタンは元のまま（正円、平塗り）。色だけ金に */
.sgo {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--g-gold);
  color: var(--g-navy);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
}
.sgo svg { width: 20px; height: 20px; }
.sgo.idle { transform: scale(0.82); opacity: 0.35; }
.sgo:active { transform: scale(0.88); }
.sfield.ok .sgo, .sfield.ok .slabel, .sfield.ok .sbox { opacity: 0; pointer-events: none; }

.sdone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #3a2a00;
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}
.sdone svg { width: 20px; height: 20px; }
.sdone path { stroke-dasharray: 24; stroke-dashoffset: 24; }
.sfield.ok .sdone { opacity: 1; transform: none; transition: opacity 0.3s 0.15s, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s; }
.sfield.ok .sdone path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.45s cubic-bezier(0.65, 0, 0.35, 1) 0.3s; }

.shelp {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  min-height: 18px;
  text-align: center;
  transition: color 0.2s;
}
.shelp.err { color: #ff8a94; }

@media (prefers-reduced-motion: reduce) {
  .ch.in, .ch.out, .ch.nope, .ch.fly { animation-duration: 0.01s; animation-delay: 0ms; }
  .sgo { transition: none; }
}
