/*
 * static/css/login.css
 * ログイン画面専用のスタイル。
 * 明るい背景に、流れる罫線と斜めのリボン、外周が回るガラスカードを重ねる。
 * 動きが苦手な環境では prefers-reduced-motion ですべて静止させる。
 */

:root {
  --ink: #10233b;
  --ink-soft: #5b7089;
  --line: rgba(31, 95, 176, 0.14);
  --accent: #0aa6d8;
  --accent-2: #2e75d4;
  --accent-3: #7b5cf0;
  --err: #e05260;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "Meiryo UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 50% 42%, rgba(255, 255, 255, 0.9), transparent 70%),
    linear-gradient(155deg, #eaf1fa 0%, #dde7f5 55%, #e6e3f7 100%);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* ------------------------------------------------------------ 背景 */
/* 斜めのリボン。ゆっくり流れて奥行きを出す。 */
.ribbon {
  position: fixed;
  left: -20%;
  width: 140%;
  height: 300px;
  transform: rotate(-14deg);
  filter: blur(2px);
  pointer-events: none;
}
.ribbon--1 {
  top: 6%;
  background: linear-gradient(90deg, transparent, rgba(10, 166, 216, 0.30), transparent);
  animation: drift 17s ease-in-out infinite;
}
.ribbon--2 {
  bottom: 4%;
  height: 240px;
  background: linear-gradient(90deg, transparent, rgba(123, 92, 240, 0.28), transparent);
  animation: drift 22s ease-in-out infinite reverse;
}

@keyframes drift {
  0%, 100% { transform: rotate(-14deg) translate(-13%, 0); }
  50%      { transform: rotate(-14deg) translate(13%, -22px); }
}

/* 帳票の罫線をイメージした横線。右へゆっくり流れる。 */
.rules {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(46, 117, 212, 0.10) 0 1px,
    transparent 1px 34px);
  mask-image: radial-gradient(circle at 50% 45%, #000 15%, transparent 80%);
  animation: slide 9s linear infinite;
}
@keyframes slide {
  from { background-position-x: 0; }
  to   { background-position-x: 60px; }
}

/* カードの背後から広がる波紋 */
.pulse {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 460px;
  height: 460px;
  margin: -230px 0 0 -230px;
  border: 1.5px solid rgba(46, 117, 212, 0.45);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: ripple 7.5s ease-out infinite;
}
.pulse--2 { animation-delay: 2.5s; border-color: rgba(123, 92, 240, 0.42); }
.pulse--3 { animation-delay: 5s; border-color: rgba(10, 166, 216, 0.40); }

@keyframes ripple {
  0%   { transform: scale(0.55); opacity: 0; }
  15%  { opacity: 0.85; }
  100% { transform: scale(3.2); opacity: 0; }
}

/* 画面を斜めに横切る光 */
.sheen {
  position: fixed;
  top: -30%;
  left: -40%;
  width: 26%;
  height: 160%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent,
    rgba(255, 255, 255, 0.75), transparent);
  filter: blur(14px);
  pointer-events: none;
  animation: cross 11s ease-in-out infinite;
}
@keyframes cross {
  0%, 55% { left: -40%; }
  100%    { left: 130%; }
}

/* ------------------------------------------------------------ カード */
/* 外周のグラデーションが回る枠。回すのは疑似要素だけで、枠の形は動かさない。 */
.frame {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 2px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.6),
    0 24px 60px rgba(16, 35, 59, 0.22),
    0 0 50px rgba(46, 117, 212, 0.18);
}
.frame::before {
  content: "";
  position: absolute;
  inset: -60%;
  background: conic-gradient(from 0deg,
    #0aa6d8, #7b5cf0, #2e75d4, rgba(46, 117, 212, 0.12), #0aa6d8);
  animation: spin 7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  position: relative;
  z-index: 1;
  border-radius: 22px;
  background: #fff;
  padding: 40px 34px 30px;
}

.card.shake { animation: shake 0.45s; }
@keyframes shake {
  0%, 100% { margin-left: 0; }
  20% { margin-left: -9px; }
  40% { margin-left: 8px; }
  60% { margin-left: -5px; }
  80% { margin-left: 3px; }
}

/* ------------------------------------------------------------ ロゴ */
/* 等間隔に並んだ3つのマークが、左から順に1つずつ描かれる。
   3つ揃ったら1秒見せてまとめて消え、1秒おいてまた左から始まる。
   1周 5.2秒（描画0.9秒×3 → 表示1秒 → 消える0.5秒 → 休み1秒）。 */
.stack {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  height: 84px;
  margin: 0 auto 16px;
}

.mark {
  width: 65px;
  height: 65px;
  flex: none;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* stroke-dasharray / dashoffset は継承するので use の中身にも効く */
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  opacity: 0;
  animation-duration: 5.2s;
  animation-timing-function: ease-out;
  animation-iteration-count: infinite;
}

.mark--1 { animation-name: draw1; }
.mark--2 { animation-name: draw2; }
.mark--3 { animation-name: draw3; }

/* 1つめ：0.0〜0.9秒で描く */
@keyframes draw1 {
  0%   { opacity: 1; stroke-dashoffset: 300; }
  17%  { opacity: 1; stroke-dashoffset: 0; }
  71%  { opacity: 1; stroke-dashoffset: 0; }
  81%  { opacity: 0; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}
/* 2つめ：0.9〜1.8秒で描く */
@keyframes draw2 {
  0%   { opacity: 0; stroke-dashoffset: 300; }
  17%  { opacity: 1; stroke-dashoffset: 300; }
  35%  { opacity: 1; stroke-dashoffset: 0; }
  71%  { opacity: 1; stroke-dashoffset: 0; }
  81%  { opacity: 0; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}
/* 3つめ：1.8〜2.7秒で描く */
@keyframes draw3 {
  0%   { opacity: 0; stroke-dashoffset: 300; }
  35%  { opacity: 1; stroke-dashoffset: 300; }
  52%  { opacity: 1; stroke-dashoffset: 0; }
  71%  { opacity: 1; stroke-dashoffset: 0; }
  81%  { opacity: 0; stroke-dashoffset: 0; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

/* タイトル。1文字ずつ色を変えて、波のように順番に跳ねさせる。 */
.title {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.22em;
}
/* 1文字が跳ね終わってから次の文字が跳ねる。1周 8秒（0.45秒ずつ順番＋休み）。 */
.title span {
  display: inline-block;
  animation: hop 8s ease-in-out infinite;
}
.title .sp { animation: none; }

/* 左から右へ、青→紫のグラデーションになるよう1文字ずつ色を指定 */
.title span:nth-child(1)  { color: #2e75d4; animation-delay: 0.00s; }
.title span:nth-child(2)  { color: #3473d6; animation-delay: 0.45s; }
.title span:nth-child(3)  { color: #3a71d9; animation-delay: 0.90s; }
.title span:nth-child(4)  { color: #416fdb; animation-delay: 1.35s; }
.title span:nth-child(5)  { color: #476ddd; animation-delay: 1.80s; }
.title span:nth-child(6)  { color: #4e6ae0; animation-delay: 2.25s; }
.title span:nth-child(7)  { color: #5468e2; animation-delay: 2.70s; }
.title span:nth-child(8)  { animation-delay: 3.15s; }
.title span:nth-child(9)  { color: #6164e7; animation-delay: 3.60s; }
.title span:nth-child(10) { color: #6762e9; animation-delay: 4.05s; }
.title span:nth-child(11) { color: #6e60eb; animation-delay: 4.50s; }
.title span:nth-child(12) { color: #745eee; animation-delay: 4.95s; }
.title span:nth-child(13) { color: #7a5df0; animation-delay: 5.40s; }
.title span:nth-child(14) { color: #7b5cf0; animation-delay: 5.85s; }

@keyframes hop {
  0%   { transform: translateY(0); }
  2.0% { transform: translateY(-10px); }
  4.4% { transform: translateY(0); }
  5.5% { transform: translateY(-2.5px); }   /* 小さく2度目 */
  6.8% { transform: translateY(0); }
  100% { transform: translateY(0); }        /* 次の順番まで静止 */
}
.lead {
  margin: 6px 0 26px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: #7c8ea6;
}

/* ------------------------------------------------------------ 入力欄 */
/* ラベルが枠線の上に浮き上がるフローティングラベル */
.field { position: relative; margin-bottom: 18px; }

.field input {
  width: 100%;
  height: 52px;
  padding: 20px 14px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 166, 216, 0.16);
}

.field label {
  position: absolute;
  left: 15px;
  top: 16px;
  font-size: 13.5px;
  color: #8ea0b6;
  pointer-events: none;
  transition: 0.16s ease;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 7px;
  font-size: 10.5px;
  letter-spacing: 0.10em;
  color: var(--accent-2);
}

/* ------------------------------------------------------------ ボタン */
.submit {
  position: relative;
  width: 100%;
  height: 50px;
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent-2), var(--accent-3));
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(46, 117, 212, 0.32);
  transition: transform 0.16s, box-shadow 0.16s;
}
.submit:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(46, 117, 212, 0.42); }
.submit:active { transform: translateY(0); }

/* 光が横切る演出 */
.submit::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  animation: sweep 3.6s ease-in-out infinite;
}
@keyframes sweep {
  0%, 65% { left: -60%; }
  100% { left: 130%; }
}

.submit.busy { pointer-events: none; opacity: 0.85; }
.submit.busy::after { animation: none; }

.spinner {
  display: none;
  width: 15px; height: 15px;
  margin-right: 9px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}
.submit.busy .spinner { display: inline-block; }

/* ------------------------------------------------------------ その他 */
.error {
  margin-bottom: 18px;
  padding: 11px 14px;
  border: 1px solid rgba(224, 82, 96, 0.35);
  border-radius: 11px;
  background: rgba(224, 82, 96, 0.07);
  color: var(--err);
  font-size: 12.5px;
}

.foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: #9fb0c4;
}

/* 動きを減らす設定のときは、すべて静止させる */
@media (prefers-reduced-motion: reduce) {
  .ribbon, .rules, .pulse, .sheen, .frame::before, .card,
  .mark, .title span, .submit::after, .spinner {
    animation: none !important;
  }
  .pulse, .sheen { display: none; }
  .mark { stroke-dashoffset: 0; opacity: 1; }
}

@media (max-width: 420px) {
  .card { padding: 30px 22px 24px; }
}
