/* ============================================================
   Valmet — конвертер валют
   Тёмный современный дизайн с анимациями
   ============================================================ */

:root {
  --bg: #07070f;
  --card: rgba(255, 255, 255, 0.045);
  --card-solid: #10101d;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f3f8;
  --muted: #9aa1b8;
  --faint: #6b7189;
  --c1: #22d3ee;   /* cyan   */
  --c2: #818cf8;   /* indigo */
  --c3: #e879f9;   /* fuchsia */
  --grad: linear-gradient(135deg, var(--c1), var(--c2) 55%, var(--c3));
  --radius-lg: 26px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.65);
  --font-body: "Manrope", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Manrope", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(129, 140, 248, 0.4); }

button { font-family: inherit; cursor: pointer; color: inherit; background: none; border: none; }

/* ---------- Анимированный фон ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 50% -10%, rgba(129, 140, 248, 0.10), transparent 60%),
    var(--bg);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.42;
  animation: drift 22s ease-in-out infinite alternate;
  will-change: transform;
}
.blob-1 { width: 560px; height: 560px; top: -14%; left: -10%;
  background: radial-gradient(circle at 30% 30%, rgba(34, 211, 238, 0.5), transparent 70%); }
.blob-2 { width: 640px; height: 640px; bottom: -20%; right: -12%;
  background: radial-gradient(circle at 60% 40%, rgba(232, 121, 249, 0.34), transparent 70%);
  animation-delay: -7s; }
.blob-3 { width: 420px; height: 420px; top: 38%; left: 52%;
  background: radial-gradient(circle at 50% 50%, rgba(129, 140, 248, 0.4), transparent 70%);
  animation-delay: -13s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(70px, 50px) scale(1.15); }
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 75%);
}

/* ---------- Появление элементов ---------- */
.fade-up {
  opacity: 0;
  animation: fadeUp 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Шапка ---------- */
.site-header {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 26px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--grad);
  background-size: 180% 180%;
  display: grid;
  place-items: center;
  overflow: hidden; /* обрезаем картинку по скруглённым углам квадратика */
  box-shadow: 0 8px 26px -6px rgba(129, 140, 248, 0.55);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
  animation: gradShift 6s ease-in-out infinite alternate;
}
.logo-mark svg { width: 22px; height: 22px; }
.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.logo:hover .logo-mark { transform: rotate(-8deg) scale(1.08); box-shadow: 0 10px 30px -4px rgba(34, 211, 238, 0.6); }

.logo-text {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-right { display: flex; align-items: center; gap: 14px; }

.header-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 500; }

/* ---------- Переключатель языка ---------- */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  transition: border-color 0.3s ease;
}
.lang-switch:focus-within { border-color: rgba(129, 140, 248, 0.5); }

.lang-btn {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.25s ease, background 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  color: #0b0b16;
  background: var(--grad);
  background-size: 180% 180%;
  box-shadow: 0 4px 14px -4px rgba(129, 140, 248, 0.6);
  animation: gradShift 5s ease-in-out infinite alternate;
}
.lang-btn:active { transform: scale(0.94); }

.live-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2.2s ease-out infinite;
}
.live-dot.small { width: 7px; height: 7px; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ---------- Основная часть ---------- */
.main {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 20px;
  flex: 1;
}

.hero { text-align: center; margin-bottom: 40px; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.grad {
  background: var(--grad);
  background-size: 220% 220%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradShift 7s ease-in-out infinite alternate;
}
@keyframes gradShift {
  from { background-position: 0% 50%; }
  to   { background-position: 100% 50%; }
}

.hero-sub {
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

/* ---------- Карточка конвертера ---------- */
.converter-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 26px 22px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.converter-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(34, 211, 238, 0.45), transparent 30%, transparent 70%, rgba(232, 121, 249, 0.35));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
}

/* ---------- Блок ---------- */
.block {
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 10px;
  transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
}
.block:focus-within, .block:hover {
  border-color: rgba(129, 140, 248, 0.45);
  box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.09);
}

.block-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin-bottom: 6px;
}

.amount-row, .result-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 58px;
}

.amount-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.amount-input::placeholder { color: var(--faint); opacity: 0.7; }

.amount-symbol {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease, transform 0.3s ease;
}
.block:focus-within .amount-symbol { color: var(--c1); transform: scale(1.08); }

.result-num {
  flex: 1;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Скелетон при загрузке */
.skeleton {
  color: transparent;
  background: linear-gradient(100deg, rgba(255,255,255,0.05) 40%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.05) 60%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  border-radius: 8px;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.block-hint {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--faint);
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}
.block-hint b { color: var(--muted); font-weight: 600; }

/* ---------- Селектор валюты ---------- */
.selector { position: relative; margin-top: 12px; }

.selector-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 8px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.25s ease;
}
.selector-btn:hover { background: rgba(255, 255, 255, 0.05); }

.flag { font-size: 1.55rem; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35)); }

.sel-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sel-code { font-weight: 800; font-size: 0.98rem; letter-spacing: 0.03em; }
.sel-name {
  font-size: 0.76rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  width: 18px; height: 18px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1), color 0.3s ease;
}
.selector.open .chevron { transform: rotate(180deg); color: var(--c1); }

/* ---------- Дропдаун ---------- */
.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 100%;
  min-width: 280px;
  z-index: 60;
  background: var(--card-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top center;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.25s;
}
.dropdown.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity 0.22s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dropdown-search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.dropdown-search svg { width: 16px; height: 16px; color: var(--faint); flex-shrink: 0; }
.dropdown-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.dropdown-search input::placeholder { color: var(--faint); }

