/* =============================================================
   Ali Alshaheen, travel globe
   Shares the design system with alisroom.com, the blog and the
   portfolio. The globe is the page; everything else is quiet glass.
   ============================================================= */

:root {
    --bg:        #0c0e12;
    --surface:   #14171d;
    --surface-2: #1a1e26;
    --border:    #252a34;
    --border-s:  #1d222b;
    --text:      #e8ebf0;
    --text-2:    #b3bcc9;
    --muted:     #7f8a9a;
    --accent:    #4ade80;
    --accent-d:  #1c3a29;
    --link:      #7dd3fc;
    --planned:   #7dd3fc;
    --glass:     rgba(17, 20, 26, .78);
    --glass-2:   rgba(23, 27, 34, .9);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --radius: 12px;
    --panel-w: 420px;
    --gutter: 24px;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
    left: 8px; top: 8px; z-index: 200;
    background: var(--accent); color: #04140c; padding: 10px 16px; border-radius: 0 0 8px 0;
}

/* ---------- Globe ---------- */
.globe { position: fixed; inset: 0; z-index: 0; }
.globe canvas { display: block; outline: none; }

/* globe.gl's hover tooltip */
.scene-tooltip {
    font-family: var(--font) !important;
    font-size: 13px !important;
    color: var(--text) !important;
    background: var(--glass-2) !important;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px !important;
    backdrop-filter: blur(8px);
    pointer-events: none;
    white-space: nowrap;
}
.tip b { font-weight: 600; }
.tip span { color: var(--muted); margin-left: 8px; }
.tip .tip-visited { color: var(--accent); }
.tip .tip-planned { color: var(--planned); }

