/* Cartridge AI: motion layer */

:root {
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Sections: softer entrance than the base 30px slide */
section {
    transform: translateY(16px);
    transition: opacity 0.7s var(--ease-out-expo), transform 0.7s var(--ease-out-expo);
}

/* ---------- Generic reveals inside a visible section ---------- */
.motion-ready section:not(.hero) .section-label,
.motion-ready section:not(.hero) .section-headline,
.motion-ready section:not(.hero) .section-text {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(6px);
    transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo), filter 0.8s var(--ease-out-expo);
}

.motion-ready section .section-headline { transition-delay: 0.08s; }
.motion-ready section .section-text { transition-delay: 0.16s; }

.motion-ready section.visible .section-label,
.motion-ready section.visible .section-headline,
.motion-ready section.visible .section-text {
    opacity: 1;
    transform: none;
    filter: none;
}

/* Staggered children */
.motion-ready .step,
.motion-ready .feature-card,
.motion-ready .connector-row,
.motion-ready .trust-badge,
.motion-ready .faq-item,
.motion-ready .platform-tag {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s var(--ease-out-expo), transform 0.7s var(--ease-out-expo),
                border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    transition-delay: calc(0.25s + var(--i, 0) * 0.09s);
}

.motion-ready section.visible .step,
.motion-ready section.visible .feature-card,
.motion-ready section.visible .connector-row,
.motion-ready section.visible .trust-badge,
.motion-ready section.visible .faq-item,
.motion-ready section.visible .platform-tag {
    opacity: 1;
    transform: none;
}

/* Hover lifts keep working after reveal */
.motion-ready section.visible .feature-card:hover,
.motion-ready section.visible .step:hover {
    transform: translateY(-4px);
    transition-delay: 0s;
}

/* Feature cards: a connector stub that "plugs" on hover */
.feature-card {
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, var(--electric-blue), rgba(var(--accent-rgb), 0));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s var(--ease-out-expo);
}

.feature-card:hover::before {
    transform: scaleX(1);
}

/* ---------- Hero ---------- */
.hero h1 .rotator-line {
    display: block;
}

.rotator {
    position: relative;
    display: inline-grid;
    color: var(--accent-text);
    vertical-align: bottom;
}

.rotator-word {
    grid-area: 1 / 1;
    display: inline-block;
    white-space: nowrap;
    transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo), filter 0.6s var(--ease-out-expo);
}

.rotator-word.is-entering {
    opacity: 0;
    transform: translateY(0.45em);
    filter: blur(8px);
}

.rotator-word.is-leaving {
    opacity: 0;
    transform: translateY(-0.45em);
    filter: blur(8px);
}

.rotator::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.04em;
    height: 0.08em;
    border-radius: 0.04em;
    background: linear-gradient(90deg, var(--electric-blue), rgba(var(--accent-rgb), 0.15));
    transform-origin: left;
    animation: underline-sweep 2.2s var(--ease-out-expo) infinite;
}

@keyframes underline-sweep {
    0% { transform: scaleX(0); opacity: 1; }
    40% { transform: scaleX(1); opacity: 1; }
    85% { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0; }
}

/* ---------- Problem: things that get lost ---------- */
.strike {
    position: relative;
    white-space: nowrap;
    transition: color 0.4s ease;
    transition-delay: calc(0.5s + var(--i, 0) * 0.35s);
}

.strike::after {
    content: '';
    position: absolute;
    left: -2px;
    right: -2px;
    top: 55%;
    height: 2px;
    background: #E5484D;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.45s var(--ease-out-expo);
    transition-delay: calc(0.5s + var(--i, 0) * 0.35s);
}

.problem.visible .strike {
    color: var(--medium-gray);
}

.problem.visible .strike::after {
    transform: scaleX(1);
}

.problem-statement .fix {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-spring);
    transition-delay: 1.9s;
}

.problem.visible .problem-statement .fix {
    opacity: 1;
    transform: none;
}

/* ---------- Hub ---------- */
.hub {
    position: relative;
    isolation: isolate;
    background-image:
        linear-gradient(rgba(var(--accent-rgb), 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--accent-rgb), 0.05) 1px, transparent 1px),
        linear-gradient(135deg, var(--light-blue), var(--pure-white));
    background-size: 32px 32px, 32px 32px, auto;
}

.hub > .hub-group,
.hub > .hub-core {
    position: relative;
    z-index: 2;
}

.hub-group.hub-bottom {
    border-top: none;
}

/* Label sits under the slots so the wires never cross it */
.hub-bottom .hub-group-label {
    order: 2;
    margin-top: 4px;
}

