/* ==========================================================================
   /tools/reyting-imen — рейтинг имён по данным ЗАГС Москвы
   Hero / FAQ / share наследуются из maternity-bag.css.
   Палитра — розово-золотая, как у остальных инструментов раздела «Имена».
   ========================================================================== */
@import url("/assets/css/maternity-bag.css");

.ri-page {
  --ri-girl: #c9607d; /* один сплошной оттенок на все столбцы графика:
                         серия одна, поэтому категорийная палитра не нужна.
                         Контраст к белой подложке — выше 3:1. */
  --ri-boy: #4a7fa8;
  --ri-line: rgba(17, 17, 17, 0.09);
  --ri-ink: #5d5750;
}

.ri-page {
  background:
    radial-gradient(70% 45% at 6% 3%, rgba(247, 203, 202, 0.55) 0%, transparent 60%),
    radial-gradient(60% 40% at 96% 20%, rgba(226, 232, 242, 0.7) 0%, transparent 62%),
    linear-gradient(180deg, #fbf8f7 0%, #f5f2f4 100%) !important;
}

.ri-hero {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52) 0%, rgba(247, 203, 202, 0.8) 100%),
    url("/assets/images/imya-po-otchestvu-hero-bg.webp") center / cover no-repeat,
    linear-gradient(180deg, #ffffff 0%, #f7cbca 100%) !important;
  border-bottom-color: #efc9c8 !important;
}

.ri-hero .mb-hero-title span::after {
  background: linear-gradient(90deg, rgba(247, 203, 202, 0.9), rgba(189, 160, 0, 0.35));
}

/* Общая «стеклянная» основа блоков — как на соседних инструментах */
.ri-board,
.ri-lookup-card,
.ri-mover-card,
.ri-related-card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.66) 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(17, 17, 17, 0.04),
    0 18px 38px -24px rgba(80, 50, 55, 0.4);
  border-radius: 18px;
}

/* ---------- Переключатели года и глубины ---------- */
.ri-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 22px 34px;
  margin-bottom: 18px;
}

.ri-control { min-width: 0; }

.ri-control-label {
  display: block;
  margin-bottom: 8px;
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a7069;
}

.ri-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ri-chip {
  padding: 7px 13px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  font-family: "Montserrat", sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ri-ink);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.ri-chip:hover { border-color: rgba(201, 96, 125, 0.45); color: var(--main-bg-color); }

.ri-chip.is-on {
  background: var(--main-bg-color);
  border-color: var(--main-bg-color);
  color: #fff;
}

/* Звёздочка = год неполный. Дублируется текстом в подписи под таблицами. */
.ri-chip-part { color: var(--gold-color); font-size: 15px; line-height: 0; }
.ri-chip.is-on .ri-chip-part { color: #f0d97a; }

.ri-caption {
  margin: 0 0 14px !important;
  font-family: "Montserrat", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--main-bg-color);
}

/* ---------- Две таблицы рейтинга ---------- */
.ri-boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ri-board { padding: 20px 22px 14px; }

.ri-board-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Montserrat", sans-serif;
  font-size: 17px !important;
  font-weight: 800 !important;
  margin: 0 0 14px !important;
  color: var(--main-bg-color);
}

.ri-board-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ri-board-mark-f { background: var(--ri-girl); }
.ri-board-mark-m { background: var(--ri-boy); }

.ri-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.ri-table th {
  padding: 0 8px 8px;
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6f665f;
  text-align: right;
  border-bottom: 1px solid var(--ri-line);
}

.ri-table th:first-child,
.ri-table th:nth-child(2) { text-align: left; }

.ri-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--ri-line);
  color: var(--ri-ink);
  text-align: right;
}

.ri-table tr:last-child td { border-bottom: none; }
.ri-table tbody tr:hover { background: rgba(201, 96, 125, 0.05); }

.ri-pos {
  width: 34px;
  text-align: left !important;
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  color: #6f665f;
}

/* Первая тройка — единственное место, где ранг подсвечен цветом.
   Дальше по списку разница в несколько детей, подсвечивать нечего. */
