/* ==========================================================================
   Refugee Timeline — design tokens
   Modern glassmorphism, violet/teal/coral/amber, compact sizing, mobile-first.
   ========================================================================== */
:root {
    --violet: #7C5CFF;
    --violet-deep: #5B3DE0;
    --teal: #14B8A6;
    --coral: #FF6B7A;
    --amber: #FFB648;
    --ink: #1B1E2B;
    --ink-soft: #454A5E;
    --slate: #6B7086;
    --slate-light: #97A0B5;
    --paper: #F1F0F9;
    --glass: rgba(255, 255, 255, 0.6);
    --glass-strong: rgba(255, 255, 255, 0.82);
    --glass-border: rgba(255, 255, 255, 0.55);
    --good: #12A177;
    --radius-s: 8px;
    --radius-m: 14px;
    --radius-l: 20px;
    --shadow-glass: 0 6px 24px rgba(69, 51, 138, 0.13), 0 1.5px 0 rgba(255,255,255,0.6) inset;
    --shadow-soft: 0 3px 14px rgba(69, 51, 138, 0.09);
    --sans: 'Inter', 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --display: 'Sora', 'Inter', -apple-system, sans-serif;
    --sans-zh: 'Noto Sans SC', var(--sans);
    --sans-ur: 'Noto Nastaliq Urdu', 'Noto Sans Arabic', var(--sans);
    --sans-ar: 'Noto Kufi Arabic', 'Noto Sans Arabic', var(--sans);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 15px; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background: var(--paper);
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(38vw 38vw at 8% 8%, rgba(124, 92, 255, 0.32), transparent 65%),
        radial-gradient(34vw 34vw at 95% 18%, rgba(20, 184, 166, 0.27), transparent 65%),
        radial-gradient(40vw 40vw at 30% 95%, rgba(255, 107, 122, 0.25), transparent 65%),
        radial-gradient(30vw 30vw at 85% 90%, rgba(255, 182, 72, 0.25), transparent 65%),
        var(--paper);
}

html[lang="zh-CN"] body, html[lang="zh"] body { font-family: var(--sans-zh); }
html[dir="rtl"] body { font-family: var(--sans-ur); }
html[lang="ar"] body { font-family: var(--sans-ar); }

img { max-width: 100%; display: block; }
a { color: inherit; }

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; margin: 0 0 .35em; color: var(--ink); letter-spacing: -0.01em; }
p { margin: 0 0 .85em; }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; padding: 10px 10px 0; }
.site-header .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    gap: 14px;
    max-width: 1180px;
    margin: 0 auto;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-glass);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; min-width: 0; }
.brand-logo { width: 32px; height: 32px; flex-shrink: 0; }
.brand-text .name { font-family: var(--display); font-size: 1.02rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.brand-text .tag { font-size: .66rem; color: var(--slate); display: block; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }

.main-nav { display: flex; align-items: center; gap: 3px; }
.main-nav a { text-decoration: none; color: var(--ink-soft); font-size: .84rem; font-weight: 600; padding: 7px 12px; border-radius: 999px; white-space: nowrap; }
.main-nav a:hover { background: rgba(124, 92, 255, 0.10); color: var(--violet-deep); }
.main-nav a.active { background: linear-gradient(135deg, var(--violet), var(--coral)); color: #fff; }

.header-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.flag-strip {
    width: 30px; height: 20px; border-radius: 4px; overflow: hidden; flex-shrink: 0;
    box-shadow: var(--shadow-soft);
    background: linear-gradient(90deg, #D80621 0 25%, #fff 25% 75%, #D80621 75% 100%);
    position: relative;
}
.flag-strip .leaf { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; }

.lang-switch select {
    font-family: var(--sans);
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.7);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .78rem;
    color: var(--ink);
    font-weight: 600;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--ink); border-radius: 2px; }

@media (max-width: 780px) {
    .nav-toggle { display: flex; }
    .main-nav {
        display: none;
        position: absolute;
        top: calc(100% + 6px);
        inset-inline: 10px;
        flex-direction: column;
        align-items: stretch;
        background: var(--glass-strong);
        backdrop-filter: blur(18px) saturate(160%);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-m);
        padding: 8px;
        box-shadow: var(--shadow-glass);
        gap: 2px;
    }
    .main-nav.open { display: flex; }
    .main-nav a { text-align: center; padding: 10px 12px; }
    .brand-text .tag { max-width: 40vw; }
}

/* ---------- Hero / Calculator flanked by ranking panels ---------- */
.hero { padding: 34px 0 12px; text-align: center; }
.hero h1 {
    font-size: 1.7rem;
    max-width: 640px;
    margin: 0 auto .4em;
    background: linear-gradient(120deg, var(--violet-deep), var(--coral) 60%, var(--amber));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero .sub { color: var(--slate); max-width: 520px; margin: 0 auto 1.6em; font-size: .92rem; }

.calc-desk {
    padding: 0 0 40px;
    display: grid;
    grid-template-columns: 230px 1fr 230px;
    gap: 18px;
    align-items: start;
}
@media (max-width: 1040px) {
    .calc-desk { grid-template-columns: 1fr; }
    .calc-desk .panel { order: 3; }
}

.calc-card {
    background: var(--glass);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-glass);
    margin: 0 auto;
    text-align: left;
    overflow: hidden;
    width: 100%;
}
html[dir="rtl"] .calc-card { text-align: right; }

