/* Story demo: Excel Troubleshooting & Optimization service (page-specific pieces, prefix sfp-) */

/* ---------- Formula bar ---------- */

.sfp-fx {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 10px;
    border-bottom: 1px solid #edf1f5;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
}

.sfp-fx b {
    flex: none;
    font-style: italic;
    font-weight: 600;
    color: #94a3b8;
    padding-right: 8px;
    border-right: 1px solid #e2e8f0;
}

.sfp-fx code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #b91c1c;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sfp-fx-ok { background: #f0fdf4; }
.sfp-fx-ok code { color: #15803d; }

/* ---------- Scene 1: frozen workbook ---------- */

.sfp-frozen { position: relative; padding: 10px; }

.sfp-ghost {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 6px;
    filter: grayscale(1);
    opacity: 0.55;
}

.sfp-ghost span { height: 18px; border-radius: 4px; background: #e2e8f0; }
.sfp-ghost span:nth-child(3n+1) { background: #cbd5e1; }

.sfp-busy {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 200px;
    transform: translate(-50%, -50%);
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 24px -10px rgba(15, 23, 42, 0.4);
}

.sfp-busy b { font-size: 12px; color: #0f172a; }

.sfp-spin {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
}

.sfp-busy-bar {
    display: block;
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.sfp-busy-bar span { display: block; width: 12%; height: 100%; background: #f59e0b; border-radius: inherit; }

.sfp-size {
    position: absolute;
    right: 10px;
    bottom: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 10.5px;
    font-weight: 700;
}

/* Pivot with duplicates and blanks */
.sfp-pivot { padding: 6px 12px 10px; font-size: 11.5px; }

.sfp-pv {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-variant-numeric: tabular-nums;
}

.sfp-pv.head { font-size: 10.5px; font-weight: 600; color: #94a3b8; }
.sfp-pv.warn { background: #fffbeb; }
.sfp-pv.sum { font-weight: 700; color: #0f172a; border-bottom: 0; }

.sfp-pv em {
    font-style: normal;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #fef3c7;
    color: #b45309;
    font-size: 9.5px;
    font-weight: 700;
}

.sfp-bad {
    padding: 1px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 10.5px;
}

/* ---------- Scene 2: health check ---------- */

.sfp-hc-sum {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 14px 4px;
}

.sfp-hc-sum div {
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #eef2f6;
}

.sfp-hc-sum b { display: block; font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sfp-hc-sum span { font-size: 10.5px; color: #64748b; }
.sfp-hc-sum .hot { background: #fffbeb; border-color: #fde68a; }
.sfp-hc-sum .hot b { color: #b45309; }

.sfp-hc .sfx-row { grid-template-columns: 1.35fr 1.25fr 0.45fr 1fr; }
.sfp-hc .sfx-row span:nth-child(3) { font-weight: 700; }
.sfp-hc .sfx-scan { top: 34px; height: 32px; }

/* ---------- Scene 3: fix + optimise ---------- */

.sfp-sp {
    display: inline-block;
    width: 9px;
    height: 12px;
    margin-left: 2px;
    vertical-align: -2px;
    border-radius: 2px;
    background: #fecaca;
    box-shadow: inset 0 -2px 0 #ef4444;
}

.sfp-flip { position: relative; background: #fee2e2; }
.sfp-flip .o,
.sfp-flip .n { display: block; }
.sfp-flip .o { color: #dc2626; font-weight: 700; }
.sfp-flip .n { position: absolute; right: 8px; top: 6px; color: transparent; font-weight: 700; }

.sfp-perf { padding: 14px 16px 16px; }

.sfp-meter { margin-bottom: 14px; }

.sfp-meter-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.sfp-swap { position: relative; display: inline-block; min-width: 60px; text-align: right; font-size: 16px; color: #0f172a; }
.sfp-swap .o { color: #dc2626; }
.sfp-swap .n { position: absolute; right: 0; top: 0; color: #15803d; opacity: 0; }

.sfp-meter-bar {
    height: 10px;
    border-radius: 999px;
    background: #eef2f6;
    overflow: hidden;
}

.sfp-meter-bar span {
    display: block;
    height: 100%;
    width: var(--to);
    border-radius: inherit;
    background: #10b981;
}

.sfp-fixes { list-style: none; margin: 4px 0 0; padding: 10px 0 0; border-top: 1px dashed #e2e8f0; }

.sfp-fixes li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    color: #334155;
}

.sfp-fixes i {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    font-style: normal;
    font-size: 10px;
    font-weight: 800;
}

/* ---------- Scene 4: healthy workbook ---------- */

.sfp-done .sfx-sheet td.ok { color: #15803d; font-weight: 600; }
.sfp-done .sfx-sheet td.sfp-total { color: #15803d; text-align: right; }

.sfp-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    background: #f8fafc;
    border-top: 1px solid #edf1f5;
}

.sfp-tabs span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-size: 10.5px;
    color: #334155;
}

.sfp-tabs span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

.sfp-stat {
    position: absolute;
    width: 180px;
    padding: 10px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-left: 4px solid #16a34a;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 16px -6px rgba(15, 23, 42, 0.12),
        0 24px 44px -18px rgba(15, 23, 42, 0.28);
}

.sfp-stat span { display: block; font-size: 11px; color: #64748b; }
.sfp-stat b { display: block; font-size: 22px; line-height: 1.25; color: #15803d; }
.sfp-stat em { font-style: normal; font-size: 10.5px; color: #94a3b8; }

/* ---------- Motion ---------- */

.is-active .sfp-spin { animation: sfp-rot 0.9s linear infinite; }

.is-active .sfp-sp { animation: sfp-gone 0.35s ease forwards; animation-delay: var(--d); }
/* colour-only swaps: opacity/transform layers inside a tilted window glitch in Chromium */
.is-active .sfp-flip .o { animation: sfp-hide 0.2s ease forwards; animation-delay: var(--d); }
.is-active .sfp-flip .n { animation: sfp-show 0.35s ease forwards; animation-delay: calc(var(--d) + 0.15s); }
.is-active .sfp-flip { animation: sfp-cell 0.6s ease forwards; animation-delay: var(--d); }

.is-active .sfp-meter-bar span { animation: sfp-shrink 1.3s cubic-bezier(.6, 0, .3, 1) both 0.5s; }
.is-active .sfp-swap .o { animation: sfx-out 0.2s ease forwards 1.5s; }
.is-active .sfp-swap .n { animation: sfp-pop 0.4s cubic-bezier(.2, 1.5, .4, 1) forwards 1.6s; }
.is-active .sfp-fixes li { opacity: 0; animation: sfx-row 0.4s ease forwards; animation-delay: var(--d); }

.is-active .sfp-done { animation: sfp-rise 0.7s ease both; }
.is-active .sfp-tabs span::before { animation: sfp-pop 0.35s cubic-bezier(.2, 1.5, .4, 1) both 0.9s; }
.is-active .sfp-stat { opacity: 0; animation: sfp-deal 0.6s cubic-bezier(.2, 1.2, .4, 1) forwards; animation-delay: var(--d); }

@keyframes sfp-rot { to { transform: rotate(360deg); } }
@keyframes sfp-gone { to { width: 0; margin-left: 0; background: transparent; box-shadow: none; } }
@keyframes sfp-hide { to { color: transparent; } }
@keyframes sfp-show { to { color: #15803d; } }
@keyframes sfp-pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes sfp-cell { from { background: #fee2e2; } to { background: #f0fdf4; } }

@keyframes sfp-shrink {
    from { width: var(--from); background: #ef4444; }
    to { width: var(--to); background: #10b981; }
}

@keyframes sfp-rise {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-deal {
    from { opacity: 0; transform: translateX(30px) scale(0.94); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sfp-spin { border-top-color: #2563eb; }
}

/* ---------- Scene 2: incoming files panel ---------- */

.sfp-inbox { padding: 10px 12px 12px; }

.sfp-inbox div {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 8px;
    margin-bottom: 6px;
    border: 1px solid #eef2f6;
    border-radius: 10px;
    font-size: 11.5px;
    color: #334155;
    white-space: nowrap;
}

.sfp-inbox i {
    flex: none;
    font-style: normal;
    font-size: 8.5px;
    font-weight: 700;
    color: #fff;
    padding: 4px 5px;
    border-radius: 5px;
    background: #16a34a;
}

.sfp-inbox span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sfp-inbox em { font-style: normal; font-size: 10px; color: #94a3b8; }
.sfp-inbox div:nth-child(2) em { color: #dc2626; font-weight: 600; }

.sfp-fly { left: 70px; }

@media (prefers-reduced-motion: reduce) {
    .sfp-fly { display: none; }
}
