/* ------------------------------------------------------------------------------
    Key Statistics Widget Stylesheet (Homepage "Built at City Scale")
    Category: CustomWidgets
    Desktop (>= 992px): 4 columns | Tab (768px - 991px): 2 x 2 | Mobile (< 768px): compact 2 x 2
    Full Multilingual support (LTR English & RTL Arabic)
------------------------------------------------------------------------------ */

.key-stats-section {
    --ks-bg: #1B313B;
    --ks-cream: #FFEDBD;
    --ks-text: #FFFFFF;
    --ks-muted: rgba(255, 255, 255, 0.6);
    --ks-rule: rgba(255, 255, 255, 0.55);
    --ks-sep: rgba(255, 255, 255, 0.2);
    --ks-teal: #2BB5A2;
    --ks-font-display: 'DINProCondBold', 'DINProBold', 'DINPro', sans-serif;
    --ks-font-body: 'DINPro', Tahoma, Arial, sans-serif;

    position: relative;
    width: 100%;
    background-color: var(--ks-bg);
    color: var(--ks-text);
    padding: 72px 0 56px;
    box-sizing: border-box;
    overflow: hidden;
}

.key-stats-section.rtl {
    --ks-font-display: 'Noto Sans Arabic', 'DINProCondBold', 'DINProBold', Tahoma, sans-serif;
    --ks-font-body: 'Noto Sans Arabic', 'DINPro', Tahoma, Arial, sans-serif;
}

.key-stats-section *,
.key-stats-section *::before,
.key-stats-section *::after {
    box-sizing: border-box;
}

.key-stats-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 64px;
}

/* --- Header --- */
.key-stats-header {
    margin-bottom: 76px;
}

.key-stats-section .key-stats-title {
    font-family: var(--ks-font-display) !important;
    font-size: 56px !important;
    font-weight: 700 !important;
    line-height: 1.05 !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--ks-text) !important;
    margin: 0 !important;
}

.key-stats-section.rtl .key-stats-title {
    font-size: 48px !important;
    line-height: 1.3 !important;
    letter-spacing: 0;
    text-transform: none;
}

.key-stats-divider {
    width: 100%;
    height: 1px;
    background-color: var(--ks-rule);
    margin-top: 24px;
}

/* --- Grid --- */
.key-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.key-stat {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-inline-start: 20px;
    padding-inline-end: 20px;
    border-inline-start: 1px solid var(--ks-sep);
}

.key-stat:first-child {
    padding-inline-start: 0;
    border-inline-start: 0;
}

.key-stat:last-child {
    padding-inline-end: 0;
}

/* --- Figure (value + unit) --- */
.key-stat-figure {
    display: flex;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 14px;
    white-space: nowrap;
}

.key-stats-section .key-stat-value {
    display: inline-block;
    font-family: 'DINProCondBold', 'DINProBold', sans-serif;
    font-size: clamp(64px, 6.67vw, 96px);
    font-weight: 700;
    line-height: 0.9;
    color: var(--ks-cream);
    font-variant-numeric: tabular-nums;
}

.key-stats-section .key-stat-unit {
    font-family: var(--ks-font-body);
    font-size: 18px;
    line-height: 1;
    color: var(--ks-cream);
    padding-bottom: 10px;
}

/* Arabic: unit sits raised at the top of the figure (per Figma AR) */
.key-stats-section.rtl .key-stat-figure {
    align-items: flex-start;
}

.key-stats-section.rtl .key-stat-value {
    font-family: 'DINProCondBold', 'Noto Sans Arabic', sans-serif;
}

.key-stats-section.rtl .key-stat-unit {
    font-size: 16px;
    padding-bottom: 0;
    padding-top: 4px;
}

.key-stats-section .key-stat-label {
    font-family: var(--ks-font-body) !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    color: var(--ks-text) !important;
    margin: 24px 0 0 !important;
}

.key-stats-section.rtl .key-stat-label {
    font-weight: 500;
}

/* --- Graphic area (all graphics bottom-aligned) --- */
.key-stat-graphic {
    margin-top: auto;
    padding-top: 40px;
    width: 100%;
    max-width: 290px;
}

/* Dots: 15 x 3 */
.ks-dots {
    display: grid;
    grid-template-columns: repeat(15, 8px);
    justify-content: space-between;
    row-gap: 9px;
}

