/* ==========================================================================
   Landing page animations & premium touches (index.php only)
   --------------------------------------------------------------------------
   Rules:
   - Only transform/opacity are animated (compositor-friendly, 80% mobile users)
   - Entrance animations are pure CSS, so nothing depends on JS to appear
   - Scroll reveals are gated behind html.js so content is never hidden without JS
   - The global prefers-reduced-motion rule in style.css collapses every
     animation/transition to 0.01ms, so all end-states below must be complete
   ========================================================================== */

:root {
    --road-h: clamp(72px, 14vw, 104px);
    --road-surface: #061529;
    --road-edge: rgba(255, 255, 255, 0.45);
    --road-dash: rgba(255, 255, 255, 0.75);
    --car-body: #f4f6fa;
    --car-body-dark: #c9d2e0;
    --car-glass: #1e3a5f;
    --car-tire: #0a0f16;
    --car-rim: #d9dee6;
    --beam: rgba(255, 224, 130, 0.5);
    --scan: rgba(0, 51, 153, 0.18);
    --step-line: rgba(var(--primary-rgb), 0.22);
}

[data-theme="dark"] {
    --road-surface: #050d18;
    --road-edge: rgba(255, 255, 255, 0.35);
    --road-dash: rgba(255, 255, 255, 0.6);
    --car-body: #e9eef6;
    --car-body-dark: #b9c4d6;
    --car-glass: #1e3a5f;
    --car-tire: #05080d;
    --car-rim: #9fb0c8;
    --beam: rgba(255, 224, 130, 0.35);
    --scan: rgba(0, 51, 153, 0.22);
    --step-line: rgba(var(--primary-rgb), 0.35);
}

/* Scroll progress bar, [data-reveal] and count-up live in css/motion.css + js/motion.js */

/* ---------- Hero entrance (pure CSS) ---------- */
@keyframes heroRise {
    from {
        opacity: 0;
        transform: translateY(26px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.homepage .hero-title,
.homepage .hero-subtitle,
.homepage .hero-benefits .benefit-badge,
.homepage .hero-search-card {
    animation: heroRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.homepage .hero-subtitle { animation-delay: 0.12s; }
.homepage .hero-benefits .benefit-badge:nth-child(1) { animation-delay: 0.24s; }
.homepage .hero-benefits .benefit-badge:nth-child(2) { animation-delay: 0.32s; }
.homepage .hero-benefits .benefit-badge:nth-child(3) { animation-delay: 0.40s; }
.homepage .hero-search-card { animation-delay: 0.5s; }

/* Soft light glows drifting behind the navy hero */
.homepage .landing-hero::before,
.homepage .landing-hero::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    z-index: 0;
}

.homepage .landing-hero::before {
    width: 420px;
    height: 420px;
    top: -200px;
    right: -120px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 70%);
    animation: blobDrift 16s ease-in-out infinite alternate;
}

.homepage .landing-hero::after {
    width: 320px;
    height: 320px;
    left: -90px;
    top: 30%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.45) 0%, rgba(var(--primary-rgb), 0) 70%);
    animation: blobDrift 20s ease-in-out infinite alternate-reverse;
}

@keyframes blobDrift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-36px, 28px, 0) scale(1.12); }
}

/* Make room for the road at the bottom of the hero */
.homepage .landing-hero {
    padding-bottom: calc(clamp(2.5rem, 5vw, 4.5rem) + var(--road-h));
}

/* ---------- Hero road & car scene ---------- */
.hero-road {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--road-h);
    /* overflow stays visible so the badge above the car isn't clipped; the hero clips horizontally */
    pointer-events: none;
    z-index: 0;
    background: linear-gradient(180deg, transparent 0%, transparent 42%, var(--road-surface) 42%, var(--road-surface) 100%);
}

.hero-road::before {
    /* road edge line */
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 42%;
    height: 2px;
    background: var(--road-edge);
}

.hero-road__line {
    position: absolute;
    left: 0;
    top: 71%;
    width: calc(100% + 720px); /* keeps dashes across the full width after the -640px drive */
    height: 3px;
    background: repeating-linear-gradient(90deg, var(--road-dash) 0 44px, transparent 44px 80px);
    transform: translate3d(0, 0, 0);
    animation: roadDrive 2.4s cubic-bezier(0.16, 0.84, 0.3, 1) both;
}

