/* ================================================================
 * SITE: PhoneSnaps
 * FILE: assets/peanut-spinner.css
 * REVISION: 1
 * DATE: May 16, 2026
 * PURPOSE: Global loading animation. Used anywhere on the site
 *          that has a multi-second wait state (video render,
 *          AI image generation, flyer build, photo upload,
 *          writeup generation, etc).
 *
 *          Include this CSS in header.php so it's available
 *          site-wide. Show/hide via assets/peanut-spinner.js
 *          which exposes PhoneSnaps.showSpinner() and hideSpinner().
 *
 * USAGE FROM ANY PAGE:
 *   <button onclick="PhoneSnaps.showSpinner({
 *       title: 'Building your video…',
 *       sub:   'This usually takes 2-3 minutes.',
 *       withProgress: true,
 *       withSteps: [...]
 *   })">Go</button>
 *
 *   PhoneSnaps.setProgress(45, 'Rendering clips…');
 *   PhoneSnaps.hideSpinner();
 *
 * Colors are scoped to brand vars (--teal, --teal-dark, etc).
 * If a page doesn't define those, defaults are provided below.
 * ================================================================ */

:root {
    /* fallbacks if a page didn't already set brand vars */
    --ps-teal:        #26A69A;
    --ps-teal-dark:   #1A7A72;
    --ps-paper:       #ffffff;
    --ps-bg:          #f3f5f4;
    --ps-line:        #e0e6e3;
    --ps-ink:         #1f2a28;
    --ps-ink-soft:    #6b7d79;
}

/* ---- Backdrop (full viewport, blocks interaction) ---- */
.ps-spinner-backdrop {
    position: fixed; inset: 0;
    background: rgba(20, 30, 28, 0.45);
    display: none;
    align-items: center; justify-content: center;
    z-index: 9999;
    padding: 16px;
    animation: ps-fade-in 0.18s ease;
}
.ps-spinner-backdrop.open { display: flex; }

@keyframes ps-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Card ---- */
.ps-spinner-card {
    background: var(--paper, var(--ps-paper));
    border-radius: 16px;
    padding: 28px 30px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
    text-align: center;
}

/* ---- Peanut stage (the centerpiece) ---- */
.ps-peanut-stage {
    display: flex; justify-content: center; align-items: center;
    margin: 4px auto 22px;
    position: relative;
    width: 160px; height: 160px;
}
/* Single spinning ring framing the peanut. (Rev 2 of the spinner
   dropped the outer counter-rotating ring per Jon's feedback —
   two spinners felt busy. One ring + a bigger peanut reads cleaner.) */
.ps-peanut-stage .ps-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 4px solid var(--bg, var(--ps-bg));
    border-top-color: var(--teal, var(--ps-teal));
    border-right-color: var(--teal, var(--ps-teal));
    animation: ps-spin 1.4s linear infinite;
}
.ps-peanut-stage .ps-peanut-img {
    width: 146px; height: 146px;
    border-radius: 50%;
    object-fit: cover;
    position: relative; z-index: 2;
    animation: ps-peanut-bob 2.4s ease-in-out infinite;
}
@keyframes ps-spin { to { transform: rotate(360deg); } }
@keyframes ps-peanut-bob { 50% { transform: translateY(-4px) scale(1.04); } }

/* ---- Title + subtitle ---- */
.ps-spinner-card h3.ps-title {
    margin: 0 0 6px;
    font-size: 1.15em;
    color: var(--ink, var(--ps-ink));
}
.ps-spinner-card .ps-sub {
    color: var(--ink-soft, var(--ps-ink-soft));
    font-size: 0.9em;
    margin: 0 0 18px;
    transition: opacity 0.4s;
    min-height: 1.2em;
}

/* ---- Progress bar with continuous shimmer stripes ---- */
.ps-progress-bar {
    height: 10px;
    background: var(--bg, var(--ps-bg));
    border-radius: 30px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
}
.ps-progress-bar .ps-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal, var(--ps-teal)), var(--teal-dark, var(--ps-teal-dark)));
    border-radius: 30px;
    width: 0%;
    transition: width 0.35s ease;
    position: relative;
    overflow: hidden;
}
.ps-progress-bar .ps-fill::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(
        45deg,
        rgba(255,255,255,0.20) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255,255,255,0.20) 50%,
        rgba(255,255,255,0.20) 75%,
        transparent 75%
    );
    background-size: 24px 24px;
    animation: ps-stripes 1s linear infinite;
}
@keyframes ps-stripes {
    from { background-position: 0 0; }
    to   { background-position: 24px 0; }
}

/* Indeterminate variant: when percent isn't known, sweep a glow
   left-to-right across the bar instead of showing % */
.ps-progress-bar.ps-indeterminate .ps-fill {
    width: 100% !important;
    background: var(--bg, var(--ps-bg));
}
.ps-progress-bar.ps-indeterminate .ps-fill::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--teal, var(--ps-teal)) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: ps-sweep 1.6s ease-in-out infinite;
}
@keyframes ps-sweep {
    from { background-position: -100% 0; }
    to   { background-position:  100% 0; }
}

/* ---- Optional step list ---- */
.ps-progress-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--ink-soft, var(--ps-ink-soft));
    font-size: 0.92em;
    text-align: left;
}
.ps-progress-steps li {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ps-progress-steps li.ps-done { color: var(--teal-dark, var(--ps-teal-dark)); }
.ps-progress-steps li.ps-current {
    color: var(--ink, var(--ps-ink));
    font-weight: 600;
}
.ps-progress-steps li .ps-step-ico {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.ps-progress-steps li.ps-current .ps-step-ico {
    color: var(--teal, var(--ps-teal));
    animation: ps-step-pulse 1.2s ease-in-out infinite;
}
@keyframes ps-step-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.85); }
}

/* ---- Optional footer note ---- */
.ps-spinner-card .ps-footer-note {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line, var(--ps-line));
    color: var(--ink-soft, var(--ps-ink-soft));
    font-size: 0.85em;
}

/* ---- Inline mini variant for in-page spots (gallery tiles, etc) ---- */
.ps-mini-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 48px; height: 48px;
}
.ps-mini-spinner .ps-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 3px solid var(--bg, var(--ps-bg));
    border-top-color: var(--teal, var(--ps-teal));
    animation: ps-spin 1.1s linear infinite;
}
.ps-mini-spinner .ps-peanut-img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    position: relative; z-index: 2;
}