/* ============================================================
 * 朝圣仙门 · 入山加载器
 * 3D 立方体 spinner 参考 Uiverse.io 组件 "nasty-fireant-91"
 * 原作者 reesaldles：https://uiverse.io/reesaldles/nasty-fireant-91
 * 本项目将其改写为宣纸 / 墨线 / 朱砂的水墨配色，并用于启动与表单忙碌态。
 *
 * MIT License
 *
 * Copyright (c) 2023 Uiverse.io
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * ============================================================ */

.ink-loader {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 78% 34% at 50% 108%, rgba(88, 108, 92, .15), transparent 70%),
    radial-gradient(ellipse 52% 24% at 23% 104%, rgba(73, 92, 77, .12), transparent 72%),
    radial-gradient(ellipse 48% 26% at 79% 106%, rgba(73, 92, 77, .10), transparent 72%),
    radial-gradient(ellipse 62% 56% at 50% 42%, rgba(255, 253, 247, .98), rgba(247, 242, 231, .97) 52%, rgba(239, 232, 219, .99) 100%);
  transition: opacity .52s ease, visibility .52s ease;
}

.ink-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 46%, transparent 42%, rgba(64, 51, 31, .06) 100%),
    repeating-linear-gradient(0deg, rgba(120, 100, 70, .018) 0 1px, transparent 1px 3px);
}

.ink-loader::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(154, 116, 40, .14);
  pointer-events: none;
}

.ink-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ink-loader-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 34px;
}

.ink-loader-seal {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 3px;
  background: linear-gradient(150deg, #b64735, #8f2a1d);
  color: #fbf5e9;
  font-family: var(--font-display, "STKaiti", "KaiTi", serif);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(120, 40, 25, .22), inset 0 0 0 1px rgba(255, 240, 214, .22);
}

.ink-loader-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  perspective: 340px;
}

.ink-loader-stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border: 1px solid rgba(154, 116, 40, .18);
  border-radius: 50%;
  box-shadow: 0 0 42px rgba(200, 165, 92, .12);
}

.ink-loader-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 66px;
  height: 10px;
  margin-left: -33px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(42, 45, 35, .26), transparent 70%);
  filter: blur(2.5px);
}

/* 3D 立方体：尺寸由 --cube-size 控制，六面按透视拼合 */
.ink-cube {
  --cube-size: 72px;
  --cube-half: calc(var(--cube-size) / 2);
  position: relative;
  width: var(--cube-size);
  height: var(--cube-size);
  transform-style: preserve-3d;
  animation: ink-cube-spin 2s infinite ease;
}

