/* ============================================================
 * SYシフト — 認証の画面（ログイン・登録・パスワード・メールアドレスの確認、管理者のログイン）
 *   左: ブランドのステージ（背景のオーロラ＋時計のリングと光の弧）／右: ガラスのカードのフォーム
 *   スマホ: ステージは細い帯になり、カードの上に置く
 *   common.css のトークンを使う（docs/DESIGN_SYSTEM.md）
 * ============================================================ */

:root {
  --auth-dial: 0.2;
  --auth-dial-minor: 0.1;
  --auth-ring: 0.1;
  --auth-hours: 0.4;
  --auth-glow: 0.5;
  --auth-card-bg: rgba(255, 255, 255, 0.78);
  --auth-card-edge: 0.55;
}

:root[data-theme="dark"] {
  --auth-dial: 0.3;
  --auth-dial-minor: 0.13;
  --auth-ring: 0.12;
  --auth-hours: 0.45;
  --auth-glow: 0.85;
  --auth-card-bg: rgba(19, 19, 30, 0.66);
  --auth-card-edge: 0.7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --auth-dial: 0.3;
    --auth-dial-minor: 0.13;
    --auth-ring: 0.12;
    --auth-hours: 0.45;
    --auth-glow: 0.85;
    --auth-card-bg: rgba(19, 19, 30, 0.66);
    --auth-card-edge: 0.7;
  }
}

/* ============================================================
 * Page layout
 * ============================================================ */

.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

/* JS がヘッダーを描くまで、同じ大きさのガラスのバーを置いておく（描いたときにずれない） */
.auth-page #header:empty {
  display: block;
  padding: 12px clamp(10px, 2vw, 24px) 0;
}

.auth-page #header:empty::before {
  content: "";
  display: block;
  max-width: 1440px;
  height: 58px;
  margin: 0 auto;
  border-radius: var(--radius-3);
  background: var(--surface-strong);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--highlight), var(--shadow);
}

.auth {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(400px, 0.88fr);
  align-items: stretch;
  gap: clamp(16px, 2.5vw, 40px);
  width: 100%;
  max-width: 1440px;
  min-height: 0;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px) clamp(10px, 2vw, 24px) 8px;
}

/* ============================================================
 * Stage（左）
 * ============================================================ */

.auth-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: min(740px, calc(100svh - 170px));
  padding: clamp(28px, 4vw, 60px);
  border-radius: var(--radius-3);
  overflow: hidden;
}

.auth-stage-copy {
  position: relative;
  z-index: 2;
  max-width: 40rem;
}

/* 文字の後ろだけ、リングの線をやわらげる（見出しが 2 行になっても読みやすく） */
.auth-stage-copy::before {
  content: "";
  position: absolute;
  inset: -48px -72px -36px -56px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--bg) 62%, transparent), transparent);
}

.auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-mute);
  animation: auth-rise 0.9s var(--ease) 0.08s both;
}

.auth-eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--grad-aurora);
  box-shadow: 0 0 10px color-mix(in srgb, var(--iris) 70%, transparent);
}

.auth-stage-title {
  margin: 0;
  font-family: var(--font-mincho);
  font-weight: 700;
  font-size: clamp(2.4rem, 1rem + 3.1vw, 4.25rem);
  line-height: 1.18;
  letter-spacing: 0.02em;
  color: var(--ink);
  word-break: keep-all;
  word-break: auto-phrase;
  overflow-wrap: anywhere;
  text-wrap: balance;
  animation: auth-rise 1.1s var(--ease) 0.16s both;
}

.auth-stage-lead {
  margin: 20px 0 0;
  max-width: 30em;
  font-size: clamp(0.95rem, 0.86rem + 0.3vw, 1.1rem);
  line-height: 1.85;
  color: var(--ink-soft);
  animation: auth-rise 1.1s var(--ease) 0.3s both;
}

/* --- 時計のリング（24 時間の目盛り・8 店舗の光の粒・ゆっくり回る光の弧） --- */
.auth-orbit {
  position: absolute;
  z-index: 0;
  top: 39%;
  left: 58%;
  width: min(540px, 74%, 60vh);
  aspect-ratio: 1;
  color: var(--ink);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: auth-orbit-in 1.8s var(--ease) both;
}

