/* ==========================================================
   rin姫 loading screen
   Uses the color + font variables from assets/styles.css,
   so link this file AFTER styles.css.
   ========================================================== */

/* ---- page state while loading ---- */
html.loader-skip #rin-loader { display: none; }
html.is-loading body { overflow: hidden; }
/* keep the scrollbar's space reserved while scroll is locked, so the page
   doesn't shift sideways when the scrollbar comes back on exit */
html.is-loading { scrollbar-gutter: stable; }

/* hold every page animation (hero .rise, stickers, twinkles…) at its
   first frame until the loader starts leaving, so the hero still
   animates in for the visitor instead of playing hidden underneath */
html.is-loading body > :not(#rin-loader),
html.is-loading body > :not(#rin-loader) * {
  animation-play-state: paused !important;
}

/* ---- shell ---- */
#rin-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none; /* only shown once the inline script opts in, so no-JS visitors never get stuck behind it */
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg, #EDE9E4);
  font-family: var(--font-body, 'Quicksand', 'Noto Sans JP', sans-serif);
  color: var(--ink, #3A2E36);
}
html.is-loading #rin-loader,
#rin-loader[data-phase="exit"] { display: flex; }
#rin-loader[data-phase="exit"] { animation: rl-liftOut .8s cubic-bezier(.2,.8,.3,1) forwards; pointer-events: none; }

/* ---- twinkles (same as the site's starfield) ---- */
.rl-tw { position: absolute; animation: rl-twinkle 3s ease-in-out infinite; }

/* ---- stage 1: sakura progress ---- */
.rl-load { display: flex; flex-direction: column; align-items: center; gap: 22px; animation: rl-fadeIn .5s ease both; }
#rin-loader[data-phase="bloom"] .rl-load { animation: rl-bloomOut .5s cubic-bezier(.2,.8,.3,1) forwards; }
#rin-loader[data-phase="brand"] .rl-load,
#rin-loader[data-phase="exit"] .rl-load { display: none; }

.rl-flower { width: 120px; height: 120px; transform-origin: 50% 50%; animation: rl-spin 24s linear infinite; }
.rl-flower > g path,
.rl-flower > circle { transform-box: view-box; transform-origin: 0 0; animation: rl-petalGrow .7s cubic-bezier(.3,.7,.4,1) backwards; }
.rl-flower > g:nth-of-type(2) path { animation-delay: .12s; }
.rl-flower > g:nth-of-type(3) path { animation-delay: .24s; }
.rl-flower > g:nth-of-type(4) path { animation-delay: .36s; }
.rl-flower > g:nth-of-type(5) path { animation-delay: .48s; }
.rl-flower > circle { animation-duration: .5s; animation-delay: .7s; }

.rl-label { display: flex; align-items: baseline; gap: 10px; }
.rl-word { font-size: 13px; font-weight: 700; letter-spacing: 6px; text-transform: uppercase; color: var(--muted, #6B5A64); }
.rl-pct { font-family: var(--font-num, 'Outfit', sans-serif); font-weight: 600; font-size: 13px; color: var(--rose, #A8455F); min-width: 34px; }

.rl-dots { display: flex; gap: 20px; margin-top: -4px; }
.rl-dots span { width: 9px; height: 9px; border-radius: 3px; background: var(--rose-line, #E7B9C7); animation: rl-pulse 2.6s ease-in-out infinite; }
.rl-dots span:nth-child(2) { animation-delay: .33s; }
.rl-dots span:nth-child(3) { animation-delay: .66s; }
.rl-dots span:nth-child(4) { animation-delay: 1s; }

/* ---- stage 2: chord + wordmark ---- */
.rl-brand { display: none; flex-direction: column; align-items: center; gap: 12px; }
#rin-loader[data-phase="brand"] .rl-brand,
#rin-loader[data-phase="exit"] .rl-brand { display: flex; }
.rl-brand-row { display: flex; align-items: center; gap: 22px; }

.rl-staff { position: relative; width: 96px; height: 100px; }
.rl-lines { position: absolute; inset: 10px 0; display: flex; flex-direction: column; justify-content: space-between; }
.rl-lines i { display: block; height: 1.5px; background: var(--teal-line, #C6E4E4); }
.rl-note {
  position: absolute; left: 33px; width: 30px; height: 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Sans JP', sans-serif; font-size: 9px; font-weight: 700; line-height: 1; white-space: nowrap;
  animation: rl-noteIn .5s cubic-bezier(.2,.9,.3,1.3) backwards, rl-noteBob 2.4s ease-in-out infinite;
}
.rl-note--teal { top: 60px; background: var(--teal, #96D6D8); box-shadow: 0 3px 0 var(--teal-shadow, #6FB8BA); color: var(--teal-ink, #14484A); animation-delay: .25s, 1.2s; }
.rl-note--rose { top: 40px; background: var(--rose-line, #E7B9C7); box-shadow: 0 3px 0 var(--rose-soft, #C77F93); color: var(--rose-darkest, #7E3145); animation-delay: .45s, 1.5s; }
.rl-note--gold { top: 20px; background: #E8B963; box-shadow: 0 3px 0 #CFA04E; color: #6B4A1E; font-size: 9.5px; animation-delay: .65s, 1.8s; }

.rl-word-mark { position: relative; font-family: var(--font-display, 'Baloo 2', 'Noto Sans JP', cursive); font-weight: 800; font-size: 88px; line-height: 1; letter-spacing: -2px; }
.rl-ch {
  display: inline-block; color: transparent;
  background: linear-gradient(110deg, #A8455F 0 42%, #FFE4EE 50%, #A8455F 58% 100%);
  background-size: 300% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text;
  animation: rl-rise .6s cubic-bezier(.2,.8,.3,1) backwards, rl-sheen .9s ease-in-out 1.1s both;
}
.rl-ch:nth-child(2) { animation-delay: .07s, 1.17s; }
.rl-ch:nth-child(3) { animation-delay: .14s, 1.24s; }
.rl-ch:nth-child(4) { animation-delay: .21s, 1.31s; font-family: 'Noto Sans JP', sans-serif; font-size: 76px; }
.rl-spark { position: absolute; color: var(--teal, #96D6D8); opacity: 0; animation: rl-spark 1s ease-out 1.5s both; }
.rl-spark--a { right: -26px; top: -6px; font-size: 24px; }
.rl-spark--b { left: -16px; bottom: 6px; font-size: 15px; color: var(--rose-line, #E7B9C7); animation-delay: 1.65s; }
.rl-sub { font-size: 12px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; color: var(--muted, #6B5A64); animation: rl-fadeIn .6s ease .7s both; }

/* ---- phones ---- */
@media (max-width: 520px) {
  .rl-brand-row { gap: 12px; }
  .rl-staff { transform: scale(.75); margin: 0 -12px; }
  .rl-word-mark { font-size: 60px; }
  .rl-ch:nth-child(4) { font-size: 52px; }
  .rl-sub { font-size: 10px; letter-spacing: 2px; }
}

/* ---- keyframes ---- */
@keyframes rl-twinkle { 0%,100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes rl-spin { to { transform: rotate(360deg); } }
@keyframes rl-fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rl-petalGrow { 0% { opacity: 0; transform: scale(0); } 70% { opacity: 1; transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
@keyframes rl-pulse { 0%,100% { background: #E7B9C7; transform: scale(.85); } 25% { background: #A8455F; transform: scale(1.15); } 50% { background: #E7B9C7; transform: scale(.85); } }
@keyframes rl-bloomOut { 0% { opacity: 1; transform: scale(1); } 40% { opacity: 1; transform: scale(1.08); } 100% { opacity: 0; transform: scale(.9); } }
@keyframes rl-noteIn { 0% { opacity: 0; transform: translateY(-22px) rotate(-20deg); } 100% { opacity: 1; transform: none; } }
@keyframes rl-noteBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes rl-rise { 0% { opacity: 0; transform: translateY(26px); } 100% { opacity: 1; transform: none; } }
@keyframes rl-sheen { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
@keyframes rl-spark { 0% { opacity: 0; transform: scale(.4) rotate(0); } 35% { opacity: 1; transform: scale(1.2) rotate(18deg); } 100% { opacity: 0; transform: scale(.8) rotate(30deg); } }
@keyframes rl-liftOut { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-30px); } }

/* ---- reduced motion: no spin, bounce, twinkle or wordmark;
        the petals still fill with progress, then a quick fade ---- */
@media (prefers-reduced-motion: reduce) {
  #rin-loader *, #rin-loader *::before, #rin-loader *::after { animation: none !important; }
  .rl-tw { display: none; }
  #rin-loader[data-phase="exit"] { animation: rl-fadeOut .25s ease forwards; }
}
@keyframes rl-fadeOut { to { opacity: 0; } }