.calc-tabs { display: flex; gap: 5px; padding: 8px; }
.calc-tab {
    flex: 1;
    padding: 10px 12px;
    text-align: center;
    font-weight: 700;
    font-size: .78rem;
    color: var(--slate);
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: var(--radius-m);
    font-family: var(--sans);
    transition: background .15s ease, color .15s ease;
}
.calc-tab.active { color: #fff; background: linear-gradient(135deg, var(--violet), var(--violet-deep)); box-shadow: var(--shadow-soft); }

.calc-body { padding: 6px 22px 24px; }
.calc-pane { display: none; }
.calc-pane.active { display: block; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .78rem; font-weight: 700; margin-bottom: 5px; color: var(--ink-soft); }
.field select, .field input[type=date], .field input[type=month], .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(27,30,43,0.12);
    border-radius: var(--radius-s);
    font-size: .88rem;
    font-family: inherit;
    background: rgba(255,255,255,0.75);
    color: var(--ink);
}
.field select:focus, .field input:focus, .field textarea:focus { border-color: var(--violet); }
.field textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.radio-row { display: flex; gap: 16px; }
.radio-row label { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: .85rem; color: var(--ink); }

.btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--violet), var(--coral));
    color: #fff;
    border: none;
    padding: 11px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 5px 15px rgba(124, 92, 255, 0.32);
    transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(124, 92, 255, 0.4); }
.btn-secondary { background: linear-gradient(135deg, var(--teal), #0D9488); box-shadow: 0 5px 15px rgba(20, 184, 166, 0.32); }
.btn-secondary:hover { box-shadow: 0 8px 18px rgba(20, 184, 166, 0.4); }
.btn-outline {
    background: rgba(124,92,255,0.08);
    color: var(--violet-deep);
    box-shadow: none;
    border: 1px solid rgba(124,92,255,0.3);
}
.btn-outline:hover { background: rgba(124,92,255,0.14); box-shadow: none; }
.btn[disabled] { opacity: .6; cursor: not-allowed; transform: none; }
.btn-block { display: block; width: 100%; text-align: center; }

.result-box { margin-top: 18px; border-top: 1px dashed rgba(27,30,43,0.15); padding-top: 16px; display: none; }
.result-box.show { display: block; }
.result-range {
    font-family: var(--display);
    font-weight: 800;
    font-size: 1.9rem;
    margin: 3px 0 2px;
    background: linear-gradient(120deg, var(--violet-deep), var(--teal));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.result-range .unit { font-size: .88rem; color: var(--slate); font-family: var(--sans); -webkit-text-fill-color: var(--slate); }
.result-dates { font-size: .84rem; font-weight: 700; color: var(--violet-deep); margin: 6px 0 2px; }
.result-meta { color: var(--slate); font-size: .8rem; margin: 8px 0; }
.result-accept { display: inline-flex; align-items: center; gap: 7px; background: rgba(18, 161, 119, 0.12); color: var(--good); border-radius: 999px; padding: 6px 13px; font-weight: 700; font-size: .8rem; }
.caveat {
    margin-top: 13px;
    font-size: .74rem;
    color: var(--slate);
    background: rgba(255, 182, 72, 0.14);
    border: 1px solid rgba(255, 182, 72, 0.4);
    padding: 10px 13px;
    border-radius: var(--radius-s);
}
.consent-note { font-size: .76rem; color: var(--slate); margin-top: -4px; margin-bottom: 13px; }

/* ---------- Searchable nationality combobox ---------- */
.combo { position: relative; }
.combo-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(27,30,43,0.12);
    border-radius: var(--radius-s);
    background: rgba(255,255,255,0.75);
    cursor: text;
}
.combo-input-wrap:focus-within { border-color: var(--violet); }
.combo-flag { font-size: 1.05rem; flex-shrink: 0; }
.combo-input-wrap input {
    border: none; outline: none; background: transparent; flex: 1; font-size: .88rem; font-family: inherit; color: var(--ink); padding: 0; min-width: 0;
}
.combo-caret { color: var(--slate-light); font-size: .7rem; flex-shrink: 0; }
.combo-list {
    display: none;
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    inset-inline: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--glass-strong);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-glass);
    padding: 6px;
}
.combo-list.open { display: block; }
.combo-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-s);
    font-size: .85rem;
    cursor: pointer;
}
.combo-option:hover, .combo-option.active { background: rgba(124, 92, 255, 0.12); }
.combo-empty { padding: 14px; text-align: center; color: var(--slate); font-size: .82rem; }