.terminal {
    fill: var(--pure-white);
    stroke: var(--electric-blue);
    stroke-width: 2;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.hub.is-live .terminal.is-on { opacity: 1; }

.hub-wires {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

.wire-track {
    fill: none;
    stroke: rgba(var(--accent-rgb), 0.14);
    stroke-width: 2;
    stroke-dasharray: 3 6;
}

.wire {
    fill: none;
    stroke: var(--electric-blue);
    stroke-width: 2;
    stroke-linecap: round;
    opacity: 0.55;
    transition: stroke-dashoffset 0.9s var(--ease-out-expo), opacity 0.3s ease, stroke-width 0.3s ease;
}

.hub.has-hot .wire { opacity: 0.2; }
.hub.has-hot .wire.is-hot { opacity: 1; stroke-width: 3; }

.packet {
    fill: var(--electric-blue);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.hub.is-flowing .packet { opacity: 1; }

/* ---------- The cartridge: a line drawing ---------- */
@keyframes ping {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(2.6); opacity: 0; }
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

.cart {
    --cart-ink: #F5F5F7;
    --cart-fill: #0F0F0F;
    position: relative;
    width: 300px;
    max-width: 100%;
    aspect-ratio: 240 / 274;
    color: var(--cart-ink);
    cursor: pointer;
    outline: none;
    transform-origin: 50% 100%;
    transition: transform 0.85s var(--ease-spring), opacity 0.35s ease;
}

.cart-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ca-fill { fill: var(--cart-fill); }

.ca-lines {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.ca-thin { stroke-opacity: 0.45; }

.ca-draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
}

.motion-ready .ca-draw {
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 1.1s var(--ease-out-expo);
}

.motion-ready .ca-draw:nth-child(2) { transition-delay: 0.1s; }
.motion-ready .ca-draw:nth-child(3) { transition-delay: 0.18s; }
.motion-ready .ca-draw:nth-child(4) { transition-delay: 0.26s; }
.motion-ready .ca-draw:nth-child(5) { transition-delay: 0.34s; }
.motion-ready .ca-draw:nth-child(6) { transition-delay: 0.42s; }
.motion-ready .ca-draw:nth-child(7) { transition-delay: 0.5s; }
.motion-ready .ca-draw:nth-child(8) { transition-delay: 0.58s; }

.hub.is-inserting .ca-draw,
.reduce-motion .ca-draw {
    stroke-dashoffset: 0;
}

.ca-led {
    fill: transparent;
    stroke: currentColor;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.hub.is-live .ca-led,
.reduce-motion .ca-led {
    fill: var(--electric-blue);
    stroke: var(--electric-blue);
    filter: drop-shadow(0 0 4px var(--electric-blue));
}

.cart:focus-visible .ca-lines {
    stroke: var(--electric-blue);
}

/* Pre-insert: a faint outline hovering above the socket */
.motion-ready .cart {
    opacity: 0;
    transform: translateY(-48px);
}

.hub.is-inserting .cart,
.reduce-motion .cart {
    opacity: 1;
    transform: none;
}

.hub.is-live .cart {
    animation: cart-thunk 0.35s ease-out;
}

.hub.is-flowing .cart:hover {
    transform: translateY(-5px);
}

@keyframes cart-thunk {
    0% { transform: translateY(0); }
    40% { transform: translateY(5px) scaleY(0.985); }
    100% { transform: translateY(0); }
}

/* Label: sits in the drawn recess */
.cart-label {
    position: absolute;
    left: 10.83%;
    top: 21.17%;
    width: 78.33%;
    height: 54.74%;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    color: var(--cart-ink);
    opacity: 0;
    transition: opacity 0.4s ease 0.2s;
}

.hub.is-live .cart-label,
.reduce-motion .cart-label {
    opacity: 1;
}

.cart-label-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(245, 245, 247, 0.7);
}

.cart-label-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cart-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 15px;
    line-height: 1.3;
    margin: 12px 0 10px;
    color: var(--accent-text);
    text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.55);
}

.hub-core-list {
    list-style: none;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hub-core-list li {
    position: relative;
    padding: 5px 6px 5px 18px;
    border-radius: 4px;
    color: rgba(245, 245, 247, 0.75);
    transition: background 0.15s steps(2), color 0.15s steps(2);
}

.hub-core-list li::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    margin-top: -4px;
    border-left: 6px solid var(--electric-blue);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    opacity: 0;
}

.hub-core-list li.is-selected {
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--pure-white);
}

.hub-core-list li.is-selected::before {
    opacity: 1;
    animation: cursor-blink 0.8s steps(2) infinite;
}

.motion-ready .hub-core-list li {
    opacity: 0;
    transition: opacity 0.01s linear, background 0.15s steps(2), color 0.15s steps(2);
    transition-delay: calc(0.45s + var(--i, 0) * 0.12s);
}