.ri-table tr:nth-child(1) .ri-pos { color: #8a7300; } /* var(--gold-color) на светлом даёт 2.5:1 — для цифры мало */
.ri-table tr:nth-child(2) .ri-pos,
.ri-table tr:nth-child(3) .ri-pos { color: #6f665f; }

.ri-name { text-align: left !important; }

.ri-pick {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--main-bg-color);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px dashed rgba(17, 17, 17, 0.22);
}

.ri-pick:hover { color: var(--ri-girl); border-bottom-color: var(--ri-girl); }
.ri-board[data-sex="m"] .ri-pick:hover { color: var(--ri-boy); border-bottom-color: var(--ri-boy); }

.ri-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.ri-table .ri-share { width: 58px; font-variant-numeric: tabular-nums; color: #6f665f; font-size: 13px; }

.ri-tablenote {
  margin: 12px 0 30px !important;
  font-size: 13px;
  line-height: 1.55;
  color: #7a7069;
}

/* ---------- Поиск имени ---------- */
.ri-lookup { margin-bottom: 30px; }
.ri-lookup-card { padding: 26px 28px; }

.ri-lookup-title {
  font-family: "Montserrat", sans-serif;
  font-size: 21px !important;
  font-weight: 800 !important;
  margin: 0 0 6px !important;
  color: var(--main-bg-color);
}

.ri-lookup-sub {
  margin: 0 0 16px !important;
  font-size: 14.5px;
  color: var(--ri-ink);
}

.ri-search { position: relative; }

.ri-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #6f665f;
  pointer-events: none;
}

.ri-search input {
  width: 100%;
  padding: 13px 16px 13px 46px;
  border: 1.5px solid rgba(17, 17, 17, 0.12);
  border-radius: 12px;
  background: #fff;
  font-family: "Nunito", sans-serif;
  font-size: 16px; /* < 16px заставляет iOS зумить страницу на фокусе */
  color: var(--main-bg-color);
}

.ri-search input:focus {
  outline: none;
  border-color: var(--ri-girl);
  box-shadow: 0 0 0 3px rgba(201, 96, 125, 0.15);
}

.ri-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ri-hint {
  margin: 10px 0 0 !important;
  font-size: 13px;
  color: #7a7069;
}

/* ---------- Карточка имени ---------- */
.ri-card {
  --ri-accent: var(--ri-girl);
  margin-top: 20px;
  padding: 20px 22px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(17, 17, 17, 0.07);
}

.ri-card-m { --ri-accent: var(--ri-boy); }

.ri-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ri-card-head h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 26px !important;
  font-weight: 800 !important;
  margin: 0 !important;
  color: var(--main-bg-color);
}

.ri-card-sex { font-size: 13.5px; color: #7a7069; }

.ri-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.ri-stat {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(17, 17, 17, 0.028);
}

.ri-stat-val {
  display: block;
  font-family: "Montserrat", sans-serif;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ri-accent);
  font-variant-numeric: tabular-nums;
}

.ri-stat-lab {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.35;
  color: #7a7069;
}

/* ---------- График по годам ----------
   Одна серия -> легенда не нужна, заголовок и так называет, что нарисовано.
   Подписи значений только у пика и последнего года, остальное — в тултипе
   и в таблице под графиком. */
.ri-chart { margin-bottom: 20px; }

.ri-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-family: "Montserrat", sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--main-bg-color);
}

.ri-chart-note {
  font-weight: 600;
  font-size: 12px;
  color: #6f665f;
}

.ri-cols {
  display: flex;
  align-items: flex-end;
  gap: 2px; /* разделяет соседние столбцы подложкой, а не обводкой */
  height: 150px;
  padding-top: 18px; /* место под подпись значения над пиковым столбцом */
  overflow-x: clip; /* страховка: тултип не растягивает страницу; clip, а не hidden — подпись сверху должна торчать */
  border-bottom: 1px solid var(--ri-line);
}

