/* =============================================================
   Spreadnix — Components
   ============================================================= */

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: .01em;
  font-size: var(--fs-sm);
  line-height: 1;
  padding: 13px 22px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              background var(--t-med), color var(--t-med), border-color var(--t-med);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn--primary {
  background: var(--grad-primary);
  color: var(--on-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), var(--sh-glow);
}
.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), var(--sh-glow), 0 18px 50px rgba(233,188,85,.30);
  color: var(--on-primary);
}

.btn--ghost {
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  color: var(--text);
  border-color: var(--glass-border);
  box-shadow: var(--sh-xs);
}
.btn--ghost:hover { border-color: var(--c-primary-400); color: var(--c-primary-400); transform: translateY(-2px); box-shadow: var(--glow-ring); }

.btn--accent { background: var(--c-accent-600); color:#04221a; }
.btn--accent:hover { background: var(--c-accent-500); transform: translateY(-2px); }

.btn--block { width: 100%; }
.btn--lg { padding: 16px 30px; font-size: var(--fs-base); }
.btn--sm { padding: 9px 16px; font-size: var(--fs-xs); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ---- Cards ------------------------------------------------ */
.card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--sh-sm);
  transition: transform var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              border-color var(--t-med);
}
/* Subtle top-edge highlight for the glass material. */
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%);
  opacity: .8;
}
[data-theme="light"] .card::before { background: linear-gradient(180deg, rgba(255,255,255,.5), transparent 45%); }
.card > * { position: relative; z-index: 1; }
.card--hover:hover {
  transform: translateY(-6px);
  box-shadow: var(--sh-lg), var(--glow-ring);
  border-color: color-mix(in srgb, var(--c-primary-400) 50%, var(--glass-border));
}
.card__icon {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--c-primary-100);
  color: var(--c-primary-600);
  margin-bottom: var(--sp-4);
}
.card__icon svg { width: 26px; height: 26px; }
.card h3 { margin-bottom: var(--sp-2); }
.card p { font-size: var(--fs-sm); }

