/* Globe story: sticky three.js stage, hero/intro/partners scenes, pins, planes. */

/*2b. scroll globe story (hero → about → key partners)*/
.globe-story {
    position: relative;
    width: 100%;
}

/* sticky layer behind the story sections; its height is cancelled by the
   negative margin so the first section starts at the top.
   Sized to the *largest* viewport (lvh): on phones the browser bars shrink as you
   scroll, and a smaller layer would end in a hard edge above the screen bottom. */
.globe-story__stage {
    --globe-bg-mix: 0%;

    position: sticky;
    top: 0;
    z-index: 0;
    width: 100%;
    height: 100vh;
    height: 100lvh;
    margin-bottom: -100vh;
    margin-bottom: -100lvh;
    overflow: hidden;
    pointer-events: none;
    background-color: color-mix(in srgb, var(--bg-40) var(--globe-bg-mix), var(--bg));
}

.globe-story__stars,
.globe-story__canvas,
.globe-story__pins {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.globe-story > .section {
    z-index: 1;
    background-color: transparent;
}

/* the scroll story needs a full screen per scene (other sections size to content) */
.globe-story > .section {
    min-height: 100vh;
    min-height: 100svh;
}

/* hero frame 1: "horizon" — centred headline above a rising planet */
.section.hero-horizon {
    justify-content: flex-start;
    padding-top: calc(var(--navigation-height, 4.5rem) + var(--space-2xl));
    overflow: hidden;
}

/* atmosphere glow along the horizon */
.section.hero-horizon::after {
    content: '';
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: -20%;
    height: 75%;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse 60% 55% at 50% 100%, hsl(214 85% 62% / 0.22), transparent 70%);
}

.hero-horizon .section__wrapper {
    align-items: center;
}

.hero-horizon__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-m);
    text-align: center;
}

.section p.hero-horizon__eyebrow {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--fg-20);
    animation: hero-horizon-in 1s cubic-bezier(.2, .75, .25, 1) both;
}

.section p.hero-horizon__eyebrow::before,
.section p.hero-horizon__eyebrow::after {
    content: '';
    width: 2.5rem;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--fg-20));
}

.section p.hero-horizon__eyebrow::after {
    background: linear-gradient(to left, transparent, var(--fg-20));
}

.hero-horizon__title {
    font-size: clamp(2.5rem, 6.2vw, 5.75rem);
    font-weight: 300;
    line-height: 1.04;
    letter-spacing: -0.035em;
    animation: hero-horizon-in 1.2s 0.15s cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes hero-horizon-in {
    from {
        opacity: 0;
        filter: blur(8px);
        transform: translateY(1rem);
    }
}

@media (max-width: 48rem) {
    .section p.hero-horizon__eyebrow {
        letter-spacing: 0.14em;
        line-height: 1.6;
    }

    .section p.hero-horizon__eyebrow::before,
    .section p.hero-horizon__eyebrow::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .section p.hero-horizon__eyebrow,
    .hero-horizon__title {
        animation: none;
    }
}

/* hero frame 2: intro copy centred over the globe */
.section.hero-intro {
    justify-content: center;
}

.hero-intro .section__wrapper {
    align-items: center;
}

.section.hero-intro p {
    position: relative;
    isolation: isolate;
    max-width: 52rem;
    font-size: var(--text-l);
    line-height: 1.3;
    text-align: center;
    text-shadow:
        0 1px 2px color-mix(in srgb, var(--bg-40) 80%, transparent),
        0 2px 16px color-mix(in srgb, var(--bg-40) 70%, transparent);
}

/* soft dark glow behind the copy so it reads over the bright land masses;
   fades out at the edges so the globe still shows around it */
.section.hero-intro p::before {
    content: "";
    position: absolute;
    inset: -18% -12%;
    z-index: -1;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--bg-40) 78%, transparent), color-mix(in srgb, var(--bg-40) 55%, transparent) 55%, transparent);
    filter: blur(12px);
    pointer-events: none;
}

