/* ════════════════════════════════════════════════
   PAGE LOADER
   Full-screen transition state shown while a slow
   page is on its way. The brand mark draws itself -
   a trend line being plotted - so the wait reads as
   the product working, not as a generic spinner.
   ════════════════════════════════════════════════ */

.tp-loader {
    position: fixed;
    inset: 0;
    /* Above the tour (100010) and the upgrade gate (99999): while a page is on
       its way, nothing else should be competing for attention. */
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 0%, #101c33 0%, #070c1a 62%, #05080f 100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.32s ease, visibility 0s linear 0.32s;
}

.tp-loader[hidden] {
    display: none;
}

.tp-loader.tpl-on {
    opacity: 1;
    visibility: visible;
    /* Blocks input while the next page is being fetched, so an impatient
       second click cannot fire off a second request. */
    pointer-events: auto;
    transition: opacity 0.28s ease, visibility 0s;
}

/* The tour paints its own dim underneath. Two stacked scrims turn the screen
   to mud, so hand the background back and keep only the mark. */
body.tour-running .tp-loader,
body.tour-preload .tp-loader {
    background: rgba(5, 8, 15, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* ── Atmosphere ───────────────────────────────── */
/* A slow drifting terminal grid: barely there, but it stops the backdrop
   reading as a flat wash of navy. */
.tpl-grid {
    position: absolute;
    inset: -60px;
    background-image:
        linear-gradient(rgba(148, 197, 255, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 197, 255, 0.055) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(74% 62% at 50% 46%, #000 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(74% 62% at 50% 46%, #000 0%, transparent 100%);
    animation: tplDrift 14s linear infinite;
}

@keyframes tplDrift {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(0, -44px, 0); }
}

.tpl-glow {
    position: absolute;
    width: 46vmax;
    height: 46vmax;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.5;
}

.tpl-glow-a {
    top: -16vmax;
    left: -12vmax;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.32), transparent 66%);
    animation: tplFloatA 11s ease-in-out infinite;
}

.tpl-glow-b {
    right: -14vmax;
    bottom: -18vmax;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.34), transparent 66%);
    animation: tplFloatB 13s ease-in-out infinite;
}

@keyframes tplFloatA {
    0%, 100% { transform: translate3d(0, 0, 0)        scale(1); }
    50%      { transform: translate3d(4vmax, 3vmax, 0) scale(1.12); }
}

@keyframes tplFloatB {
    0%, 100% { transform: translate3d(0, 0, 0)          scale(1); }
    50%      { transform: translate3d(-3vmax, -4vmax, 0) scale(1.1); }
}

/* ── Stage ────────────────────────────────────── */
.tpl-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 0 24px;
    text-align: center;
}

