/* ------------------------------------------------------------------
   PANTEON — «Вісь часу» (/timeline/)
   Поверх site.css: токены, шапка, подвал, .record, .chip, .note —
   оттуда. Здесь только сама шкала.

   Геометрия шкалы задаётся двумя числами: --row (высота ряда правителя)
   и --cw (ширина полотна, её ставит JS по уровню приближения). Полития
   занимает прямоугольник (годы × ряды), уложенный «по горизонту» ещё
   на сборке данных: uy — верхний ряд, uh — высота в рядах.
   ------------------------------------------------------------------ */

.tl-page {
  --row: 23px;
  --head: 18px;
  --cw: 20000px;
  --axis: 78px;
  --mini: 56px;
}

/* ---------- заголовок страницы ---------- */

.pagehead { padding-block: clamp(104px, 13vw, 168px) clamp(26px, 3.4vw, 44px); }
.pagehead h1 { font-size: clamp(2.5rem, 6.4vw, 5.2rem); max-width: 18ch; text-wrap: balance; }
.pagehead .lead { max-width: 56ch; margin-top: 1.1rem; }
.crumb {
  display: inline-flex; align-items: center; gap: .7em; margin-bottom: 1.5rem;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .15em; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
}
.crumb i { font-style: normal; color: var(--amber-dim); transition: translate .2s var(--e-ui); }
.crumb:hover { color: var(--stone); }
.crumb:hover i { translate: -3px 0; }

.facts { display: flex; flex-wrap: wrap; gap: .4rem 2.4rem; margin-top: clamp(22px, 3vw, 34px); padding: 0; list-style: none; }
.facts li { display: grid; gap: .25rem; }
.facts b {
  font-family: var(--display); font-weight: 400; color: var(--stone);
  font-size: clamp(1.7rem, 3.2vw, 2.6rem); line-height: .9; letter-spacing: -.02em;
}
.facts span { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- полоса управления ---------- */

.tl { position: relative; padding-bottom: clamp(40px, 5vw, 72px); }
.tl::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 340px;
  background: linear-gradient(180deg, var(--ink-deep), transparent);
  pointer-events: none;
}
.tl__bar {
  display: flex; flex-wrap: wrap; gap: .8rem 1.6rem; align-items: center; justify-content: space-between;
  padding-bottom: 1.1rem;
}
.eras { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px;
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); }
.eras::-webkit-scrollbar { display: none; }
.eras .chip { white-space: nowrap; font-size: .74rem; padding: .42em .9em; }
.eras .chip[aria-current="true"] { color: var(--ink); background: var(--amber-hi); border-color: var(--amber-hi); font-weight: 500; }

.tools { display: flex; align-items: center; gap: .45rem; }
.tools__z {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); min-width: 7.5ch; text-align: center;
}
.icbtn {
  appearance: none; cursor: pointer; width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--stone-dim);
  font-family: var(--mono); font-size: 1rem; line-height: 1; display: grid; place-items: center;
  transition: color .18s var(--e-ui), background-color .18s var(--e-ui), border-color .18s var(--e-ui);
}
.icbtn:hover:not(:disabled) { color: var(--ink); background: var(--amber-hi); border-color: var(--amber-hi); }
.icbtn:disabled { opacity: .3; cursor: default; }

/* ---------- полотно ---------- */

/* сцена: окно шкалы плюс то, что висит над ним и не едет с полотном */
.stage { position: relative; }
.stage::before, .stage::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: clamp(24px, 4vw, 64px);
  z-index: 8; pointer-events: none;
}
.stage::before { left: 0; background: linear-gradient(90deg, var(--ink), transparent); }
.stage::after { right: 0; background: linear-gradient(270deg, var(--ink), transparent); }

