/* =========================
   ПОИСК
   ========================= */

.topbar {
    position: relative;
    z-index: 20;
}

.search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    background-color: var(--surface-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    cursor: pointer;
}

.search-toggle:hover {
    background-color: var(--surface-hover);
}

.search-toggle:focus-visible,
.search-input:focus-visible,
.search-result:focus-visible {
    outline: 2px solid var(--text-muted);
    outline-offset: 2px;
}

.search-toggle svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.8;
}

.search-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 16px;
    z-index: 30;
    width: min(460px, calc(100vw - 32px));
    max-height: min(70vh, 520px);
    overflow: auto;
    padding: 12px;
    background-color: var(--panel-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgb(0 0 0 / 24%);
}

.search-panel[hidden] {
    display: none;
}

.search-input {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    background-color: var(--deep-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-status {
    margin: 10px 2px 6px;
    color: var(--text-muted);
    font-size: 13px;
}

.search-status:empty,
.search-status[hidden] {
    display: none;
}

.search-results {
    display: grid;
    gap: 2px;
}

.search-result {
    display: grid;
    width: 100%;
    gap: 3px;
    padding: 9px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 0;
    border-radius: 5px;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-result:hover,
.search-result:focus-visible {
    background-color: var(--surface-bg);
}

.search-result-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.search-result-context,
.search-result-snippet {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

/* =========================
   ОБЩИЕ СТИЛИ КНОПОК
   ========================= */

.content button,
.wiki-card,
.belonging-button,
.god-button,
.creature-category-button {
    background-color: var(--surface-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 18px 22px;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
}

.content button:hover,
.wiki-card:hover,
.belonging-button:hover,
.god-button:hover,
.creature-category-button:hover {
    transform: translateY(-3px);
    background-color: var(--surface-hover);
}

.wiki-cards {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.wiki-card {
    width: 220px;
    min-height: 170px;
    text-align: center;
    padding: 24px 18px;
}

.wiki-card h2 {
    margin-top: 0;
    font-size: 22px;
}

.wiki-card p {
    color: var(--text-muted);
    margin-bottom: 0;
}

.church-branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 281.25px), 281.25px));
    align-items: stretch;
    justify-content: center;
}

.church-branch-item {
    display: flex;
    width: min(100%, 281.25px);
    flex-direction: column;
    align-items: stretch;
    justify-self: center;
    gap: 10px;
}

.church-branch-item--silver {
    --branch-color: 174 192 210;
}

.church-branch-item--gold {
    --branch-color: 200 167 107;
}

.church-branch-item--azure {
    --branch-color: 99 166 199;
}

.content .church-branch-card {
    position: relative;
    display: flex;
    width: min(100%, 281.25px);
    height: auto;
    min-height: 0;
    aspect-ratio: 9 / 16;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    justify-self: center;
    overflow: hidden;
    padding: 20px 20px 48px;
}

.church-branch-image {
    position: absolute;
    inset: 0 0 120px;
    border-radius: inherit;
    color: var(--branch-emblem-color);
}

.content .church-branch-card h2 {
    position: relative;
    z-index: 1;
    font-size: 26px;
}

.content .church-branch-card p {
    position: relative;
    z-index: 1;
}

.content .church-branch-card--silver {
    --branch-emblem-color: rgb(var(--branch-color));
    background: linear-gradient(145deg, rgb(141 157 174 / 26%), var(--surface-bg) 78%);
    border-color: rgb(174 192 210 / 55%);
}

.content .church-branch-card--gold {
    --branch-emblem-color: rgb(var(--branch-color));
    background: linear-gradient(145deg, rgb(176 137 66 / 30%), var(--surface-bg) 78%);
    border-color: rgb(200 167 107 / 65%);
}

.content .church-branch-card--azure {
    --branch-emblem-color: rgb(var(--branch-color));
    background: linear-gradient(145deg, rgb(54 116 150 / 32%), var(--surface-bg) 78%);
    border-color: rgb(99 166 199 / 58%);
}

.content .church-branch-card:hover,
.content .church-branch-card.is-selected {
    transform: translateY(-3px);
    background-color: var(--surface-hover);
}

.church-branch-card--silver:hover,
.church-branch-card--silver.is-selected {
    box-shadow: inset 0 0 0 1px rgb(174 192 210 / 28%);
}

.content .church-branch-card--silver:hover,
.content .church-branch-card--silver.is-selected {
    background: linear-gradient(145deg, rgb(141 157 174 / 32%), var(--surface-hover) 78%);
}

.church-branch-card--gold:hover,
.church-branch-card--gold.is-selected {
    box-shadow: inset 0 0 0 1px rgb(200 167 107 / 35%);
}

.content .church-branch-card--gold:hover,
.content .church-branch-card--gold.is-selected {
    background: linear-gradient(145deg, rgb(176 137 66 / 36%), var(--surface-hover) 78%);
}

.church-branch-card--azure:hover,
.church-branch-card--azure.is-selected {
    box-shadow: inset 0 0 0 1px rgb(99 166 199 / 32%);
}

.content .church-branch-card--azure:hover,
.content .church-branch-card--azure.is-selected {
    background: linear-gradient(145deg, rgb(54 116 150 / 38%), var(--surface-hover) 78%);
}

.church-branch-chevron {
    position: absolute;
    bottom: 15px;
    left: 50%;
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    transform: translateX(-50%);
    transition: transform 0.2s ease;
}

.church-branch-card[aria-expanded="true"] .church-branch-chevron {
    transform: translateX(-50%) rotate(180deg);
}

.church-chamber-panel {
    grid-column: 1 / -1;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.3s ease;
}

.church-chamber-panel[hidden] {
    display: none;
}

.church-chamber-panel.is-open {
    max-height: 900px;
    opacity: 1;
    transform: translateY(0);
}

.church-chamber-panel-inner {
    padding: 26px 12px 10px;
    text-align: center;
}

.church-chamber-panel-inner > h2 {
    margin: 0;
    color: var(--accent-strong);
    font-size: 27px;
}

.church-chamber-panel .wiki-cards {
    margin-top: 18px;
}

.content .church-chamber-card {
    min-height: 190px;
}

.content .church-chamber-card--silver {
    background: linear-gradient(145deg, rgb(141 157 174 / 26%), var(--surface-bg) 78%);
    border-color: rgb(174 192 210 / 55%);
}

.content .church-chamber-card--gold {
    background: linear-gradient(145deg, rgb(176 137 66 / 30%), var(--surface-bg) 78%);
    border-color: rgb(200 167 107 / 65%);
}

.content .church-chamber-card--azure {
    background: linear-gradient(145deg, rgb(54 116 150 / 32%), var(--surface-bg) 78%);
    border-color: rgb(99 166 199 / 58%);
}

.church-chamber-card h3 {
    margin-top: 0;
    font-size: 22px;
}

.church-chambers-empty {
    margin: 18px 0 8px;
    color: var(--text-muted);
}

.content .church-branch-details-link {
    width: 100%;
    padding: 10px 12px;
    color: rgb(var(--branch-color));
    background: rgb(var(--branch-color) / 12%);
    border-color: rgb(var(--branch-color) / 55%);
    font-size: 14px;
}

.content .church-branch-details-link:hover {
    transform: translateY(-2px);
    background: rgb(var(--branch-color) / 20%);
}

.church-branch-page {
    max-width: 1000px;
    margin: 0 auto;
}

.church-branch-hero {
    position: relative;
    display: flex;
    min-height: clamp(280px, 40vw, 440px);
    align-items: flex-end;
    overflow: hidden;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
}

.church-chamber-hero {
    min-height: clamp(260px, 32vw, 360px);
}

.church-branch-hero-image {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
}

.church-branch-page--silver .church-branch-hero-image {
    background-image: linear-gradient(160deg, rgb(174 192 210 / 40%), rgb(21 24 28 / 82%));
}

.church-branch-page--gold .church-branch-hero-image {
    background-image: linear-gradient(160deg, rgb(200 167 107 / 44%), rgb(30 24 15 / 84%));
}

.church-branch-page--azure .church-branch-hero-image {
    background-image: linear-gradient(160deg, rgb(99 166 199 / 46%), rgb(15 26 32 / 84%));
}

.church-branch-hero-content {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: clamp(24px, 5vw, 56px);
    background: linear-gradient(transparent, rgb(10 10 10 / 78%));
}

.content .church-branch-eyebrow {
    margin: 0 0 6px;
    color: var(--accent-strong);
    font-family: var(--font-body);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.content .church-branch-hero h1 {
    margin: 0;
    font-size: clamp(38px, 6vw, 68px);
}

.church-branch-description,
.church-branch-chambers {
    max-width: 850px;
    margin: 36px auto;
}

.church-branch-description h2,
.church-branch-chambers > h2 {
    margin: 0 0 12px;
    color: var(--accent-strong);
    font-size: 30px;
}

.church-branch-description p {
    margin: 0;
    color: var(--text-secondary);
}

.church-branch-chambers .wiki-cards {
    margin-top: 20px;
}

/* =========================
   ПРИНАДЛЕЖНОСТЬ
   ========================= */

.section-description {
    color: var(--text-muted);

    font-size: 17px;

    margin-top: -15px;
    margin-bottom: 35px;
}

.belonging-list {
    display: flex;

    justify-content: center;

    gap: 20px;

    flex-wrap: wrap;
}

.belonging-button {
    width: 200px;

    padding: 25px;

    background-color: var(--surface-bg);

    color: var(--text-primary);

    border: 1px solid var(--border-strong);

    border-radius: 10px;

    font-size: 19px;

    cursor: pointer;

    transition: 0.2s;
}

.belonging-button:hover {
    transform: translateY(-5px);

    background-color: var(--surface-hover);
}

#belonging-info {
    margin-top: 40px;

    padding: 25px;

    background-color: var(--panel-bg);

    border-radius: 10px;

    min-height: 100px;
}


/* =========================
   ГЛАВНАЯ — НЕБЕСНЫЙ СВОД
   ========================= */

#home {
    position: relative;
    isolation: isolate;
    min-height: calc(100vh - var(--topbar-height) - var(--content-top-gutter) - 50px);
}

.app.is-home #home {
    flex: 1;
    min-height: 0;
}