.auth-orbit svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.auth-orbit-glow {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side at 62% 34%, rgba(123, 97, 255, 0.55), transparent),
    radial-gradient(closest-side at 32% 66%, rgba(47, 199, 224, 0.4), transparent),
    radial-gradient(closest-side at 72% 78%, rgba(255, 138, 91, 0.32), transparent);
  filter: blur(48px);
  opacity: var(--auth-glow);
  animation: auth-breathe 10s ease-in-out infinite alternate;
}

.auth-orbit-minor,
.auth-orbit-major,
.auth-orbit-track,
.auth-orbit-ring {
  fill: none;
  stroke: currentColor;
}

/* 目盛り（96 本＝15 分ごと、24 本＝1 時間ごと）。pathLength で等間隔に切る */
.auth-orbit-minor {
  stroke-opacity: var(--auth-dial-minor);
  stroke-width: 7;
  stroke-dasharray: 0.06 0.94;
  stroke-dashoffset: 0.03;
}

.auth-orbit-major {
  stroke-opacity: var(--auth-dial);
  stroke-width: 14;
  stroke-dasharray: 0.03 0.97;
  stroke-dashoffset: 0.015;
}

.auth-orbit-track {
  stroke-opacity: var(--auth-ring);
  stroke-width: 1;
}

.auth-orbit-hours {
  fill: currentColor;
  fill-opacity: var(--auth-hours);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* 8 店舗の光の粒（外周をゆっくり逆回り） */
.auth-orbit-stores {
  animation: auth-spin 240s linear infinite reverse;
}

.auth-orbit-stores circle {
  fill: currentColor;
  fill-opacity: 0.32;
}

.auth-orbit-stores circle.is-lit {
  fill: #ff8a5b;
  fill-opacity: 1;
  filter: drop-shadow(0 0 6px rgba(255, 138, 91, 0.9));
}

.auth-orbit-stores circle.is-lit-2 {
  fill: #2fc7e0;
  fill-opacity: 1;
  filter: drop-shadow(0 0 6px rgba(47, 199, 224, 0.9));
}

/* ロゴのリングと光の弧（ゆっくり回る） */
.auth-orbit-light {
  animation: auth-spin 96s linear infinite;
  will-change: transform;
}

.auth-orbit-ring {
  stroke-opacity: calc(var(--auth-ring) + 0.04);
  stroke-width: 2;
}

.auth-orbit-arc,
.auth-orbit-arc-glow {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  animation: auth-draw 2s var(--ease-in-out) 0.25s both;
}

.auth-orbit-arc {
  stroke-width: 9;
}

.auth-orbit-arc-glow {
  stroke-width: 18;
  opacity: 0.7;
}

.auth-orbit-orb {
  fill: #ff8a5b;
  animation: auth-pop 0.9s var(--ease) 1.9s both;
}

.auth-orbit-orb-glow {
  fill: #ff8a5b;
  opacity: 0.85;
  animation: auth-pop 1.2s var(--ease) 1.9s both;
}

.auth-orbit-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 7%, transparent);
}

/* ============================================================
 * Form column（右）
 * ============================================================ */

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 16px;
}

.auth-main > [id] {
  width: 100%;
  max-width: 456px;
}

.auth-footer {
  padding: 10px 16px 22px;
}

/* ============================================================
 * Card — 認証フォームの共通部品（各コンポーネントの HTML が使う）
 * ============================================================ */

.auth-card {
  position: relative;
  isolation: isolate;
  padding: 36px 36px 32px;
  border-radius: var(--radius-3);
  background: var(--auth-card-bg);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--highlight), var(--shadow-lg);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
}

/* 縁にうっすらオーロラの光 */
.auth-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(155deg, rgba(123, 97, 255, 0.9), rgba(47, 199, 224, 0.25) 32%, transparent 52%, transparent 70%, rgba(255, 138, 91, 0.6));
  opacity: var(--auth-card-edge);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* マウスの位置に淡い光（front_end/lib/motion/spotlight.ts が --mx / --my を更新する） */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, -400px) var(--my, -400px), color-mix(in srgb, var(--iris) 12%, transparent), transparent 62%);
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}

