/* =============================================
   FACTIONS PAGE — «Зал Судеб»
   Each faction = full viewport section
   ============================================= */

/* ---- Faction accent tokens (per section) ---- */
.faction-section[data-f="1"] { --f-hue: 30; --f-r:220; --f-g:130; --f-b:40; }   /* amber — Warriors */
.faction-section[data-f="2"] { --f-hue: 180; --f-r:40; --f-g:200; --f-b:210; } /* teal — Runists */
.faction-section[data-f="3"] { --f-hue: 270; --f-r:160; --f-g:80; --f-b:240; }  /* violet — Mages */
.faction-section[data-f="4"] { --f-hue: 340; --f-r:210; --f-g:50; --f-b:100; }  /* crimson — Politicians */
.faction-section[data-f="5"] { --f-hue: 200; --f-r:70; --f-g:140; --f-b:200; }  /* steel-blue — Prisoners */

/* Derived per-faction shorthands */
.faction-section {
  --f-accent:     rgba(var(--f-r), var(--f-g), var(--f-b), 1);
  --f-glow:       rgba(var(--f-r), var(--f-g), var(--f-b), 0.35);
  --f-glow-soft:  rgba(var(--f-r), var(--f-g), var(--f-b), 0.12);
  --f-border:     rgba(var(--f-r), var(--f-g), var(--f-b), 0.3);
}


/* =============================================
   FACTIONS PAGE WRAPPER
   ============================================= */
.factions-page {
  position: relative;
  padding-top: var(--nav-height);
}

/* ---- Chapter nav (right side dots) ---- */
.factions-nav {
  position: fixed;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  transition: opacity 0.4s;
}
.factions-page-active .factions-nav { opacity: 1; }

.factions-nav__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}
.factions-nav__dot::after {
  content: attr(data-label);
  position: absolute;
  right: 18px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.factions-nav__dot:hover::after { opacity: 1; }
.factions-nav__dot.active {
  background: #fff;
  border-color: #fff;
  transform: scale(1.4);
}
.factions-nav__dot[data-f="1"].active { background: rgba(220,130,40,1); border-color: rgba(220,130,40,1); }
.factions-nav__dot[data-f="2"].active { background: rgba(40,200,210,1); border-color: rgba(40,200,210,1); }
.factions-nav__dot[data-f="3"].active { background: rgba(160,80,240,1); border-color: rgba(160,80,240,1); }
.factions-nav__dot[data-f="4"].active { background: rgba(210,50,100,1); border-color: rgba(210,50,100,1); }
.factions-nav__dot[data-f="5"].active { background: rgba(70,140,200,1); border-color: rgba(70,140,200,1); }


/* =============================================
   SINGLE FACTION SECTION
   ============================================= */
.faction-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Full-bleed background image */
.faction-section__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.faction-section__img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  transform: scale(1.08);
  transition: transform 0.1s linear;
  filter: brightness(0.5) saturate(0.6);
}
.faction-section__overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(105deg,
      rgba(2,10,24,0.97) 0%,
      rgba(2,10,24,0.80) 38%,
      rgba(2,10,24,0.25) 65%,
      transparent 100%),
    linear-gradient(0deg,
      rgba(2,10,24,0.9) 0%,
      transparent 30%);
}
.faction-section__color-wash {
  position: absolute; inset: 0;
  background: radial-gradient(
    ellipse 55% 70% at 65% 50%,
    var(--f-glow-soft) 0%,
    transparent 70%
  );
}

/* Separator line between sections */
.faction-section + .faction-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--f-border) 30%,
    rgba(255,255,255,0.08) 50%,
    var(--f-border) 70%,
    transparent 100%);
  z-index: 2;
}

/* ---- Content layout ---- */
.faction-section__content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 80px 64px 80px 80px;
  min-height: 100vh;
  align-items: center;
}

/* Left: text column */
.faction-section__left {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-right: 60px;
}

