/* About page: the map of the Gulf in the hero (about.html). In 3D (main/static/js/about-map/)
   the Gulf states rise into a platform with the Kanidata emblem on Dubai and links out across
   the region. Without WebGL or with reduced motion, the SVG version below builds itself the
   same way (borders, fill, Dubai's pin, then the links). The point glow afterwards only runs
   while the hero is on screen (about.js toggles .is-live). */
/* ---------- The map ---------- */
/* A 4:3 frame keeps the hero compact (the tilted 3D map needs less height than the flat
   map). The map fades out in an oval that reaches nothing by the frame's edges, so the map
   melts into the hero instead of stopping at a straight line. */
.ab-hero-map__frame {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden; /* or the map's own shape would stretch the frame past 4:3 */
    -webkit-mask-image: radial-gradient(50% 50% at 50% 50%, #000 86%, transparent 100%);
    mask-image: radial-gradient(50% 50% at 50% 50%, #000 86%, transparent 100%);
}

/* The country borders (includes/gulf-map.svg), one path per country, fitted inside the frame
   the same way as the layer of links and points over it. */
.ab-map-land {
    display: block;
    width: 100%;
    height: 100%;
}

.ab-map-land path {
    stroke-linejoin: round;
}

.ab-map-land__near path {
    fill: none;
    stroke: var(--kd-line-strong);
    stroke-width: 1;
}

.ab-map-land__gcc path {
    fill: var(--kd-brand-soft);
    stroke: #8FA6D6;
    stroke-width: 1.2;
}

/* With a mouse the map leans towards the pointer (about.js sets --rx and --ry). The two
   layers share one box, so they tilt as one; the wrapper's own transform is the reveal. */
.ab-hero-map__frame > .ab-map-land,
.ab-hero-map__frame > .ab-map {
    transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.ab-map__arcs path {
    fill: none;
    stroke: #FFFFFF;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-opacity: 0.75;
}

.ab-map__points circle,
.ab-map__pop {
    transform-box: fill-box;
    transform-origin: center;
}

.ab-map__points circle {
    fill: var(--kd-mint);
    stroke: #FFFFFF;
    stroke-width: 2;
}

.ab-map__dot {
    fill: var(--kd-brand-darkest);
    stroke: #FFFFFF;
    stroke-width: 3;
}

.ab-map__label rect {
    fill: var(--kd-brand-deep);
}

.ab-map__label text {
    fill: #FFFFFF;
    font-size: 12px;
    font-weight: 600;
}

/* ---------- The 3D map (main/static/js/about-map/) ---------- */
/* Holds the map and, outside its mask, the 3D map's labels. */
.ab-hero-map {
    position: relative;
}

/* Once the 3D map draws its first frame it adds .has-3d: the canvas fades in over the SVG,
   which stays in place (hidden) only to give the map its size. */
.ab-map3d {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.ab-hero-map__frame.has-3d .ab-map3d {
    opacity: 1;
}

.ab-hero-map__frame.has-3d > .ab-map-land,
.ab-hero-map__frame.has-3d > .ab-map {
    visibility: hidden;
}

.ab-map3d__label {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--kd-brand-deep);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.ab-map3d__label.is-shown {
    opacity: 1;
}

/* A point's name, shown above its marker while it is hovered or tapped. */
.ab-map3d__city {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: #FFFFFF;
    box-shadow: 0 0 0 1px var(--kd-line), 0 8px 20px -10px rgba(15, 23, 42, 0.35);
    color: var(--ab-ink);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.ab-map3d__city.is-shown {
    opacity: 1;
}

/* ---------- Motion (with JavaScript) ---------- */
/* The map builds itself in order: the neighbouring borders trace in, then the Gulf
   states, their fill washes in, Dubai is pinned, and the links draw out to each point.
   It plays once, as the hero opens (.is-in). */
.about.is-js .ab-map-land path,
.about.is-js .ab-map__arcs path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.about.is-js .ab-map-land__near path {
    transition: stroke-dashoffset 1s var(--ab-ease) calc(var(--i) * 0.04s);
}

.about.is-js .ab-map-land__gcc path {
    fill-opacity: 0;
    transition:
        stroke-dashoffset 1.2s var(--ab-ease) calc(0.2s + var(--i) * 0.08s),
        fill-opacity 0.6s ease 0.9s;
}

.about.is-js .ab-map__pop {
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.34, 1.6, 0.6, 1) 1.1s;
}

.about.is-js .ab-map__arcs path {
    transition: stroke-dashoffset 0.9s var(--ab-ease) calc(1.2s + var(--i) * 0.1s);
}

.about.is-js .ab-map__points circle {
    transform: scale(0);
    transition: transform 0.5s cubic-bezier(0.34, 1.6, 0.6, 1) calc(1.8s + var(--i) * 0.1s);
}

.about.is-js .ab-hero-map__frame.is-in .ab-map-land path,
.about.is-js .ab-hero-map__frame.is-in .ab-map__arcs path {
    stroke-dashoffset: 0;
}

.about.is-js .ab-hero-map__frame.is-in .ab-map-land__gcc path {
    fill-opacity: 1;
}

.about.is-js .ab-hero-map__frame.is-in .ab-map__pop,
.about.is-js .ab-hero-map__frame.is-in .ab-map__points circle {
    transform: none;
}

/* While on screen, the points glow in turn. */
.ab-map__points circle {
    animation: ab-point-glow 4.8s ease-in-out infinite;
    animation-delay: calc(2.4s + var(--i) * 0.8s);
    animation-play-state: paused;
}

.ab-hero.is-live .ab-map__points circle {
    animation-play-state: running;
}

@keyframes ab-point-glow {
    0%,
    24%,
    100% {
        fill: var(--kd-mint);
    }

    10% {
        fill: var(--kd-brand);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ab-map__points circle {
        animation: none;
    }

    .ab-hero-map__frame > .ab-map-land,
    .ab-hero-map__frame > .ab-map {
        transform: none;
        transition: none;
    }

    .about.is-js .ab-map-land path,
    .about.is-js .ab-map__arcs path,
    .about.is-js .ab-map__pop,
    .about.is-js .ab-map__points circle {
        stroke-dashoffset: 0;
        fill-opacity: 1;
        transform: none;
        transition: none;
    }
}