#home-sky {
    position: absolute;
    z-index: 0;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Виньетка: небо мягко уходит в тень по краям */

#home::after {
    content: "";
    position: absolute;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 140px 50px rgb(10 10 10 / 55%);
}

.home-content {
    position: absolute;
    z-index: 1;
    top: clamp(20px, 5vh, 56px);
    left: var(--mobile-gutter);
    right: var(--mobile-gutter);
    max-width: 980px;
    margin: 0 auto;
    text-align: left;
    pointer-events: none;
    text-shadow: 0 2px 14px rgb(0 0 0 / 90%);
}

.home-subtitle {
    max-width: 640px;
    margin: -14px 0 0;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
}

.home-actions {
    margin-top: 16px;
    pointer-events: auto;
}

.content .home-random-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 10px 15px;
    color: var(--accent-strong);
    text-shadow: none;
    background: rgb(21 21 21 / 50%);
    border-color: var(--accent-border);
    font-size: 14px;
}

.content .home-random-button:hover {
    background: rgb(200 167 107 / 18%);
}

.home-changelog {
    width: min(100%, 520px);
    margin-top: 10px;
    text-align: left;
    pointer-events: auto;
}

.home-changelog-panel {
    max-height: min(30vh, 240px);
    overflow: hidden;
    color: var(--text-primary);
    text-shadow: none;
    background: rgb(21 21 21 / 38%);
    border: 1px solid rgb(200 167 107 / 28%);
    border-radius: 7px;
    backdrop-filter: blur(3px);
}

.home-changelog-panel[hidden] {
    display: none;
}

.home-changelog-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 5px 10px;
    border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.home-changelog-header h2 {
    margin: 0;
    color: var(--accent-strong);
    font-size: 18px;
}

.content .home-changelog-toggle {
    flex: 0 0 auto;
    padding: 5px 9px;
    color: var(--text-secondary);
    font-size: 12px;
    background: rgb(21 21 21 / 32%);
    border-color: rgb(200 167 107 / 30%);
}

.content .home-changelog-toggle:hover {
    transform: none;
    background: rgb(21 21 21 / 52%);
}

.home-changelog-list {
    min-height: 0;
    padding: 0 10px;
    overflow: auto;
}

.home-changelog-empty {
    margin: 8px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.home-changelog-entry {
    border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.home-changelog-entry:last-child {
    border-bottom: 0;
}

.home-changelog-entry summary {
    display: flex;
    align-items: baseline;
    gap: 9px;
    padding: 7px 0;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}

.home-changelog-date {
    flex: 0 0 auto;
    color: var(--accent-strong);
    font-size: 12px;
}

.home-changelog-entry-title {
    font-weight: 600;
}

.home-changelog-entry-content {
    margin: -1px 0 9px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
}