.tp-loader.tpl-on .tpl-stage > * {
    animation: tplRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tp-loader.tpl-on .tpl-mark   { animation-delay: 0.02s; }
.tp-loader.tpl-on .tpl-word   { animation-delay: 0.09s; }
.tp-loader.tpl-on .tpl-status { animation-delay: 0.15s; }
.tp-loader.tpl-on .tpl-bar    { animation-delay: 0.21s; }

@keyframes tplRise {
    from { opacity: 0; transform: translateY(9px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── The mark ─────────────────────────────────── */
.tpl-mark {
    position: relative;
    width: 108px;
    height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tpl-arc {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}

/* An eased spin, not a linear one - it gathers pace and settles, which reads
   as an instrument taking a reading rather than a loading GIF. */
.tpl-arc-outer {
    inset: 0;
    border-top-color: #00d4ff;
    border-right-color: rgba(0, 212, 255, 0.28);
    box-shadow: 0 0 22px rgba(0, 212, 255, 0.28);
    animation: tplSpin 2.6s cubic-bezier(0.62, 0.04, 0.36, 0.98) infinite;
}

.tpl-arc-inner {
    inset: 13px;
    border-bottom-color: #6366f1;
    border-left-color: rgba(99, 102, 241, 0.26);
    box-shadow: 0 0 18px rgba(99, 102, 241, 0.24);
    animation: tplSpin 1.9s cubic-bezier(0.62, 0.04, 0.36, 0.98) infinite reverse;
}

@keyframes tplSpin {
    to { transform: rotate(360deg); }
}

.tpl-core {
    position: absolute;
    inset: 24px;
    border-radius: 22px;
    background: radial-gradient(circle at 50% 50%,
                rgba(0, 212, 255, 0.26), rgba(99, 102, 241, 0.12) 58%, transparent 72%);
    animation: tplBreathe 2.4s ease-in-out infinite;
}

@keyframes tplBreathe {
    0%, 100% { transform: scale(0.9);  opacity: 0.55; }
    50%      { transform: scale(1.08); opacity: 1; }
}

.tpl-line {
    position: relative;
    width: 46px;
    height: 46px;
    color: #00d4ff;
    filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.55));
}

/* Total path length is ~28.3 units; 30 covers it with room to spare, so the
   line draws on from the right, holds, then slides away and starts over. */
.tpl-trend {
    stroke-dasharray: 30;
    animation: tplDraw 2.4s cubic-bezier(0.55, 0, 0.3, 1) infinite;
}

@keyframes tplDraw {
    0%        { stroke-dashoffset: 30;  opacity: 0; }
    10%       { opacity: 1; }
    52%, 74%  { stroke-dashoffset: 0;   opacity: 1; }
    100%      { stroke-dashoffset: -30; opacity: 0; }
}

/* The arrow head lands the moment the line reaches the top right. */
.tpl-tip {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: tplTip 2.4s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

@keyframes tplTip {
    0%, 44%  { opacity: 0; transform: scale(0.55); }
    58%      { opacity: 1; transform: scale(1.18); }
    68%, 76% { opacity: 1; transform: scale(1); }
    100%     { opacity: 0; transform: scale(1); }
}

/* ── Wordmark ─────────────────────────────────── */
.tpl-word {
    margin: 0;
    font-family: 'Poppins', 'Poppins Fallback', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #f8fafc;
}

.tpl-word span {
    background: linear-gradient(100deg,
                #00d4ff 0%, #7dd3fc 26%, #ffffff 38%, #818cf8 54%, #6366f1 78%, #00d4ff 100%);
    background-size: 260% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: tplShimmer 3.4s ease-in-out infinite;
}

@keyframes tplShimmer {
    0%, 100% { background-position: 100% 50%; }
    50%      { background-position: 0% 50%; }
}

/* ── Status line ──────────────────────────────── */
.tpl-status {
    margin: -6px 0 0;
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-family: 'Poppins', 'Poppins Fallback', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #7c8dab;
    min-height: 17px;
}

.tpl-status i {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.25;
    animation: tplDot 1.35s ease-in-out infinite;
}

.tpl-status i:nth-child(2) { animation-delay: 0.16s; }
.tpl-status i:nth-child(3) { animation-delay: 0.32s; }

@keyframes tplDot {
    0%, 70%, 100% { opacity: 0.22; transform: translateY(0); }
    35%           { opacity: 1;    transform: translateY(-2px); }
}

/* Once a wait stops feeling normal, say so rather than leaving the user to
   wonder whether the click landed. */
.tp-loader.tpl-slow .tpl-status {
    color: #f0b429;
}

/* ── Sweep ────────────────────────────────────── */
.tpl-bar {
    position: relative;
    width: 172px;
    max-width: 60vw;
    height: 3px;
    border-radius: 99px;
    background: rgba(148, 163, 184, 0.16);
    overflow: hidden;
}

.tpl-bar span {
    display: block;
    width: 44%;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, transparent, #00d4ff 35%, #6366f1 70%, transparent);
    animation: tplSweep 1.55s cubic-bezier(0.66, 0, 0.34, 1) infinite;
}

@keyframes tplSweep {
    from { transform: translateX(-115%); }
    to   { transform: translateX(345%); }
}

/* ── Small screens ────────────────────────────── */
@media (max-width: 480px) {
    .tpl-mark { width: 88px; height: 88px; }
    .tpl-arc-inner { inset: 11px; }
    .tpl-core { inset: 19px; }
    .tpl-line { width: 38px; height: 38px; }
    .tpl-word { font-size: 0.9375rem; }
    .tpl-status { font-size: 0.625rem; letter-spacing: 0.13em; }
}

/* ── Reduced motion ───────────────────────────── */
/* Keep one calm pulse so the screen still reads as busy, and drop everything
   that moves. */
@media (prefers-reduced-motion: reduce) {
    .tpl-grid,
    .tpl-glow-a,
    .tpl-glow-b,
    .tpl-tip,
    .tpl-word span,
    .tpl-status i,
    .tp-loader.tpl-on .tpl-stage > * {
        animation: none;
    }

    .tpl-arc-outer,
    .tpl-arc-inner {
        animation: tplSpin 2.4s linear infinite;
    }

    .tpl-trend {
        stroke-dasharray: none;
        animation: none;
        opacity: 1;
    }

    .tpl-tip { opacity: 1; }

    .tpl-core {
        animation: tplBreathe 2.6s ease-in-out infinite;
    }

    .tpl-bar span {
        width: 100%;
        animation: tplBreathe 1.8s ease-in-out infinite;
    }
}