@keyframes roadDrive {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-640px, 0, 0); }
}

.hero-car {
    position: absolute;
    left: 50%;
    bottom: 10%;
    width: clamp(150px, 28vw, 250px);
    margin-left: calc(clamp(150px, 28vw, 250px) / -2);
    transform: translate3d(0, 0, 0);
    animation: carDriveIn 2.4s cubic-bezier(0.16, 0.84, 0.3, 1) both;
    will-change: transform;
}

[dir="rtl"] .hero-car {
    /* Keep the car readable in RTL layouts: drive in from the right instead */
    animation-name: carDriveInRtl;
}

@keyframes carDriveIn {
    from { transform: translate3d(calc(-50vw - 160px), 0, 0); }
    to   { transform: translate3d(0, 0, 0); }
}

@keyframes carDriveInRtl {
    from { transform: translate3d(calc(50vw + 160px), 0, 0) scaleX(-1); }
    to   { transform: translate3d(0, 0, 0) scaleX(-1); }
}

.hero-car svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.hero-car__body { fill: var(--car-body); }
.hero-car__body-shade { fill: var(--car-body-dark); }
.hero-car__glass { fill: var(--car-glass); }
.hero-car__tire { fill: var(--car-tire); }
.hero-car__rim { fill: var(--car-rim); }
.hero-car__hub { fill: var(--car-tire); }
.hero-car__spoke { stroke: var(--car-tire); stroke-width: 2.5; stroke-linecap: round; }
.hero-car__light { fill: #ffe082; }
.hero-car__tail { fill: #ff5252; }
.hero-car__shadow { fill: rgba(0, 0, 0, 0.35); }

/* Subtle suspension bounce as the car settles */
.hero-car__chassis {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: carSettle 2.4s cubic-bezier(0.16, 0.84, 0.3, 1) both;
}

@keyframes carSettle {
    0%   { transform: translateY(0); }
    80%  { transform: translateY(0); }
    88%  { transform: translateY(2.5px) rotate(0.6deg); }
    100% { transform: translateY(0) rotate(0); }
}

.hero-car__wheel {
    transform-box: fill-box;
    transform-origin: center;
    animation: wheelSpin 2.4s cubic-bezier(0.16, 0.84, 0.3, 1) both;
}

@keyframes wheelSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(1440deg); }
}

.hero-car__beam {
    fill: var(--beam);
    animation: beamFade 2.6s ease-out both;
}

@keyframes beamFade {
    0%   { opacity: 1; }
    85%  { opacity: 1; }
    100% { opacity: 0.35; }
}

/* Green "approved" badge that pops once the car has parked */
.hero-car__badge {
    transform-box: fill-box;
    transform-origin: center;
    animation: badgePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 2.45s both;
}