/* ---- Pills / badges --------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--c-accent-100); color: var(--c-accent-700);
}
.badge--dot::before {
  content:""; width:7px; height:7px; border-radius:50%;
  background: currentColor; animation: pulseRing 2s infinite;
}

/* ===========================================================
   Header / Navigation
   =========================================================== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-med), box-shadow var(--t-med), background var(--t-med);
}
.site-header.is-scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom-color: var(--surface-line);
  box-shadow: var(--sh-sm);
}
.site-header .container {
  display: flex; align-items: center; gap: var(--sp-5);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 500;
  font-size: 1.02rem; color: var(--text);
  letter-spacing: .015em;
}
.brand:hover { color: var(--text); }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--grad-primary);
  color: var(--on-primary);
  display: grid; place-items: center;
  box-shadow: var(--sh-glow);
}
.brand__mark svg { width: 20px; height: 20px; }

.nav { display: flex; align-items: center; gap: 4px; margin-left: var(--sp-4); }
.nav__link {
  position: relative;
  font-family: var(--font-head); font-weight: 500; font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: 9px 14px; border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.nav__link:hover { color: var(--text); background: var(--c-ink-100); }
.nav__link.is-active { color: var(--c-primary-700); }
.nav__link.is-active::after {
  content:""; position: absolute; left: 14px; right: 14px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--grad-primary);
}

.nav-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }

/* ---- Dropdown --------------------------------------------- */
.dropdown { position: relative; }
.dropdown__toggle svg.chev { transition: transform var(--t-fast); width: 14px; height: 14px; }
.dropdown.is-open .dropdown__toggle svg.chev { transform: rotate(180deg); }
.dropdown__menu {
  position: absolute; top: calc(100% + 10px); left: 0;
  min-width: 250px;
  background: color-mix(in srgb, var(--bg-elev) 86%, transparent);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: var(--sp-2);
  opacity: 0; visibility: hidden;
  transform: translateY(8px) scale(.98);
  transform-origin: top left;
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
}
.dropdown.is-open .dropdown__menu {
  opacity: 1; visibility: visible; transform: none;
}
.dropdown__item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text); transition: background var(--t-fast);
}
.dropdown__item:hover { background: var(--c-ink-100); color: var(--text); }
.dropdown__item .ico {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 9px;
  background: var(--c-primary-100); color: var(--c-primary-600);
  display: grid; place-items: center;
}
.dropdown__item .ico svg { width: 18px; height: 18px; }
.dropdown__item strong { font-size: var(--fs-sm); font-family: var(--font-head); display: block; }
.dropdown__item span { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---- Theme toggle / icon button --------------------------- */
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { color: var(--c-primary-600); border-color: var(--c-primary-400); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .moon { display: none; }
[data-theme="dark"] .icon-btn .sun { display: none; }
[data-theme="dark"] .icon-btn .moon { display: block; }

/* ---- Language switcher ------------------------------------ */
.lang-switch { position: relative; }
.lang-switch__toggle { color: var(--text); }
.lang-switch__flag { font-size: 1.25rem; line-height: 1; }
.profile-btn { display: inline-flex; align-items: center; gap: 7px; }
.lang-switch__menu { padding: var(--sp-2); max-height: min(420px, 72vh); overflow-y: auto; }
.lang-switch__opt { width: 100%; text-align: left; cursor: pointer; align-items: center; }
.lang-switch__opt .lang-switch__flag { font-size: 1.4rem; flex: 0 0 auto; width: 30px; text-align: center; }
.lang-switch__opt.is-active { background: var(--c-primary-100); }
.lang-switch__opt.is-active strong { color: var(--c-primary-700); }

/* ---- Mobile nav ------------------------------------------- */
.hamburger { display: none; }
.mobile-nav { display: none; }

@media (max-width: 940px) {
  .nav { display: none; }
  .nav-actions .btn--ghost { display: none; }
  .hamburger {
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: var(--r-sm);
    border: 1px solid var(--surface-line); color: var(--text);
  }
  .hamburger svg { width: 22px; height: 22px; }
  .mobile-nav {
    display: block;
    /* Explicit top+height (not top/bottom inset): the header's backdrop-filter
       makes it the containing block for this fixed child, so a bottom:0 inset
       would collapse the drawer to the header's height. */
    position: fixed; left: 0; right: 0; top: var(--header-h);
    height: calc(100dvh - var(--header-h)); z-index: 90;
    background: var(--bg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
    padding: var(--sp-5);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .mobile-nav.is-open { transform: none; visibility: visible; transition: transform var(--t-med) var(--ease-out); }
  .mobile-nav a {
    display: block; padding: 16px 12px; font-family: var(--font-head);
    font-weight: 600; font-size: var(--fs-md); color: var(--text);
    border-bottom: 1px solid var(--surface-line);
  }
  .mobile-nav a.is-active { color: var(--c-primary-600); }
  .mobile-nav .btn { margin-top: var(--sp-5); }
}

/* ===========================================================
   Forms
   =========================================================== */
.field { margin-bottom: var(--sp-5); }
.field label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  font-family: var(--font-head); margin-bottom: 8px; color: var(--text);
}
.hint { font-size: var(--fs-xs); color: var(--text-subtle); margin-top: 6px; line-height: 1.5; }

.input, .select {
  width: 100%;
  padding: 13px 16px;
  font-size: var(--fs-base);
  background: var(--bg-elev);
  border: 1.5px solid var(--surface-line);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 4px var(--c-primary-100);
}
.input-wrap { position: relative; }
.input-wrap .toggle-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-subtle); padding: 4px;
}
.input-wrap .toggle-eye:hover { color: var(--c-primary-600); }
.input-wrap .toggle-eye svg { width: 20px; height: 20px; }

.field.is-invalid .input { border-color: var(--c-down); animation: shake .4s; }
.field.is-invalid .input:focus { box-shadow: 0 0 0 4px var(--c-down-soft); }
.field.is-valid .input { border-color: var(--c-accent-600); }

.error-msg {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); color: var(--c-down);
  margin-top: 7px; min-height: 1em;
  opacity: 0; transform: translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.field.is-invalid .error-msg { opacity: 1; transform: none; }
.error-msg svg { width: 14px; height: 14px; flex: none; }

/* Checkbox */
.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer;
}
.check input { position: absolute; opacity: 0; }
.check .box {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--surface-line); background: var(--bg-elev);
  display: grid; place-items: center; transition: all var(--t-fast);
}
.check .box svg { width: 14px; height: 14px; color: var(--on-primary); opacity: 0; transform: scale(.5); transition: all var(--t-fast); }
.check input:checked + .box { background: var(--c-primary-600); border-color: var(--c-primary-600); }
.check input:checked + .box svg { opacity: 1; transform: none; }
.check input:focus-visible + .box { box-shadow: 0 0 0 4px var(--c-primary-100); }
.field.is-invalid .check .box { border-color: var(--c-down); }

