/* ClearRun catalogue — Trigger Arc demo component
 *
 * Bespoke shared visual identity for the four "something happens →
 * time passes → personal message goes out" pages:
 *   missed-call-text-back, customer-milestones, lapsed-customer, review-request.
 *
 * Three-pane layout (trigger / arc / message). CSS-only animation on a
 * 7s loop. Mobile stacks the panes vertically and rotates the arc.
 *
 * Tokens consumed (from styles.css :root):
 *   --navy, --navy-light, --navy-dark
 *   --accent, --accent-hover, --accent-light
 *   --white, --off-white, --light-grey, --mid-grey
 *   --text, --text-light, --text-on-dark
 *   --radius-sm, --radius-md, --radius-lg
 *   --shadow-sm, --shadow-md
 *
 * Markup is hydrated by trigger-arc.js from data-* attributes on the
 * .trigger-arc-demo root. Animations live purely in this file.
 */

.trigger-arc-demo {
    --ta-cycle: 9s;
    --ta-pulse: var(--accent);
    --ta-line: rgba(255, 255, 255, 0.18);
    --ta-line-bright: rgba(26, 158, 143, 0.85);

    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 8px 4px;
    width: 100%;
    min-height: 280px;
    color: var(--white);
    font-family: inherit;
}

/* ---------- Pane wrapper ---------- */

.ta-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ta-pane__caption {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-on-dark);
    opacity: 0.7;
}

/* ---------- Pane 1: trigger device ---------- */

.ta-device {
    position: relative;
    width: 100%;
    max-width: 200px;
    background: linear-gradient(155deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    animation: ta-device-pulse var(--ta-cycle) ease-in-out infinite;
}

@keyframes ta-device-pulse {
    0%, 6% { transform: scale(1); box-shadow: 0 0 0 0 rgba(26, 158, 143, 0); border-color: rgba(255,255,255,0.12); }
    8% { transform: scale(1.03); box-shadow: 0 0 0 6px rgba(26, 158, 143, 0.18); border-color: var(--accent); }
    14% { transform: scale(1); box-shadow: 0 0 0 14px rgba(26, 158, 143, 0); border-color: rgba(255,255,255,0.18); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(26, 158, 143, 0); border-color: rgba(255,255,255,0.12); }
}

.ta-device__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 10px;
    display: block;
    color: var(--accent);
}

.ta-device__icon svg { width: 100%; height: 100%; display: block; }

.ta-device__label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--white);
    line-height: 1.3;
}

.ta-device__sub {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-on-dark);
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
}

/* Tiny "live" indicator dot, pulses with the trigger */
.ta-device__dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: ta-dot-blink var(--ta-cycle) ease-in-out infinite;
}

@keyframes ta-dot-blink {
    0%, 5% { opacity: 0.3; transform: scale(1); }
    8% { opacity: 1; transform: scale(1.4); }
    14% { opacity: 0.3; transform: scale(1); }
    100% { opacity: 0.3; transform: scale(1); }
}

/* ---------- Pane 2: arc + elapsed-time label ---------- */

.ta-pane--arc {
    width: 180px;
    flex-shrink: 0;
    gap: 14px;
}

.ta-arc {
    width: 100%;
    height: 90px;
    overflow: visible;
}

.ta-arc__line {
    fill: none;
    stroke: var(--ta-line);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
    stroke-linecap: round;
}

.ta-arc__line--bright {
    stroke: var(--ta-line-bright);
    stroke-width: 2;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: ta-arc-draw var(--ta-cycle) ease-in-out infinite;
}

@keyframes ta-arc-draw {
    0%, 14% { stroke-dashoffset: 200; opacity: 0; }
    18% { opacity: 1; }
    50% { stroke-dashoffset: 0; opacity: 1; }
    72% { stroke-dashoffset: 0; opacity: 1; }
    78% { stroke-dashoffset: 0; opacity: 0; }
    100% { stroke-dashoffset: 200; opacity: 0; }
}

.ta-arc__pulse {
    fill: var(--accent);
    r: 4;
    opacity: 0;
    animation: ta-arc-travel var(--ta-cycle) ease-in-out infinite;
    /* offset-path is browser-supported on modern engines; fallback path is the static arc */
    offset-path: path("M 6 70 Q 90 -10 174 70");
    offset-rotate: 0deg;
}

