/* ===== SearchMania 読み込み画面：どの案でも使う共通部分 =====
   これに patterns/ の案の CSS を1つ重ねて使う。html に .sm-loading が付いている間だけ表示される。 */

html.sm-loading { overflow: hidden; }

/* data-sm-wait を付けた部分（ヒーローなど）の動きは、読み込み画面が閉じ始めるまで止めておく */
html.sm-loading:not(.sm-leaving) [data-sm-wait],
html.sm-loading:not(.sm-leaving) [data-sm-wait] * { animation-play-state: paused !important; }

.sm-loader { display: none; }
html.sm-loading .sm-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(66,133,244,.16) 0%, rgba(66,133,244,0) 70%),
    radial-gradient(120% 90% at 50% 40%, #102760 0%, #0a1a3a 55%, #060f24 100%);
  color: #fff;
  cursor: pointer;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .65s cubic-bezier(.4,0,.2,1) .5s, visibility 0s linear 1.15s;
  /* JS が動かなかったときの保険：12秒で自動的に消える */
  animation: smFailsafe 0s linear 12s forwards;
}
@keyframes smFailsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

.sm-loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.4vh, 22px);
}

.sm-loader__mark {
  display: block;
  width: min(58vmin, 340px);
  height: auto;
  overflow: visible;
  transform-origin: 48.9% 47.6%; /* 地球儀の中心 */
  transition: transform 1s cubic-bezier(.7,0,.84,0), opacity .45s ease .5s, filter .7s ease;
}

/* ---------- 案どうしで使い回す動き ---------- */
/* 線が描かれる */
.sm-loader .d {
  /* 1.02 ずらして、描き始める前の線の端に丸い点が残らないようにする */
  stroke-dasharray: 1 1.1;
  stroke-dashoffset: 1.02;
  animation: smDraw var(--t, .6s) cubic-bezier(.65,0,.35,1) var(--d, 0s) forwards;
}
@keyframes smDraw { to { stroke-dashoffset: 0; } }

/* 点がはじける */
.sm-loader .n {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0);
  animation: smPop .5s cubic-bezier(.34,1.7,.64,1) var(--d, 0s) forwards;
}
@keyframes smPop { to { transform: scale(1); } }

/* 虫めがねの青い光 */
.sm-loader .glow { opacity: 0; animation: smGlow 1.4s ease-out var(--d, 2.3s) forwards; }
@keyframes smGlow { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: .5; } }

/* 回路を流れる光（待っている間くり返す） */
.sm-loader .p {
  stroke: #8ab8ff;
  stroke-dasharray: .16 1.4;
  stroke-dashoffset: .16;
  opacity: 0;
  animation: smPulse 1.7s cubic-bezier(.4,0,.6,1) var(--d, 2.6s) infinite;
}
@keyframes smPulse {
  0%   { stroke-dashoffset: .16; opacity: 0; }
  12%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { stroke-dashoffset: -1; opacity: 0; }
}

/* 先端のまたたき */
.sm-loader .tw {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: smTwinkle 1.7s ease-in-out var(--d, 2.6s) infinite;
}
@keyframes smTwinkle {
  0%, 55%, 100% { opacity: 0; transform: scale(.6); }
  75%           { opacity: .95; transform: scale(1.25); }
}

/* ---------- 社名 ---------- */
.sm-loader__word {
  margin: 0;
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 5.2vmin, 40px);
  letter-spacing: .02em;
  line-height: 1;
  white-space: nowrap;
}
.sm-loader__word span {
  display: inline-block;
  opacity: 0;
  transform: translateY(.55em);
  filter: blur(8px);
  animation: smRise .8s cubic-bezier(.16,1,.3,1) calc(var(--word-delay, 2.3s) + var(--i) * 45ms) forwards;
}
@keyframes smRise { to { opacity: 1; transform: none; filter: blur(0); } }

.sm-loader__tag {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 500;
  font-size: clamp(10px, 1.7vmin, 13px);
  letter-spacing: .7em;
  padding-left: .7em; /* 字間の分だけ中央をそろえる */
  color: #8ab8ff;
  white-space: nowrap;
  opacity: 0;
  animation: smTag 1.1s cubic-bezier(.16,1,.3,1) var(--tag-delay, 2.9s) forwards;
}
@keyframes smTag { to { opacity: 1; letter-spacing: .32em; padding-left: .32em; } }

/* ---------- 閉じるとき（案ごとに上書きする） ---------- */
html.sm-leaving .sm-loader { opacity: 0; visibility: hidden; }
html.sm-leaving .sm-loader__word,
html.sm-leaving .sm-loader__tag { transition: opacity .35s ease, transform .5s ease; opacity: 0; transform: translateY(10px); }

/* ---------- 動きを減らす設定の人には、仕上がりの形をすぐ出して静かに消す ---------- */
@media (prefers-reduced-motion: reduce) {
  .sm-loader *, .sm-loader__word span {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .2s !important;
    transition-delay: 0s !important;
  }
  html.sm-leaving .sm-loader__mark { transform: none !important; filter: none !important; }
  /* 閉じるときも幕を動かさず、その場で薄く消す */
  html.sm-leaving .sm-loader {
    transform: none !important;
    opacity: 0 !important;
    transition: opacity .2s ease, visibility 0s linear .2s !important;
  }
}