/* Password strength meter */
.pw-meter { display: flex; gap: 5px; margin-top: 9px; }
.pw-meter span { height: 5px; flex: 1; border-radius: 3px; background: var(--c-ink-200); transition: background var(--t-med); }
.pw-meter[data-score="1"] span:nth-child(-n+1),
.pw-meter[data-score="2"] span:nth-child(-n+2),
.pw-meter[data-score="3"] span:nth-child(-n+3),
.pw-meter[data-score="4"] span:nth-child(-n+4) { background: var(--meter-color, var(--c-accent-600)); }

/* ===========================================================
   Modal
   =========================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8,6,3,.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: var(--sp-5);
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-med), visibility var(--t-med);
}
.modal-backdrop.is-open { opacity: 1; visibility: visible; }
.modal {
  width: 100%; max-width: 440px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: var(--sp-7);
  transform: scale(.9) translateY(20px);
  transition: transform var(--t-med) var(--ease-spring);
  text-align: center;
}
.modal-backdrop.is-open .modal { transform: none; }
.modal__icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto var(--sp-4);
  background: var(--c-accent-100); color: var(--c-accent-700);
}
.modal__icon svg { width: 32px; height: 32px; }
.modal__close {
  position: absolute; top: 18px; right: 18px;
  color: var(--text-subtle); padding: 6px;
}

/* ===========================================================
   Toast
   =========================================================== */
.toast-wrap {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 300;
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 380px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--bg-elev); border: 1px solid var(--surface-line);
  box-shadow: var(--sh-lg);
  animation: popIn .3s var(--ease-spring);
  font-size: var(--fs-sm);
}
.toast.is-leaving { animation: fadeIn .3s reverse; }
.toast .ic { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; }
.toast--success .ic { background: var(--c-up-soft); color: var(--c-up); }
.toast--error .ic { background: var(--c-down-soft); color: var(--c-down); }
.toast--info .ic { background: var(--c-primary-100); color: var(--c-primary-600); }
.toast .ic svg { width: 18px; height: 18px; }

/* ===========================================================
   Footer
   =========================================================== */
.site-footer {
  background: var(--c-ink-900);
  color: var(--c-ink-300);
  padding-block: var(--sp-8) var(--sp-6);
  margin-top: var(--sp-8);
}
[data-theme="dark"] .site-footer { background: #080706; }
.site-footer a { color: var(--c-ink-300); }
.site-footer a:hover { color: #fff; }
.footer-grid {
  display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: var(--sp-6);
  padding-bottom: var(--sp-6); border-bottom: 1px solid rgba(255,255,255,.08);
}
.footer-grid h4 { color: #fff; font-size: var(--fs-sm); margin-bottom: var(--sp-4); letter-spacing: .04em; text-transform: uppercase; }
.footer-grid li { margin-bottom: 10px; font-size: var(--fs-sm); }
.footer-grid .brand { color: #fff; margin-bottom: var(--sp-4); }
.footer-bottom {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  padding-top: var(--sp-5); flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--c-ink-400);
}
.risk-note {
  font-size: var(--fs-xs); color: var(--c-ink-400);
  margin-top: var(--sp-4); line-height: 1.6; max-width: 70ch;
}
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---- Trading-pair logos (flags / coin / company marks) ----- */
/* Rendered by pairLogo() — used in the pair picker, signal card,
   live markets and the hero market widget. */
.pair-ico {
  position: relative; width: 26px; height: 26px; flex: none;
  border-radius: 50%; background: var(--c-primary-100); color: var(--c-primary-600);
  display: inline-grid; place-items: center; vertical-align: middle;
}
.pair-ico > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover; background: var(--bg-elev);
}
.pair-ico--fx { background: none; }
.pair-ico--fx .f1, .pair-ico--fx .f2 {
  position: absolute; inset: auto; width: 18px; height: 18px;
  border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 2px var(--bg-elev);
}
.pair-ico--fx .f1 { left: 0; top: 0; z-index: 1; }
.pair-ico--fx .f2 { right: 0; bottom: 0; }
.pair-ico--lg { width: 34px; height: 34px; }
.pair-ico--lg.pair-ico--fx .f1, .pair-ico--lg.pair-ico--fx .f2 { width: 23px; height: 23px; }