.hero-car__badge-circle { fill: var(--success); }
.hero-car__badge-check { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

@keyframes badgePop {
    from { opacity: 0; transform: scale(0.2) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Badge pulse ring */
.hero-car__badge-ring {
    fill: none;
    stroke: var(--success);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0;
    animation: badgeRing 2.4s ease-out 2.9s infinite;
}

@keyframes badgeRing {
    0%   { opacity: 0.7; transform: scale(0.8); }
    60%  { opacity: 0;   transform: scale(1.9); }
    100% { opacity: 0;   transform: scale(1.9); }
}

/* ---------- Licence-plate search field: scan sweep on focus ---------- */
.homepage .plate-input-group {
    position: relative;
}

.homepage .plate-input-group::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: linear-gradient(90deg, transparent 0%, var(--scan) 50%, transparent 100%);
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, 0, 0);
    z-index: 2;
}

.homepage .plate-input-group:focus-within::after {
    animation: plateScan 1.1s ease-out 1;
}

@keyframes plateScan {
    0%   { opacity: 0; transform: translate3d(0, 0, 0); }
    15%  { opacity: 1; }
    100% { opacity: 0; transform: translate3d(350%, 0, 0); }
}

/* Plate frame lifts slightly when focused */
.homepage .search-form-hero .input-group.plate-input-group {
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.homepage .search-form-hero .input-group.plate-input-group:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* Primary CTA: periodic sheen + press feedback */
.homepage .plate-input-group .btn,
.homepage .landing-checklist-section .btn-primary.btn-lg {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.homepage .plate-input-group .btn::after,
.homepage .landing-checklist-section .btn-primary.btn-lg::after {
    content: "";
    position: absolute;
    top: -20%;
    bottom: -20%;
    left: -60%;
    width: 40%;
    background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
    transform: skewX(-18deg) translate3d(0, 0, 0);
    animation: btnSheen 7s ease-in-out 3s infinite;
    pointer-events: none;
}

@keyframes btnSheen {
    0%   { transform: skewX(-18deg) translate3d(0, 0, 0); }
    18%  { transform: skewX(-18deg) translate3d(420%, 0, 0); }
    100% { transform: skewX(-18deg) translate3d(420%, 0, 0); }
}

.homepage .plate-input-group .btn:active,
.homepage .landing-checklist-section .btn-primary.btn-lg:active {
    transform: scale(0.97);
}

/* ---------- Stats: tabular numbers so count-up doesn't jitter ---------- */
.homepage .homepage-stats .stat-number {
    font-variant-numeric: tabular-nums;
}

.homepage .homepage-stats .stat-item {
    transition: transform 0.3s ease;
}

.homepage .homepage-stats .stat-item:hover {
    transform: translateY(-4px);
}

/* ---------- How it works: 3 animated steps ---------- */
.homepage .how-it-works-section {
    padding: clamp(1.5rem, 4vw, 3rem);
    border-radius: 30px;
    border: 1px solid rgba(var(--primary-rgb), 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 249, 255, 0.98) 100%);
    box-shadow: 0 22px 44px rgba(15, 38, 65, 0.08);
}

[data-theme="dark"] .homepage .how-it-works-section {
    background: rgba(26, 31, 38, 0.9);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.35);
}

.how-steps {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Connector line that draws itself when the section becomes visible */
.how-steps::before {
    content: "";
    position: absolute;
    top: 40px;
    left: calc(100% / 6);
    right: calc(100% / 6);
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
    z-index: 0;
}

[dir="rtl"] .how-steps::before {
    transform-origin: 100% 50%;
}

.how-steps.is-visible::before,
html:not(.js) .how-steps::before {
    transform: scaleX(1);
}

.how-step {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 0.5rem;
}

.how-step__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--surface-primary);
    color: var(--primary);
    font-size: 1.75rem;
    border: 3px solid var(--step-line);
    box-shadow: 0 12px 26px rgba(var(--shadow-color), 0.12);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.how-step:hover .how-step__icon {
    transform: translateY(-4px) scale(1.04);
    border-color: var(--primary);
    box-shadow: 0 16px 30px rgba(var(--primary-rgb), 0.22);
}

.how-step__num {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.35);
}

[dir="rtl"] .how-step__num {
    right: auto;
    left: -6px;
}

/* Icon pop-in once revealed */
.js .how-step .how-step__icon i {
    display: inline-block;
    opacity: 0;
    transform: scale(0.4) rotate(-20deg);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    transition-delay: calc(var(--reveal-delay, 0s) + 0.25s);
}

.js .how-step.is-visible .how-step__icon i {
    opacity: 1;
    transform: none;
}

.how-step__title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.how-step__text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
    margin: 0;
}

@media (max-width: 768px) {
    .how-steps {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    /* On mobile each step draws its own short connector down to the next icon */
    .how-steps::before {
        display: none;
    }

    .how-step:not(:last-child)::before {
        content: "";
        position: absolute;
        left: 30px;
        top: 64px;
        bottom: -1.25rem;
        width: 3px;
        border-radius: 3px;
        background: linear-gradient(180deg, var(--primary) 0%, var(--success) 100%);
        transform: scaleY(0);
        transform-origin: 50% 0;
        transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s;
        z-index: 0;
    }

    [dir="rtl"] .how-step:not(:last-child)::before {
        left: auto;
        right: 30px;
    }

    .how-step.is-visible:not(:last-child)::before,
    html:not(.js) .how-step:not(:last-child)::before {
        transform: scaleY(1);
    }

    .how-step {
        display: grid;
        grid-template-columns: 64px 1fr;
        column-gap: 1rem;
        text-align: start;
        padding: 0;
    }

    .how-step__icon {
        width: 64px;
        height: 64px;
        margin: 0;
        font-size: 1.4rem;
    }

    .how-step__title {
        margin-top: 0.4rem;
    }
}

/* ---------- Failure list: animated share bars ---------- */
.failure-bar {
    position: relative;
    height: 6px;
    margin-top: 0.5rem;
    border-radius: 6px;
    background: rgba(var(--shadow-color), 0.1);
    overflow: hidden;
}

[data-theme="dark"] .failure-bar {
    background: rgba(255, 255, 255, 0.1);
}

.failure-bar__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--pct, 0) * 1%);
    border-radius: 6px;
    background: linear-gradient(90deg, var(--danger) 0%, var(--warning) 100%);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--bar-delay, 0s);
}