.ri-col {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.ri-col-bar {
  width: 100%;
  max-width: 24px;
  background: var(--ri-accent);
  opacity: 0.5;
  /* Скруглён только верх: низ — общая базовая линия, её скруглять нельзя,
     иначе столбец «отрывается» от оси. */
  border-radius: 4px 4px 0 0;
  transition: opacity 0.18s;
}

.ri-col.is-peak .ri-col-bar,
.ri-col:last-child .ri-col-bar { opacity: 1; }
.ri-col:hover .ri-col-bar { opacity: 1; }

.ri-col-val {
  position: absolute;
  top: -18px;
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--ri-ink); /* текст не носит цвет данных */
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ri-col-x {
  position: absolute;
  bottom: -20px;
  font-size: 11px;
  color: #6f665f;
  font-variant-numeric: tabular-nums;
}

/* Подпись крайних столбцов центрируется по столбцу и вылезала за график — прижимаем к его краю. */
.ri-col:first-child .ri-col-val { left: 0; }
.ri-col:last-child .ri-col-val { right: 0; }

.ri-col-x::before { content: "’"; }

.ri-col-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--main-bg-color);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 3;
}

/* Тултип у крайних столбцов шире самого столбца и вылезал за правый край,
   растягивая страницу. На тач-экранах он всё равно мёртвый — hover там нет,
   а цифры по годам есть в таблице ниже. */
@media (hover: none) {
  .ri-col-tip { display: none; }
}

.ri-col:hover .ri-col-tip { opacity: 1; }

/* ---------- Таблица по годам (она же табличный вид графика) ---------- */
.ri-years-table {
  width: 100%;
  margin-top: 34px;
  border-collapse: collapse;
  font-size: 14px;
}

.ri-years-table caption {
  margin-bottom: 8px;
  font-family: "Montserrat", sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  text-align: left;
  color: var(--main-bg-color);
}

.ri-years-table th[scope="col"] {
  padding: 0 8px 7px;
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6f665f;
  text-align: right;
  border-bottom: 1px solid var(--ri-line);
}

.ri-years-table th[scope="col"]:first-child { text-align: left; }

.ri-years-table th[scope="row"] {
  padding: 6px 8px;
  text-align: left;
  font-weight: 700;
  color: var(--main-bg-color);
  border-bottom: 1px solid var(--ri-line);
}

.ri-years-table td {
  padding: 6px 8px;
  text-align: right;
  color: var(--ri-ink);
  border-bottom: 1px solid var(--ri-line);
  font-variant-numeric: tabular-nums;
}

.ri-part {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(189, 160, 0, 0.14);
  color: #8a7600;
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.ri-out { color: #6f665f; font-size: 12.5px; }

.ri-card-empty h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 19px !important;
  font-weight: 800 !important;
  margin: 0 0 8px !important;
}

.ri-card-empty p { margin: 0 !important; font-size: 14.5px; line-height: 1.6; color: var(--ri-ink); }

/* ---------- Кто вырос и упал ---------- */
.ri-article { margin: 34px 0; }

.ri-article h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 26px !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em;
  margin: 0 0 14px !important;
  color: var(--main-bg-color);
}

.ri-article h3 {
  font-family: "Montserrat", sans-serif;
  font-size: 18px !important;
  font-weight: 700 !important;
  margin: 22px 0 8px !important;
  color: var(--main-bg-color);
}

.ri-article p {
  margin: 0 0 12px !important;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ri-ink);
}

.ri-movers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 12px;
}

.ri-mover-card { padding: 16px 18px; }

.ri-mover-card h3 {
  font-size: 14px !important;
  font-weight: 700 !important;
  margin: 0 0 10px !important;
}

.ri-mover-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--ri-line);
  font-size: 14px;
}

.ri-mover-list li:last-child { border-bottom: none; }

.ri-move {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Знак дублируется символом «+»/«−», не только цветом */
.ri-move-up { color: #3f7d4d; }
.ri-move-down { color: #b4574f; }

.ri-movers-note {
  font-size: 13px !important;
  line-height: 1.55 !important;
  color: #7a7069 !important;
}

/* ---------- Перелинковка ---------- */
.ri-related { margin: 34px 0; }

.ri-related h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 24px !important;
  font-weight: 800 !important;
  margin: 0 0 16px !important;
  color: var(--main-bg-color);
}

.ri-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.ri-related-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 20px;
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s;
}

.ri-related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 42px -24px rgba(80, 50, 55, 0.55);
}