.ks-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--ks-cream);
}

/* Bars: 10 */
.ks-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 72px;
}

.ks-bar {
    width: 20px;
    height: var(--h, 50%);
    background-color: var(--ks-cream);
    transform-origin: bottom;
}

/* People: 10 */
.ks-people {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.ks-person {
    width: 20px;
    height: 36px;
    fill: var(--ks-cream);
    display: block;
}

/* Route: Masdar City -> Airport */
.ks-route-track {
    position: relative;
    display: flex;
    align-items: center;
    height: 14px;
}

.ks-route-start,
.ks-route-end {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: relative;
    z-index: 2;
}

.ks-route-start {
    background-color: var(--ks-cream);
}

.ks-route-end {
    border: 2px solid var(--ks-cream);
    background-color: var(--ks-bg);
}

.ks-route-line {
    flex: 1 1 auto;
    height: 2px;
    margin: 0 4px;
    background-image: linear-gradient(to right, var(--ks-cream) 50%, transparent 50%);
    background-size: 8px 2px;
    background-repeat: repeat-x;
    opacity: 0.8;
}

.ks-route-mover {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    margin-left: -4px;
    border-radius: 50%;
    background-color: var(--ks-teal);
    z-index: 1;
}

.key-stats-section.rtl .ks-route-mover {
    left: auto;
    right: 50%;
    margin-left: 0;
    margin-right: -4px;
}

.ks-route-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-family: var(--ks-font-body);
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--ks-muted);
}

.key-stats-section.rtl .ks-route-labels {
    letter-spacing: 0;
    font-size: 12px;
}

/* ------------------------------------------------------------------------------
    Animations (only when JS is present: .is-ready -> .is-visible)
------------------------------------------------------------------------------ */
.key-stats-section.ks-anim.is-ready .ks-dot {
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.35s ease, transform 0.35s ease;
    transition-delay: calc(var(--i) * 18ms);
}

.key-stats-section.ks-anim.is-ready .ks-bar {
    transform: scaleY(0);
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--i) * 60ms);
}

.key-stats-section.ks-anim.is-ready .ks-person {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    transition-delay: calc(var(--i) * 70ms);
}

.key-stats-section.ks-anim.is-ready .ks-route-line {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 1.2s ease;
}

.key-stats-section.ks-anim.is-ready.rtl .ks-route-line {
    clip-path: inset(0 0 0 100%);
}

.key-stats-section.ks-anim.is-ready .ks-route-mover {
    opacity: 0;
}

.key-stats-section.ks-anim.is-visible .ks-dot,
.key-stats-section.ks-anim.is-visible .ks-person {
    opacity: 1;
    transform: none;
}

.key-stats-section.ks-anim.is-visible .ks-bar {
    transform: scaleY(1);
}

.key-stats-section.ks-anim.is-visible .ks-route-line,
.key-stats-section.ks-anim.is-visible.rtl .ks-route-line {
    clip-path: inset(0 0 0 0);
}

.key-stats-section.ks-anim.is-visible .ks-route-mover {
    opacity: 1;
    animation: ks-route-travel 3.2s ease-in-out 1.2s infinite;
}

.key-stats-section.ks-anim.is-visible.rtl .ks-route-mover {
    animation-name: ks-route-travel-rtl;
}