/* ---------- Ranking panels (flanking the calculator) ---------- */
.panel {
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-glass);
    padding: 16px;
}
.panel h3 { font-size: .9rem; margin-bottom: 1px; }
.panel .sub { font-size: .72rem; color: var(--slate); margin-bottom: 10px; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(27,30,43,0.08); font-size: .8rem; }
.rank-list li:last-child { border-bottom: none; }
.rank-num {
    color: #fff; font-size: .64rem; font-weight: 800; width: 17px; height: 17px; flex-shrink: 0;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--violet), var(--teal));
}
.rank-flag { font-size: 1.05rem; }
.rank-name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-values { text-align: end; flex-shrink: 0; }
.rank-value { font-weight: 800; color: var(--violet-deep); font-size: .74rem; white-space: nowrap; display: block; }
.rank-subvalue { font-weight: 600; color: var(--good); font-size: .68rem; white-space: nowrap; display: block; }

/* ---------- Stories ---------- */
.stories-section { padding: 30px 0 10px; }
.stories-section h2 { font-size: 1.2rem; text-align: center; }
.stories-section > .container > .sub { text-align: center; color: var(--slate); font-size: .8rem; margin-bottom: 18px; }
.story-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; max-width: 900px; margin: 0 auto; }
@media (max-width: 700px) { .story-grid { grid-template-columns: 1fr; } }
.story-card {
    background: var(--glass-strong);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-m);
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
}
.story-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.story-flag { font-size: 1.2rem; }
.story-country { font-weight: 700; font-size: .86rem; }
.badge { margin-inline-start: auto; font-size: .64rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.badge.pending { background: rgba(255, 182, 72, 0.22); color: #9A6300; }
.badge.completed { background: rgba(18, 161, 119, 0.16); color: var(--good); }
.story-dates { font-size: .7rem; color: var(--slate); margin-bottom: 6px; }
.story-text { font-size: .82rem; color: var(--ink-soft); }
.story-empty { text-align: center; color: var(--slate); padding: 26px; border: 1px dashed rgba(27,30,43,0.18); border-radius: var(--radius-m); background: rgba(255,255,255,0.4); max-width: 900px; margin: 0 auto; }
.load-more-wrap { text-align: center; margin-top: 18px; }

/* ---------- Stats section ---------- */
.stats-section { padding: 14px 0 50px; }
.stats-section h2 { text-align: center; font-size: 1.25rem; }
.stats-section > .container > .sub { text-align: center; color: var(--slate); margin-bottom: 20px; font-size: .82rem; }
.stats-note {
    max-width: 620px;
    margin: -8px auto 20px;
    text-align: center;
    font-size: .74rem;
    color: #9A6300;
    background: rgba(255, 182, 72, 0.16);
    border: 1px solid rgba(255, 182, 72, 0.4);
    border-radius: var(--radius-s);
    padding: 8px 14px;
}
.stats-stack { display: flex; flex-direction: column; gap: 12px; max-width: 780px; margin: 0 auto; }
.stat-card {
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-inline-start: 4px solid var(--violet);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-glass);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.stat-card:nth-child(1) { border-inline-start-color: var(--violet); }
.stat-card:nth-child(2) { border-inline-start-color: var(--teal); }
.stat-card:nth-child(3) { border-inline-start-color: var(--coral); }
.stat-card:nth-child(4) { border-inline-start-color: var(--amber); }
.stat-card:nth-child(5) { border-inline-start-color: #5B3DE0; }
.stat-info { flex: 0 0 auto; min-width: 130px; }
.stat-card .label { font-size: .74rem; color: var(--slate); margin-bottom: 3px; font-weight: 600; }
.stat-card .value { font-family: var(--display); font-weight: 800; font-size: 1.4rem; color: var(--ink); }
.stat-chart-wrap { position: relative; flex: 1; height: 60px; min-width: 0; }
@media (max-width: 640px) {
    .stat-card { flex-direction: column; align-items: stretch; gap: 6px; }
    .stat-info { min-width: 0; }
    .stat-chart-wrap { height: 56px; }
}

/* ---------- Footer ---------- */
.site-footer { padding: 16px 10px 24px; margin-top: 12px; }
.site-footer .container {
    display: grid;
    gap: 8px;
    background: linear-gradient(135deg, rgba(27,30,43,0.94), rgba(58, 42, 110, 0.94));
    border-radius: var(--radius-l);
    padding: 26px 26px;
    color: #C9CCE0;
}
.site-footer p { margin: 0; font-size: .76rem; line-height: 1.55; color: #B9BDD6; }
.site-footer .lead { color: #fff; font-weight: 800; font-family: var(--display); font-size: .98rem; margin-bottom: 4px; }
.site-footer .rights { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12); font-size: .72rem; color: #8C90AD; }

/* ---------- Utility ---------- */
.section-title { text-align: center; margin-bottom: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 480px) {
    html { font-size: 14px; }
    .container { padding: 0 14px; }
    .hero h1 { font-size: 1.4rem; }
}