.auth-card:hover::before {
  opacity: 1;
}

.auth-card-head {
  margin-bottom: 24px;
}

.auth-card-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-mute);
}

.auth-card-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grad-aurora);
  box-shadow: 0 0 12px color-mix(in srgb, var(--iris) 70%, transparent);
}

.auth-card-title {
  margin: 0 0 8px;
  font-family: var(--font-mincho);
  font-size: clamp(1.55rem, 1.35rem + 0.6vw, 1.85rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.auth-card-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--ink-mute);
}

.auth-card-text + .auth-card-text {
  margin-top: 4px;
}

/* --- 入力欄（左にアイコン） --- */
.auth-form .form-group {
  margin-bottom: 18px;
}

.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.auth-field {
  position: relative;
}

.auth-field .form-control {
  height: 48px;
  padding-left: 44px;
  border-radius: 12px;
}

.auth-field-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
  pointer-events: none;
  transform: translateY(-50%);
  transition: color var(--dur-2) var(--ease);
}

.auth-field:focus-within .auth-field-icon {
  color: var(--accent);
}

/* 入力して離れたあとに形式が合わない欄（メールアドレスなど）は、赤い枠でそっと知らせる */
.auth-form .form-control:user-invalid {
  border-color: color-mix(in srgb, var(--danger) 65%, transparent);
}

.auth-form .form-control:user-invalid:focus {
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.auth-field:has(.form-control:user-invalid) .auth-field-icon {
  color: var(--danger);
}

/* 文字だけのボタン（パスワードを忘れた方 など） */
.auth-text-button {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}

.auth-text-button:hover {
  text-decoration-color: currentColor;
}

/* --- 送信ボタン --- */
.auth-submit {
  width: 100%;
  height: 50px;
  margin-top: 6px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.auth-submit svg {
  transition: transform 0.4s var(--ease);
}

.auth-submit:hover svg {
  transform: translateX(3px);
}

/* --- Google / LINE --- */
.auth-social {
  display: grid;
  gap: 10px;
}

.btn.btn-social {
  position: relative;
  width: 100%;
  height: 48px;
  padding: 0 52px;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.btn-social-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  transform: translateY(-50%);
}

.btn.btn-line {
  color: #ffffff;
  background: #06c755;
  border-color: #06c755;
  box-shadow: 0 12px 26px -16px rgba(6, 199, 85, 0.9);
}

/* LINE のボタンはロゴと文字の間に細い線 */
.btn-line .btn-social-icon::after {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  right: -10px;
  width: 1px;
  background: rgba(0, 0, 0, 0.12);
}

.btn.btn-line:hover {
  color: #ffffff;
  background: #05b34c;
  border-color: #05b34c;
}

.btn.btn-line:active {
  background: #048b3b;
  border-color: #048b3b;
}

.btn.btn-google {
  color: #1f1f1f;
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(21, 20, 27, 0.06);
}

.btn.btn-google:hover {
  color: #1f1f1f;
  background: #f7f8fa;
  border-color: #c4c7cc;
}

:root[data-theme="dark"] .btn.btn-google {
  border-color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.btn-google {
    border-color: #ffffff;
  }
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 20px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  white-space: nowrap;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule-strong));
}

.auth-divider::after {
  background: linear-gradient(90deg, var(--rule-strong), transparent);
}

/* --- カードの下の案内（新規登録・ログインへ） --- */
.auth-alt {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-mute);
}

.auth-alt a {
  margin-left: 4px;
  font-weight: 700;
}

.auth-terms {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--ink-mute);
}

/* --- 登録の流れ（1 メール → 2 確認 → 3 パスワード） --- */
.auth-steps {
  display: flex;
  gap: 8px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
}

.auth-steps li {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--ink-mute);
}

.auth-steps li::before {
  content: "";
  height: 3px;
  border-radius: 3px;
  background: var(--rule-soft);
}

.auth-steps li.is-done::before {
  background: color-mix(in srgb, var(--accent) 50%, transparent);
}

.auth-steps li.is-current {
  color: var(--ink);
}

.auth-steps li.is-current::before {
  background: var(--grad-aurora);
  box-shadow: 0 0 12px color-mix(in srgb, var(--iris) 60%, transparent);
}

