/* ==========================================================
   TAPPITRACK — HOMEPAGE HERO (4-segment carousel)
   Markup: generated by scripts/site/home.py (HERO_SLIDES)
   Script: assets/js/pages/home.js
   Layers, back to front: navy gradient (section background), the
   route-line texture (assets/images/ui/hero-map-lines.svg) or, when a
   slide has one, its background photo; a navy overlay (photo only);
   the blue glow; the content.
   Each slide: copy on the left, the product visual centred in a fixed
   16:10 frame on the right, with two "live notification" chips attached
   to the visual's top-left and bottom-right corners. All slides share
   one grid cell, so switching never changes the hero's height.
   Brand blue (#0067EE) is only the accent: primary button and the
   active tab's progress bar.
   ========================================================== */

.tt-hero {
    --slide-ms: 7000ms; /* keep in sync with slideMs in home.js */
    --hero-pad: 38px;   /* 20% less than the previous 48px */

    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    min-height: clamp(520px, calc(100svh - var(--tt-header-height)), 720px);
    overflow: hidden;
    color: var(--tt-white);
    background: linear-gradient(180deg, var(--tt-navy) 0%, var(--tt-navy-2) 100%);
}

/* ---------- Background ---------- */

.tt-hero-decor {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

/* Abstract route lines, faded out towards the copy on the left. */
.tt-hero-map {
    position: absolute;
    inset: 0;
    background: url("/assets/images/ui/hero-map-lines.svg") center / cover no-repeat;
    opacity: 0.06;
    -webkit-mask-image: linear-gradient(90deg, transparent 25%, #000 65%);
    mask-image: linear-gradient(90deg, transparent 25%, #000 65%);
}

/* Background photos (optional, one per slide): sharp and close to their
   natural colour, crossfaded with the slide. The active photo zooms in
   very slowly over the slide's time (off with reduced motion). */
.tt-hero-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.92) contrast(1.05);
    opacity: 0;
    transition: opacity 600ms ease;
}

.tt-hero-photo.is-active {
    opacity: 1;
    animation: tt-hero-zoom calc(var(--slide-ms) + 1500ms) ease-out forwards;
}

@keyframes tt-hero-zoom { from { transform: scale(1); } to { transform: scale(1.06); } }

/* Blue-navy overlay over a photo: solid behind the copy, opening up
   towards the visual so about half of the scene shows on the right, plus
   a fade behind the tabs. Measured on the four hero photos at 1366 px:
   worst-case contrast behind the copy is 8.1:1 for the headline and
   5.8:1 for the paragraph (WCAG AA needs 4.5:1). */
.tt-hero-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 68%, rgba(6, 22, 52, 0.85) 100%),
        linear-gradient(90deg, rgba(6, 28, 66, 0.9) 0%, rgba(6, 28, 66, 0.84) 30%, rgba(6, 28, 66, 0.66) 50%, rgba(6, 28, 66, 0.46) 75%, rgba(6, 28, 66, 0.36) 100%);
    opacity: 0;
    transition: opacity 600ms ease;
}

.tt-hero.has-photo .tt-hero-overlay {
    opacity: 1;
}

.tt-hero-map {
    transition: opacity 600ms ease;
}

.tt-hero.has-photo .tt-hero-map {
    opacity: 0;
}

/* Blue glow above the texture or photo, behind the media. Softer over a
   photo, so it lights the screenshot without washing the scene out. */
.tt-hero-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(900px 600px at 75% 40%, rgba(0, 103, 238, 0.45), transparent 70%);
    transition: opacity 600ms ease;
}

.tt-hero.has-photo .tt-hero-glow {
    opacity: 0.55;
}

/* ---------- Layout ---------- */

.tt-hero-inner {
    display: grid;
    gap: 28px;
    padding-top: var(--hero-pad);
    padding-bottom: var(--hero-pad);
}

.tt-hero-slides {
    display: grid;
}

.tt-hero-slide {
    grid-area: 1 / 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: center;
    gap: clamp(32px, 5vw, 80px);
    visibility: hidden;
}

.tt-hero-slide.is-active {
    visibility: visible;
}

/* ---------- Copy ---------- */

.tt-hero-copy > *,
.tt-hero-frame {
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity 250ms ease,
        transform 400ms var(--tt-ease);
}

.tt-hero-slide.is-active .tt-hero-copy > *,
.tt-hero-slide.is-active .tt-hero-frame {
    opacity: 1;
    transform: none;
}

.tt-hero-slide.is-active .tt-hero-copy > :nth-child(2) { transition-delay: 40ms; }
.tt-hero-slide.is-active .tt-hero-copy > :nth-child(3) { transition-delay: 80ms; }
.tt-hero-slide.is-active .tt-hero-copy > :nth-child(n + 4) { transition-delay: 120ms; }
.tt-hero-slide.is-active .tt-hero-frame { transition-delay: 60ms; }

