/* ============================================
   LOADING SCREEN — "Matcha Latte" brewing cup
   Pure CSS, on-palette (sage + blush + cream).
   ============================================ */

/* ── Full-screen overlay ── */
.status-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  background-color: #F8F6F3;
  background-image:
    radial-gradient(circle at 20% 25%, rgba(184,212,205,0.55), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(245,221,216,0.55), transparent 45%),
    radial-gradient(circle, #E8C5BF 1px, transparent 1px),
    radial-gradient(circle, #88B5A8 0.8px, transparent 0.8px);
  background-size: 100% 100%, 100% 100%, 60px 60px, 45px 45px;
  background-position: 0 0, 0 0, 10px 10px, 55px 20px;
  opacity: 1;
  animation: loaderFadeIn 0.5s ease both;
  transition: opacity 0.6s ease;
  pointer-events: all;
}

/* Fade out once #app gets real content */
#app.loaded .status-loading {
  opacity: 0;
  pointer-events: none;
}

/* ── Loader scene ── */
.cafe-loader {
  position: relative;
  width: 130px;
  height: 140px;
  animation: cupBob 3.2s ease-in-out infinite;
}

/* ── Steam ── */
.cl-steam {
  position: absolute;
  top: -2px;
  left: 40px;
  width: 54px;
  height: 46px;
}
.cl-steam i {
  position: absolute;
  bottom: 0;
  width: 9px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(to top, rgba(127,169,155,0.55), rgba(127,169,155,0));
  filter: blur(2.5px);
  opacity: 0;
  animation: steamRise 2.6s ease-in-out infinite;
}
.cl-steam i:nth-child(1) { left: 4px;  animation-delay: 0s;    }
.cl-steam i:nth-child(2) { left: 22px; animation-delay: 0.55s; height: 32px; }
.cl-steam i:nth-child(3) { left: 40px; animation-delay: 1.1s;  }

/* ── Cup ── */
.cl-cup {
  position: absolute;
  left: 22px;
  bottom: 22px;
  width: 86px;
  height: 74px;
  background: linear-gradient(135deg, #ffffff, #f1ece6);
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 12px 12px 44px 44px / 12px 12px 52px 52px;
  box-shadow:
    inset 0 -8px 16px rgba(0,0,0,0.06),
    inset 0 2px 0 rgba(255,255,255,0.9),
    0 10px 26px rgba(127,169,155,0.28);
  overflow: hidden;
}

/* ── Handle ── */
.cl-handle {
  position: absolute;
  top: 48px;
  left: 100px;
  width: 24px;
  height: 30px;
  border: 7px solid #ffffff;
  border-left: none;
  border-radius: 0 50% 50% 0;
  box-shadow: 4px 4px 12px rgba(127,169,155,0.22);
}

/* ── Liquid (matcha) — fills & drains in a loop ── */
.cl-liquid {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 16%;
  background: linear-gradient(to top, #6f9b8d, #88B5A8 55%, #9ec8bc);
  animation: brewFill 2.8s ease-in-out infinite;
}
/* foam line on top of the liquid, gently sloshing */
.cl-liquid::before {
  content: '';
  position: absolute;
  top: -7px; left: -10%;
  width: 120%; height: 16px;
  background: radial-gradient(circle at 50% 60%, #f0f7f4, #d7eae3);
  border-radius: 50%;
  animation: slosh 1.6s ease-in-out infinite;
}
/* tiny rising bubbles */
.cl-liquid::after {
  content: '';
  position: absolute;
  left: 30%; bottom: 6px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  box-shadow: 16px 4px 0 -1px rgba(255,255,255,0.6),
              30px -2px 0 -2px rgba(255,255,255,0.55);
  animation: bubbles 1.9s ease-in infinite;
}

/* glass shine */
.cl-shine {
  position: absolute;
  top: 8px; left: 12px;
  width: 14px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.85), rgba(255,255,255,0));
  transform: rotate(8deg);
  z-index: 3;
}

/* ── Saucer ── */
.cl-saucer {
  position: absolute;
  left: 8px;
  bottom: 6px;
  width: 114px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5DDD8, #E8C5BF);
  box-shadow: 0 10px 20px rgba(232,197,191,0.45), inset 0 2px 0 rgba(255,255,255,0.6);
}

/* ── Coffee bean dropping into the cup ── */
.cl-bean {
  position: absolute;
  top: -28px;
  left: 60px;
  width: 12px;
  height: 16px;
  background: linear-gradient(135deg, #7FA99B, #6f9b8d);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  opacity: 0;
  animation: beanDrop 2.8s ease-in infinite;
}
.cl-bean::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-left: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  transform: rotate(12deg);
}

/* ── Loading text ── */
.status-loading > p {
  font-family: var(--font-fa);
  font-size: clamp(0.9rem, 2.6vw, 1.05rem);
  font-weight: 700;
  color: #7FA99B;
  letter-spacing: 0.02em;
  position: relative;
}
.status-loading > p::after {
  content: '';
  animation: dots 1.6s steps(1, end) infinite;
}

/* ── Keyframes ── */
@keyframes loaderFadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes cupBob {
  0%, 100% { transform: translateY(0)   rotate(0deg); }
  50%      { transform: translateY(-8px) rotate(-1.5deg); }
}

@keyframes steamRise {
  0%   { opacity: 0;    transform: translateY(0)    translateX(0)   scaleY(0.6); }
  25%  { opacity: 0.8;  }
  60%  { transform: translateY(-18px) translateX(4px) scaleY(1.1); }
  100% { opacity: 0;    transform: translateY(-34px) translateX(-3px) scaleY(1.4); }
}

@keyframes brewFill {
  0%   { height: 16%; }
  45%  { height: 74%; }
  70%  { height: 70%; }
  100% { height: 16%; }
}

@keyframes slosh {
  0%, 100% { transform: translateX(-3px) rotate(-2deg); }
  50%      { transform: translateX(3px)  rotate(2deg);  }
}

@keyframes bubbles {
  0%   { opacity: 0; transform: translateY(0); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

@keyframes beanDrop {
  0%, 12%   { opacity: 0; top: -28px; transform: rotate(0deg); }
  16%       { opacity: 1; }
  34%       { opacity: 1; top: 34px;  transform: rotate(220deg); }
  40%, 100% { opacity: 0; top: 40px;  transform: rotate(240deg); }
}

@keyframes dots {
  0%   { content: '';     }
  25%  { content: '·';    }
  50%  { content: '··';   }
  75%  { content: '···';  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .cafe-loader,
  .cl-steam i,
  .cl-liquid,
  .cl-liquid::before,
  .cl-liquid::after,
  .cl-bean,
  .status-loading > p::after { animation: none !important; }
  .cl-liquid { height: 60%; }
  .cl-bean { display: none; }
}