.scroller {
  position: relative;
  overflow: auto;
  overscroll-behavior-x: contain;
  /* без этого браузер «якорит» прокрутку на растущем содержимом и полотно
     открывается не на сегодняшнем дне, а на 1975 годе (поймано замером) */
  overflow-anchor: none;
  height: clamp(390px, 56vh, 660px);
  border-block: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 8% 0%, rgba(200, 154, 98, .07), transparent 60%),
    linear-gradient(180deg, var(--ink-2), var(--ink-deep));
  cursor: grab;
  scrollbar-color: var(--amber-dim) transparent;
  scrollbar-width: thin;
}
.scroller.is-drag { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.scroller::-webkit-scrollbar { height: 10px; width: 10px; }
.scroller::-webkit-scrollbar-track { background: rgba(0, 0, 0, .25); }
.scroller::-webkit-scrollbar-thumb { background: var(--amber-dim); border-radius: 999px; }
.scroller:focus-visible { outline: 2px solid var(--amber-hi); outline-offset: -2px; }

.canvas { position: relative; width: var(--cw); }

/* века призраком на фоне — даёт полотну масштаб */
.ghosts { position: absolute; inset: var(--axis) 0 0 0; pointer-events: none; z-index: 0; }
.ghost {
  position: absolute; top: 34%; left: 0; height: 1em;
  font-family: var(--display); font-size: clamp(76px, 11vh, 150px); line-height: 1;
  color: var(--stone); opacity: .036; translate: -50% 0; pointer-events: none; user-select: none;
  white-space: nowrap;
}

/* ---------- ось ---------- */

.axis {
  position: sticky; top: 0; z-index: 6; height: var(--axis);
  background: linear-gradient(180deg, rgba(6, 12, 22, .94) 62%, rgba(6, 12, 22, .66));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.axis__eras, .axis__ticks { position: absolute; inset: 0; }

.era {
  position: absolute; top: 0; height: 100%;
  border-left: 1px solid var(--line-soft);
}
/* имя эпохи липнет к левой кромке окна, пока эпоха в кадре: иначе на узком
   экране подпись уезжает за край и читатель не знает, где он во времени */
.era b {
  position: sticky; left: 12px; top: 9px; display: inline-block; margin: 9px 0 0 12px;
  white-space: nowrap;
  font-family: var(--display); font-weight: 400; font-size: 1.12rem; letter-spacing: -.01em;
  color: var(--amber); opacity: .92;
}
.era--cut b { display: none; }

.tick { position: absolute; bottom: 0; height: 9px; border-left: 1px solid var(--line); }
.tick--mi { height: 5px; border-color: var(--line-soft); }
.tick span {
  position: absolute; bottom: 11px; left: 0; translate: -50% 0; white-space: nowrap;
  font-family: var(--mono); font-size: .62rem; font-weight: 500; letter-spacing: .06em; color: var(--stone-dim);
}
.tick--mi span { display: none; }

/* лента «скільки держав одночасно» — в самой оси, по тому же масштабу */
.ribbon { position: absolute; left: 0; bottom: 0; height: 22px; width: 100%; overflow: visible; }
.ribbon path { fill: rgba(200, 154, 98, .16); stroke: rgba(233, 197, 145, .5); stroke-width: 1; }
.js .ribbon { transform: scaleY(0); transform-origin: 50% 100%; transition: transform 1.1s var(--e-display) .25s; }
.js .tl.is-live .ribbon { transform: scaleY(1); }

/* ---------- политии и правители ---------- */

.field { position: relative; }

.pol {
  position: absolute;
  border-radius: var(--r);
  background: rgba(230, 225, 214, .028);
  box-shadow: inset 0 1px 0 rgba(230, 225, 214, .07);
  transition: background-color .22s var(--e-ui), box-shadow .22s var(--e-ui);
}
.pol::before {           /* торец «сьогодні»: с этой стороны полития живёт позже */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: linear-gradient(var(--amber-dim), transparent);
  border-radius: 999px; opacity: .8;
}
.pol:hover, .pol.is-on { background: rgba(230, 225, 214, .06); box-shadow: inset 0 1px 0 rgba(230, 225, 214, .14); }
.pol__h {
  position: absolute; inset: 0 0 auto 0; height: var(--head);
  display: flex; align-items: center; gap: .8em; padding-inline: 9px;
  overflow: hidden; white-space: nowrap;
}
.pol__h b {
  font-family: var(--display); font-weight: 400; font-size: .86rem; letter-spacing: .005em;
  color: var(--stone-dim); transition: color .2s var(--e-ui);
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.pol:hover .pol__h b, .pol.is-on .pol__h b { color: var(--stone); }
.pol__h span { flex: 0 0 auto; font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; color: var(--amber-dim); }
.pol--tight .pol__h { padding-inline: 5px; }
.pol--tight .pol__h span { display: none; }
.pol--mute .pol__h b { opacity: .55; }

.rl {
  position: absolute; appearance: none; cursor: pointer; text-align: left;
  height: calc(var(--row) - 6px);
  padding: 0 7px 0 8px; border: 0; border-radius: 999px;
  background: rgba(230, 225, 214, .075);
  color: var(--stone-dim); font-family: var(--sans); font-size: .76rem; font-weight: 400;
  line-height: 1; letter-spacing: -.004em;
  display: flex; align-items: center; gap: .55em; overflow: hidden; white-space: nowrap;
  transition: background-color .16s var(--e-ui), color .16s var(--e-ui), box-shadow .16s var(--e-ui);
}
.rl::before {            /* след зовнішності — тем же цветом, что крапки стены */
  content: ""; flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%;
  border: 1px solid rgba(230, 225, 214, .3); background: transparent;
}
.rl[data-k="photo"]::before    { background: #EDE7DA; border-color: #EDE7DA; }
.rl[data-k="portrait"]::before { background: #DFBB84; border-color: #DFBB84; }
.rl[data-k="icon"]::before     { background: #C89A62; border-color: #C89A62; }
.rl[data-k="coin"]::before     { background: #B4834F; border-color: #B4834F; }
.rl[data-k="desc"]::before     { background: #8E6B44; border-color: #8E6B44; }
.rl[data-k="yes"]::before      { background: rgba(200, 154, 98, .5); border-color: rgba(200, 154, 98, .62); }
.rl i { font-style: normal; font-family: var(--mono); font-size: .58rem; letter-spacing: .04em; color: var(--muted); }
.rl u { text-decoration: none; font-size: .68rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.rl--tight { padding-inline: 4px; justify-content: center; }
.rl--tight em, .rl--tight i, .rl--tight u { display: none; }
.rl--mid i, .rl--mid u { display: none; }
.rl em { font-style: normal; overflow: hidden; text-overflow: ellipsis; }

/* приблизительная дата — отрезок стоит тише; неизвестная граница растушёвана
   с той стороны, с которой её не знают (справа — древняя, слева — поздняя) */
.rl--ap { background: rgba(230, 225, 214, .05); }
.rl--fa { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
.rl--fb { -webkit-mask-image: linear-gradient(to right, transparent, #000 22px); mask-image: linear-gradient(to right, transparent, #000 22px); }
.rl--fa.rl--fb { -webkit-mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 22px), transparent); }

.rl:hover, .rl.is-on, .rl:focus-visible {
  background: var(--amber-hi); color: var(--ink); z-index: 4;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .45);
}
.rl:hover::before, .rl.is-on::before, .rl:focus-visible::before { border-color: rgba(8, 17, 30, .45); }
.rl:hover i, .rl.is-on i, .rl:focus-visible i { color: rgba(8, 17, 30, .62); }
.rl:focus-visible { outline: 2px solid var(--stone); outline-offset: 2px; }
/* правление в несколько каденций: волосок связывает отрезки одного человека */
.rl-link { position: absolute; height: 1px; background: var(--line); pointer-events: none; }

/* появление полотна: волна идёт от «сьогодні» в глубину */
.js .pol { opacity: 0; translate: 0 14px; }
.js .pol.is-in {
  opacity: 1; translate: 0 0;
  transition: opacity .6s var(--e-body) var(--d, 0s), translate .72s var(--e-display) var(--d, 0s),
              background-color .22s var(--e-ui), box-shadow .22s var(--e-ui);
}

/* ---------- бегунок года ---------- */

.play { position: absolute; top: 0; bottom: 0; width: 1px; background: linear-gradient(180deg, var(--amber-hi), rgba(200, 154, 98, .15)); z-index: 7; opacity: 0; transition: opacity .2s var(--e-ui); pointer-events: none; }
.play.is-on { opacity: 1; }
.play b {
  position: absolute; top: 6px; left: 0; translate: -50% 0;
  font-family: var(--mono); font-size: .62rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink); background: var(--amber-hi); padding: .22em .55em; border-radius: 999px; white-space: nowrap;
}

/* подсказка «ниже ещё есть» — на густых годах полотно выше окна */
.more {
  position: absolute; right: 14px; bottom: 12px; z-index: 7;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink); background: var(--stone); padding: .4em .8em; border-radius: 999px;
  opacity: 0; transition: opacity .3s var(--e-ui); pointer-events: none;
}
.more.is-on { opacity: .92; }

/* ---------- мини-карта ---------- */

.mini {
  position: relative; height: var(--mini); margin-top: 14px;
  border: 1px solid var(--line-soft); border-radius: var(--r);
  background: linear-gradient(180deg, rgba(230, 225, 214, .022), transparent);
  cursor: pointer; overflow: hidden;
}
.mini svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mini path { fill: rgba(200, 154, 98, .22); stroke: rgba(233, 197, 145, .45); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mini__eras { position: absolute; inset: 0; pointer-events: none; }
.mini__e { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-soft); }
.mini__e span {
  position: absolute; bottom: 5px; left: 5px; white-space: nowrap;
  font-family: var(--mono); font-size: .54rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.mini__win {
  position: absolute; top: 0; bottom: 0; min-width: 6px;
  border: 1px solid var(--amber-hi); border-radius: 4px;
  background: rgba(233, 197, 145, .12);
  pointer-events: none;
}
.mini__e span {
  max-width: calc(100% - 10px); overflow: hidden; text-overflow: ellipsis;
}

/* ---------- полоса «у цьому році» ---------- */

.readout { margin-top: clamp(18px, 2.4vw, 28px); display: grid; gap: clamp(16px, 2.2vw, 30px); }
@media (min-width: 900px) { .readout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); } }

.ro__head { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; }
.ro__year { font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: .9; letter-spacing: -.02em; color: var(--stone); }
.ro__era { font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--amber); }
.ro__par { font-size: .9rem; color: var(--muted); }
.ro__par b { color: var(--stone); font-weight: 500; }
.ro__list { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
.ro__list li {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .02em;
  border: 1px solid var(--line-soft); border-radius: 999px; padding: .34em .7em;
  color: var(--muted); max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ro__list li b { color: var(--stone-dim); font-weight: 500; }
.ro__list li.is-known { border-color: rgba(200, 154, 98, .3); }
.readout .record { margin-top: 0; min-height: 11em; }

.hint {
  display: flex; align-items: center; gap: .6em 1.6rem; flex-wrap: wrap; margin-top: 12px;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.hint i { font-style: normal; color: var(--amber-dim); }
.hint em { font-style: normal; margin-left: auto; text-align: right; }

/* ---------- без дат ---------- */

.nodate { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 1.4rem; list-style: none; }
.nodate li {
  border: 1px dashed var(--line); border-radius: 999px; padding: .45em .95em;
  font-size: .82rem; color: var(--stone-dim);
}
.nodate li span { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-left: .6em; }

/* ---------- узкие экраны ---------- */

@media (max-width: 760px) {
  .tl-page { --row: 21px; --head: 17px; --axis: 66px; --mini: 44px; }
  .scroller { height: clamp(360px, 56vh, 520px); }
  .tl__bar { gap: .7rem; }
  .tools { width: 100%; justify-content: space-between; }
  .pol__h span { display: none; }
  .facts { gap: .4rem 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .js .pol, .js .pol.is-in { opacity: 1; translate: none; transition: background-color .2s linear; }
  .js .ribbon, .js .tl.is-live .ribbon { transform: none; transition: none; }
  .crumb i, .play { transition: none; }
}
