/* ============================================================
   Homepage Hero Pipeline Animation
   One continuous, self-running loop (no tabs, no clicks):
   document is scanned -> data chips extracted -> flow into
   the bookkeeping ledger -> DATEV export completes -> repeat.
   All elements share one master cycle for perfect sync.
   ============================================================ */

.hero-pipeline {
    --hp-cycle: 12s;
    --hp-brand: #1a2f6e;
    --hp-brand-light: #EEF2FF;
    --hp-green: #16a34a;
    --hp-green-bg: rgba(34, 197, 94, 0.14);
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 460px;
    margin: 0 auto;
    font-family: 'Inter', 'Roboto', sans-serif;
}

.hp-card {
    position: absolute;
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 2px 20px rgba(26, 47, 110, 0.10),
        0 16px 44px rgba(0, 0, 0, 0.08);
}

.hp-tag {
    position: absolute;
    top: -12px;
    left: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hp-brand);
    background: var(--hp-brand-light);
    border: 1px solid #dbe3ff;
    border-radius: 20px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* ── Card 1: the document being scanned ── */
/* top offset leaves headroom for the -12px tag plus the -6px float,
   so nothing ever leaves the container (ancestors clip overflow) */
.hp-doc-card {
    top: 32px;
    left: 0;
    width: 58%;
    padding: 22px 18px 18px;
    transform: rotate(-2deg);
    z-index: 1;
}

.hp-doc-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.hp-doc-logo {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--hp-brand), #4763b8);
    flex-shrink: 0;
}

.hp-doc-headlines {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.hp-doc-headlines span {
    display: block;
    height: 7px;
    border-radius: 4px;
    background: #d9dceb;
}

.hp-doc-headlines span:nth-child(1) { width: 75%; }
.hp-doc-headlines span:nth-child(2) { width: 50%; }

.hp-doc-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hp-doc-line {
    height: 6px;
    border-radius: 3px;
    background: #e4e7f2;
}

.hp-doc-line.hl {
    background: #d9dceb;
}

.hp-doc-total {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed #d9dceb;
}

.hp-doc-total span {
    display: block;
    height: 8px;
    border-radius: 4px;
    background: #c3c9de;
}

.hp-doc-total span:nth-child(1) { width: 30%; }
.hp-doc-total span:nth-child(2) { width: 22%; background: var(--hp-brand); opacity: 0.75; }

/* Scanline sweeping the document (start of cycle) */
.hp-scan {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, #4facfe 30%, #4facfe 70%, transparent);
    box-shadow: 0 0 14px 3px rgba(79, 172, 254, 0.55);
    opacity: 0;
    animation: hpScan var(--hp-cycle) linear infinite;
}

@keyframes hpScan {
    0%       { top: 6%;  opacity: 0; }
    2%       { opacity: 1; }
    16%      { top: 94%; opacity: 1; }
    18%      { opacity: 0; }
    100%     { top: 94%; opacity: 0; }
}

/* Extracted data chips popping off the document */
.hp-chip {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #dbe3ff;
    border-radius: 20px;
    padding: 5px 11px;
    box-shadow: 0 6px 18px rgba(26, 47, 110, 0.16);
    opacity: 0;
    z-index: 3;
    white-space: nowrap;
}

.hp-chip i {
    color: var(--hp-green);
    font-size: 0.62rem;
}

.hp-chip-1 {
    top: 26%;
    right: 26%;
    animation: hpChipIn var(--hp-cycle) ease-in-out infinite;
    animation-delay: 0s;
}

.hp-chip-2 {
    top: 40%;
    right: 20%;
    animation: hpChipIn2 var(--hp-cycle) ease-in-out infinite;
}

@keyframes hpChipIn {
    0%, 8%   { opacity: 0; transform: translateY(8px) scale(0.85); }
    12%      { opacity: 1; transform: translateY(0) scale(1.04); }
    13.5%    { transform: scale(1); }
    90%      { opacity: 1; }
    96%, 100% { opacity: 0; transform: translateY(-6px) scale(0.95); }
}

@keyframes hpChipIn2 {
    0%, 13%  { opacity: 0; transform: translateY(8px) scale(0.85); }
    17%      { opacity: 1; transform: translateY(0) scale(1.04); }
    18.5%    { transform: scale(1); }
    90%      { opacity: 1; }
    96%, 100% { opacity: 0; transform: translateY(-6px) scale(0.95); }
}

/* ── Flow dots travelling from document to ledger ── */
.hp-flow {
    position: absolute;
    top: 47%;
    left: 46%;
    width: 26%;
    height: 18%;
    z-index: 2;
    pointer-events: none;
}

.hp-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hp-brand), #4facfe);
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.5);
    opacity: 0;
    animation: hpDot var(--hp-cycle) ease-in-out infinite;
}

.hp-dot-2 { animation-delay: 0.35s; }
.hp-dot-3 { animation-delay: 0.7s; }

