/* Story demo pieces for: order routing & shipping allocation */

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

.sfp-shadow,
.sfp-clock,
.sfp-map,
.sfp-split-card {
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 8px 16px -6px rgba(15, 23, 42, 0.12),
        0 24px 48px -18px rgba(15, 23, 42, 0.28);
}

/* ---------- Scene 1: cut-off clock ---------- */
.sfp-clock {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px 7px 8px;
    border-radius: 999px;
    background: #fff;
    white-space: nowrap;
}

.sfp-clock b { font-size: 13px; color: #0f172a; }
.sfp-clock em { font-style: normal; font-size: 12px; font-weight: 600; color: #dc2626; background: #fee2e2; padding: 2px 8px; border-radius: 999px; }

.sfp-clock-face {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2.5px solid #f97316;
    background: #fff7ed;
}

.sfp-clock-face::before,
.sfp-clock-face i {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 2px;
    margin-left: -1px;
    border-radius: 2px;
    background: #0f172a;
    transform-origin: 50% 100%;
}

.sfp-clock-face::before { height: 6px; transform: rotate(-30deg); }
.sfp-clock-face i { height: 8px; transform: rotate(130deg); }

/* ---------- Scene 2: order hub ---------- */
.sfp-hub-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

.sfp-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #dcfce7;
    color: #15803d;
    font-size: 11px;
    font-weight: 700;
}

.sfp-live i { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; }

.sfp-count-badge {
    margin-left: auto;
    min-width: 40px;
    padding: 2px 9px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-style: normal;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---------- Scene 3: SKU mapping card ---------- */
.sfp-map {
    position: absolute;
    left: 26px;
    top: 44px;
    width: 236px;
    padding: 18px 14px 10px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    transform: rotate(-3deg);
    z-index: 2;
}

.sfp-card-tag {
    position: absolute;
    top: -11px;
    left: 14px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
}

.sfp-map-row {
    display: grid;
    grid-template-columns: 1fr 16px auto;
    align-items: center;
    gap: 6px;
    padding: 7px 0;
    border-top: 1px dashed #e2e8f0;
    font-size: 11.5px;
}

.sfp-map-row:first-of-type { border-top: 0; }
.sfp-map-row span { color: #64748b; white-space: nowrap; }
.sfp-map-row i { font-style: normal; color: #93c5fd; font-weight: 700; text-align: center; }

.sfp-map-row b {
    padding: 2px 8px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
}

/* Routing table: wider last column for carrier pills */
.sfp-route .sfx-row { grid-template-columns: 1.05fr .85fr .9fr 1.35fr; }
.sfx-st b.sfp-truck { background: #e0e7ff; color: #4338ca; }
.sfx-st b.sfp-air { background: #e0f2fe; color: #0369a1; }
.sfx-st b.sfp-split { background: #ede9fe; color: #6d28d9; }

/* Shipment split card */
.sfp-split-card {
    position: absolute;
    left: 30px;
    top: 238px;
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    transform: rotate(2deg);
    z-index: 2;
}

.sfp-parcel {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.sfp-parcel b, .sfp-label b { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: #0f172a; }
.sfp-parcel em, .sfp-label em { display: block; font-style: normal; font-size: 10.5px; color: #64748b; }

.sfp-box-ico {
    position: relative;
    width: 26px;
    height: 22px;
    border-radius: 4px;
    background: linear-gradient(#e7c79a, #d4a76a);
    box-shadow: inset 0 -2px 0 rgba(120, 72, 20, 0.18);
}

.sfp-box-ico::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 6px;
    margin-left: -3px;
    background: #f5e3c6;
}

.sfp-fork { width: 40px; height: 92px; flex: none; }

.sfp-labels { display: flex; flex-direction: column; gap: 22px; }

.sfp-label {
    padding: 6px 10px 6px 12px;
    border-radius: 8px;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-left: 4px solid #7c3aed;
}

/* ---------- Scene 4: cut-off dashboard ---------- */
.sfp-dash-body { padding: 14px 16px 16px; }

.sfp-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

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

.sfp-kpi span { display: block; font-size: 11px; color: #64748b; }
.sfp-kpi b { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.sfp-kpi b i { font-style: normal; }
.sfp-kpi-ok { background: #f0fdf4; border-color: #dcfce7; }
.sfp-kpi-ok b { color: #15803d; }

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

.sfp-split-title { margin: 14px 0 6px; font-size: 11px; font-weight: 600; color: #94a3b8; letter-spacing: 0.04em; }

.sfp-hbar {
    display: grid;
    grid-template-columns: 96px 1fr 36px;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 12px;
    color: #334155;
}

.sfp-hbar span { white-space: nowrap; }
.sfp-hbar b { text-align: right; font-variant-numeric: tabular-nums; }
.sfp-hbar div { height: 12px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.sfp-hbar i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--c); transform-origin: left; }

/* ---------- Motion ---------- */
.is-active .sfp-live i { animation: sfp-blink 1.4s ease-in-out infinite; }
.is-active .sfp-count-badge { opacity: 0; animation: sfp-badge 0.4s cubic-bezier(.2, 1.5, .4, 1) forwards; animation-delay: var(--d); }

.is-active .sfp-map { animation: sfp-slide-map 0.6s ease both; }
.is-active .sfp-map-row b { opacity: 0; animation: sfp-badge 0.35s cubic-bezier(.2, 1.5, .4, 1) forwards; animation-delay: var(--d); }
.is-active .sfp-map-row i { opacity: 0; animation: sfx-in 0.3s ease forwards; animation-delay: calc(var(--d) - 0.15s); }

.is-active .sfp-split-card { opacity: 0; animation: sfp-rise 0.6s ease forwards 1.9s; }
.is-active .sfp-fork path { stroke-dashoffset: 0; animation: sfp-dash 1s linear infinite; }
.is-active .sfp-label { opacity: 0; animation: sfp-label 0.45s cubic-bezier(.2, 1.3, .4, 1) forwards; animation-delay: var(--d); }

.is-active .sfp-dash { opacity: 0; animation: sfp-rise 0.6s ease forwards 0.1s; }
.is-active .sfp-count { animation: sfp-count 1.2s cubic-bezier(.2, .7, .3, 1) both 0.5s; }
.is-active .sfp-hbar i { animation: sfp-grow-x 0.8s cubic-bezier(.3, .8, .3, 1) both; animation-delay: var(--d); }

@keyframes sfp-blink { 50% { opacity: 0.25; } }

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

@keyframes sfp-slide-map {
    from { opacity: 0; transform: rotate(-3deg) translateX(-30px); }
    to { opacity: 1; transform: rotate(-3deg); }
}

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

@keyframes sfp-label {
    from { opacity: 0; transform: translateX(-14px); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-dash { to { stroke-dashoffset: -14; } }

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

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

@media (prefers-reduced-motion: reduce) {
    .is-active .sfp-fork path { animation: none !important; }
}