.tt-hero-copy {
    max-width: 560px;
}

.tt-hero-title {
    margin: 0 0 28px;
    color: var(--tt-white);
    font-size: clamp(34px, 3.9vw, 56px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.tt-hero-text {
    max-width: 500px;
    margin: 0 0 36px;
    color: rgba(255, 255, 255, 0.86);
    font-size: clamp(16px, 1.2vw, 18px);
    line-height: 1.6;
}

.tt-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Secondary button on navy. */
.tt-hero .btn-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
}

.tt-hero .btn-light:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--tt-white);
}

.tt-hero-call {
    margin: 18px 0 0;
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
    line-height: 1.5;
}

.tt-hero-call a {
    color: var(--tt-white);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tt-hero-call a:hover {
    text-decoration-thickness: 2px;
}

/* ---------- Media area (identical on every slide) ----------
   The frame is a fixed 16:10 box (no border or background). Inside it,
   .tt-hero-shot is sized to the image's own aspect ratio (--ar, set by
   home.py) at up to 88% of the frame, and centred; the chips are placed
   on this wrapper, so they stay attached to the image's corners.
   Opaque screenshots (--shot) get a 16px radius, shadow and 1px ring;
   transparent laptop + phone cutouts (--cutout) get a drop shadow that
   follows their shape. home.py picks the kind from the WebP's
   transparency. */

.tt-hero-visual {
    position: relative;
}

.tt-hero-frame {
    display: grid;
    place-items: center;
    margin: 0;
    aspect-ratio: 16 / 10;
    container-type: size;
}

.tt-hero-shot {
    position: relative;
    width: min(88cqw, calc(88cqh * var(--ar, 1.6)));
    aspect-ratio: var(--ar, 1.6);
}

.tt-hero-shot picture {
    display: contents;
}

.tt-hero-shot img {
    display: block;
    width: 100%;
    height: 100%;
}

.tt-hero-frame--shot img {
    object-fit: cover;
    border-radius: 16px;
    box-shadow:
        0 40px 100px rgba(2, 12, 30, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tt-hero-frame--cutout img {
    object-fit: contain;
    filter: drop-shadow(0 30px 45px rgba(2, 12, 30, 0.55));
}

/* ---------- Live notification chips ---------- */

.tt-hero-chips {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tt-hero-chip {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    padding: 10px 16px 10px 10px;
    color: var(--tt-dark);
    background: var(--tt-white);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(2, 12, 30, 0.28);
    font-size: 12px;
    line-height: 1.35;
    opacity: 0;
    translate: 0 12px;
    transition:
        opacity 400ms ease,
        translate 600ms var(--tt-ease);
}

/* Chip A on the visual's top-left corner, chip B on its bottom-right,
   each overlapping the edge by about 24px. Nudges (HERO_SLIDES "nudge"
   in home.py) keep a chip off a logo or key label in a screenshot. */
.tt-hero-chip--a { top: -24px; left: -24px; }
.tt-hero-chip--b { right: -24px; bottom: -24px; }
.tt-hero-shot--a-up .tt-hero-chip--a { top: -50px; }
.tt-hero-shot--a-right .tt-hero-chip--a { left: 22%; }
.tt-hero-shot--b-down .tt-hero-chip--b { bottom: -46px; }
.tt-hero-shot--b-left .tt-hero-chip--b { right: 22%; }

.tt-hero-slide.is-active .tt-hero-chip {
    opacity: 1;
    translate: 0 0;
    transition-delay: 300ms;
}

.tt-hero-slide.is-active .tt-hero-chip:nth-child(2) {
    transition-delay: 520ms;
}

.tt-hero-chip svg {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 8px;
    color: var(--tt-blue);
    background: var(--tt-blue-soft);
    border-radius: 9px;
}

.tt-hero-chip strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
}

.tt-hero-chip span {
    color: #5F738A;
}

.tt-hero-chip strong,
.tt-hero-chip span strong {
    color: var(--tt-dark);
}

/* Icons from the build's Lucide set (stroke icons). */
.tt-hero-chip svg,
.tt-hero-tab svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Segment tabs ---------- */

.tt-hero-tabs {
    display: flex;
    gap: 10px;
    max-width: 800px;
}

.tt-hero-tab {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    flex: 1 1 0;
    column-gap: 8px;
    row-gap: 10px;
    min-width: 0;
    min-height: 44px;
    padding: 6px 0;
    color: rgba(255, 255, 255, 0.7);
    background: none;
    border: 0;
    font-family: var(--tt-font-body);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: color 150ms ease;
}

.tt-hero-tab svg {
    width: 18px;
    height: 18px;
}

.tt-hero-tab span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-hero-tab:hover,
.tt-hero-tab[aria-selected="true"] {
    color: var(--tt-white);
}

.tt-hero-tab:focus-visible {
    outline: 2px solid var(--tt-white);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Progress bar: fills over the autoplay duration on the active tab. */
.tt-hero-tab i {
    position: relative;
    grid-column: 1 / -1;
    display: block;
    height: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
}

.tt-hero-tab i::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--tt-blue);
    transform: scaleX(0);
    transform-origin: left;
}

.tt-hero-tab[aria-selected="true"] i::after {
    transform: scaleX(1);
}

.tt-hero.is-playing .tt-hero-tab[aria-selected="true"] i::after {
    animation: tt-hero-progress var(--slide-ms) linear forwards;
}

.tt-hero.is-paused .tt-hero-tab[aria-selected="true"] i::after {
    animation-play-state: paused;
}

/* ---------- Keyframes ---------- */

@keyframes tt-hero-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Responsive ---------- */

/* Short desktop screens (e.g. 1366 x 768): keep the tabs above the fold. */
@media (min-width: 1025px) and (max-height: 820px) {
    .tt-hero {
        --hero-pad: 28px;
    }

    .tt-hero-inner {
        gap: 20px;
    }

    .tt-hero-title {
        font-size: clamp(32px, 3.4vw, 48px);
    }

    .tt-hero-text {
        font-size: 16px;
    }

    .tt-hero-call {
        margin-top: 14px;
    }
}

@media (max-width: 1024px) {
    .tt-hero {
        min-height: 0;
    }

    /* Every slide is as tall as the tallest one; the frame sits in the
       last row, so it is in the same place on every slide. */
    .tt-hero-slide {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 1fr auto;
        align-items: start;
        gap: 36px;
    }

    .tt-hero-copy {
        max-width: 640px;
    }

    /* Stacked layout: the copy spans the full width at the top, so the
       overlay runs top to bottom (solid behind the copy, lighter behind
       the visual, darker again behind the tabs). */
    .tt-hero-overlay {
        background: linear-gradient(180deg, rgba(6, 28, 66, 0.9) 0%, rgba(6, 28, 66, 0.86) 50%, rgba(6, 28, 66, 0.62) 78%, rgba(6, 22, 52, 0.88) 100%);
    }

    .tt-hero-visual {
        width: 100%;
        max-width: 720px;
    }

    .tt-hero-chip {
        gap: 8px;
        max-width: 220px;
        padding: 8px 12px 8px 8px;
        font-size: 11px;
    }

    .tt-hero-chip strong {
        font-size: 12px;
    }

    .tt-hero-chip svg {
        width: 28px;
        height: 28px;
        padding: 6px;
    }

    .tt-hero-chip--a { top: -16px; left: -12px; }
    .tt-hero-chip--b { right: -12px; bottom: -16px; }
    .tt-hero-shot--a-up .tt-hero-chip--a { top: -40px; }
    .tt-hero-shot--b-down .tt-hero-chip--b { bottom: -38px; }
}

/* Tablet and mobile: tabs are one scrollable row, no wrapping. On
   tablets the row stops short of the floating WhatsApp pill. */
@media (max-width: 1024px) {
    .tt-hero-tabs {
        gap: 18px;
        max-width: none;
        margin-right: 176px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .tt-hero-tabs::-webkit-scrollbar {
        display: none;
    }

    .tt-hero-tab {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .tt-hero-tab span {
        overflow: visible;
    }
}

@media (min-width: 641px) and (max-width: 767px) {
    .tt-hero-tabs {
        margin-right: 76px;
    }
}

/* Mobile: chip A only. */
@media (max-width: 767px) {
    .tt-hero-chip--b {
        display: none;
    }
}

@media (max-width: 640px) {
    .tt-hero {
        --hero-pad: 26px;
    }

    .tt-hero-inner {
        gap: 22px;
    }

    .tt-hero-slide {
        gap: 28px;
    }

    .tt-hero-actions .btn {
        flex: 1 1 100%;
    }

    /* Tabs start at the screen edge and stop 76px short of the right
       edge, so the WhatsApp circle (16px + 52px) never sits on a tab. */
    .tt-hero-tabs {
        margin-left: calc(var(--tt-gutter, 20px) * -1);
        margin-right: calc(76px - var(--tt-gutter, 20px));
        padding-inline: var(--tt-gutter, 20px) 8px;
        scroll-padding-inline: var(--tt-gutter, 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tt-hero-copy > *,
    .tt-hero-frame,
    .tt-hero-chip {
        transform: none;
        translate: none;
        transition: none;
    }

    .tt-hero-photo,
    .tt-hero-overlay,
    .tt-hero-map,
    .tt-hero-glow {
        transition: none;
    }

    .tt-hero-photo.is-active {
        animation: none;
    }
}
