/* Home page vignette: problem section (the weight of manual work in one picture) */

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

/* Stage is transparent so the section's own blue shows through; the last few pixels fade so window shadows never end on a hard edge */
.sfp-problem-frame {
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent);
}

.sfp-problem-win {
    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.26);
}

.sfp-problem-floor { left: 40px; right: 40px; bottom: 2px; height: 50px; }

.sfp-problem-tilt-l { transform-origin: 250px 155px; transform: rotateX(8deg) rotateY(12deg); }
.sfp-problem-tilt-r { transform-origin: 635px 155px; transform: rotateX(8deg) rotateY(-12deg); }

/* ---------- Excel windows ---------- */

.sfp-problem-a { left: 24px; top: 26px; width: 224px; height: 132px; }
.sfp-problem-b { left: 296px; top: 20px; width: 200px; height: 112px; }
.sfp-problem-c { left: 30px; top: 170px; width: 176px; height: 106px; }
.sfp-problem-main { left: 168px; top: 84px; width: 300px; }

.sfp-problem-xl { display: inline-flex; align-items: center; gap: 5px; }
.sfp-problem-xl img { width: 13px; height: 13px; object-fit: contain; flex: none; }

.sfp-problem-mini { width: auto; table-layout: fixed; }
.sfp-problem-mini th { height: 15px; padding: 0 4px; font-size: 9px; }
.sfp-problem-mini th:nth-child(1) { width: 20px; }
.sfp-problem-mini th:nth-child(2) { width: 56px; }
.sfp-problem-mini th:nth-child(3) { width: 62px; }
.sfp-problem-mini td { height: 20px; padding: 0 6px; font-size: 10.5px; white-space: nowrap; }

.sfp-problem-sheet { table-layout: fixed; }
.sfp-problem-sheet th { height: 15px; padding: 0 4px; }
.sfp-problem-sheet th:nth-child(1) { width: 22px; }
.sfp-problem-sheet th:nth-child(2) { width: 82px; }
.sfp-problem-sheet th:nth-child(3) { width: 96px; }
.sfp-problem-sheet td { height: 20px; padding: 0 8px; white-space: nowrap; }
.sfp-problem-sheet td.b { text-align: right; }
.sfp-problem-sheet td.b:first-of-type { text-align: left; }

.sfp-problem-fx {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 20px;
    padding: 0 8px;
    border-bottom: 1px solid #e8edf3;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    color: #334155;
}

.sfp-problem-fx em { font-style: italic; color: #94a3b8; padding-right: 8px; border-right: 1px solid #e2e8f0; }

/* Faux grid inside the background files */
.sfp-problem-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 0;
}

.sfp-problem-grid span {
    position: relative;
    height: 20px;
    border-right: 1px solid #edf1f5;
    border-bottom: 1px solid #edf1f5;
}

.sfp-problem-grid span::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 8px;
    width: 55%;
    height: 5px;
    border-radius: 3px;
    background: #e5eaf0;
}

