/* ==========================================================================
   NOMADO — Секция «История, которую мы создаём вместе» (таймлайн)
   Белый фон + левый рельс с оранжевыми узлами. Карточки этапов разного цвета
   (белые / тёмные / оранжевые), кульминационная оранжевая карточка (этап 7).
   ========================================================================== */

.history {
  --ink: #14100e;
  --muted: #746a64;
  position: relative;
  padding-block: var(--nm-section-gap);
  background: #fff;
  color: var(--ink);
  overflow: hidden;
}
/* фоновая фактура: мелкая точечная сетка + тёплые свечения */
.history::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(rgba(20, 16, 14, .05) 1px, transparent 1.4px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(120% 78% at 50% 42%, #000 42%, transparent 100%);
          mask-image: radial-gradient(120% 78% at 50% 42%, #000 42%, transparent 100%);
}
.history__inner { position: relative; z-index: 1; width: 100%; max-width: var(--nm-content); margin-inline: auto;
  padding-inline: var(--nm-gutter); }

/* ------------------------------------------------------------- шапка */
.history__head {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(24px, 4vw, 70px);
  align-items: start; margin-bottom: clamp(34px, 4.5vw, 60px);
}
.history__title {
  margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: -.02em;
  line-height: .98; font-size: clamp(2rem, 4.6vw, 3.8rem);
}
.history__title em { font-style: normal; color: var(--nm-orange); }
.history__lead p { margin: 0 0 .85em; color: var(--muted); line-height: 1.66;
  font-size: clamp(.95rem, 1.08vw, 1.05rem); }
.history__lead p:last-child { margin-bottom: 0; }
.history__lead p.is-accent { color: var(--ink); font-weight: 600; }

/* ============================== ТАЙМЛАЙН ============================== */
.timeline { position: relative; margin: 0 auto; padding: 0; list-style: none; max-width: 1300px; counter-reset: tlghost; }

.tl {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: clamp(34px, 3.4vw, 64px);
  padding-bottom: clamp(16px, 2vw, 30px);
  counter-increment: tlghost;
}
.tl:last-child { padding-bottom: 0; }

/* гигантская «призрачная» цифра этапа на пустой (внешней) стороне ряда */
.tl::before {
  content: counter(tlghost, decimal-leading-zero);
  position: absolute; top: 50%; z-index: 0; transform: translateY(-50%);
  font-weight: 800; letter-spacing: -.05em; line-height: .74;
  font-variant-numeric: tabular-nums; font-size: clamp(5rem, 12.5vw, 11.5rem);
  color: rgba(20, 16, 14, .045); pointer-events: none; user-select: none;
  transition: color .4s ease;
}
.tl--left::before  { right: clamp(6px, 3vw, 48px); left: auto; text-align: right; }
.tl--right::before { left: clamp(6px, 3vw, 48px); right: auto; text-align: left; }
.tl.is-lit::before { color: rgba(242, 53, 0, .07); }
.tl--final::before { display: none; }

/* центральный рельс: серая база + оранжевая заливка по скроллу (позиции задаёт JS) */
.timeline__rail, .timeline__fill {
  position: absolute; left: 50%; width: 2px; transform: translateX(-50%);
  z-index: 0; border-radius: 2px; pointer-events: none;
}
.timeline__rail { background: rgba(20, 16, 14, .13); }
.timeline__fill {
  height: 0;
  background: linear-gradient(180deg, #f23500, #ff6a1a);
  box-shadow: 0 0 12px rgba(242, 53, 0, .55);
}

/* узел-ромб на рельсе */
.tl__node {
  position: absolute; left: 50%; top: 8px; width: 16px; height: 16px; z-index: 2;
  transform: translate(-50%, 0) rotate(45deg);
  background: #fff; border: 2px solid rgba(20, 16, 14, .22); border-radius: 3px;
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.tl.is-lit .tl__node {
  background: var(--nm-orange); border-color: var(--nm-orange); box-shadow: 0 0 0 6px rgba(242, 53, 0, .16);
}
/* зигзаг */
.tl--left  .tl__card { grid-column: 1; }
.tl--right .tl__card { grid-column: 2; }
.tl--right .tl__chev { right: auto; left: -8px; transform: scaleX(-1); }
.tl--right .tl__card:hover .tl__chev { transform: scaleX(-1) translate(-6px, -4px); }

/* карточка */
.tl__card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; column-gap: clamp(12px, 1.3vw, 20px); align-items: center;
  border: 1px solid rgba(20, 16, 14, .1); border-radius: var(--nm-radius-lg); background: #fff;
  padding: clamp(18px, 1.9vw, 30px) clamp(20px, 2.2vw, 36px);
  transition: transform .4s cubic-bezier(.19,.9,.22,1), border-color .3s ease, box-shadow .3s ease;
}
.tl__card:hover { transform: translateY(-4px); border-color: rgba(242, 53, 0, .4);
  box-shadow: 0 26px 50px -30px rgba(20, 16, 14, .4); }
.tl__chev { display: none; }

/* номер + вертикальный разделитель */
.tl__idx {
  grid-column: 1; grid-row: 1; align-self: center;
  font-weight: 800; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums;
  font-size: clamp(1.5rem, 2vw, 1.95rem); color: var(--nm-orange);
  padding-right: clamp(12px, 1.2vw, 18px); border-right: 2px solid rgba(20, 16, 14, .14);
  transition: color .3s ease, border-color .3s ease;
}
/* кикер */
.tl__kicker {
  grid-column: 2; grid-row: 1; align-self: center; justify-self: start;
  font-size: .74rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--nm-orange);
}
/* заголовок с разделителем-шапкой */
.tl__title {
  grid-column: 1 / -1; grid-row: 2; margin: 0; font-weight: 800; letter-spacing: -.01em;
  line-height: 1.12; font-size: clamp(1.4rem, 2.3vw, 2.15rem); color: var(--ink);
  border-top: 1px solid rgba(20, 16, 14, .1);
  margin-top: clamp(14px, 1.5vw, 20px); padding-top: clamp(14px, 1.5vw, 20px);
}
.tl__text {
  grid-column: 1 / -1; grid-row: 3; margin: .55em 0 0; max-width: 62ch;
  color: var(--muted); line-height: 1.66; font-size: clamp(.94rem, 1.05vw, 1.04rem);
}
.tl__text b { color: var(--ink); font-weight: 700; }

/* ---- ЦВЕТОВЫЕ ВАРИАНТЫ ---- */
/* тёмная */
.tl--dark .tl__card { border-color: transparent; color: #fff;
  background: radial-gradient(130% 130% at 85% 12%, #2a1a12 0%, #17110d 55%, #0c0805 100%); }
.tl--dark .tl__card:hover { box-shadow: 0 28px 56px -28px rgba(0,0,0,.6); }
.tl--dark .tl__title { color: #fff; }
.tl--dark .tl__text { color: rgba(255,255,255,.7); }
.tl--dark .tl__text b { color: #fff; }
.tl--dark .tl__idx { color: var(--nm-orange); border-right-color: rgba(255,255,255,.16); }
.tl--dark .tl__kicker { color: var(--nm-orange); }
.tl--dark .tl__title { border-top-color: rgba(255,255,255,.14); }

/* оранжевая */
.tl--orange .tl__card { border-color: transparent; color: #fff;
  background: radial-gradient(130% 130% at 82% 12%, #ff6a1a 0%, #f23500 48%, #c8340c 100%); }
.tl--orange .tl__card:hover { box-shadow: 0 30px 58px -28px rgba(242,53,0,.55); }
.tl--orange .tl__kicker { color: #fff; }
.tl--orange .tl__idx { color: #fff; border-right-color: rgba(255,255,255,.32); }
.tl--orange .tl__title { color: #fff; border-top-color: rgba(255,255,255,.22); }
.tl--orange .tl__text { color: rgba(255,255,255,.92); }
.tl--orange .tl__text b { color: #fff; }

/* ---- ЭТАП 7: кульминация на всю ширину по центру ---- */
.tl--final { grid-template-columns: 1fr; justify-items: center; }
.tl--final .tl__card { display: block; grid-column: 1; max-width: 860px; width: 100%; text-align: center; }
.tl--final .tl__node { display: none; }
/* шапка «07 | НОВАЯ ГЛАВА» — та же сетка, что и в обычных карточках */
.tl--final .tl__head {
  display: inline-grid; grid-template-columns: auto auto; align-items: center;
  column-gap: clamp(12px, 1.3vw, 20px); vertical-align: middle;
}
.tl--final .tl__title { display: block; border-top: 0; padding-top: 0;
  margin: clamp(14px, 1.5vw, 20px) auto 0; font-size: clamp(1.6rem, 2.8vw, 2.5rem); }
.tl--final .tl__text { margin: .6em auto 0; }

/* ------------------------------------------------------------- финал-подпись */
.history__outro {
  margin: clamp(34px, 4.5vw, 66px) 0 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(16px, 2vw, 34px);
}
.history__outro p { margin: 0; padding-top: clamp(14px, 1.4vw, 20px);
  border-top: 2px solid var(--nm-orange);
  font-size: clamp(.98rem, 1.2vw, 1.16rem); line-height: 1.4; font-weight: 600; color: var(--ink); }
.history__outro b { color: var(--nm-orange); }

/* ------------------------------------------------------------- появление */
.js .history [data-io] { opacity: 0; transform: translateY(26px); }
.js .history [data-io].io-in { opacity: 1; transform: none;
  transition: opacity .7s ease, transform .8s cubic-bezier(.19,.9,.22,1); }

/* таймлайн: .tl виден (узел на рельсе); карточка просто появляется */
.js .tl[data-io], .js .tl[data-io].io-in { opacity: 1; transform: none; }
.js .tl__card { opacity: 0; transform: translateY(22px);
  transition: opacity .6s ease, transform .7s cubic-bezier(.19,.9,.22,1),
              border-color .35s ease, box-shadow .35s ease; }
.js .tl.io-in .tl__card { opacity: 1; transform: none; }

/* подкраска карточки, когда линия дошла до её узла */
.tl.is-lit .tl__card { border-color: rgba(242, 53, 0, .5);
  box-shadow: 0 0 0 1px rgba(242, 53, 0, .12), 0 20px 44px -30px rgba(242, 53, 0, .4); }
.tl--white.is-lit .tl__idx { border-right-color: var(--nm-orange); }
.tl--dark.is-lit  .tl__idx { border-right-color: rgba(255, 255, 255, .28); }
.tl--orange.is-lit .tl__idx { border-right-color: rgba(255, 255, 255, .55); }
.tl--white.is-lit .tl__card { background: #fff7f3; }

/* ------------------------------------------------------------- адаптив */
@media (max-width: 860px) {
  .history__head { grid-template-columns: 1fr; gap: 18px; }
  .tl { grid-template-columns: 1fr; }
  /* рельс и ромбы — чуть правее, чтобы левый угол не срезался краем секции */
  .tl__node { left: 14px; top: 50%; transform: translate(-50%, -50%) rotate(45deg); }
  /* без розовой подсветки-halo вокруг ромба */
  .tl.is-lit .tl__node { box-shadow: none; }
  .timeline__rail, .timeline__fill { left: 14px; }
  .tl::before { display: none; }
  .tl__card { grid-column: 1 !important; margin-left: clamp(34px, 8vw, 48px); }
  .tl--left .tl__node::after, .tl--right .tl__node::after { left: 50%; right: auto; }
  .tl--right .tl__chev { left: auto; right: -8px; transform: none; }
  /* последняя карточка — как остальные: ромб на линии слева, содержимое по левому краю */
  .tl--final { justify-items: stretch; }
  .tl--final .tl__node { display: block; }
  /* width:auto (в базе 100%) — иначе карточка + margin-left вылезает за край */
  .tl--final .tl__card { max-width: none; width: auto; text-align: left; }
  .tl--final .tl__title {
    text-align: left; border-top: 1px solid rgba(255, 255, 255, .22);
    margin-top: clamp(14px, 1.5vw, 20px); padding-top: clamp(14px, 1.5vw, 20px);
  }
  .tl--final .tl__text { text-align: left; }
  .history__outro { grid-template-columns: 1fr; gap: 14px; }
}
/* на тач-устройствах вся полоса-рельс сразу оранжевая (scroll-заливка не нужна визуально) */
@media (hover: none) {
  .timeline__rail { background: linear-gradient(180deg, #f23500, #ff6a1a); }
}
@media (prefers-reduced-motion: reduce) {
  .js .history [data-io] { opacity: 1; transform: none; }
}