.dropdown-list {
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.dropdown-list::-webkit-scrollbar { width: 8px; }
.dropdown-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 8px; }
.dropdown-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  text-align: left;
  transition: background 0.18s ease, transform 0.15s ease;
}
.dropdown-item:hover, .dropdown-item.active { background: rgba(129, 140, 248, 0.14); }
.dropdown-item.active { box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35); }
.dropdown-item .flag { font-size: 1.3rem; }
.dd-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dd-code { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.03em; }
.dd-name { font-size: 0.74rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-rate {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dd-check {
  color: var(--c1);
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dd-check.show { opacity: 1; transform: scale(1); }

.dropdown-empty { padding: 18px; text-align: center; color: var(--faint); font-size: 0.85rem; }

/* ---------- Кнопка обмена ---------- */
.swap-wrap { display: grid; place-items: center; }

.swap-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(var(--card-solid), var(--card-solid)) padding-box,
              var(--grad) border-box;
  border: 1.5px solid transparent;
  color: var(--text);
  box-shadow: 0 8px 24px -8px rgba(129, 140, 248, 0.5);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.swap-btn svg { width: 22px; height: 22px; }
.swap-btn:hover { transform: scale(1.1); box-shadow: 0 10px 30px -6px rgba(34, 211, 238, 0.55); }
.swap-btn:active { transform: scale(0.94); }
.swap-btn.spin { animation: spin 0.55s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes spin { from { transform: rotate(0deg) scale(0.85); } to { transform: rotate(360deg) scale(1); } }

/* ---------- Строка курса ---------- */
.rate-line-wrap { display: flex; justify-content: center; margin-top: 22px; }

.rate-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: all 0.3s ease;
}
.rate-line svg { width: 15px; height: 15px; opacity: 0.7; }
.rate-line:hover {
  color: var(--text);
  border-color: rgba(129, 140, 248, 0.5);
  background: rgba(129, 140, 248, 0.1);
  transform: translateY(-1px);
}
.rate-line:active { transform: scale(0.97); }

/* ---------- Популярные курсы ---------- */
.rates-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 30px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.rates-head-base { color: var(--muted); text-transform: none; letter-spacing: 0.02em; font-weight: 600; }

.rates-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.rate-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  transition: transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1), border-color 0.3s ease, background 0.3s ease;
}
.rate-card:hover {
  transform: translateY(-4px);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.06);
}
.rate-card:active { transform: translateY(-1px) scale(0.98); }

.rc-top { display: flex; align-items: center; gap: 8px; }
.rc-top .flag { font-size: 1.15rem; }
.rc-code { font-weight: 800; font-size: 0.82rem; letter-spacing: 0.05em; }
.rc-value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rc-base { font-size: 0.7rem; color: var(--faint); font-weight: 600; }

/* ---------- Криптовалюты ---------- */
.crypto-badge {
  width: 1.55rem;
  height: 1.55rem;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--cc);
  color: #0b0b16;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  font-family: var(--font-body);
  box-shadow: 0 0 14px -4px var(--cc), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.dropdown-item .crypto-badge { width: 1.3rem; height: 1.3rem; font-size: 0.78rem; }
.rate-card .crypto-badge { width: 1.15rem; height: 1.15rem; font-size: 0.68rem; }

.dropdown-group {
  padding: 11px 12px 5px;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  user-select: none;
}

/* Быстрые кнопки-чипы криптовалют над списком */
.dropdown-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 4px;
  border-bottom: 1px solid var(--border);
}
.dropdown-chips.hidden { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.chip:hover {
  border-color: rgba(34, 211, 238, 0.55);
  color: var(--text);
  background: rgba(34, 211, 238, 0.08);
  transform: translateY(-1px);
}
.chip:active { transform: scale(0.96); }
.chip .crypto-badge { width: 1.2rem; height: 1.2rem; font-size: 0.7rem; }

.rates-head-crypto { margin-top: 26px; }

/* ---------- Статус обновления ---------- */
.update-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--faint);
}

/* ---------- Ошибка ---------- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
  font-size: 0.88rem;
  flex-wrap: wrap;
  animation: fadeUp 0.5s ease forwards;
}
.error-banner svg { width: 20px; height: 20px; flex-shrink: 0; }
.error-banner span { flex: 1; min-width: 200px; }
.error-banner button {
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fecdd3;
  font-size: 0.85rem;
  font-weight: 700;
  transition: background 0.25s ease, transform 0.2s ease;
}
.error-banner button:hover { background: rgba(244, 63, 94, 0.32); }
.error-banner button:active { transform: scale(0.96); }

/* Важно: display автора перекрывает атрибут hidden */
.error-banner[hidden] { display: none; }
.rates-head[hidden] { display: none; }

/* Скрытый регион для скринридеров */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Футер ---------- */
.site-footer {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 28px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  color: var(--faint);
  font-size: 0.78rem;
}

/* ---------- Адаптивность ---------- */
@media (max-width: 760px) {
  .converter-grid { grid-template-columns: 1fr; }
  .swap-wrap { padding: 4px 0; }
  .swap-btn { width: 46px; height: 46px; }
  .swap-btn svg { transform: rotate(90deg); }
  .converter-card { padding: 20px 16px 18px; }
  .main { padding: 36px 16px 16px; }
  .header-status-text { display: none; }
  .header-right { gap: 10px; }
  .dropdown { min-width: 240px; }
}

/* ---------- Доступность ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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