/* =============================================================
   factions.css — Иконки фракций, свиток, панель иерархии
   ============================================================= */

/* === ИКОНКИ ФРАКЦИЙ === */

.faction-icons-container {
    display: flex;
    justify-content: space-around;
    margin-top: 30px;
    border-top: 1px solid #333;
    padding-top: 25px;
}

.faction-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    cursor: pointer;
    color: #666;
    transition: transform 0.3s ease, color 0.3s ease;
}

.faction-icons-container .faction-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    cursor: pointer;
}

.faction-icon:hover,
.faction-icon.active-icon {
    color: var(--blood-red);
    transform: scale(1.1);
    text-shadow: 0 0 10px rgba(138, 3, 3, 0.5);
}

/* Иконка-символ */
.icon-sym {
    font-size: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 10px;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 5px rgba(138, 3, 3, 0));
    transition: filter 0.3s ease;
}

.faction-icon:hover .icon-sym,
.faction-icon.active-icon .icon-sym {
    filter: drop-shadow(0 0 8px var(--blood-red));
}

/* Иконки-картинки (изображения фракций) */
.faction-icons-container .faction-icon img {
    width: 45px; height: 45px;
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.6;
    transition: all 0.3s ease;
}

.faction-icons-container .faction-icon:hover img {
    opacity: 1;
    filter: brightness(0) invert(1) drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

.faction-icons-container .faction-icon .icon-sym {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.icon-label {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* === ВЫЕЗЖАЮЩИЙ СВИТОК ФРАКЦИИ === */

.faction-scroll {
    display: none;
    margin-top: 15px;
    width: 100%;
    box-sizing: border-box;

    /* Стиль подфайла */
    background: #0a0a0a;
    border: 1px solid var(--blood-red);
    border-top: none;
    
    /* Анимация появления */
    animation: fadeInScroll 0.3s ease-out;
}

.faction-scroll.open {
    max-height: 600px;
    opacity: 1;
    padding: 30px;
}

@keyframes fadeInScroll {
    from { opacity: 0; transform: translateY(-15px); }
    to   { opacity: 1; transform: translateY(0);     }
}

.scroll-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.faction-description,
.faction-characters {
    border-bottom: 1px solid #222;
    padding-bottom: 15px;
}

.faction-characters:last-child {
    border-bottom: none;
}

#scroll-characters-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

/* Персонаж в списке свитка — кликабелен */
.faction-char-item {
    font-family: monospace;
    color: var(--text-main);
    cursor: pointer;
    transition: color 0.2s;
    list-style-type: none;
    padding: 3px 0;
}

.faction-char-item:hover {
    color: var(--blood-red);
    text-shadow: 0 0 5px var(--blood-red);
}

/* === БОКОВАЯ ПАНЕЛЬ ИЕРАРХИИ (узкая версия) === */

.side-panel {
    position: fixed;
    top: 50%;
    right: -550px;
    transform: translateY(-50%);
    width: 450px;
    height: 85vh;
    background: rgba(2, 2, 2, 0.98);
    border-left: 2px solid var(--blood-red);
    box-shadow: -15px 0 40px rgba(138, 3, 3, 0.2);
    z-index: 9999;
    transition: right 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    padding: 30px;
    overflow-y: auto;
    pointer-events: auto;
}

.side-panel.open { right: 20px; }

/* === ШИРОКАЯ ПАНЕЛЬ ИЕРАРХИИ === */

#hierarchy-panel {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 85vw;
    max-width: 1600px;
    background: rgba(5, 5, 5, 0.98);
    border-left: 2px solid var(--blood-red);
    box-shadow: -10px 0 40px rgba(0,0,0,1);
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5100;
    display: block !important;
}

#hierarchy-panel.open { transform: translateX(0); }

#hierarchy-tree-container {
    height: calc(100vh - 100px);
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 40px;
}

/* === ГЕНЕАЛОГИЧЕСКОЕ ДРЕВО (ORG TREE) === */

.org-tree ul {
    padding-top: 20px;
    position: relative;
    display: flex;
    justify-content: center;
    padding-left: 0;
}

.org-tree li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 10px 0 10px;
}