/* Right: image accent column */
.faction-section__right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}


/* ---- Number badge ---- */
.faction-section__badge {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.faction-section__badge-line {
  width: 40px; height: 1px;
  background: var(--f-accent);
  opacity: 0.7;
}
.faction-section__badge-num {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--f-accent);
  opacity: 0.9;
}

/* ---- Name ---- */
.faction-section__name {
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 0.9;
  color: var(--text-primary);
  margin-bottom: 28px;
  text-shadow:
    0 0 60px var(--f-glow),
    0 4px 32px rgba(0,0,0,0.5);
}

/* ---- Rune accent beside name ---- */
.faction-section__name-rune {
  display: block;
  font-size: clamp(1rem, 2vw, 1.4rem);
  letter-spacing: 0.3em;
  color: var(--f-accent);
  opacity: 0.55;
  margin-bottom: 8px;
  font-weight: 400;
}

/* ---- Short tagline ---- */
.faction-section__tagline {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.8vw, 1.1rem);
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 36px;
  max-width: 440px;
  border-left: 2px solid var(--f-accent);
  padding-left: 20px;
  opacity: 0.9;
}

/* ---- Lore text ---- */
.faction-section__lore {
  font-size: clamp(0.82rem, 1.4vw, 0.9rem);
  color: var(--text-muted);
  line-height: 1.9;
  margin-bottom: 48px;
  max-width: 420px;
}

/* ---- Stats row ---- */
.faction-section__stats {
  display: flex;
  gap: 32px;
  margin-bottom: 48px;
}
.faction-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.faction-stat__label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.faction-stat__bar-wrap {
  width: 80px; height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.faction-stat__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--f-accent), transparent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.9s cubic-bezier(0.16,1,0.3,1);
}
/* JS sets transform directly on .in-view */
.faction-stat__val {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--f-accent);
}

/* ---- CTA ---- */
.faction-section__cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.faction-section__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 13px 28px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1), box-shadow 0.3s, opacity 0.3s;
}
.faction-section__btn svg { width: 14px; height: 14px; flex-shrink: 0; transition: transform 0.3s; }
.faction-section__btn:hover svg { transform: translateX(5px); }
.faction-section__btn--primary {
  background: var(--f-accent);
  color: #020e21;
  border: 1px solid transparent;
  box-shadow: 0 0 24px var(--f-glow);
}
.faction-section__btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 40px var(--f-glow), 0 8px 20px rgba(0,0,0,0.3);
}
.faction-section__btn--ghost {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.15);
}
.faction-section__btn--ghost:hover {
  color: #fff;
  border-color: var(--f-border);
  background: var(--f-glow-soft);
  transform: translateY(-1px);
}


/* ---- Right side: decorative portrait card ---- */
.faction-portrait {
  position: relative;
  width: clamp(260px, 30vw, 400px);
  aspect-ratio: 2/3;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--f-border);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 32px 80px rgba(0,0,0,0.6),
    0 0 60px var(--f-glow);
}
.faction-portrait__img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: saturate(0.75) brightness(0.85);
  transition: transform 0.6s cubic-bezier(0.16,1,0.3,1), filter 0.5s;
}
.faction-section:hover .faction-portrait__img {
  transform: scale(1.04);
  filter: saturate(0.9) brightness(0.95);
}
.faction-portrait__overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, rgba(2,10,24,0.85) 0%, transparent 40%),
    linear-gradient(180deg, rgba(2,10,24,0.3) 0%, transparent 25%);
}
.faction-portrait__corner {
  position: absolute;
  width: 28px; height: 28px;
  border-color: var(--f-accent);
  border-style: solid;
  opacity: 0.6;
}
.faction-portrait__corner--tl { top: 10px; left: 10px; border-width: 1px 0 0 1px; border-radius: 4px 0 0 0; }
.faction-portrait__corner--br { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; border-radius: 0 0 4px 0; }
.faction-portrait__label {
  position: absolute;
  bottom: 16px; left: 16px; right: 16px;
}
.faction-portrait__label-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  display: block;
}
.faction-portrait__label-sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--f-accent);
  display: block;
  margin-top: 4px;
  opacity: 0.8;
}