@media (max-width: 640px) {
    .section.hero-intro p::before {
        inset: -10% -8%;
        background: radial-gradient(closest-side, color-mix(in srgb, var(--bg-40) 82%, transparent), color-mix(in srgb, var(--bg-40) 60%, transparent) 60%, transparent);
    }
}

.text-accent {
    color: var(--primary);
}

/* hero frame 1: dashed flight trail + planes */
.globe-flight {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.globe-flight__trail {
    fill: none;
    stroke: var(--fg);
    stroke-width: 2;
    stroke-dasharray: 14 12;
    stroke-linecap: round;
}

.globe-plane {
    position: absolute;
    top: 0;
    left: 0;
    color: var(--fg);
    will-change: transform, opacity;
}

.globe-plane svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.globe-plane--side {
    width: clamp(5.5rem, 10vw, 9.5rem);
    aspect-ratio: 3 / 1;
    filter: drop-shadow(0 8px 18px hsl(216 66% 4% / 0.45));
}

.globe-plane--top {
    width: clamp(2rem, 3.2vw, 3rem);
    aspect-ratio: 1;
    opacity: 0;
}

.section.partner-globe {
    /* two stops, one screen of scroll apart: big-globe overview, then the
       zoom onto the European partners with their cards */
    height: 200vh;
    height: 200svh;
    min-height: 0;
    padding: 0;
}

/* Snapping parks these sections flush with the top of the viewport, so their
   headings must always clear the fixed navigation (on phones --space-4xl alone
   is shorter than the nav bar). */
.globe-story #about-us {
    padding-top: max(var(--space-4xl), calc(var(--navigation-height, 4.5rem) + var(--space-l)));
}

.partner-globe__sticky {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    padding: var(--space-4xl) var(--space-2xl);
    padding-top: max(var(--space-4xl), calc(var(--navigation-height, 4.5rem) + var(--space-l)));
    display: flex;
    flex-direction: column;
    align-items: center;
    /* keep the heading's dark fade inside this screen so it can't spill over
       the bottom of About Us */
    overflow: clip;
}

.partner-globe__header {
    position: relative;
    z-index: 1;
    text-shadow:
        0 1px 2px color-mix(in srgb, var(--bg-40) 80%, transparent),
        0 2px 16px color-mix(in srgb, var(--bg-40) 70%, transparent);
}

/* dark fade behind the heading so it reads over the bright land masses;
   it ends just below the heading so the pins underneath stay bright */
.partner-globe__header::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: -12rem;
    bottom: -1.25rem;
    left: -50vw;
    right: -50vw;
    /* solid behind the headline (no dots show through), then a short fade */
    background: linear-gradient(to bottom,
            var(--bg-40) 0%,
            var(--bg-40) calc(100% - 2.5rem),
            transparent 100%);
    pointer-events: none;
}

/* ---------- the three partner cards ----------
   Portrait (phones): stacked along the bottom, map in the upper half.
   Landscape (desktop/tablet): a column on the left, map on the right
   (matches the `wide` camera frame in globe-story.js, aspect >= 1). */
.partner-globe__body {
    position: relative;
    z-index: 1;
    flex: 1;
    justify-content: flex-end;
    min-height: 0;
}

.partner-info-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* hidden until the zoom step; globe-story.js fades them in (shown as-is in the no-WebGL fallback) */
.globe-story:not(.globe-story--fallback) .partner-info-list {
    opacity: 0;
    visibility: hidden;
}

.partner-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid hsl(0 0% 100% / 0.16);
    border-radius: var(--radius-m);
    background-color: var(--bg-40); /* solid: no dots behind the text */
}

.partner-info__logo {
    flex: 0 0 auto;
    width: 5.5rem;
    height: 3rem;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.partner-info__text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding-left: 0.875rem;
    border-left: 1px solid hsl(0 0% 100% / 0.14);
}

