/*
 * Site-wide loading animation (T4 「字母波浪」 lit by a gliding star).
 * Shared by the HTML bootstrap in index.html and the React <TuoyaoLoader />,
 * so it must not depend on Tailwind or index.css.
 */
.tuoyao-loader {
  --tuoyao-loader-text: #a5d3d4;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  width: 100%;
  padding: 32px 24px;
  color: var(--tuoyao-loader-text);
  font-family: "Noto Sans TC", system-ui, -apple-system, sans-serif;
  text-align: center;
}

/* Full screen with the site's navy sky. */
.tuoyao-loader--screen {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 42%, rgba(165, 211, 212, 0.12), transparent 58%),
    linear-gradient(150deg, #00162f 0%, #002b5b 52%, #001a39 100%);
}

/* Covers the page (bootstrap, Google sign-in, payment redirect). */
.tuoyao-loader--fixed {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  padding-top: max(32px, env(safe-area-inset-top, 0px));
  padding-bottom: max(32px, env(safe-area-inset-bottom, 0px));
}

/* Inside a page layout, below the header. */
.tuoyao-loader--section {
  min-height: 60vh;
  min-height: 60dvh;
}

/* Inside a card or list. */
.tuoyao-loader--compact {
  padding: 40px 0;
}

/* On white admin surfaces. */
.tuoyao-loader--light {
  --tuoyao-loader-text: #002b5b;
}

/* Fast loads finish before the content appears, so nothing flashes. */
.tuoyao-loader--delayed > * {
  animation: tuoyao-loader-in 0.3s ease 0.25s both;
}

.tuoyao-loader__word {
  position: relative;
  display: flex;
  align-items: baseline;
  padding-left: 0.28em;
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 500;
  letter-spacing: 0.28em;
  line-height: 1;
  white-space: nowrap;
  color: var(--tuoyao-loader-text);
}

/* Each letter lifts and glows just as the star passes beneath it. */
.tuoyao-loader__word > span {
  display: inline-block;
  opacity: 0.45;
  animation: tuoyao-loader-lit 3.6s ease-out infinite;
  animation-delay: calc(var(--i, 0) * 0.235s - 0.29s);
}

.tuoyao-loader__word > .tuoyao-loader__gap {
  width: 0.55em;
}

/* A small four-point star (from the logo) glides along under the letters. */
.tuoyao-loader__star {
  position: absolute;
  bottom: -0.95em;
  left: 0;
  width: 0.55em;
  height: 0.55em;
  margin-left: -0.275em;
  color: #e8f6f6;
  filter: drop-shadow(0 0 4px rgba(165, 211, 212, 0.9));
  animation: tuoyao-loader-star 3.6s linear infinite;
}

.tuoyao-loader__star svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
  animation: tuoyao-loader-twinkle 1.2s ease-in-out infinite;
}

.tuoyao-loader--light .tuoyao-loader__star {
  color: #3bceb6;
  filter: none;
}

.tuoyao-loader__message {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.12em;
  color: var(--tuoyao-loader-text);
}

.tuoyao-loader__detail {
  max-width: 24rem;
  margin: 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--tuoyao-loader-text);
  opacity: 0.72;
}

.tuoyao-loader__slow {
  max-width: 24rem;
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--tuoyao-loader-text);
  opacity: 0.8;
}

.tuoyao-loader__slow a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@keyframes tuoyao-loader-lit {
  0% { transform: translateY(0); opacity: 0.45; text-shadow: none; }
  8% { transform: translateY(-4px); opacity: 1; text-shadow: 0 0 8px rgba(165, 211, 212, 0.85); }
  26%, 100% { transform: translateY(0); opacity: 0.45; text-shadow: none; }
}

@keyframes tuoyao-loader-star {
  0% { left: 4%; opacity: 0; }
  6% { opacity: 1; }
  72% { left: 96%; opacity: 1; }
  80%, 100% { left: 96%; opacity: 0; }
}

@keyframes tuoyao-loader-twinkle {
  0%, 100% { transform: scale(0.8) rotate(0deg); }
  50% { transform: scale(1.15) rotate(45deg); }
}

@keyframes tuoyao-loader-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tuoyao-loader__word > span {
    animation: none;
    opacity: 0.9;
  }
  .tuoyao-loader__star {
    display: none;
  }
  .tuoyao-loader--delayed > * {
    animation: none;
  }
}