@keyframes ta-arc-travel {
    0%, 14% { offset-distance: 0%; opacity: 0; }
    18% { opacity: 1; }
    50% { offset-distance: 100%; opacity: 1; }
    55% { offset-distance: 100%; opacity: 0; }
    100% { offset-distance: 0%; opacity: 0; }
}

/* Arrow head at the end of the arc, fades in late in the cycle */
.ta-arc__head {
    fill: var(--accent);
    opacity: 0;
    animation: ta-arc-head var(--ta-cycle) ease-in-out infinite;
}

@keyframes ta-arc-head {
    0%, 48% { opacity: 0; }
    52% { opacity: 1; }
    78% { opacity: 1; }
    82% { opacity: 0; }
    100% { opacity: 0; }
}

.ta-arc__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--white);
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 6px 12px;
    line-height: 1.2;
    letter-spacing: 0.01em;
    animation: ta-label-glow var(--ta-cycle) ease-in-out infinite;
}

@keyframes ta-label-glow {
    0%, 14% { border-color: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.05); }
    30% { border-color: rgba(26, 158, 143, 0.5); background: rgba(26, 158, 143, 0.08); }
    60% { border-color: rgba(26, 158, 143, 0.3); background: rgba(26, 158, 143, 0.05); }
    100% { border-color: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.05); }
}

/* ---------- Pane 3: outbound message on a phone ---------- */

.ta-phone {
    position: relative;
    width: 100%;
    max-width: 220px;
    background: var(--white);
    color: var(--text);
    border-radius: 22px;
    padding: 14px 12px 16px;
    border: 1px solid var(--mid-grey);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 0 0 4px rgba(11, 29, 58, 0.04);
    overflow: hidden;
}

.ta-phone__notch {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: var(--navy);
    border-radius: 4px;
    opacity: 0.85;
}

.ta-phone__channel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--off-white);
    color: var(--text-light);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--light-grey);
}

.ta-phone__channel svg { width: 12px; height: 12px; }

.ta-phone__bubble {
    margin-top: 12px;
    background: var(--accent-light);
    border: 1px solid rgba(26, 158, 143, 0.18);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    text-align: left;
    opacity: 0;
    transform: translateY(12px);
    animation: ta-bubble-in var(--ta-cycle) ease-out infinite;
}

@keyframes ta-bubble-in {
    0%, 42% { opacity: 0; transform: translateY(12px); }
    50% { opacity: 1; transform: translateY(0); }
    93% { opacity: 1; transform: translateY(0); }
    97% { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 0; transform: translateY(12px); }
}

.ta-bubble__from {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-hover);
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.ta-bubble__body {
    color: var(--text);
    font-size: 13px;
}

/* "Delivered" indicator under the bubble */
.ta-phone__meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-light);
    opacity: 0;
    animation: ta-meta-in var(--ta-cycle) ease-out infinite;
}

.ta-phone__meta svg { width: 10px; height: 10px; color: var(--accent); }

@keyframes ta-meta-in {
    0%, 56% { opacity: 0; }
    64% { opacity: 0.85; }
    93% { opacity: 0.85; }
    97% { opacity: 0; }
    100% { opacity: 0; }
}

/* ---------- Mobile: stack vertically ---------- */

@media (max-width: 600px) {
    .trigger-arc-demo {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 4px 0;
        min-height: 0;
    }

    .ta-pane--arc {
        width: 100%;
        max-width: 240px;
        margin: 0 auto;
    }

    .ta-arc {
        height: 70px;
        transform: rotate(90deg);
        transform-origin: center;
        max-width: 70px;
        margin: 4px auto;
    }

    /* The rotated SVG occupies a 70x70 box; balance the height for layout */
    .ta-pane--arc {
        gap: 8px;
    }

    .ta-device, .ta-phone { max-width: 280px; }
}

/* ---------- Reduced motion: keep the layout, drop the loop ---------- */

@media (prefers-reduced-motion: reduce) {
    .ta-device,
    .ta-device__dot,
    .ta-arc__line--bright,
    .ta-arc__pulse,
    .ta-arc__head,
    .ta-arc__label,
    .ta-phone__bubble,
    .ta-phone__meta {
        animation: none !important;
    }
    .ta-phone__bubble { opacity: 1; transform: none; }
    .ta-phone__meta { opacity: 0.85; }
    .ta-arc__line--bright { stroke-dashoffset: 0; opacity: 1; }
    .ta-arc__head { opacity: 1; }
}