/* Floating rune behind portrait */
.faction-portrait__bg-rune {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 14rem;
  color: var(--f-accent);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  z-index: -1;
  line-height: 1;
}


/* ---- Reveal animation states ---- */
.faction-section__left > * {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.7s cubic-bezier(0.16,1,0.3,1),
              transform 0.7s cubic-bezier(0.16,1,0.3,1);
}
.faction-portrait {
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.8s cubic-bezier(0.16,1,0.3,1),
              transform 0.8s cubic-bezier(0.16,1,0.3,1);
}

.faction-section.in-view .faction-section__left > * {
  opacity: 1; transform: translateX(0);
}
.faction-section.in-view .faction-portrait {
  opacity: 1; transform: translateY(0) scale(1);
}

/* Stagger children */
.faction-section.in-view .faction-section__badge  { transition-delay: 0.05s; }
.faction-section.in-view .faction-section__name   { transition-delay: 0.15s; }
.faction-section.in-view .faction-section__tagline{ transition-delay: 0.25s; }
.faction-section.in-view .faction-section__lore   { transition-delay: 0.35s; }
.faction-section.in-view .faction-section__stats  { transition-delay: 0.45s; }
.faction-section.in-view .faction-section__cta    { transition-delay: 0.55s; }
.faction-section.in-view .faction-portrait        { transition-delay: 0.20s; }


/* ---- Alternating layout (even sections flip) ---- */
.faction-section:nth-child(even) .faction-section__content {
  padding: 80px 80px 80px 64px;
}
.faction-section:nth-child(even) .faction-section__left {
  order: 2;
  padding-right: 0;
  padding-left: 60px;
}
.faction-section:nth-child(even) .faction-section__right {
  order: 1;
  justify-content: flex-start;
}
.faction-section:nth-child(even) .faction-section__overlay {
  background:
    linear-gradient(255deg,
      rgba(2,10,24,0.97) 0%,
      rgba(2,10,24,0.80) 38%,
      rgba(2,10,24,0.25) 65%,
      transparent 100%),
    linear-gradient(0deg, rgba(2,10,24,0.9) 0%, transparent 30%);
}
.faction-section:nth-child(even) .faction-section__left > * {
  transform: translateX(30px);
}
.faction-section:nth-child(even).in-view .faction-section__left > * {
  transform: translateX(0);
}
.faction-section:nth-child(even) .faction-section__color-wash {
  background: radial-gradient(
    ellipse 55% 70% at 35% 50%,
    var(--f-glow-soft) 0%,
    transparent 70%
  );
}

/* ---- Header section ---- */
.factions-hero {
  position: relative;
  padding: 80px 80px 72px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(6,22,50,0.6) 0%, transparent 100%);
}
.factions-hero::before {
  content: 'ФРАКЦИИ';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(5rem, 15vw, 14rem);
  font-weight: 900;
  letter-spacing: 0.25em;
  color: rgba(111,169,214,0.03);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.factions-hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent-secondary);
  opacity: 0.7;
  margin-bottom: 16px;
  display: block;
}
.factions-hero__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1;
}
.factions-hero__desc {
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.8;
  font-style: italic;
}

/* Progress tracker */
.factions-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 36px;
}
.factions-progress__step {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.3s;
}
.factions-progress__step.active { opacity: 1; }
.factions-progress__step-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.55rem; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5);
  transition: all 0.3s;
}
.factions-progress__step.active .factions-progress__step-dot {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
  box-shadow: 0 0 10px var(--accent-glow);
}
.factions-progress__line {
  width: 32px; height: 1px;
  background: rgba(255,255,255,0.1);
}


