/* Developed by Mohammad Rameez Imdad (Rameez Scripts) · WhatsApp: https://whatsapp.rameezscripts.com/ (For Custom Projects) · YouTube: https://www.youtube.com/@rameezimdad (Subscribe for more!) */
/* countries.php — the customer globe. everything scoped to body.page-countries; colours ride the
   admin-picked --c-* palette that public_header.php declares, so the page follows ui_setting */

/* repeat buyers = green ink on the header line */
body.page-countries { --cg-repeat-ink: #15803d; margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--c-text); line-height: 1.55; }
body.page-countries .cg-main { padding: 18px 0 48px; }
/* no container: the globe runs the full page width on the page's own ground; only the text + list keep a gutter */
body.page-countries .cg-stage { --cg-gutter: clamp(18px, 5vw, 72px); }
body.page-countries .cg-note, body.page-countries .cg-empty { padding-left: var(--cg-gutter); padding-right: var(--cg-gutter); }

/* title line — deliberately not a hero: one heading, one fact line, then the globe */
body.page-countries .cg-head { text-align: center; padding: 6px var(--cg-gutter) 14px; }
body.page-countries .cg-head h1 { margin: 0 0 4px; font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: clamp(24px, 3.2vw, 36px); font-weight: 800; letter-spacing: -.02em; color: var(--c-primary); }
body.page-countries .cg-head p { margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; font-size: 15px; color: var(--c-text-muted); }
body.page-countries .cg-head b { color: var(--c-primary); font-weight: 800; }
body.page-countries .cg-rep-in, body.page-countries .cg-rep-in b { color: var(--cg-repeat-ink); }
body.page-countries .cg-rep-in i { margin-right: 3px; font-size: 12px; }
body.page-countries .cg-sep { color: rgba(var(--c-primary-rgb), .25); }
body.page-countries .cg-live { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px; background: rgba(var(--c-accent-rgb), .1); color: var(--c-accent-strong, var(--c-accent)); font-size: 12.5px; font-weight: 700; }
body.page-countries .cg-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 0 0 rgba(var(--c-accent-rgb), .6); animation: cgLive 1.8s ease-out infinite; }
@keyframes cgLive { to { box-shadow: 0 0 0 9px rgba(var(--c-accent-rgb), 0); } }

/* the globe — 100% of the page width, no box, no background: the planet floats on the page itself */
body.page-countries .cg-globe {
    position: relative; width: 100%; height: min(88vh, 940px); min-height: 460px; cursor: grab;
    -webkit-user-select: none; user-select: none;
}
body.page-countries .cg-globe.is-grabbing { cursor: grabbing; }
body.page-countries .cg-globe canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; outline: none; }

body.page-countries .cg-load { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: var(--c-text-muted); font-size: 14px; font-weight: 600; }
body.page-countries .cg-load[hidden] { display: none; }
body.page-countries .cg-load i { font-size: 44px; color: var(--c-accent); animation: cgSpin 2.4s linear infinite; }
body.page-countries .cg-load.is-error i { animation: none; opacity: .5; }
@keyframes cgSpin { to { transform: rotate(360deg); } }

body.page-countries .cg-tip {
    position: absolute; z-index: 3; pointer-events: none; transform: translate(-50%, calc(-100% - 16px));
    display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 12px; white-space: nowrap;
    background: rgba(255, 255, 255, .98); color: var(--c-primary); font-size: 13.5px; box-shadow: 0 12px 30px rgba(var(--c-primary-rgb), .22), 0 0 0 1px rgba(var(--c-primary-rgb), .06);
}
body.page-countries .cg-tip[hidden] { display: none; }
body.page-countries .cg-tip::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: translateX(-50%) rotate(45deg); }
body.page-countries .cg-tip img { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
body.page-countries .cg-tip b { font-weight: 800; }
body.page-countries .cg-tip span { color: var(--c-accent-strong, var(--c-accent)); font-weight: 700; }

/* legend — what the dots mean */
body.page-countries .cg-legend { position: absolute; top: 14px; left: var(--cg-gutter); z-index: 1; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 7px 12px; border-radius: 12px; background: rgba(255, 255, 255, .88); border: 1px solid rgba(var(--c-primary-rgb), .08); color: var(--c-primary); font-size: 12px; font-weight: 600; pointer-events: none; }
body.page-countries .cg-legend span { display: inline-flex; align-items: center; gap: 6px; }
body.page-countries .cg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 8px var(--c-accent); }