.ri-related-tag {
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-color);
}

.ri-related-title {
  font-family: "Montserrat", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--main-bg-color);
}

.ri-related-text { font-size: 13.5px; line-height: 1.5; color: var(--ri-ink); }

/* ---------- Источники (общий для инструментов блок) ---------- */
.sr-sources-block {
  margin: 32px 0 8px; padding: 26px 30px 22px !important; border-radius: 16px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.80) 0%, rgba(250, 247, 235, 0.58) 100%);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 28px rgba(150, 120, 30, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.sr-sources-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed rgba(200, 180, 90, 0.4); }
.sr-sources-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  background: linear-gradient(135deg, #d9c24a, #bda000); color: #fff; border-radius: 10px; flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(189, 160, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.sr-sources-head h2 { font-family: "Montserrat", sans-serif; font-size: 20px !important; font-weight: 800 !important; margin: 0 !important; letter-spacing: -0.02em; color: var(--main-bg-color); }
.sr-sources { counter-reset: sr-source; list-style: none !important; margin: 0 !important; padding: 0 !important; font-size: 13.5px !important; line-height: 1.6 !important; color: var(--main-bg-color); }
.sr-sources li { position: relative; counter-increment: sr-source; padding: 10px 12px 10px 42px !important; margin: 0 !important; border-radius: 10px; transition: background 0.2s ease; }
.sr-sources li:hover { background: rgba(189, 160, 0, 0.05); }
.sr-sources li::before {
  content: counter(sr-source); position: absolute; left: 8px; top: 9px; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.8); border: 1.5px solid rgba(200, 180, 90, 0.5); border-radius: 50%;
  font-family: "Montserrat", sans-serif; font-size: 11px; font-weight: 800; color: #bda000;
}
.sr-sources-authors { font-weight: 700; color: var(--main-bg-color); margin-right: 4px; }
.sr-sources a { color: var(--main-bg-color); text-decoration: underline; text-decoration-color: rgba(189, 160, 0, 0.5); text-decoration-thickness: 1.5px; text-underline-offset: 2px; transition: color .2s, text-decoration-color .2s; }
.sr-sources a:hover { color: #8a7600; text-decoration-color: #bda000; }
.sr-sources a[target="_blank"]::after { content: "\2197"; display: inline-block; margin-left: 3px; font-size: 0.85em; color: #bda000; text-decoration: none; vertical-align: middle; }
.sr-sources-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; background: rgba(189, 160, 0, 0.14); color: #8a7600; border-radius: 999px; font-family: "Montserrat", sans-serif; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle; white-space: nowrap; }
.sr-sources-note { margin: 16px 0 0 !important; padding: 10px 14px !important; background: rgba(255, 255, 255, 0.55); border-left: 3px solid #bda000; border-radius: 8px; font-size: 12.5px !important; line-height: 1.5 !important; color: #6b6555; font-style: italic; }

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
  .ri-boards { grid-template-columns: 1fr; }
  .ri-movers { grid-template-columns: 1fr 1fr; }
  .ri-related-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 576px) {
  .ri-board { padding: 16px 14px 10px; }
  .ri-lookup-card { padding: 20px 16px; }
  .ri-card { padding: 16px 14px; }
  .ri-stats { grid-template-columns: 1fr; gap: 8px; }
  .ri-stat { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; }
  .ri-stat-val { font-size: 22px; }
  .ri-stat-lab { margin-top: 0; }
  .ri-stat-lab br { display: none; }
  .ri-movers,
  .ri-related-grid { grid-template-columns: 1fr; }
  .ri-cols { height: 120px; }
  .ri-col-x { font-size: 10px; }
  .ri-table { font-size: 13.5px; }
  .ri-table .ri-share { display: none; } /* доля на узком экране лишняя: число рядом */
  .ri-table th:nth-child(4) { display: none; }
}

/* Уважать системную настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  .ri-related-card,
  .ri-col-bar,
  .ri-col-tip { transition: none; }
}