.auth-steps b {
  font-family: var(--font-display);
  font-weight: 700;
  margin-right: 4px;
  color: inherit;
}

/* --- パスワードの条件 --- */
.auth-note {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--ink-soft);
}

.auth-note p {
  margin: 0;
  color: inherit;
}

.auth-note code {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--muted-soft);
  word-break: break-all;
}

/* --- 確認するメールアドレス --- */
.auth-email {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 22px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--muted-soft);
  border: 1px solid var(--rule-soft);
}

.auth-email-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}

.auth-email dl {
  min-width: 0;
  margin: 0;
}

.auth-email dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

.auth-email dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--ink);
  word-break: break-all;
}

/* 日本語の文を、文節で自然に折り返す（1 文字だけ次の行に残さない） */
.auth-stage-lead,
.auth-card-text,
.auth-terms,
.auth-alt,
.auth-note p {
  text-wrap: pretty;
  word-break: auto-phrase;
}

/* ============================================================
 * Motion
 * ============================================================ */

@keyframes auth-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
    filter: blur(8px);
  }
}

@keyframes auth-orbit-in {
  from {
    opacity: 0;
    scale: 0.94;
  }
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-draw {
  from {
    stroke-dashoffset: 1;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@keyframes auth-pop {
  from {
    opacity: 0;
  }
}

@keyframes auth-breathe {
  from {
    transform: scale(0.94) rotate(0deg);
  }

  to {
    transform: scale(1.06) rotate(18deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-eyebrow,
  .auth-stage-title,
  .auth-stage-lead,
  .auth-orbit,
  .auth-orbit-light,
  .auth-orbit-stores,
  .auth-orbit-glow,
  .auth-orbit-arc,
  .auth-orbit-arc-glow,
  .auth-orbit-orb,
  .auth-orbit-orb-glow {
    animation: none !important;
  }

  .auth-orbit-arc,
  .auth-orbit-arc-glow {
    stroke-dasharray: none;
  }
}

/* ============================================================
 * Responsive
 * ============================================================ */

@media (max-width: 1100px) {
  .auth {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 1fr);
  }

  .auth-orbit {
    left: 50%;
  }
}

/* タブレット縦・スマホ: ステージはカードの上の細い帯 */
@media (max-width: 900px) {
  .auth-page #header:empty {
    padding: 10px 10px 0;
  }

  .auth {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px 12px 8px;
  }

  .auth-stage {
    justify-content: flex-start;
    width: 100%;
    max-width: 560px;
    min-height: 0;
    margin: 0 auto;
    padding: 26px 22px 24px;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    border: 1px solid var(--rule-soft);
    box-shadow: var(--highlight);
  }

  .auth-stage-copy {
    max-width: 76%;
  }

  .auth-stage-copy::before {
    display: none;
  }

  .auth-eyebrow {
    margin-bottom: 10px;
    font-size: 0.66rem;
  }

  .auth-eyebrow::before {
    width: 18px;
  }

  .auth-stage-title {
    font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.4rem);
  }

  .auth-stage-lead {
    margin-top: 10px;
    font-size: 0.84rem;
    line-height: 1.7;
  }

  /* 帯の右端に大きなリングの左半分だけを見せる（光の弧は見える側に止めておく） */
  .auth-orbit {
    top: 50%;
    left: auto;
    right: -172px;
    width: 300px;
    transform: translateY(-50%);
  }

  .auth-orbit-dial,
  .auth-orbit-stores,
  .auth-orbit-hub {
    display: none;
  }

  .auth-orbit-glow {
    inset: 8%;
    filter: blur(36px);
  }

  .auth-orbit-light {
    animation: none;
    transform: rotate(196deg);
  }

  .auth-orbit-ring {
    stroke-width: 3;
  }

  .auth-orbit-arc {
    stroke-width: 12;
  }

  .auth-main {
    padding: 0 0 8px;
  }

  .auth-main > [id] {
    max-width: 560px;
  }
}

@media (max-width: 768px) {
  .auth-page #header:empty::before {
    height: 56px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 28px 20px 24px;
  }

  .auth-stage-copy {
    max-width: 86%;
  }

  .btn.btn-social {
    padding: 0 44px;
  }
}