body.page-countries .cg-hint { position: absolute; left: 50%; bottom: 14px; z-index: 1; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .88); border: 1px solid rgba(var(--c-primary-rgb), .08); color: var(--c-text-muted); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
body.page-countries .cg-hint-m { display: none; }
@media (hover: none) and (pointer: coarse) {
    body.page-countries .cg-hint-d { display: none; }
    body.page-countries .cg-hint-m { display: inline; }
}

/* countries, largest share first — each one flies the globe to it. shares only, never counts */
body.page-countries .cg-list > li { display: flex; }   /* every card in a row as tall as the tallest */
/* breathing room: clear of the globe's drag hint, cards apart, never touching the screen edge */
body.page-countries .cg-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 16px; margin: 36px 0 0; padding: 0 var(--cg-gutter); box-sizing: border-box; }
/* card grid: flag | name | share */
body.page-countries .cg-item {
    position: relative; width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "flag name share";
    align-items: center; column-gap: 12px; padding: 16px 18px; overflow: hidden;
    border: 1px solid rgba(var(--c-primary-rgb), .08); border-radius: 12px; background: var(--c-card, #fff); color: var(--c-text);
    font: inherit; font-size: 14px; text-align: left; cursor: pointer; touch-action: manipulation;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
body.page-countries .cg-item:hover { border-color: var(--c-accent); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(var(--c-primary-rgb), .08); }
body.page-countries .cg-item:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
body.page-countries .cg-flag { grid-area: flag; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
body.page-countries .cg-name { grid-area: name; min-width: 0; font-weight: 600; line-height: 1.25; color: var(--c-primary); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }   /* long names wrap, never cut */
body.page-countries .cg-item b { grid-area: share; font-weight: 800; color: var(--c-accent-strong, var(--c-accent)); font-variant-numeric: tabular-nums; }
/* the share reads as a sentence: "43% / of customers" — a bare number was ambiguous */
body.page-countries .cg-share { display: flex; flex-direction: column; align-items: flex-end; font-size: 16px; line-height: 1.1; }
body.page-countries .cg-share small { margin-top: 2px; font-size: 10.5px; font-weight: 600; color: var(--c-text-muted); white-space: nowrap; }
body.page-countries .cg-empty { margin: 36px 0 0; text-align: center; color: var(--c-text-muted); }
body.page-countries .cg-note { display: flex; align-items: flex-start; justify-content: center; gap: 8px; margin: 32px 0 0; font-size: 13px; color: var(--c-text-muted); text-align: center; }
body.page-countries .cg-note i { margin-top: 3px; color: var(--c-accent); }

@media (max-width: 768px) {
    body.page-countries .cg-main { padding: 10px 0 calc(var(--ph-bottom-nav-h, 80px) + 24px); }
    body.page-countries .cg-head p { font-size: 14px; }
    body.page-countries .cg-sep { display: none; }   /* the wrap leaves a dangling dot at a line end */
    body.page-countries .cg-globe { height: auto; min-height: 0; aspect-ratio: 1 / 1.08; }   /* the phone's width is the short side */
    body.page-countries .cg-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 26px; }
    body.page-countries .cg-item { padding: 13px 13px 14px; gap: 8px; font-size: 13px; }
    body.page-countries .cg-note { margin-top: 24px; }
    body.page-countries .cg-hint { font-size: 11.5px; bottom: 10px; }
    body.page-countries .cg-legend { top: 6px; font-size: 11.5px; padding: 6px 10px; }
    body.page-countries .cg-note { font-size: 12.5px; }
    /* tooltip: name on one line, the two shares under it, never wider than the screen */
    body.page-countries .cg-tip { flex-wrap: wrap; justify-content: center; row-gap: 5px; max-width: calc(100% - 20px); padding: 8px 12px; font-size: 13px; white-space: normal; text-align: center; }
    body.page-countries .cg-tip b { flex-basis: auto; }
    body.page-countries .cg-tip span { white-space: nowrap; }
}
/* phones: one card per row — a two-up card (~170px) had to stack name / share, which left uneven
   gaps and wrapped long names. full width fits the desktop flag | name | share line with room to spare */
@media (max-width: 480px) {
    body.page-countries .cg-list { grid-template-columns: 1fr; gap: 10px; margin-top: 22px; }
    body.page-countries .cg-item { padding: 13px 16px; column-gap: 12px; font-size: 15px; min-height: 64px; }
    body.page-countries .cg-share { font-size: 17px; }
    body.page-countries .cg-head h1 { font-size: 26px; }
    body.page-countries .cg-head p { gap: 6px 10px; }
    body.page-countries .cg-note { font-size: 12.5px; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
    body.page-countries .cg-live i, body.page-countries .cg-load i { animation: none; }
}