/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1024px) {
  .faction-section__content { padding: 80px 40px; }
  .faction-section__left { padding-right: 40px; }
  .faction-section:nth-child(even) .faction-section__content { padding: 80px 40px; }
  .faction-section:nth-child(even) .faction-section__left { padding-left: 40px; }
  .faction-portrait { width: clamp(220px, 28vw, 340px); }
  .factions-hero { padding: 60px 40px; }
}

@media (max-width: 768px) {
  /* Stop any horizontal scroll */
  .faction-section {
    overflow-x: hidden;
  }

  /* Single column, constrained to viewport */
  .faction-section__content {
    grid-template-columns: 1fr;
    padding: 60px 24px 72px;
    gap: 36px;
    align-content: center;
    box-sizing: border-box;
    width: 100%;
  }

  /* Left column: no extra horizontal padding */
  .faction-section__left {
    padding-right: 0;
    width: 100%;
    box-sizing: border-box;
  }

  /* Even sections reset */
  .faction-section:nth-child(even) .faction-section__content { padding: 60px 24px 72px; }
  .faction-section:nth-child(even) .faction-section__left { order: 1; padding-left: 0; }
  .faction-section:nth-child(even) .faction-section__right { order: 2; }

  /* Right column: full width, portrait centred — override desktop flex-end */
  .faction-section__right,
  .faction-section:nth-child(even) .faction-section__right {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Portrait card: centred, capped width */
  .faction-portrait {
    width: min(240px, 62vw);
    margin-left: auto;
    margin-right: auto;
    align-self: center;
  }

  /* Image: keep face centred on small cards */
  .faction-portrait__img {
    object-position: center 15%;
  }

  /* Rune decoration: no layout impact */
  .faction-portrait__bg-rune {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9rem;
  }

  /* CTA buttons: side-by-side, equal width, shrink to fit screen */
  .faction-section__cta {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }
  .faction-section__btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 12px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Stats: wrap so they don't overflow */
  .faction-section__stats {
    flex-wrap: wrap;
    gap: 20px 28px;
  }

  .factions-hero { padding: 48px 24px; }
  .factions-hero::before { display: none; }
  .factions-nav { display: none; }
}

@media (max-width: 400px) {
  .faction-section__content { padding: 48px 16px 60px; }
  .faction-portrait { width: min(200px, 68vw); }
  .faction-section__name { font-size: 2.2rem; }
  .faction-section__btn {
    padding: 11px 8px;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
  }
}

/* =============================================
   SCROLL SNAP — подсказка «листай вниз»
   ============================================= */
.faction-section__scroll-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.6s ease 1.2s; /* появляется с задержкой */
  pointer-events: none;
}
.faction-section.in-view .faction-section__scroll-hint {
  opacity: 1;
}
/* скрываем у последней фракции */
.faction-section:last-child .faction-section__scroll-hint {
  display: none;
}

.faction-section__scroll-hint__label {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
}
.faction-section__scroll-hint__arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.faction-section__scroll-hint__arrow span {
  display: block;
  width: 1px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  animation: snapArrowDrop 1.6s ease-in-out infinite;
}
.faction-section__scroll-hint__arrow span:nth-child(1) { animation-delay: 0s; }
.faction-section__scroll-hint__arrow span:nth-child(2) { animation-delay: 0.15s; }
.faction-section__scroll-hint__arrow span:nth-child(3) { animation-delay: 0.3s; }

/* шеврон-стрелка */
.faction-section__scroll-hint__chevron {
  color: rgba(255,255,255,0.2);
  animation: snapChevronBounce 1.8s ease-in-out infinite;
}
@keyframes snapArrowDrop {
  0%, 100% { opacity: 0.15; transform: translateY(-3px); }
  50%       { opacity: 0.7;  transform: translateY(3px); }
}
@keyframes snapChevronBounce {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50%       { transform: translateY(5px); opacity: 0.8; }
}