/* Windows не рисует флаги-эмодзи — подключаем шрифт с флагами только для этих символов */
@font-face {
    font-family: "Twemoji Country Flags";
    unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
    src: url("https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1.8/dist/TwemojiCountryFlags.woff2") format("woff2");
    font-display: swap;
}
:root {
    --bg: #f3f4f7;
    --card: #fff;
    --text: #1f2330;
    --muted: #6b7183;
    --border: #e2e5ec;
    --accent: #b5121b;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Twemoji Country Flags", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 0px; }
h1 { margin: 0 0 16px; font-size: 24px; }

.search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.search input, .search select, .search button, .search a {
    height: 40px; padding: 0 12px; font: inherit; font-size: 15px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text);
}
.search input { flex: 1 1 260px; }
.search select { flex: 0 1 220px; }
.search button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }
.search a { display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); }
.summary { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 860px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 400px)  { .grid { grid-template-columns: 1fr; } }

.card {
    color: inherit; text-decoration: none;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px; display: grid; grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px; align-items: center;
    transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 18px rgba(20, 30, 60, .08); transform: translateY(-2px); }
.photo {
    width: 64px; height: 78px; border-radius: 8px; object-fit: cover; object-position: top;
    background: #eef0f4; display: block;
}
.info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.name { font-weight: 600; font-size: 15px; line-height: 1.3; word-break: break-word; }
.country, .birth { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.flag { font-size: 18px; line-height: 1; }
.birth svg { width: 16px; height: 16px; flex: none; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 28px; }
.pagination a, .pagination span {
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; font-size: 15px;
}
.pagination a { background: var(--card); border: 1px solid var(--border); color: var(--text); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; font-weight: 600; }
.pagination .disabled { color: #b5bac6; border: 1px solid var(--border); }
.pagination .dots { color: var(--muted); }

.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Страница пользователя */
.back {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 20px;
    color: var(--muted); text-decoration: none; font-size: 15px;
}
.back:hover { color: var(--accent); }
.profile {
    max-width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start;
}
.profile-photo {
    width: 220px; height: 265px; border-radius: 12px; object-fit: cover; object-position: top;
    background: #eef0f4; display: block;
}
.profile h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; word-break: break-word; }
.profile .country { font-size: 16px; margin-bottom: 24px; }
.profile .country .flag { font-size: 24px; }
.details { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px 24px; }
.details dt { color: var(--muted); font-size: 14px; }
.details dd { margin: 0; font-size: 15px; }
.pager { display: flex; justify-content: space-between; gap: 12px; max-width: 880px; margin-top: 16px; }
.pager a {
    color: var(--text); text-decoration: none; font-size: 15px; padding: 8px 14px;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) {
    .profile { grid-template-columns: 1fr; padding: 20px; gap: 20px; }
    .profile-photo { margin: 0 auto; width: 180px; height: 217px; }
    .details { grid-template-columns: 1fr; gap: 4px; }
    .details dd { margin-bottom: 10px; }
}
.pager { align-items: center; }
.pager > * { flex: 1 1 0; }
.pager a:last-child { text-align: right; }
.pager-count { flex: 0 0 auto; color: var(--muted); font-size: 14px; white-space: nowrap; }

.section-title {
    margin: 28px 0 12px; padding-top: 20px; border-top: 1px solid var(--border);
    font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.details a { color: var(--accent); text-decoration: none; }
.details a:hover { text-decoration: underline; }

/* Статистика по странам */
.stats {
    margin-top: 40px; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    padding: 20px 24px 16px;
    margin-bottom: 40px;
}
.stats h2 { margin: 0; font-size: 18px; }
.stats-sub { margin: 4px 0 16px; color: var(--muted); font-size: 14px; }
.stats-list { list-style: none; margin: 0; padding: 0; }
.stats-list a {
    display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) 96px; gap: 16px; align-items: center;
    padding: 6px 8px; margin: 0 -8px; border-radius: 8px; color: var(--text); text-decoration: none;
}
.stats-list a:hover, .stats-list a:focus-visible { background: var(--bg); outline: none; }
.stats-country { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.stats-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-track { height: 12px; }
.stats-bar {
    display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0;
    background: var(--accent); opacity: .85; transition: opacity .15s;
}
.stats-list a:hover .stats-bar { opacity: 1; }
.stats-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.stats-value span { font-weight: 400; color: var(--muted); margin-left: 4px; }
@media (max-width: 640px) {
    .stats { padding: 16px; }
    .stats-list a { grid-template-columns: minmax(0, 1fr) 80px; gap: 4px 12px; }
    .stats-track { grid-column: 1 / -1; grid-row: 2; height: 8px; }
}
