/* ============================================================
   БАЗА · общие стили для всех страниц
   Подключать ПОСЛЕ tokens.css
   ============================================================ */

/* ---------- Префлайт ---------- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img {
  max-width: 100%;
  display: block;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
a {
  color: inherit;
  text-decoration: none;
}
::selection {
  background: var(--rose-soft);
  color: var(--rose-deep);
}

/* Скроллбар */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(30, 26, 22, 0.12);
  border-radius: 10px;
  border: 3px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(30, 26, 22, 0.22);
}

/* ---------- Тело ---------- */
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 90% 60% at 15% -10%,
      rgba(232, 212, 216, 0.55),
      transparent 55%
    ),
    radial-gradient(
      ellipse 60% 50% at 95% 15%,
      rgba(207, 184, 163, 0.28),
      transparent 55%
    ),
    radial-gradient(
      ellipse 70% 55% at 5% 105%,
      rgba(181, 135, 148, 0.16),
      transparent 60%
    ),
    var(--paper);
}

/* Зерно поверх всего */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0.10 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- Основной контейнер ---------- */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 140px 32px 80px;
}
main.wide {
  max-width: 1240px;
}

/* ---------- ТОПБАР ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: rgba(243, 237, 228, 0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  padding-bottom: 2px;
  transition: transform 0.4s var(--ease-spring);
}
.brand:hover .brand-mark {
  transform: rotate(-12deg) scale(1.05);
}
.brand-label {
  color: var(--ink-2);
  font-weight: 500;
}
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  transition: color 0.2s;
  user-select: none;
}
.topbar-meta:hover {
  color: var(--ink);
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.meta-item .icon {
  font-size: 13px;
  filter: saturate(0.7);
}
.meta-sep {
  color: var(--ink-4);
}

/* ---------- HERO ---------- */
.hero {
  padding: 20px 0 40px;
  text-align: center;
}
.hero.center {
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rose-deep);
  margin-bottom: 28px;
}
.eyebrow::before,
.eyebrow::after {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--rose-deep);
}
.eyebrow.left::before {
  display: none;
}

h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(38px, 5.4vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 22px;
  max-width: 18ch;
  margin-left: auto;
  margin-right: auto;
}
h1 em {
  font-style: italic;
  color: var(--rose-deep);
}
.hero-sub {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 auto;
  max-width: 50ch;
}

/* ---------- КНОПКИ ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 30px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    transform 0.35s var(--ease),
    background 0.3s,
    box-shadow 0.35s var(--ease);
}
.btn-primary:hover {
  background: #000;
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(30, 26, 22, 0.24);
}
.btn-primary .arrow {
  display: inline-block;
  transition: transform 0.4s var(--ease);
}
.btn-primary:hover .arrow {
  transform: translateX(4px);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid var(--line-2);
  transition: all 0.35s var(--ease);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-3);
  transform: translateY(-2px);
}
.btn-ghost .icon {
  font-size: 14px;
  filter: saturate(0.75);
}

/* Кнопки нижней навигации (back-link / nav-link-secondary) */
.nav-wrap {
  margin-top: 96px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 18px 32px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: 14.5px;
  font-weight: 500;
  transition: all 0.35s var(--ease);
}
.back-link:hover {
  background: #000;
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(30, 26, 22, 0.24);
}
.back-link .arrow {
  display: inline-block;
  transition: transform 0.4s var(--ease);
  font-size: 15px;
}
.back-link:hover .arrow {
  transform: translateX(-5px);
}
.nav-link-secondary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 18px 28px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  font-size: 14.5px;
  font-weight: 500;
  transition: all 0.35s var(--ease);
}
.nav-link-secondary:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-3);
  transform: translateY(-2px);
}
.nav-link-secondary .icon {
  font-size: 14px;
  filter: saturate(0.75);
}

/* Круглая иконка-кнопка */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(253, 250, 246, 0.94);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: all 0.3s var(--ease);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.icon-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  transform: scale(1.06);
}
.icon-btn.danger:hover {
  background: var(--decline-dark);
  border-color: var(--decline-dark);
  color: #fff;
}

/* ---------- ФУТЕР ---------- */
.footer {
  padding: 40px 32px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  max-width: 1240px;
  margin: 40px auto 0;
}

/* ---------- TOAST ---------- */
#toast,
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  padding: 14px 22px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  box-shadow: 0 18px 40px rgba(30, 26, 22, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s var(--ease-spring);
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
#toast.show,
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- МОДАЛКА (базовая) ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 16px;
  justify-content: center;
  align-items: center;
  background: rgba(30, 26, 22, 0.44);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: overlayIn 0.35s var(--ease);
  overflow-y: auto;
}
.modal-overlay.active {
  display: flex;
}
@keyframes overlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 40px 34px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 50px 100px rgba(30, 26, 22, 0.3);
  animation: modalIn 0.5s var(--ease-spring);
}
@keyframes modalIn {
  from {
    transform: translateY(20px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 14px;
  transition: all 0.35s var(--ease);
  z-index: 10;
}
.modal-close:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  transform: rotate(90deg);
}

/* ---------- АДАПТИВ ---------- */
@media (max-width: 640px) {
  main {
    padding: 120px 20px 60px;
  }
  h1 {
    font-size: clamp(32px, 9vw, 46px);
  }
  .topbar {
    padding: 16px 20px;
    font-size: 11.5px;
  }
  .brand-label {
    display: none;
  }
  .brand-mark {
    width: 26px;
    height: 26px;
    font-size: 15px;
  }
  .meta-sep {
    display: none;
  }
  .topbar-meta {
    gap: 10px;
    font-size: 11.5px;
  }
  .nav-wrap {
    margin-top: 72px;
    padding-top: 32px;
    gap: 10px;
  }
  .back-link,
  .nav-link-secondary,
  .btn-primary,
  .btn-ghost {
    padding: 15px 24px;
    font-size: 13.5px;
  }
  .footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 10.5px;
    padding: 32px 20px;
  }
  .modal {
    padding: 32px 22px 26px;
    border-radius: 18px;
  }
}

/* Уважаем предпочтения по анимации */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