.partner-info__text strong {
    color: var(--fg);
    font-size: 1rem;
    line-height: 1.25;
}

.partner-info__summary {
    color: var(--fg-20);
    font-size: 0.875rem;
    line-height: 1.4;
}

@media (min-aspect-ratio: 1/1) {
    .partner-globe__sticky {
        padding-bottom: var(--space-l);
    }

    /* `safe` keeps a tall card column from overflowing up into the heading */
    .partner-globe__body {
        justify-content: safe center;
        padding-top: var(--space-s);
    }

    .partner-info-list {
        gap: var(--space-s);
        max-width: min(26rem, 38vw);
    }

    .partner-info {
        padding: var(--space-s) var(--space-m);
    }

    .partner-info__logo {
        width: 7rem;
        height: 3.75rem;
    }

    .partner-info__text strong {
        font-size: var(--text-s);
    }

    .partner-info__summary {
        font-size: 0.9375rem;
    }
}

/* short landscape screens (laptops, tablets on their side, phones on their side) */
@media (min-aspect-ratio: 1/1) and (max-height: 50rem) {
    .partner-info-list {
        gap: 0.625rem;
    }

    .partner-info {
        padding: 0.65rem 0.9rem;
    }

    .partner-info__logo {
        width: 5.5rem;
        height: 3rem;
    }

    .partner-info__summary {
        font-size: 0.875rem;
    }
}

@media (min-aspect-ratio: 1/1) and (max-height: 30rem) {
    .partner-info__summary {
        display: none;
    }
}

/* portrait (phones / upright tablets): compact cards + heading so the zoomed
   map between them keeps enough room for the pins and their labels */
@media (max-aspect-ratio: 1/1) {
    .partner-globe__sticky {
        padding-bottom: var(--space-m);
    }

    .section.partner-globe .partner-globe__header p {
        font-size: clamp(1.5rem, 6.4vw, 2.25rem);
        line-height: 1.15;
    }

    .partner-info-list {
        gap: 0.5rem;
    }

    .partner-info {
        gap: 0.75rem;
        padding: 0.6rem 0.75rem;
    }

    .partner-info__logo {
        width: 4.5rem;
        height: 2.4rem;
    }

    .partner-info__text {
        padding-left: 0.75rem;
    }

    .partner-info__text strong {
        font-size: 0.9375rem;
    }

    .partner-info__summary {
        font-size: 0.8125rem;
        line-height: 1.35;
    }
}

/* upright tablets have room for the larger card */
@media (max-aspect-ratio: 1/1) and (min-width: 40rem) {
    .partner-info-list {
        max-width: 34rem;
    }
}

/* map pins, projected from the globe each frame */
.globe-pin {
    position: absolute;
    top: 0;
    left: 0;
    width: 1.75rem;
    height: 2.25rem;
    /* marker tip sits on the coordinate */
    translate: -50% -100%;
    will-change: transform, opacity;
}

.globe-pin__marker {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    transform-origin: 50% 100%;
    transition: transform 0.3s ease;
}

/* one red for every pin (hero, About Us, Key Partners) */
.globe-pin__marker path {
    fill: #c8373b;
    stroke: hsl(0 0% 100% / 0.85);
    stroke-width: 1.5;
}

.globe-pin__marker .globe-pin__dot {
    fill: hsl(0 0% 86%);
}

/* country flag in the pin head (partners + HQ), with a thin white ring */
.globe-pin__marker .globe-pin__flag-ring {
    fill: none;
    stroke: #fff;
    stroke-width: 1.2;
}

/* NOVATIS: Malaysian flag in Key Partners only (plain head in About Us) */
.globe-pin__alt-flag {
    display: none;
}

.globe-pin--show-flag .globe-pin__alt-flag {
    display: inline;
}

.globe-pin--show-flag .globe-pin__dot {
    display: none;
}

