/* TrustPanel branded loaders
 * Reference: design-references/loading-animations.html
 * Variants: .tp-loader--orbit (generic), .tp-loader--typing (AI drafting), .tp-loader--stars (reviews)
 * Sizes: .tp-loader--lg (splash), default (card/inline), .tp-loader--sm (button) */

.tp-loader {
    display: inline-block;
    position: relative;
    line-height: 0;
    color: #0b1212;
    --tp-accent: #1C9548;
    width: 56px;
    height: 56px;
}
.tp-loader svg { display: block; width: 100%; height: 100%; }

/* Size tiers (override the default 56x56) */
.tp-loader.tp-loader--lg { width: 88px; height: 88px; }
.tp-loader.tp-loader--sm { width: 18px; height: 18px; }
.tp-loader.tp-loader--xs { width: 14px; height: 14px; }

/* ---------- Orbit variant ---------- */
.tp-loader--orbit .tp-orbit-wrap { width: 100%; height: 100%; position: relative; }
.tp-loader--orbit .tp-big {
    position: absolute;
    inset: 16%;
    animation: tp-breath 1.6s ease-in-out infinite;
}
.tp-loader--orbit .tp-orbit {
    position: absolute;
    inset: 0;
    animation: tp-spin 3s linear infinite;
}
.tp-loader--orbit .tp-small {
    position: absolute;
    right: 0;
    bottom: 3%;
    width: 38%;
    height: 38%;
    animation: tp-counter 3s linear infinite;
}
@keyframes tp-spin    { to { transform: rotate(360deg); } }
@keyframes tp-counter { to { transform: rotate(-360deg); } }
@keyframes tp-breath  { 0%,100% { transform: scale(1); } 50% { transform: scale(0.96); } }

/* ---------- Typing variant (for AI drafting) ---------- */
.tp-loader--typing .tp-typing-wrap { width: 100%; height: 100%; position: relative; }
.tp-loader--typing .tp-big, .tp-loader--typing .tp-small { position: absolute; }
.tp-loader--typing .tp-big {
    width: 62%; height: 72%; top: 0; left: 0;
    opacity: 0;
    animation: tp-v4-big 2.4s cubic-bezier(.2,.7,.2,1) infinite;
}
.tp-loader--typing .tp-small {
    width: 48%; height: 56%; right: 0; bottom: 0;
    opacity: 0;
    animation: tp-v4-small 2.4s cubic-bezier(.2,.7,.2,1) infinite;
}
@keyframes tp-v4-big {
    0%   { opacity: 0; transform: translateY(6%) scale(.9); }
    18%  { opacity: 1; transform: translateY(0) scale(1); }
    85%  { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-4%) scale(.96); }
}
@keyframes tp-v4-small {
    0%,25% { opacity: 0; transform: translateY(8%) scale(.85); }
    45%    { opacity: 1; transform: translateY(0) scale(1); }
    85%    { opacity: 1; transform: translateY(0) scale(1); }
    100%   { opacity: 0; transform: translateY(-4%) scale(.96); }
}

/* ---------- Stars variant (for review loading) ---------- */
.tp-loader--stars {
    width: auto;
    height: auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.tp-loader--stars .tp-bubble {
    width: 64px; height: 54px;
    animation: tp-bob 1.8s ease-in-out infinite;
}
@keyframes tp-bob {
    0%,100% { transform: translateY(0) rotate(-2deg); }
    50%     { transform: translateY(-6px) rotate(2deg); }
}
.tp-loader--stars .tp-stars { display: flex; gap: 6px; }
.tp-loader--stars .tp-stars svg {
    width: 16px; height: 16px;
    fill: #ece9e2;
    opacity: 0.35;
    animation: tp-star 2.5s steps(1, end) infinite;
}
.tp-loader--stars .tp-stars svg:nth-child(1) { animation-delay: 0s;   }
.tp-loader--stars .tp-stars svg:nth-child(2) { animation-delay: .4s;  }
.tp-loader--stars .tp-stars svg:nth-child(3) { animation-delay: .8s;  }
.tp-loader--stars .tp-stars svg:nth-child(4) { animation-delay: 1.2s; }
.tp-loader--stars .tp-stars svg:nth-child(5) { animation-delay: 1.6s; }
@keyframes tp-star {
    0%      { fill: #ece9e2; opacity: 0.35; }
    8%,84%  { fill: var(--tp-accent); opacity: 1; }
    100%    { fill: #ece9e2; opacity: 0.35; }
}

/* Dark-theme adjustment */
[data-theme="dark"] .tp-loader--stars .tp-stars svg,
.tp-loader--on-dark .tp-stars svg {
    fill: #2a322e;
    animation-name: tp-star-dark;
}
@keyframes tp-star-dark {
    0%      { fill: #2a322e; opacity: 0.4; }
    8%,84%  { fill: var(--tp-accent); opacity: 1; }
    100%    { fill: #2a322e; opacity: 0.4; }
}

/* ---------- Splash layout (progress bar + tagline) ---------- */
.tp-splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}
.tp-splash__progress {
    width: 160px;
    height: 3px;
    background: #f1efe8;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.tp-splash__progress::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 40%;
    background: var(--tp-accent, #1C9548);
    border-radius: 999px;
    animation: tp-progress 1.4s ease-in-out infinite;
}
@keyframes tp-progress {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}
.tp-splash__tagline {
    font-size: 12.5px;
    color: #8a9090;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-family: 'Inter', 'Geist', ui-sans-serif, system-ui, sans-serif;
}
[data-theme="dark"] .tp-splash__progress { background: #1e2521; }
[data-theme="dark"] .tp-splash__tagline  { color: #7a857f; }

/* Inverts bubble fill when placed on dark backgrounds, or via .tp-loader--on-dark */
.tp-loader--on-dark .tp-big-fill   { fill: #eef2ee; }
.tp-loader--on-dark .tp-big-inner  { fill: #131816; }