.hub.is-live .hub-core-list li {
    opacity: 1;
}

.cart-hint {
    position: absolute;
    left: 0;
    right: 0;
    top: 84%;
    text-align: center;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(245, 245, 247, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.hub.is-flowing .cart:hover .cart-hint,
.hub.is-flowing .cart:focus-visible .cart-hint { opacity: 1; }

/* Invisible measuring strip over the drawn edge connector: wires start here */
.cart-pins {
    position: absolute;
    left: 22.5%;
    width: 55%;
    top: 93.43%;
    bottom: 0.7%;
}

@media (max-width: 860px) {
    .cart { width: 270px; }
}


/* Slots: empty socket, then plugged in */
.slot {
    position: relative;
    border-left-width: 4px;
    border-left-color: var(--light-gray);
    background: rgba(255, 255, 255, 0.6);
    border-style: dashed solid dashed solid;
    transition: border-color 0.5s ease, background 0.5s ease, box-shadow 0.5s ease, opacity 0.5s ease;
    cursor: default;
}

.motion-ready .slot {
    opacity: 0.55;
}

.slot .slot-type {
    transition: background 0.4s ease, color 0.4s ease;
    background: var(--off-white);
    color: var(--medium-gray);
}

.slot.is-connected,
.reduce-motion .slot {
    opacity: 1;
    border-style: solid;
    border-color: var(--light-gray);
    border-left-color: var(--electric-blue);
    background: var(--pure-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: plug-in 0.55s var(--ease-spring);
}

.slot.is-connected .slot-type,
.reduce-motion .slot .slot-type {
    background: var(--light-blue);
    color: var(--accent-text-deep);
}

.slot.is-connected:hover {
    box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.18);
    border-color: var(--electric-blue);
}

@keyframes plug-in {
    0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
    60% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
    100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
}

@keyframes dot-ping {
    0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ---------- Steps: a wire running through 1, 2, 3 ---------- */
.steps {
    position: relative;
}

.steps::before {
    content: '';
    position: absolute;
    top: 68px;
    left: 16%;
    right: 16%;
    height: 2px;
    background: linear-gradient(90deg, var(--electric-blue), rgba(var(--accent-rgb), 0.3));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 1.4s var(--ease-out-expo) 0.4s;
    z-index: 0;
}

.how-it-works.visible .steps::before {
    transform: scaleX(1);
}

.step {
    position: relative;
    z-index: 1;
}

.step-number {
    position: relative;
}

.how-it-works.visible .step-number::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--electric-blue);
    animation: ping 1.2s var(--ease-out-expo) both;
    animation-delay: calc(0.6s + var(--i, 0) * 0.45s);
}

@media (min-width: 961px) {
    .steps {
        grid-template-columns: repeat(3, 1fr);
        gap: 32px;
    }
}

@media (max-width: 960px) {
    .steps::before { display: none; }
}

/* ---------- Connector table: rows light up ---------- */
.connector-row span:last-child {
    display: flex;
    align-items: center;
    gap: 10px;
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--light-gray);
    flex-shrink: 0;
    transition: background 0.3s ease;
    transition-delay: calc(0.6s + var(--i, 0) * 0.15s);
}

.works-with.visible .conn-dot {
    background: #2EB67D;
    animation: live-ping 2.4s ease-out infinite;
    animation-delay: calc(0.6s + var(--i, 0) * 0.15s);
}

@keyframes live-ping {
    0% { box-shadow: 0 0 0 0 rgba(46, 182, 125, 0.5); }
    70% { box-shadow: 0 0 0 7px rgba(46, 182, 125, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 182, 125, 0); }
}

.connector-row:not(.connector-head) {
    transition: opacity 0.7s var(--ease-out-expo), transform 0.7s var(--ease-out-expo), background 0.2s ease;
    transition-delay: calc(0.25s + var(--i, 0) * 0.09s);
}

.connector-row:not(.connector-head):hover {
    background: var(--light-blue);
    transition-delay: 0s;
}

/* Roadmap tags: pending, dashed */
.works-with .platform-tag {
    background: transparent;
    border-style: dashed;
}

/* ---------- Background flow lines: a touch more presence ---------- */
.animated-bg { opacity: 0.12; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
    section, .motion-ready section .section-label, .motion-ready section .section-headline,
    .motion-ready section .section-text, .motion-ready .step, .motion-ready .feature-card,
    .motion-ready .connector-row, .motion-ready .trust-badge, .motion-ready .faq-item,
    .motion-ready .platform-tag, .motion-ready .hub-core-list li {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }
    .animated-bg { display: none; }
}