@keyframes hpDot {
    0%, 20%  { opacity: 0; left: 0; top: 0; }
    22%      { opacity: 1; }
    30%      { opacity: 1; left: 85%; top: 85%; }
    32%      { opacity: 0; left: 85%; top: 85%; }
    100%     { opacity: 0; left: 85%; top: 85%; }
}

/* ── Card 2: the bookkeeping ledger ── */
.hp-ledger-card {
    bottom: 10px;
    right: 0;
    width: 88%;
    padding: 24px 18px 18px;
    transform: rotate(1.2deg);
    z-index: 2;
}

.hp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #eceef5;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 9px;
    opacity: 0;
}

.hp-row-1 { animation: hpRow1 var(--hp-cycle) ease-in-out infinite; }
.hp-row-2 { animation: hpRow2 var(--hp-cycle) ease-in-out infinite; }

@keyframes hpRow1 {
    0%, 30%  { opacity: 0; transform: translateX(-16px); }
    35%      { opacity: 1; transform: translateX(0); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; transform: translateX(0); }
}

@keyframes hpRow2 {
    0%, 40%  { opacity: 0; transform: translateX(-16px); }
    45%      { opacity: 1; transform: translateX(0); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; transform: translateX(0); }
}

.hp-acct {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--hp-brand);
    background: var(--hp-brand-light);
    border-radius: 6px;
    padding: 3px 7px;
    flex-shrink: 0;
}

.hp-row-text {
    font-size: 0.76rem;
    font-weight: 500;
    color: #334155;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hp-conf {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.64rem;
    font-weight: 700;
    color: #15803d;
    background: var(--hp-green-bg);
    border-radius: 20px;
    padding: 3px 8px;
    flex-shrink: 0;
    opacity: 0;
}

.hp-row-1 .hp-conf { animation: hpConf1 var(--hp-cycle) ease-in-out infinite; }
.hp-row-2 .hp-conf { animation: hpConf2 var(--hp-cycle) ease-in-out infinite; }

@keyframes hpConf1 {
    0%, 37%  { opacity: 0; transform: scale(0.4); }
    41%      { opacity: 1; transform: scale(1.15); }
    43%      { transform: scale(1); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; }
}

@keyframes hpConf2 {
    0%, 47%  { opacity: 0; transform: scale(0.4); }
    51%      { opacity: 1; transform: scale(1.15); }
    53%      { transform: scale(1); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; }
}

/* Export row: dark bar that fills, then a check pops */
.hp-export {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--hp-brand);
    border-radius: 10px;
    padding: 11px 12px;
    margin-top: 4px;
    opacity: 0;
    animation: hpExportRow var(--hp-cycle) ease-in-out infinite;
}

@keyframes hpExportRow {
    0%, 52%  { opacity: 0; transform: translateY(10px); }
    57%      { opacity: 1; transform: translateY(0); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; }
}

.hp-export i.fa-file-export {
    color: #7dd3fc;
    font-size: 0.78rem;
}

.hp-export-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #ffffff;
    white-space: nowrap;
}

.hp-export-bar {
    flex: 1;
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
    position: relative;
}

.hp-export-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #4ade80, #86efac);
    animation: hpExportFill var(--hp-cycle) ease-in-out infinite;
}

@keyframes hpExportFill {
    0%, 58%  { width: 0; }
    76%      { width: 100%; }
    94%      { width: 100%; }
    98%, 100% { width: 0; }
}

.hp-export-check {
    color: #4ade80;
    font-size: 0.85rem;
    opacity: 0;
    animation: hpExportCheck var(--hp-cycle) ease-in-out infinite;
}

@keyframes hpExportCheck {
    0%, 76%  { opacity: 0; transform: scale(0.4); }
    80%      { opacity: 1; transform: scale(1.2); }
    82%      { transform: scale(1); }
    94%      { opacity: 1; }
    98%, 100% { opacity: 0; }
}

/* Gentle idle float so the scene never feels frozen */
.hp-doc-card { animation: hpFloatA 7s ease-in-out infinite; }
.hp-ledger-card { animation: hpFloatB 8s ease-in-out infinite; }

@keyframes hpFloatA {
    0%, 100% { transform: rotate(-2deg) translateY(0); }
    50%      { transform: rotate(-2deg) translateY(-6px); }
}

@keyframes hpFloatB {
    0%, 100% { transform: rotate(1.2deg) translateY(0); }
    50%      { transform: rotate(1.2deg) translateY(5px); }
}

/* ── Responsive ── */
@media (max-width: 991px) {
    .hero-pipeline {
        margin-top: 36px;
        height: 420px;
        max-width: 380px;
    }
}

@media (max-width: 420px) {
    .hero-pipeline { height: 380px; }
    .hp-row-text { font-size: 0.7rem; }
}

/* Respect reduced-motion preferences: show the finished state */
@media (prefers-reduced-motion: reduce) {
    .hp-scan, .hp-dot { display: none; }
    .hp-chip, .hp-row, .hp-conf, .hp-export, .hp-export-check {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .hp-export-bar::after { animation: none; width: 100%; }
    .hp-doc-card, .hp-ledger-card { animation: none; }
}