/* every label: dark box with a thin border, so it reads over the dots */
.globe-pin__label {
    position: absolute;
    padding: 0.2rem 0.6rem;
    border: 1px solid hsl(0 0% 100% / 0.22);
    border-radius: var(--radius-xs);
    background-color: rgba(11, 15, 23, 0.9);
    color: var(--fg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.625rem;
    line-height: 1.3;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: opacity 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.globe-pin--label-top .globe-pin__label {
    bottom: calc(100% + 0.35rem);
    left: 50%;
    translate: -50% 0;
}

.globe-pin--label-bottom .globe-pin__label {
    top: calc(100% + 0.3rem);
    left: 50%;
    translate: -50% 0;
}

.globe-pin--label-left .globe-pin__label {
    top: 0;
    right: calc(100% + 0.25rem);
}

.globe-pin--label-right .globe-pin__label {
    top: 0;
    left: calc(100% + 0.25rem);
}

/* About Us: head office and city pins share one size */
.globe-pin--region,
.globe-pin--hq {
    width: 1.5rem;
    height: 2rem;
}

/* Key Partners zoom: bigger partner pins with solid, readable labels */
.globe-pin--partner {
    transition: width 0.35s ease, height 0.35s ease;
}

.is-partner-zoom .globe-pin--partner {
    width: 2.5rem;
    height: 3.25rem;
}

.is-partner-zoom .globe-pin--partner .globe-pin__marker {
    filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--bg-40) 55%, transparent));
}

.is-partner-zoom .globe-pin--partner .globe-pin__marker path {
    fill: #c8373b;
    stroke: #fff;
    stroke-width: 2;
}

.is-partner-zoom .globe-pin--partner .globe-pin__marker .globe-pin__dot {
    fill: #fff;
}

.is-partner-zoom .globe-pin--partner .globe-pin__label {
    padding: 0.35rem 0.75rem;
    border-color: hsl(0 0% 100% / 0.3);
    background-color: rgba(11, 15, 23, 0.9);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--bg-40) 50%, transparent);
}

/* regional city names: small dark tags beside the pin head */
.globe-pin--region .globe-pin__label {
    top: 0.2rem;
    /* slim tags: the Sarawak cities sit close together */
    padding: 0 0.35rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.25;
}

/* head office label (Headquarter · Cyberjaya / NOVATIS): bold, like the city names */
.globe-pin--hq .globe-pin__label {
    font-weight: 700;
}

/* the head office pin is clickable: it scrolls to the "Locate Us" map (globe-story.js) */
.globe-story.is-over-hq-pin {
    cursor: pointer;
}

.globe-pin--hq.globe-pin--hover .globe-pin__marker {
    transform: scale(1.15);
}

.globe-pin--hq.globe-pin--hover .globe-pin__label {
    border-color: hsl(0 0% 100% / 0.6);
    background-color: rgba(11, 15, 23, 1);
}

/* small screens: move edge / crowded city names above or below their pin */
@media (max-width: 48rem) {
    .globe-pin--sm-label-top .globe-pin__label,
    .globe-pin--sm-label-bottom .globe-pin__label {
        right: auto;
        left: 50%;
        translate: -50% 0;
    }

    .globe-pin--sm-label-top .globe-pin__label {
        top: auto;
        bottom: calc(100% + 0.15rem);
    }

    .globe-pin--sm-label-bottom .globe-pin__label {
        top: calc(100% + 0.15rem);
        bottom: auto;
    }

    .globe-pin--sm-label-left .globe-pin__label,
    .globe-pin--sm-label-right .globe-pin__label {
        top: 0.2rem;
        bottom: auto;
        translate: none;
    }

    .globe-pin--sm-label-left .globe-pin__label {
        right: calc(100% + 0.25rem);
        left: auto;
    }

    .globe-pin--sm-label-right .globe-pin__label {
        left: calc(100% + 0.25rem);
        right: auto;
    }

    /* Europe zoom: the partner pins sit far apart there, and side labels would run
       off a phone's edges, so they go above their pins */
    .is-partner-zoom .globe-pin--partner.globe-pin--label-left .globe-pin__label,
    .is-partner-zoom .globe-pin--partner.globe-pin--label-right .globe-pin__label {
        top: auto;
        bottom: calc(100% + 0.15rem);
        right: auto;
        left: 50%;
        translate: -50% 0;
    }
}