/* Горизонтальные соединительные линии */
.org-tree li::before,
.org-tree li::after {
    content: '';
    position: absolute;
    top: 0; right: 50%;
    border-top: 1px solid var(--blood-red);
    width: 50%; height: 20px;
}

.org-tree li::after {
    right: auto; left: 50%;
    border-left: 1px solid var(--blood-red);
}

/* Исключения для единственных и крайних элементов */
.org-tree li:only-child::after,
.org-tree li:only-child::before { display: none; }

.org-tree li:only-child { padding-top: 0; }

.org-tree li:first-child::before,
.org-tree li:last-child::after  { border: 0 none; }

.org-tree li:last-child::before {
    border-right: 1px solid var(--blood-red);
}

/* Вертикальная линия вниз от родителя */
.org-tree ul ul::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    border-left: 1px solid var(--blood-red);
    width: 0; height: 20px;
    transform: translateX(-50%);
}

/* Убираем общую горизонтальную линию для корневых нод */
.org-tree > ul > li {
    padding-top: 0 !important;
}

.org-tree > ul > li::before,
.org-tree > ul > li::after {
    display: none !important;
}

/* === КАРТОЧКА ПЕРСОНАЖА В ДЕРЕВЕ === */

.tree-card {
    border: 1px solid #444;
    padding: 10px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: rgba(10, 10, 10, 0.9);
    cursor: pointer;
    min-width: 100px; max-width: 140px;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}

.tree-card:hover {
    border-color: var(--blood-red);
    box-shadow: 0 0 15px rgba(138, 3, 3, 0.4);
    transform: translateY(-3px);
}

.tree-portrait {
    width: 60px; height: 80px;
    object-fit: cover;
    border: 1px solid #333;
    margin-bottom: 8px;
    filter: grayscale(100%) contrast(120%);
}

.tree-silhouette {
    width: 60px; height: 80px;
    background: #111;
    border: 1px dashed #333;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-card.foreigner {
    border-style: dashed;
    border-color: #666;
    background: rgba(30, 0, 0, 0.3);
}

/* === УЗЛЫ ДЕРЕВА (SIDE PANEL) === */

.tree-node {
    margin-left: 30px;
    position: relative;
    padding-left: 20px;
    border-left: 1px solid #333;
}

.tree-node::before {
    content: "";
    position: absolute;
    left: 0; top: 22px;
    width: 18px; height: 1px;
    background: #333;
}

.tree-node:last-child { border-left: 1px solid transparent; }

.tree-node:last-child::after {
    content: "";
    position: absolute;
    left: -1px; top: 0;
    width: 1px; height: 22px;
    background: #333;
}

.node-content {
    background: #0a0a0a;
    border: 1px solid #222;
    padding: 10px 15px;
    margin: 8px 0;
    display: block;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    pointer-events: auto;
}

.node-content:hover {
    border-color: var(--blood-red);
    background: rgba(138, 3, 3, 0.1);
    box-shadow: 0 0 15px rgba(138, 3, 3, 0.4);
    transform: translateX(5px);
}

.node-name {
    color: var(--blood-red);
    font-family: monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}

.node-status {
    color: #555;
    font-size: 10px;
    font-family: monospace;
    margin-top: 4px;
    display: block;
}

.node-content::after {
    content: "DATA_NODE";
    position: absolute;
    right: 5px; bottom: 2px;
    font-size: 7px;
    color: #222;
}

.node-faction-tag {
    font-size: 8px;
    color: #555;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
    letter-spacing: 1px;
}

.node-content.foreigner {
    border-style: dashed !important;
    border-color: #444 !important;
    background: rgba(30, 30, 30, 0.3) !important;
    opacity: 0.8;
}

.node-content.foreigner .node-name { color: #888 !important; }

.hierarchy-call-btn {
    margin-top: 20px;
    padding: 10px;
    border-top: 1px solid rgba(138, 3, 3, 0.3);
    color: var(--blood-red);
    text-align: center;
    cursor: pointer;
    font-family: monospace;
    font-size: 11px;
    transition: 0.3s;
    letter-spacing: 1px;
}

.hierarchy-call-btn:hover {
    background: rgba(138, 3, 3, 0.1);
    text-shadow: 0 0 8px var(--blood-red);
}