[dir="rtl"] .failure-bar__fill {
    inset: 0 0 0 auto;
    transform-origin: 100% 50%;
}

.is-visible .failure-bar__fill,
html:not(.js) .failure-bar__fill {
    transform: scaleX(1);
}

/* ---------- Interactive checklist with progress ---------- */
.checklist-progress {
    margin-bottom: 1rem;
}

.checklist-progress__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.checklist-progress__label i {
    color: var(--success);
    opacity: 0;
    transform: scale(0.4);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.checklist-progress.is-complete .checklist-progress__label {
    color: var(--success-dark);
}

.checklist-progress.is-complete .checklist-progress__label i {
    opacity: 1;
    transform: scale(1);
}

.checklist-progress__track {
    height: 8px;
    border-radius: 8px;
    background: rgba(var(--shadow-color), 0.1);
    overflow: hidden;
}

[data-theme="dark"] .checklist-progress__track {
    background: rgba(255, 255, 255, 0.1);
}

.checklist-progress__fill {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    transform: scaleX(var(--progress, 0));
    transform-origin: 0 50%;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

[dir="rtl"] .checklist-progress__fill {
    transform-origin: 100% 50%;
}

.checklist-item {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.checklist-item:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.checklist-item i {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.checklist-item.checked {
    background: var(--success-light);
}

.checklist-item.checked i {
    animation: tickPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.checklist-item.checked strong {
    text-decoration: line-through;
    text-decoration-color: rgba(var(--shadow-color), 0.35);
    opacity: 0.75;
}

@keyframes tickPop {
    0%   { transform: scale(0.6) rotate(-12deg); }
    60%  { transform: scale(1.25) rotate(6deg); }
    100% { transform: scale(1) rotate(0); }
}

/* ---------- City chips: stagger in ---------- */
.js .popular-cities-grid [data-reveal] {
    transform: translateY(12px) scale(0.97);
}

.js .popular-cities-grid [data-reveal].is-visible {
    transform: none;
}

/* ---------- Blog cards: arrow nudge on hover ---------- */
.homepage .landing-blog-section .hover-lift .text-primary.small {
    display: inline-block;
    transition: transform 0.25s ease;
}

.homepage .landing-blog-section .hover-lift:hover .text-primary.small {
    transform: translateX(4px);
}

[dir="rtl"] .homepage .landing-blog-section .hover-lift:hover .text-primary.small {
    transform: translateX(-4px);
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 768px) {
    .homepage .landing-hero {
        padding-bottom: calc(1.75rem + var(--road-h));
    }

    .hero-car {
        bottom: 8%;
    }

    /* Sheen loops are pointless on tiny screens and cost paint */
    .homepage .plate-input-group .btn::after,
    .homepage .landing-checklist-section .btn-primary.btn-lg::after {
        display: none;
    }
}

/* ---------- Reduced motion: make sure end states are shown ---------- */
@media (prefers-reduced-motion: reduce) {
    .hero-road__line,
    .hero-car,
    .hero-car__wheel,
    .hero-car__chassis,
    .hero-car__beam,
    .hero-car__badge,
    .hero-car__badge-ring,
    .homepage .landing-hero::before,
    .homepage .landing-hero::after,
    .homepage .plate-input-group .btn::after,
    .homepage .landing-checklist-section .btn-primary.btn-lg::after {
        animation: none !important;
    }

    .hero-car__badge { opacity: 1; }
    .hero-car__beam { opacity: 0.35; }
    .hero-car__badge-ring { opacity: 0; }

    .js [data-reveal] {
        opacity: 1;
        transform: none;
    }

    .how-steps::before { transform: none; }
    .failure-bar__fill { transform: scaleX(1); }
}