/* HQ label stays above the regional pins around it */
.globe-pin--hq {
    z-index: 1;
}

/* ---------- Key Partners zoom: pins come alive ----------
   Drop in one after another (--i = order, set in globe-story.js), then bob gently
   with a ripple at the tip; while the page scrolls they vibrate (.is-shaking).
   Only the marker moves, so the labels stay easy to read. */
.is-partner-zoom .globe-pin--partner .globe-pin__marker {
    animation:
        pin-drop 0.7s cubic-bezier(.3, 1.6, .5, 1) both,
        pin-bob 2.4s ease-in-out 0.7s infinite;
    animation-delay: calc(var(--i, 0) * 0.15s), calc(0.7s + var(--i, 0) * 0.3s);
}

/* added on top (rotate only), so the drop-in and bob carry on underneath */
.is-partner-zoom.is-shaking .globe-pin--partner .globe-pin__marker {
    animation:
        pin-drop 0.7s cubic-bezier(.3, 1.6, .5, 1) both,
        pin-bob 2.4s ease-in-out 0.7s infinite,
        pin-shake 0.3s linear infinite;
    animation-delay: calc(var(--i, 0) * 0.15s), calc(0.7s + var(--i, 0) * 0.3s), 0s;
}

/* ripple on the ground under each pin */
.globe-pin--partner::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    width: 1.75rem;
    height: 0.7rem;
    border: 2px solid var(--primary);
    border-radius: 50%;
    background: hsl(358 73% 46% / 0.18);
    opacity: 0;
    translate: -50% -50%;
    pointer-events: none;
}

.is-partner-zoom .globe-pin--partner::before {
    animation: pin-ripple 2s ease-out infinite;
    animation-delay: calc(0.6s + var(--i, 0) * 0.4s);
}

@keyframes pin-drop {
    from { translate: 0 -2.5rem; opacity: 0; }
    to { translate: 0 0; opacity: 1; }
}

@keyframes pin-bob {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -0.35rem; }
}

/* wiggle around the pin's tip (the marker's transform-origin) */
@keyframes pin-shake {
    0%, 100% { rotate: 0deg; }
    25% { rotate: -10deg; }
    75% { rotate: 10deg; }
}

@keyframes pin-ripple {
    0% { scale: 0.3; opacity: 0.9; }
    100% { scale: 2.4; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .is-partner-zoom .globe-pin--partner .globe-pin__marker,
    .is-partner-zoom.is-shaking .globe-pin--partner .globe-pin__marker,
    .is-partner-zoom .globe-pin--partner::before {
        animation: none;
    }
}

.globe-story--fallback .globe-story__stage {
    display: none;
}

.globe-story--fallback .section.partner-globe {
    height: auto;
    min-height: 100vh;
}

.globe-story--fallback .partner-globe__sticky {
    position: relative;
}

/* tablets: bigger map pins and readable labels (the base sizes are for phones/desktop) */
@media (min-width: 40rem) and (max-width: 86rem) and (pointer: coarse) {
    .globe-pin {
        width: 2rem;
        height: 2.6rem;
    }

    .globe-pin--region,
    .globe-pin--hq {
        width: 1.75rem;
        height: 2.3rem;
    }

    .globe-pin__label {
        padding: 0.25rem 0.65rem;
        font-size: 0.75rem;
    }

    .globe-pin--region .globe-pin__label {
        font-size: 0.8125rem;
    }

    .is-partner-zoom .globe-pin--partner {
        width: 2.75rem;
        height: 3.6rem;
    }

    .is-partner-zoom .globe-pin--partner .globe-pin__label {
        font-size: 0.875rem;
    }
}
