/* Story demo pieces for the service page: AI Chatbot & Conversational Automation */

@property --sfp-n {
    syntax: '<integer>';
    inherits: false;
    initial-value: 0;
}

.sfp-tilt-l { transform: rotateX(10deg) rotateY(12deg); }
.sfp-tilt-r { transform: rotateX(8deg) rotateY(-14deg); }
.sfp-tilt-m { transform: rotateX(8deg) rotateY(-10deg); }

.sfp-phone,
.sfp-src,
.sfp-pane-in,
.sfp-out {
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 16px -6px rgba(15, 23, 42, 0.12),
        0 28px 56px -18px rgba(15, 23, 42, 0.3);
}

/* Channel logo */
.sfp-lg {
    flex: none;
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
}

.sfp-lg img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sfp-lg-dc img { transform: scale(1.55); }

/* Conversation type colours */
.t-order { --c: #1d4ed8; --bg: #dbeafe; }
.t-faq { --c: #6d28d9; --bg: #ede9fe; }
.t-issue { --c: #b45309; --bg: #fef3c7; }
.t-lead { --c: #15803d; --bg: #dcfce7; }

/* ---------- Scene 1: overflowing inbox ---------- */
.sfp-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #eef2f6;
}

.sfp-ch {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px 4px 4px;
    border-radius: 9px;
    border: 1px solid #eef2f6;
    font-size: 10.5px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.sfp-ch .sfp-lg { width: 18px; height: 18px; border-radius: 5px; }
.sfp-ch.on { background: #f8fafc; color: #0f172a; border-color: #e2e8f0; }

.sfp-ch b {
    min-width: 18px;
    padding: 1px 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 9.5px;
    text-align: center;
}

.sfp-list { padding: 2px 12px; }

.sfp-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 54px;
    border-bottom: 1px solid #f1f5f9;
}

.sfp-item:last-child { border-bottom: 0; }
.sfp-item .sfp-lg { width: 30px; height: 30px; border-radius: 9px; }
.sfp-item > div { flex: 1; min-width: 0; }
.sfp-item > div b { display: block; font-size: 12px; color: #0f172a; }
.sfp-item > div span { display: block; font-size: 11.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sfp-wait {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    font-style: normal;
    font-size: 10.5px;
    font-weight: 600;
}

.sfp-wait.r { background: #fee2e2; color: #dc2626; }
.sfp-wait.a { background: #fef3c7; color: #b45309; }

.sfp-unread {
    flex: none;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
}

/* Phone */
.sfp-phone {
    position: absolute;
    width: var(--w, 200px);
    height: var(--h, 370px);
    padding: 7px;
    border-radius: 32px;
    background: linear-gradient(160deg, #334155, #0f172a 40%);
}

.sfp-phone::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 13px;
    width: 54px;
    height: 14px;
    margin-left: -27px;
    border-radius: 10px;
    background: #0f172a;
    z-index: 2;
}

.sfp-screen {
    height: 100%;
    border-radius: 25px;
    overflow: hidden;
}

.sfp-lock {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    padding: 36px 9px 10px;
    background: linear-gradient(180deg, #c7d2fe, #e0e7ff 45%, #fce7f3);
    text-align: center;
}

.sfp-lock-sub { font-size: 10px; font-weight: 600; color: #475569; }
.sfp-lock-time { font-size: 40px; line-height: 1; font-weight: 600; color: #1e293b; letter-spacing: 0.02em; margin-bottom: 6px; }

.sfp-note {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 8px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 4px 10px -4px rgba(15, 23, 42, 0.25);
    text-align: left;
}

.sfp-note .sfp-lg { width: 22px; height: 22px; border-radius: 6px; }
.sfp-note div { min-width: 0; }
.sfp-note b { display: block; font-size: 9px; color: #64748b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sfp-note span { display: block; font-size: 10.5px; color: #0f172a; white-space: nowrap; }

.sfp-more { font-size: 10px; font-weight: 600; color: #475569; margin-top: 2px; }

/* ---------- Scene 2: one bot, every channel ---------- */
.sfp-src {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 156px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #fff;
}

.sfp-src .sfp-lg { width: 32px; height: 32px; border-radius: 9px; }
.sfp-src b { display: block; font-size: 12.5px; }
.sfp-src span { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: #15803d; font-weight: 500; }
.sfp-src span i { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }

.sfp-fly {
    position: absolute;
    display: flex;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 10px 10px 10px 3px;
    background: #fff;
    box-shadow: 0 6px 14px -6px rgba(15, 23, 42, 0.35);
    z-index: 2;
    opacity: 0;
}

.sfp-fly i { width: 5px; height: 5px; border-radius: 50%; background: #2563eb; }

.sfp-bothead {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #eef2f6;
}

.sfp-botico {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(#3b82f6, #2563eb);
    color: #fff;
}

.sfp-botico svg { width: 24px; height: 24px; }
.sfp-botico svg path { fill: #fff; }
.sfp-botico svg circle { fill: #2563eb; }
.sfp-bothead b { display: block; font-size: 13.5px; }

.sfp-live { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: #15803d; font-weight: 600; }
.sfp-live i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }

.sfp-speed {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-style: normal;
    font-size: 11px;
}

.sfp-speed b { display: inline; font-size: 11px; }

.sfp-rows { padding: 4px 16px; }

.sfp-row {
    display: grid;
    grid-template-columns: 30px 1fr 104px;
    align-items: center;
    gap: 10px;
    height: 46px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12.5px;
    color: #334155;
}

.sfp-row:last-child { border-bottom: 0; }
.sfp-row.head { height: 28px; font-size: 10.5px; font-weight: 600; color: #94a3b8; letter-spacing: 0.02em; }
.sfp-row .sfp-lg { width: 26px; height: 26px; border-radius: 8px; }
.sfp-row .sfx-st b { background: var(--bg); color: var(--c); font-size: 11.5px; padding: 3px 10px; }

/* ---------- Scene 3: three kinds of chats, three outcomes ---------- */
.sfp-fan { perspective: 1300px; perspective-origin: 50% 40%; }

.sfp-pane {
    position: absolute;
    width: 228px;
    transform: rotateX(6deg) rotateY(var(--ry, 0deg)) translateZ(var(--z, 0px));
}

.sfp-pane-in {
    display: flex;
    flex-direction: column;
    height: 322px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    overflow: hidden;
}

.sfp-pane-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f6;
    font-size: 12px;
}

.sfp-pane-head em {
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--c);
    font-style: normal;
    font-size: 10.5px;
    font-weight: 700;
}

.sfp-pane-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px;
    background: #eef2f7;
}

.sfp-msg {
    max-width: 88%;
    padding: 6px 10px;
    border-radius: 13px;
    font-size: 11px;
    line-height: 1.45;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
}

.sfp-msg.me { align-self: flex-end; background: #b5ef9b; color: #14532d; border-bottom-right-radius: 4px; }
.sfp-msg.me.fb { background: #2563eb; color: #fff; }
.sfp-msg.me.tg { background: #dbeafe; color: #1e3a8a; }
.sfp-msg.bot { align-self: flex-start; background: #fff; color: #334155; border-bottom-left-radius: 4px; }

.sfp-ref {
    display: block;
    margin-top: 5px;
    padding: 2px 7px;
    border-radius: 6px;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 9.5px;
    font-weight: 600;
}

.sfp-card {
    padding: 9px 10px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    font-size: 10.5px;
}

.sfp-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.sfp-card-head b { font-size: 11.5px; color: #0f172a; }
.sfp-card-head span { font-size: 10px; color: #94a3b8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.sfp-li { display: flex; justify-content: space-between; padding: 3px 0; color: #64748b; font-variant-numeric: tabular-nums; }
.sfp-li em { font-style: normal; color: #94a3b8; }
.sfp-li b { color: #0f172a; font-weight: 600; }
.sfp-li b.ok { color: #15803d; }
.sfp-li b.hi { color: #b45309; }
.sfp-li-total { border-top: 1px dashed #e2e8f0; margin-top: 2px; padding-top: 5px; }
.sfp-li-total span, .sfp-li-total b { font-size: 12px; color: #0f172a; font-weight: 700; }

.sfp-cta {
    display: block;
    margin-top: 6px;
    padding: 5px;
    border-radius: 8px;
    background: #06c755;
    color: #fff;
    text-align: center;
    font-weight: 700;
    font-size: 10.5px;
}

.sfp-kb { display: flex; flex-direction: column; gap: 4px; padding: 7px; border-radius: 10px; border: 1px dashed #c4b5fd; background: #f5f3ff; }

.sfp-kb-doc {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 7px;
    background: #fff;
    font-size: 10px;
    font-weight: 600;
    color: #334155;
    box-shadow: 0 0 0 1.5px #8b5cf6;
}

.sfp-kb-doc i {
    padding: 1px 4px;
    border-radius: 4px;
    background: #ef4444;
    color: #fff;
    font-style: normal;
    font-size: 8px;
    font-weight: 700;
}

.sfp-kb-doc.dim { box-shadow: none; color: #94a3b8; }
.sfp-kb-doc.dim i { background: #cbd5e1; }

.sfp-dest {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eef2f6;
    background: #fff;
}

.sfp-dest b { display: block; font-size: 11px; color: #0f172a; }
.sfp-dest span { display: block; font-size: 10px; color: #64748b; }
.sfp-dest > div { flex: 1; min-width: 0; }

.sfp-dest-ico {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.sfp-dest-ico svg { width: 16px; height: 16px; }
.sfp-dest-ico.g { background: #dcfce7; color: #15803d; }
.sfp-dest-ico.v { background: #ede9fe; color: #6d28d9; }
.sfp-dest-ico.a { background: #fef3c7; color: #b45309; }
.sfp-dest-ico.b { background: #dbeafe; color: #1d4ed8; }

.sfp-tick {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    font-style: normal;
    font-size: 11px;
    font-weight: 800;
}

/* ---------- Scene 4: dashboard + outputs ---------- */
.sfp-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 14px 8px; }

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

.sfp-kpi span { display: block; font-size: 10px; color: #64748b; }
.sfp-kpi b { display: block; font-size: 21px; line-height: 1.2; color: #0f172a; font-variant-numeric: tabular-nums; }
.sfp-kpi b small { font-size: 12px; font-weight: 600; color: #64748b; }
.sfp-kpi:first-child b { color: #15803d; }

.sfp-count { font-style: normal; --sfp-n: var(--to); counter-reset: sfp var(--sfp-n); }
.sfp-count::after { content: counter(sfp); }

.sfp-split { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; padding: 0 14px 14px; }

.sfp-panel {
    height: 214px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #eef2f6;
}

.sfp-panel-t { display: block; font-size: 10.5px; font-weight: 600; color: #64748b; margin-bottom: 10px; }

.sfp-donut-wrap { display: flex; align-items: center; gap: 12px; margin-top: 24px; }

.sfp-donut {
    flex: none;
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: conic-gradient(#3b82f6 0 38%, #8b5cf6 38% 82%, #f59e0b 82% 92%, #22c55e 92% 100%);
}

.sfp-donut span {
    position: absolute;
    inset: 19px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    font-size: 9.5px;
    color: #64748b;
}

.sfp-donut span b { font-size: 20px; line-height: 1.1; color: #0f172a; }

.sfp-legend { list-style: none; margin: 0; padding: 0; flex: 1; }
.sfp-legend li { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 10.5px; color: #475569; white-space: nowrap; }
.sfp-legend li i { width: 8px; height: 8px; border-radius: 3px; background: var(--c); }
.sfp-legend li i.t-order { background: #3b82f6; }
.sfp-legend li i.t-faq { background: #8b5cf6; }
.sfp-legend li i.t-issue { background: #f59e0b; }
.sfp-legend li i.t-lead { background: #22c55e; }
.sfp-legend li b { margin-left: auto; color: #0f172a; font-weight: 600; }

.sfp-hbar { display: flex; align-items: center; gap: 8px; height: 42px; }
.sfp-hbar .sfp-lg { width: 22px; height: 22px; border-radius: 6px; }
.sfp-hbar > .sfp-track { flex: 1; height: 10px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.sfp-hbar > .sfp-track i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, #60a5fa, #2563eb); transform-origin: left; }
.sfp-hbar b { width: 26px; text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; }

.sfp-out {
    position: absolute;
    width: 200px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    transform: rotate(var(--r, 0deg));
}

.sfp-out-head { display: flex; align-items: center; gap: 8px; }
.sfp-out-head b { flex: 1; font-size: 12px; white-space: nowrap; }
.sfp-out-head em { font-style: normal; font-size: 11px; font-weight: 700; color: #15803d; white-space: nowrap; }

.sfp-mini { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; }
.sfp-mini span { height: 9px; border-radius: 3px; background: #f0fdf4; border: 1px solid #dcfce7; }
.sfp-mini span:first-child { background: #bbf7d0; }
.sfp-mini span.w { width: 62%; }

.sfp-meter { margin-top: 10px; height: 8px; border-radius: 999px; background: #fef3c7; overflow: hidden; }
.sfp-meter span { display: block; width: 82%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #fbbf24, #16a34a); transform-origin: left; }

.sfp-out .sfx-stamp { left: -14px; right: auto; top: -16px; }

/* ---------- Motion (active scene only) ---------- */
.is-active .sfp-note { opacity: 0; animation: sfp-drop 0.5s cubic-bezier(.2, 1.3, .4, 1) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-item .sfp-unread { animation: sfx-pulse 1.4s ease-in-out infinite; }

.is-active .sfp-fly { animation: sfp-fly 2.4s cubic-bezier(.5, 0, .3, 1) infinite; animation-delay: var(--d, 0s); }
.is-active .sfp-row:not(.head) { opacity: 0; animation: sfp-rise 0.4s ease forwards; animation-delay: calc(var(--d) - 0.3s); }

.is-active .sfp-pane-in { opacity: 0; animation: sfp-deal 0.6s cubic-bezier(.2, 1.1, .4, 1) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-msg,
.is-active .sfp-card,
.is-active .sfp-kb { opacity: 0; animation: sfp-rise 0.4s ease forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-dest { animation: sfp-dest 0.5s ease both; animation-delay: var(--d, 0s); }
.is-active .sfp-dest .sfp-tick { opacity: 0; animation: sfp-pop 0.4s cubic-bezier(.2, 1.6, .4, 1) forwards; animation-delay: calc(var(--d, 0s) + 0.35s); }

.is-active .sfp-dash { animation: sfp-rise 0.6s ease both; }
.is-active .sfp-count { animation: sfp-count 1.3s cubic-bezier(.2, .7, .3, 1) both 0.5s; }
.is-active .sfp-donut { animation: sfp-spin 1s cubic-bezier(.2, .8, .3, 1) both 0.4s; }
.is-active .sfp-hbar > .sfp-track i { animation: sfp-grow-x 0.9s ease both 0.7s; }
.is-active .sfp-out { opacity: 0; animation: sfp-out 0.6s cubic-bezier(.2, 1.2, .4, 1) forwards; animation-delay: var(--d, 0s); }
.is-active .sfp-meter span { animation: sfp-grow-x 0.9s ease both 2s; }

@keyframes sfp-drop {
    from { opacity: 0; transform: translateY(-14px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-fly {
    0% { opacity: 0; transform: translateX(0) scale(0.8); }
    15% { opacity: 1; transform: translateX(8px) scale(1); }
    75% { opacity: 1; transform: translateX(78px) scale(0.9); }
    100% { opacity: 0; transform: translateX(96px) scale(0.6); }
}

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

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

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

@keyframes sfp-pop {
    from { opacity: 0; transform: scale(0.4); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes sfp-count {
    from { --sfp-n: 0; }
    to { --sfp-n: var(--to); }
}

@keyframes sfp-spin {
    from { opacity: 0; transform: rotate(-90deg) scale(0.7); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-grow-x {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes sfp-out {
    from { opacity: 0; transform: translateX(40px) rotate(0deg); }
    to { opacity: 1; transform: rotate(var(--r, 0deg)); }
}

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