.ink-cube > i {
  position: absolute;
  inset: 0;
  display: block;
  border: 2px solid rgba(53, 43, 27, .74);
  background: linear-gradient(145deg, #fffdf7, #efe6d4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32);
}

.ink-cube > i:nth-of-type(1) {
  transform: translateZ(calc(var(--cube-half) * -1)) rotateY(180deg);
  background: linear-gradient(145deg, #bd4c39, #922d1f);
  border-color: #782216;
}

.ink-cube > i:nth-of-type(2) {
  transform: rotateY(-270deg) translateX(50%);
  transform-origin: top right;
  background: linear-gradient(200deg, #e5d0a4, #c8a970);
  border-color: #9a7a3b;
}

.ink-cube > i:nth-of-type(3) {
  transform: rotateY(270deg) translateX(-50%);
  transform-origin: center left;
  background: linear-gradient(160deg, #fbf3df, #e8d3a6);
}

.ink-cube > i:nth-of-type(4) {
  transform: rotateX(90deg) translateY(-50%);
  transform-origin: top center;
  background: linear-gradient(180deg, #fffdf8, #f5e8c9);
}

.ink-cube > i:nth-of-type(5) {
  transform: rotateX(-90deg) translateY(50%);
  transform-origin: bottom center;
  background: linear-gradient(0deg, #c9b58f, #e6d7b9);
}

.ink-cube > i:nth-of-type(6) {
  transform: translateZ(var(--cube-half));
  background: linear-gradient(160deg, #fdfaf2, #f1e6d0);
}

.ink-cube > i:nth-of-type(6)::after {
  content: "宗";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 1px;
  background: linear-gradient(150deg, #b64735, #8f2a1d);
  color: #fbf5e9;
  font-family: var(--font-display, "STKaiti", "KaiTi", serif);
  font-size: calc(var(--cube-size) * .21);
  line-height: 1;
  box-shadow: 0 1px 2px rgba(80, 28, 18, .22);
}

@keyframes ink-cube-spin {
  0% {
    transform: rotate(45deg) rotateX(-25deg) rotateY(25deg);
  }

  50% {
    transform: rotate(45deg) rotateX(-385deg) rotateY(25deg);
  }

  100% {
    transform: rotate(45deg) rotateX(-385deg) rotateY(385deg);
  }
}

.ink-loader-name {
  padding-left: .34em;
  font-family: var(--font-display, "STKaiti", "KaiTi", "Songti SC", serif);
  font-size: clamp(25px, 2.4vw, 33px);
  font-weight: 700;
  letter-spacing: .34em;
  color: var(--ink, #2f2b22);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}

.ink-loader-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: .28em;
  font-family: var(--font-kai, "STKaiti", "KaiTi", serif);
  font-size: 11px;
  letter-spacing: .28em;
  color: var(--ink-3, #8a7a5e);
}

.ink-loader-sub::before,
.ink-loader-sub::after {
  content: "";
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(154, 116, 40, .45));
}

.ink-loader-sub::after {
  background: linear-gradient(90deg, rgba(154, 116, 40, .45), transparent);
}

/* 表单按钮内的迷你立方体 */
.ink-cube.is-inline {
  --cube-size: 15px;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: -2px;
  margin-right: 7px;
  animation-duration: 1.25s;
}

.ink-cube.is-inline > i {
  border-width: 1px;
  border-color: rgba(251, 247, 238, .82);
  background: rgba(251, 247, 238, .10);
  box-shadow: none;
}

.ink-cube.is-inline > i:nth-of-type(1) {
  border-color: rgba(251, 247, 238, .72);
  background: rgba(70, 18, 10, .18);
}

.ink-cube.is-inline > i:nth-of-type(2),
.ink-cube.is-inline > i:nth-of-type(6) {
  border-color: rgba(255, 236, 194, .9);
}

body.sect .auth-submit.is-loading,
body.sect .auth-guest.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: wait;
}

body.sect .auth-submit.is-loading {
  letter-spacing: .24em;
  padding-left: .24em;
}

/* 小于 720px：加载器收小，避免抢占小屏 */
@media (max-width: 720px) {
  .ink-loader-inner {
    gap: 14px;
    padding: 22px 26px;
  }

  .ink-loader-seal {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

  .ink-loader-stage {
    width: 110px;
    height: 110px;
  }

  .ink-loader-stage::before {
    width: 92px;
    height: 92px;
    margin: -46px 0 0 -46px;
  }

  .ink-loader-stage::after {
    bottom: 10px;
    width: 44px;
    margin-left: -22px;
  }

  .ink-cube {
    --cube-size: 58px;
  }

  .ink-loader-name {
    font-size: 24px;
    letter-spacing: .3em;
  }

  .ink-loader-sub {
    font-size: 10px;
    letter-spacing: .22em;
  }

  .ink-loader-sub::before,
  .ink-loader-sub::after {
    width: 14px;
  }

  .ink-loader::after {
    inset: 12px;
  }
}

/* 尊重系统的减少动态偏好：不旋转，只保留静态立方体 */
@media (prefers-reduced-motion: reduce) {
  .ink-cube,
  .ink-cube.is-inline {
    animation: none;
    transform: rotate(45deg) rotateX(-25deg) rotateY(25deg);
  }

  .ink-loader {
    transition: opacity .2s ease, visibility .2s ease;
  }
}