.sfp-problem-grid span.w { background: #fef3c7; }
.sfp-problem-grid span.w::after { background: #fbbf24; opacity: 0.55; }

/* Pasted values and error cells */
.sfp-problem-paste span { display: inline-block; }

.sfp-problem-x { position: relative; }

.sfp-problem-x b {
    position: absolute;
    inset: 0;
    padding: 0 8px;
    line-height: 20px;
    background: #fee2e2;
    color: #dc2626;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
    text-align: right;
    box-shadow: inset 0 0 0 1px #fca5a5;
}

/* Excel "copied" marquee on the source cell */
.sfp-problem-ants {
    position: absolute;
    left: 77px;
    top: 46px;
    width: 63px;
    height: 21px;
    opacity: 0;
    background:
        linear-gradient(90deg, #16a34a 50%, transparent 0) repeat-x 0 0 / 8px 2px,
        linear-gradient(90deg, #16a34a 50%, transparent 0) repeat-x 0 100% / 8px 2px,
        linear-gradient(0deg, #16a34a 50%, transparent 0) repeat-y 0 0 / 2px 8px,
        linear-gradient(0deg, #16a34a 50%, transparent 0) repeat-y 100% 0 / 2px 8px;
}

/* Pointer shuttling between the two files */
.sfp-problem-cur {
    position: absolute;
    left: -3px;
    top: -2px;
    width: 26px;
    height: 26px;
    opacity: 0;
    transform: translate3d(128px, 84px, 90px);
}

.sfp-problem-cur svg { display: block; width: 26px; height: 26px; filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.3)); }

.sfp-problem-key {
    position: absolute;
    left: 22px;
    top: 22px;
    display: flex;
    gap: 3px;
    opacity: 0;
}

.sfp-problem-key kbd {
    padding: 1px 5px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    font: 600 9.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #334155;
    box-shadow: 0 3px 6px -2px rgba(15, 23, 42, 0.25);
}

/* ---------- Clock: the working day runs out ---------- */

.sfp-problem-clock { left: 506px; top: 24px; width: 258px; padding: 12px 14px 0; }

.sfp-problem-clock-top { display: flex; align-items: center; gap: 10px; }

.sfp-problem-dial {
    position: relative;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
}

.sfp-problem-dial::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: repeating-conic-gradient(from -2deg, #94a3b8 0 4deg, transparent 4deg 90deg);
    -webkit-mask-image: radial-gradient(closest-side, transparent 70%, #000 71%);
    mask-image: radial-gradient(closest-side, transparent 70%, #000 71%);
}

.sfp-problem-dial i {
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 2px;
    margin-left: -1px;
    border-radius: 2px;
    background: #334155;
    transform-origin: 50% 100%;
}

.sfp-problem-dial i.h { height: 8px; transform: rotate(592.5deg); }
.sfp-problem-dial i.m { height: 12px; width: 1.5px; background: #64748b; transform: rotate(270deg); }

.sfp-problem-time {
    display: block;
    height: 34px;
    overflow: hidden;
    font-size: 28px;
    line-height: 34px;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.sfp-problem-roll { display: block; transform: translateY(-510px); }
.sfp-problem-roll span { display: block; height: 34px; }

.sfp-problem-ot {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.sfp-problem-day { margin-top: 10px; }

.sfp-problem-track {
    position: relative;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background:
        repeating-linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0 4px, rgba(239, 68, 68, 0.06) 4px 8px) 100% 0 / 18.2% 100% no-repeat,
        #e2e8f0;
}

.sfp-problem-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 97.7%; overflow: hidden; }

.sfp-problem-fill span {
    display: block;
    width: 230px;
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #2563eb 81.8%, #ef4444 81.8%);
}

.sfp-problem-ticks { position: relative; height: 16px; font-size: 9.5px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.sfp-problem-ticks span { position: absolute; top: 3px; left: 0; }
.sfp-problem-ticks span + span { left: 81.8%; transform: translateX(-50%); color: #64748b; font-weight: 600; }

.sfp-problem-lost {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 8px -14px 0;
    padding: 7px 14px 9px;
    border-top: 1px solid #eef2f6;
    background: #f8fafc;
    font-size: 11.5px;
    color: #64748b;
}

.sfp-problem-lost b { font-size: 16px; color: #b91c1c; font-variant-numeric: tabular-nums; }
.sfp-problem-count { counter-reset: sfpproblem var(--sfp-problem-n); }
.sfp-problem-count::after { content: counter(sfpproblem); }

/* ---------- Statement that refuses to match ---------- */

.sfp-problem-stmt { left: 506px; top: 166px; width: 258px; }

.sfp-problem-bad {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #dc2626;
    font-style: normal;
    font-size: 10.5px;
    font-weight: 700;
}

.sfp-problem-rows { position: relative; padding: 4px 6px; }

.sfp-problem-r {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 26px;
    padding: 0 8px;
    font-size: 11.5px;
    color: #64748b;
}

.sfp-problem-r + .sfp-problem-r { border-top: 1px dashed #e2e8f0; }
.sfp-problem-r b { font-size: 14px; color: #0f172a; font-variant-numeric: tabular-nums; }

.sfp-problem-sweep {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 4px;
    height: 26px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.08);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3);
    opacity: 0;
}

.sfp-problem-ne {
    position: absolute;
    left: 112px;
    top: 50%;
    width: 22px;
    height: 22px;
    margin-top: -11px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    color: #fff;
    font-style: normal;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 4px 10px -3px rgba(220, 38, 38, 0.55);
}

.sfp-problem-diff {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px 9px;
    border-top: 1px solid #eef2f6;
    background: #fef2f2;
    font-size: 11.5px;
    color: #64748b;
}

.sfp-problem-diff b { font-size: 14px; color: #dc2626; font-variant-numeric: tabular-nums; }

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

.is-active .sfp-problem-win { animation: sfp-problem-land 0.6s cubic-bezier(.2, 1, .3, 1) both; animation-delay: var(--d, 0s); }

.is-active .sfp-problem-ants { animation: sfp-problem-ants 3.15s linear 1.25s both, sfp-problem-march 0.6s linear infinite; }
.is-active .sfp-problem-cur { animation: sfp-problem-cur 3.6s ease-in-out 1s both; }
.is-active .sfp-problem-key.c { animation: sfp-problem-key-c 3.6s linear 1s both; }
.is-active .sfp-problem-key.v { animation: sfp-problem-key-v 3.6s linear 1s both; }

.is-active .sfp-problem-paste { animation: sfp-problem-flash 1.2s ease both; animation-delay: var(--d); }
.is-active .sfp-problem-paste span { animation: sfp-problem-pop 0.3s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: var(--d); }
.is-active .sfp-problem-x b { animation: sfp-problem-pop 0.35s cubic-bezier(.2, 1.5, .4, 1) both; animation-delay: var(--d); }

.is-active .sfp-problem-roll { animation: sfp-problem-roll 6.4s steps(15, end) 0.6s both; }
.is-active .sfp-problem-dial i.h { animation: sfp-problem-hour 6.4s linear 0.6s both; }
.is-active .sfp-problem-dial i.m { animation: sfp-problem-min 6.4s linear 0.6s both; }
.is-active .sfp-problem-fill { animation: sfp-problem-fill 6.4s linear 0.6s both; }
.is-active .sfp-problem-ot { animation: sfp-problem-pop 0.4s cubic-bezier(.2, 1.5, .4, 1) both 6s; }
.is-active .sfp-problem-count { animation: sfp-problem-count 6s linear 1s both; }

.is-active .sfp-problem-sweep { animation: sfp-problem-sweep 2.2s ease-in-out 3s both; }
.is-active .sfp-problem-ne { animation: sfp-problem-stamp 0.45s cubic-bezier(.2, 1.6, .4, 1) both 5.4s; }
.is-active .sfp-problem-diff { animation: sfp-problem-warm 0.5s ease both 5.6s; }
.is-active .sfp-problem-diff b { animation: sfp-problem-pop 0.35s cubic-bezier(.2, 1.4, .4, 1) both 5.7s; }
.is-active .sfp-problem-bad { animation: sfp-problem-pop 0.35s cubic-bezier(.2, 1.5, .4, 1) both 5.95s; }

@keyframes sfp-problem-land {
    from { opacity: 0; transform: translateZ(var(--z, 0)) translateY(-16px) scale(0.97); }
    to { opacity: 1; transform: translateZ(var(--z, 0)); }
}

@keyframes sfp-problem-warm {
    from { background-color: #f8fafc; }
    to { background-color: #fef2f2; }
}

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

@keyframes sfp-problem-stamp {
    from { opacity: 0; transform: scale(2) rotate(-20deg); }
    to { opacity: 1; transform: none; }
}

@keyframes sfp-problem-flash {
    0% { background-color: transparent; }
    12% { background-color: #dcfce7; box-shadow: inset 0 0 0 2px #16a34a; }
    100% { background-color: transparent; box-shadow: inset 0 0 0 2px transparent; }
}

@keyframes sfp-problem-ants {
    0% { opacity: 0; transform: translateY(0); }
    2%, 38% { opacity: 1; transform: translateY(0); }
    38.1%, 69.7% { transform: translateY(20px); }
    69.8%, 94% { opacity: 1; transform: translateY(40px); }
    100% { opacity: 0; transform: translateY(40px); }
}

@keyframes sfp-problem-march {
    to { background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px; }
}

/* Copy from the source file, paste into the report, three times over */
@keyframes sfp-problem-cur {
    0% { opacity: 0; transform: translate3d(150px, 108px, 90px); }
    5.56% { opacity: 1; transform: translate3d(128px, 84px, 90px); }
    7% { transform: translate3d(128px, 85px, 90px) scale(0.88); }
    8.33% { transform: translate3d(128px, 84px, 90px); }
    25% { transform: translate3d(318px, 182px, 90px); }
    26.4% { transform: translate3d(318px, 183px, 90px) scale(0.88); }
    27.78% { transform: translate3d(318px, 182px, 90px); }
    38.89% { transform: translate3d(128px, 104px, 90px); }
    40.3% { transform: translate3d(128px, 105px, 90px) scale(0.88); }
    41.67% { transform: translate3d(128px, 104px, 90px); }
    55.56% { transform: translate3d(318px, 202px, 90px); }
    57% { transform: translate3d(318px, 203px, 90px) scale(0.88); }
    58.33% { transform: translate3d(318px, 202px, 90px); }
    66.67% { transform: translate3d(128px, 124px, 90px); }
    68% { transform: translate3d(128px, 125px, 90px) scale(0.88); }
    69.44% { transform: translate3d(128px, 124px, 90px); }
    81.94% { transform: translate3d(318px, 222px, 90px); }
    83.3% { transform: translate3d(318px, 223px, 90px) scale(0.88); }
    84.72% { opacity: 1; transform: translate3d(318px, 222px, 90px); }
    100% { opacity: 0; transform: translate3d(350px, 252px, 90px); }
}

@keyframes sfp-problem-key-c {
    0%, 5.5% { opacity: 0; }
    6%, 19% { opacity: 1; }
    20%, 38.8% { opacity: 0; }
    39.3%, 49% { opacity: 1; }
    50%, 66.6% { opacity: 0; }
    67.1%, 76% { opacity: 1; }
    77%, 100% { opacity: 0; }
}

@keyframes sfp-problem-key-v {
    0%, 24.9% { opacity: 0; }
    25.4%, 35% { opacity: 1; }
    36%, 55.5% { opacity: 0; }
    56%, 64% { opacity: 1; }
    65%, 81.9% { opacity: 0; }
    82.4%, 91% { opacity: 1; }
    92%, 100% { opacity: 0; }
}

@keyframes sfp-problem-roll {
    from { transform: translateY(0); }
    to { transform: translateY(-510px); }
}

@keyframes sfp-problem-hour {
    from { transform: rotate(270deg); }
    to { transform: rotate(592.5deg); }
}

@keyframes sfp-problem-min {
    from { transform: rotate(0deg); }
    to { transform: rotate(3870deg); }
}

@keyframes sfp-problem-fill {
    from { width: 0; }
    to { width: 97.7%; }
}

@keyframes sfp-problem-count {
    from { --sfp-problem-n: 0; }
    to { --sfp-problem-n: 26; }
}

/* Recheck both rows twice, then give up */
@keyframes sfp-problem-sweep {
    0% { opacity: 0; transform: translateY(0); }
    8% { opacity: 1; transform: translateY(0); }
    30% { transform: translateY(26px); }
    52% { transform: translateY(0); }
    74% { opacity: 1; transform: translateY(26px); }
    100% { opacity: 0; transform: translateY(26px); }
}

@media (prefers-reduced-motion: reduce) {
    .sfp-problem-cur,
    .sfp-problem-ants,
    .sfp-problem-sweep { display: none; }
}