@keyframes ks-route-travel {
    0%   { left: 14px;               opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { left: calc(100% - 14px);  opacity: 0; }
}

@keyframes ks-route-travel-rtl {
    0%   { right: 14px;              opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { right: calc(100% - 14px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .key-stats-section .ks-dot,
    .key-stats-section .ks-bar,
    .key-stats-section .ks-person,
    .key-stats-section .ks-route-line,
    .key-stats-section .ks-route-mover {
        transition: none !important;
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        clip-path: none !important;
    }
}

/* ------------------------------------------------------------------------------
    Small desktop / Tablet landscape (992px - 1199.98px)
------------------------------------------------------------------------------ */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .key-stats-container {
        padding: 0 40px;
    }

    .key-stat {
        padding-inline-start: 16px;
        padding-inline-end: 16px;
    }

    .key-stats-section .key-stat-unit {
        font-size: 16px;
    }

    .key-stats-section .key-stat-label {
        font-size: 15px !important;
    }
}

/* ------------------------------------------------------------------------------
    Tab (768px - 991.98px): 2 x 2 grid with horizontal & vertical rules
------------------------------------------------------------------------------ */
@media (min-width: 768px) and (max-width: 991.98px) {
    .key-stats-section {
        padding: 56px 0 64px;
    }

    .key-stats-container {
        padding: 0 40px;
    }

    .key-stats-header {
        margin-bottom: 64px;
    }

    .key-stats-section .key-stats-title {
        font-size: 48px !important;
    }

    .key-stats-section.rtl .key-stats-title {
        font-size: 42px !important;
    }

    .key-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .key-stat,
    .key-stat:first-child,
    .key-stat:last-child {
        padding-inline-start: 24px;
        padding-inline-end: 0;
        border-inline-start: 1px solid var(--ks-sep);
    }

    .key-stat:nth-child(odd) {
        padding-inline-start: 0;
        padding-inline-end: 24px;
        border-inline-start: 0;
    }

    /* Top row: space + full-width horizontal rule under it */
    .key-stat:nth-child(-n+2) {
        padding-bottom: 28px;
        border-bottom: 1px solid var(--ks-sep);
    }

    .key-stat:nth-child(n+3) {
        padding-top: 28px;
    }

    .key-stats-section .key-stat-value {
        font-size: 96px;
    }

    .key-stat-graphic {
        padding-top: 44px;
    }
}

/* ------------------------------------------------------------------------------
    Mobile (< 768px): compact 2 x 2 grid, per-column rules, no vertical rules
------------------------------------------------------------------------------ */
@media (max-width: 767.98px) {
    .key-stats-section {
        padding: 48px 0 64px;
    }

    .key-stats-container {
        padding: 0 24px;
    }

    .key-stats-header {
        margin-bottom: 56px;
    }

    .key-stats-section .key-stats-title {
        font-size: 40px !important;
        max-width: 240px;
    }

    .key-stats-section.rtl .key-stats-title {
        font-size: 34px !important;
        max-width: 200px;
    }

    .key-stats-divider {
        margin-top: 20px;
    }

    .key-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 24px;
    }

    .key-stat,
    .key-stat:first-child,
    .key-stat:last-child {
        padding: 0;
        border: 0;
    }

    .key-stat:nth-child(-n+2) {
        padding-bottom: 32px;
        border-bottom: 1px solid var(--ks-sep);
    }

    .key-stat:nth-child(n+3) {
        padding-top: 28px;
    }

    .key-stat-figure {
        gap: 8px;
    }

    .key-stats-section .key-stat-value {
        font-size: 44px;
    }

    .key-stats-section .key-stat-unit {
        font-size: 12px;
        padding-bottom: 6px;
    }

    .key-stats-section.rtl .key-stat-value {
        font-size: 40px;
    }

    .key-stats-section.rtl .key-stat-unit {
        font-size: 11px;
        padding-top: 2px;
    }

    .key-stats-section .key-stat-label {
        font-size: 12px !important;
        margin-top: 10px !important;
    }

    .key-stat-graphic {
        padding-top: 28px;
        max-width: none;
    }

    /* Dots: 8 x 3 */
    .ks-dots {
        grid-template-columns: repeat(8, 7px);
        row-gap: 9px;
    }

    .ks-dot {
        width: 7px;
        height: 7px;
    }

    .ks-dot:nth-child(n+25) {
        display: none;
    }

    /* Bars: 8 */
    .ks-bars {
        height: 44px;
    }

    .ks-bar {
        width: 14px;
    }

    .ks-bar:nth-child(n+9) {
        display: none;
    }

    /* People: 10 small */
    .ks-person {
        width: 13px;
        height: 24px;
    }

    .ks-route-start,
    .ks-route-end {
        width: 10px;
        height: 10px;
    }

    .ks-route-end {
        border-width: 1.5px;
    }

    .ks-route-track {
        height: 10px;
    }

    .ks-route-labels {
        font-size: 9px;
        letter-spacing: 1px;
        margin-top: 8px;
    }

    .key-stats-section.rtl .ks-route-labels {
        font-size: 10px;
    }
}