/* ---------- Header ---------- */
.hdr {
    position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    height: 58px;
    background: linear-gradient(to bottom, rgba(12, 14, 18, .92), rgba(12, 14, 18, .55) 70%, transparent);
    pointer-events: none;
}
.hdr-in {
    display: flex; align-items: center; gap: 20px;
    height: 58px; padding: 0 var(--gutter);
}
.hdr-in > * { pointer-events: auto; }
.brand { font-family: var(--mono); font-weight: 700; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.hdr nav { display: flex; gap: 20px; }
.hdr nav a { color: var(--text-2); font-size: 14.5px; }
.hdr nav a:hover { color: var(--text); text-decoration: none; }
.hdr nav a.active { color: var(--accent); }

/* ---------- Search ---------- */
.search {
    position: relative; margin-left: auto;
    display: flex; align-items: center; gap: 8px;
    width: 240px; height: 34px; padding: 0 12px;
    background: var(--glass); border: 1px solid var(--border); border-radius: 8px;
    color: var(--muted);
    backdrop-filter: blur(10px);
}
.search:focus-within { border-color: var(--accent); color: var(--text-2); }
.search input {
    flex: 1; min-width: 0; background: none; border: 0; outline: none;
    color: var(--text); font: inherit; font-size: 14px;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-results {
    position: absolute; top: calc(100% + 6px); right: 0; left: 0;
    list-style: none; max-height: 320px; overflow: auto;
    background: var(--glass-2); border: 1px solid var(--border); border-radius: 10px;
    backdrop-filter: blur(12px); padding: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.search-results li {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text);
}
.search-results li:hover, .search-results li[aria-selected="true"] { background: var(--surface-2); }
.search-results li img { width: 24px; height: 18px; border-radius: 2px; object-fit: cover; }
.search-results li small { margin-left: auto; color: var(--muted); font-size: 12px; }
.search-results li small.is-visited { color: var(--accent); }
.search-results li small.is-planned { color: var(--planned); }
.search-results .none { color: var(--muted); cursor: default; }

/* ---------- Loading ---------- */
.loading {
    position: fixed; inset: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    color: var(--text-2); font-size: 14px;
    background: var(--bg);
    transition: opacity .6s var(--ease), visibility .6s;
}
.loading.done { opacity: 0; visibility: hidden; }
.loading-dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }

/* ---------- Glass surfaces ---------- */
.stats, .controls .ctl, .visited-list, .panel {
    background: var(--glass);
    border: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

/* ---------- Progress ---------- */
.stats {
    position: fixed; z-index: 10;
    left: var(--gutter); top: 78px;
    width: 300px; padding: 18px 20px 16px;
    border-radius: var(--radius);
}
.stats-title { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.count { display: flex; align-items: baseline; gap: 10px; line-height: 1; }
.count-n { font-family: var(--mono); font-weight: 700; font-size: 44px; letter-spacing: -.03em; color: var(--text); }
.count-of { font-size: 15px; color: var(--muted); }
.bar { height: 4px; background: var(--border); border-radius: 2px; margin: 14px 0 8px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width 1.2s var(--ease); }
.stats-sub { font-size: 13px; color: var(--muted); }

.regions { list-style: none; margin-top: 14px; display: grid; gap: 6px; }
.regions li { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.regions li i { height: 3px; background: var(--border-s); border-radius: 2px; overflow: hidden; display: block; }
.regions li i b { display: block; height: 100%; background: var(--accent); width: 0; transition: width 1.2s var(--ease); }
.regions li span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-visited { background: var(--accent); }
.sw-planned { background: var(--planned); }
.sw-territory { border: 2px solid var(--accent); }
.sw-none { background: rgba(255, 255, 255, .18); }

/* ---------- Controls ---------- */
.controls {
    position: fixed; z-index: 10;
    left: var(--gutter); bottom: var(--gutter);
    display: flex; flex-wrap: wrap; gap: 8px;
}
.ctl {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 14px; border-radius: 8px;
    color: var(--text-2); font-size: 13.5px; font-weight: 500; cursor: pointer;
    transition: border-color .15s, color .15s;
}
.ctl:hover { border-color: var(--accent); color: var(--text); }
.ctl[aria-pressed="true"], .ctl[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.ctl:disabled { opacity: .5; cursor: default; }
.ctl-icon { width: 36px; padding: 0; justify-content: center; }
#btn-journey svg { color: var(--accent); }
#btn-journey.playing svg { color: var(--text-2); }

/* ---------- Visited list ---------- */
.visited-list {
    position: fixed; z-index: 11;
    left: var(--gutter); bottom: 72px;
    width: 320px; max-height: min(52vh, 520px);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
}
.visited-list[hidden] { display: none; }
.vl-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.vl-head h2 { font-size: 15px; font-weight: 600; }
.visited-list ol { list-style: none; overflow: auto; padding: 0 8px 8px; }
.visited-list li button {
    display: grid; grid-template-columns: 30px 28px 1fr; align-items: center; gap: 10px;
    width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
    text-align: left; cursor: pointer;
}
.visited-list li button:hover { background: var(--surface-2); }
.visited-list li .n { font-family: var(--mono); font-size: 12.5px; color: var(--accent); }
.visited-list li img { width: 28px; height: 21px; border-radius: 2px; object-fit: cover; }
.visited-list li .name { font-size: 14px; color: var(--text); }
.visited-list li .when { display: block; font-size: 12px; color: var(--muted); }
.visited-list .empty { padding: 8px 18px 18px; color: var(--muted); font-size: 13.5px; }

/* ---------- Close buttons ---------- */
.x {
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
    background: none; border: 1px solid var(--border); color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
}
.x:hover { border-color: var(--accent); color: var(--text); }

/* ---------- Country panel ---------- */
.panel {
    position: fixed; z-index: 25;
    top: 0; right: 0; bottom: 0;
    width: min(var(--panel-w), 100vw);
    border-width: 0 0 0 1px; border-radius: 0;
    overflow-y: auto; overscroll-behavior: contain;
    padding: 74px 28px 40px;
    transform: translateX(0);
    transition: transform .45s var(--ease), visibility 0s linear 0s;
}
.panel[hidden] { display: block; transform: translateX(100%); visibility: hidden; transition: transform .45s var(--ease), visibility 0s linear .45s; }
.panel-close { position: fixed; top: 74px; right: 20px; z-index: 2; background: var(--glass-2); }

.flag { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); display: block; }
.flag-emoji { font-size: 96px; line-height: 1; margin-bottom: 8px; }

.p-name { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 18px; }
.p-official { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.p-note { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }

.status {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
    margin-top: 16px; padding: 12px 14px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.status.is-visited { background: var(--accent-d); border-color: rgba(74, 222, 128, .35); }
.status.is-planned { background: rgba(125, 211, 252, .1); border-color: rgba(125, 211, 252, .3); }
.status.is-territory { border-color: rgba(74, 222, 128, .35); }
.status .badge {
    font-family: var(--mono); font-weight: 700; font-size: 13px;
    padding: 4px 9px; border-radius: 6px; background: var(--accent); color: #04140c;
}
.status.is-planned .badge { background: var(--planned); color: #062133; }
.status.is-territory .badge { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.status .s-text { font-size: 14px; color: var(--text); }
.status .s-sub { flex-basis: 100%; font-size: 13px; color: var(--text-2); }
.status.is-none .s-text { color: var(--muted); }

.facts { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.facts div { padding: 10px 0; border-top: 1px solid var(--border-s); }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { font-size: 14.5px; color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }

.p-h { font-size: 12.5px; color: var(--muted); margin: 24px 0 8px; }
.p-known { font-size: 15px; line-height: 1.6; color: var(--text); }

.cities { list-style: none; display: grid; gap: 2px; }
.cities li { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--border-s); font-size: 14px; }
.cities li .c-region { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.cities li .c-pop { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.cities li.is-cap .c-name::before { content: "★"; color: var(--accent); font-size: 11px; margin-right: 6px; position: relative; top: -1px; }
.cities li.been .c-name::after { content: "visited"; color: var(--accent); font-size: 11px; margin-left: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--border); background: transparent; color: var(--text-2);
    font-size: 13px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-visited { border-color: rgba(74, 222, 128, .5); color: var(--accent); }
.chip.is-planned { border-color: rgba(125, 211, 252, .5); color: var(--planned); }

.p-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.p-links a {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); color: var(--text-2); padding: 7px 12px; border-radius: 8px; font-size: 13.5px;
}
.p-links a:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }

.p-foot { margin-top: 24px; font-size: 12.5px; color: var(--muted); }

/* ---------- Markers on the globe (HTML layer) ---------- */
.marker { pointer-events: auto; cursor: pointer; }
.marker .pin {
    display: flex; align-items: center; justify-content: center;
    min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px;
    font-family: var(--mono); font-weight: 700; font-size: 12px;
    background: var(--accent); color: #04140c;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, .28), 0 4px 14px rgba(0, 0, 0, .45);
    transition: transform .15s var(--ease);
}
.marker:hover .pin, .marker.is-active .pin { transform: scale(1.18); }
.marker.territory .pin { background: var(--bg); color: var(--accent); border: 1.5px solid var(--accent); box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
.marker.tiny .pin {
    min-width: 9px; height: 9px; padding: 0;
    background: rgba(232, 235, 240, .85); box-shadow: 0 0 0 3px rgba(232, 235, 240, .18);
}
.marker.tiny.planned .pin { background: var(--planned); box-shadow: 0 0 0 3px rgba(125, 211, 252, .28); }
.marker .name {
    position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px);
    white-space: nowrap; font-size: 11.5px; color: var(--text); background: var(--glass-2);
    border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px;
    opacity: 0; pointer-events: none; transition: opacity .15s;
}
.marker:hover .name { opacity: 1; }

/* ---------- Hint ---------- */
.hint {
    position: fixed; z-index: 10; left: 50%; bottom: var(--gutter); transform: translateX(-50%);
    font-size: 12.5px; color: var(--muted); pointer-events: none;
    transition: opacity .8s;
}
.hint.gone { opacity: 0; }

/* ---------- Journey toast ---------- */
.toast {
    position: fixed; z-index: 15; top: 78px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; border-radius: 10px;
    background: var(--glass-2); border: 1px solid var(--border); backdrop-filter: blur(12px);
    font-size: 14px; color: var(--text);
    opacity: 0; transition: opacity .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast img { width: 28px; height: 21px; border-radius: 2px; object-fit: cover; }
.toast .n { font-family: var(--mono); color: var(--accent); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    :root { --panel-w: 380px; }
}

@media (max-width: 760px) {
    :root { --gutter: 14px; }
    body { font-size: 14px; }
    .hdr nav { display: none; }
    .search { width: auto; flex: 1; }

    .stats {
        top: 66px; width: auto; right: var(--gutter);
        padding: 12px 14px;
    }
    .stats-title { display: none; }
    .count-n { font-size: 30px; }
    .regions, .legend, .stats-sub { display: none; }
    .stats.open .regions, .stats.open .legend, .stats.open .stats-sub { display: grid; }
    .stats.open .legend { display: flex; }
    .bar { margin: 8px 0 0; }

    .controls { right: var(--gutter); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .controls::-webkit-scrollbar { display: none; }
    .ctl { flex: 0 0 auto; height: 34px; font-size: 13px; }
    .hint { display: none; }

    .visited-list { right: var(--gutter); width: auto; bottom: 62px; }

    .panel {
        top: auto; left: 0; right: 0; bottom: 0;
        width: 100vw; max-height: 68vh;
        border-width: 1px 0 0; border-radius: 16px 16px 0 0;
        padding: 18px 20px 32px;
        transform: translateY(0);
    }
    .panel[hidden] { transform: translateY(100%); }
    .panel-close { top: auto; position: sticky; float: right; margin: 0 0 8px 8px; }
    .flag { max-height: 140px; width: auto; aspect-ratio: 4 / 3; }
    .p-name { font-size: 24px; margin-top: 12px; }
    .facts { grid-template-columns: 1fr 1fr; }
    .toast { top: auto; bottom: 64px; }
}

@media (prefers-reduced-motion: reduce) {
    .loading-dot { animation: none; }
    .panel, .bar span, .regions li i b, .marker .pin { transition: none; }
}
