/* ============================================================================
   The Ohana Chill Game — «атмосферный» слой.
   Подключается последним, после style.css / style-plus.css / brand.css.

   Здесь живут:
     · живые искры и дым над костром в hero;
     · базовый фон hero — свёрстанный вручную static/img/hero-art.svg,
       поверх него необязательный растровый арт (static/img/hero-art.jpg):
       положили файл — CSS подхватит его автоматически;
     · блок «живой статус сервера» (partials/server_live.html);
     · мелкая «ржавая» фактура карточек и предупреждения о рестарте.

   Все анимации отключаются при prefers-reduced-motion: reduce.
   ========================================================================= */

/* ---------- hero: слой растрового арта (необязательный) ------------------- */
/* Базовый фон — static/img/hero-art.svg (brand.css, .hero-home::before).
   Растр подключается inline-стилем в templates/index.html
   (static/img/hero-art.jpg) и ложится поверх вектора.
   Файла может не быть: тогда просто прозрачный слой, а фон остаётся SVG.
   В CSS ссылку не ставим намеренно: collectstatic (ManifestStaticFilesStorage)
   падает, если url() указывает на несуществующий файл. */
.hero-home::before {
    z-index: -3;
}

.hero-art {
    position: absolute;
    inset: 0;
    z-index: -2;
    background-position: center bottom;
    background-repeat: no-repeat;
    background-size: cover;
    filter: saturate(1.06) contrast(1.03);
    pointer-events: none;
}

/* мягкое «дыхание» света от костра — очень медленное, чтобы не рябило */
.hero-home {
    animation: hearth-glow 14s ease-in-out infinite;
}

@keyframes hearth-glow {
    0%, 100% { box-shadow: 0 0 0 rgba(245, 166, 35, 0); }
    50%      { box-shadow: 0 0 46px rgba(245, 166, 35, 0.10); }
}

/* ---------- hero: слой искр ---------------------------------------------- */
.hero-fx {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* дымка у горизонта */
.hero-fx::before {
    content: "";
    position: absolute;
    left: 25%;
    right: 5%;
    bottom: 8%;
    height: 45%;
    background: radial-gradient(60% 60% at 50% 100%,
                rgba(255, 190, 120, 0.10), rgba(255, 190, 120, 0) 70%);
    filter: blur(14px);
    animation: ember-haze 18s ease-in-out infinite alternate;
}

@keyframes ember-haze {
    from { opacity: 0.45; transform: translateY(6px) scale(1); }
    to   { opacity: 0.85; transform: translateY(-6px) scale(1.06); }
}

.hero-fx span {
    position: absolute;
    bottom: 6%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff2cf 0%, #f5a623 55%, rgba(245, 166, 35, 0) 72%);
    opacity: 0;
    animation: ember-rise 9s linear infinite;
    will-change: transform, opacity;
}

.hero-fx span:nth-child(1) { left: 58%; animation-delay: 0.2s;  animation-duration: 8.5s; }
.hero-fx span:nth-child(2) { left: 63%; animation-delay: 1.6s;  animation-duration: 10s;  }
.hero-fx span:nth-child(3) { left: 67%; animation-delay: 3.1s;  animation-duration: 7.8s; }
.hero-fx span:nth-child(4) { left: 71%; animation-delay: 4.4s;  animation-duration: 11s;  }
.hero-fx span:nth-child(5) { left: 75%; animation-delay: 0.9s;  animation-duration: 9.2s; }
.hero-fx span:nth-child(6) { left: 61%; animation-delay: 5.6s;  animation-duration: 8.2s; }
.hero-fx span:nth-child(7) { left: 69%; animation-delay: 6.8s;  animation-duration: 10.4s; }
.hero-fx span:nth-child(8) { left: 73%; animation-delay: 2.3s;  animation-duration: 9.6s; }

@keyframes ember-rise {
    0%   { transform: translate3d(0, 0, 0) scale(0.7); opacity: 0; }
    10%  { opacity: 0.95; }
    55%  { opacity: 0.6; }
    100% { transform: translate3d(26px, -330px, 0) scale(1.3); opacity: 0; }
}

/* ---------- живой статус сервера ----------------------------------------- */
.live-status {
    position: relative;
    margin: 0 0 22px;
    padding: 18px 20px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 120% at 0% 0%, rgba(90, 125, 60, 0.12), transparent 55%),
        linear-gradient(180deg, rgba(42, 42, 42, 0.92), rgba(30, 30, 30, 0.92));
    box-shadow: var(--shadow);
}

.live-status.is-warning {
    border-color: rgba(245, 166, 35, 0.55);
    background:
        radial-gradient(120% 120% at 0% 0%, rgba(245, 166, 35, 0.16), transparent 55%),
        linear-gradient(180deg, rgba(46, 40, 32, 0.95), rgba(32, 30, 27, 0.95));
}

.live-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.live-head b { color: #fff; }

.live-updated { margin-left: auto; }

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 0 rgba(139, 195, 74, 0.55);
}

.live-dot.is-on {
    background: var(--green-bright);
    animation: live-pulse 2.4s ease-out infinite;
}

.live-dot.is-off { background: var(--red); }

@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(139, 195, 74, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(139, 195, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 195, 74, 0); }
}

.live-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.live-metric { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.live-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
}

.live-value.small { font-size: 1.1rem; }
.live-value .muted { font-size: 0.9rem; font-weight: 600; }

.live-alert {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-left: 3px solid var(--ember);
    border-radius: 4px;
    background: rgba(245, 166, 35, 0.10);
    color: var(--ember-soft);
    font-weight: 600;
}

.live-foot { margin: 12px 0 0; }

.restart-soon {
    margin: 12px 0 0;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(245, 166, 35, 0.45);
    background: rgba(245, 166, 35, 0.10);
    color: var(--ember-soft);
    font-size: 0.86rem;
}

/* ---------- общая атмосфера: зерно, заголовки, мелочи -------------------- */
/* Плёночное зерно поверх фона: без картинок, чистая SVG-турбулентность.
   Слой не ловит клики и не мешает выделению текста. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.035;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.section-head h2 {
    position: relative;
    padding-bottom: 8px;
}

.section-head h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 54px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--ember), rgba(245, 166, 35, 0));
}

/* тёплый отблеск на карточках при наведении — «свет костра» */
.card {
    transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.card:hover {
    border-color: rgba(245, 166, 35, 0.35);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(245, 166, 35, 0.06);
}

.restarts-note {
    margin-top: 22px;
    padding: 20px 22px;
}

.restarts-note h3 { margin-top: 0; }
.restarts-note p:last-child { margin-bottom: 0; }

/* аккуратные бейджи в новом стиле */
.badge-warn {
    background: rgba(245, 166, 35, 0.14);
    border: 1px solid rgba(245, 166, 35, 0.45);
    color: var(--ember-soft);
}

/* пульсация кнопки «играть» — едва заметная, чтобы не отвлекать */
.btn-ember {
    position: relative;
}

.btn-ember::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.35);
    animation: cta-breathe 4.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes cta-breathe {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.30); }
    50%      { box-shadow: 0 0 22px 2px rgba(245, 166, 35, 0.18); }
}

/* тёмный «ржавый» скроллбар */
* {
    scrollbar-color: #4a3a28 var(--bg-soft);
}

/* ---------- обозреватель сервера (server/browser.html) ------------------- */
/* Публичная лента событий: кто в игре, чат, убийства, торговля, бункеры.  */
.browser-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.browser-card {
    min-width: 0;
}

.browser-card h3 {
    margin-bottom: 10px;
}

.browser-nick {
    color: var(--green-bright);
    font-weight: 600;
}

.browser-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 340px;
    overflow-y: auto;
}

.browser-feed li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.9rem;
    line-height: 1.45;
}

.browser-feed li:last-child {
    border-bottom: none;
}

.browser-feed time {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-right: 8px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- убийства в обозревателе: мини-карта и координаты ------------- */
/* Карточка занимает всю ширину: слева фрагмент карты, справа событие.       */
.browser-kills {
    grid-column: 1 / -1;
}

.kill-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 560px;
    overflow-y: auto;
}

.kill-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
}

.kill-item:last-child {
    border-bottom: none;
}

/* Один тайл карты (зум 6, ~950 м) с точкой в месте гибели. */
.kill-map {
    position: relative;
    flex: 0 0 104px;
    width: 104px;
    height: 104px;
    display: block;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    background-color: #12161a;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

a.kill-map:hover {
    border-color: var(--green-bright);
}

.kill-map-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: #e74c3c;
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, .35), 0 0 10px rgba(231, 76, 60, .8);
}

.kill-map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: .72rem;
    line-height: 1.2;
    color: var(--text-muted);
}

.kill-body {
    flex: 1;
    min-width: 0;
}

.kill-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: .92rem;
    line-height: 1.35;
}

.kill-head time {
    color: var(--text-muted);
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kill-badge {
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, .06);
    color: var(--text-muted);
    font-size: .68rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.kill-type-player .kill-badge {
    color: #ffd479;
    border-color: rgba(255, 212, 121, .45);
    background: rgba(255, 212, 121, .12);
}

.kill-type-puppet .kill-badge {
    color: #9ad19a;
    border-color: rgba(154, 209, 154, .4);
    background: rgba(154, 209, 154, .1);
}

.kill-type-npc .kill-badge {
    color: #9ec7ff;
    border-color: rgba(158, 199, 255, .4);
    background: rgba(158, 199, 255, .1);
}

.kill-type-animal .kill-badge {
    color: #e8b98a;
    border-color: rgba(232, 185, 138, .4);
    background: rgba(232, 185, 138, .1);
}

.kill-type-suicide .kill-badge {
    color: #ff9d9d;
    border-color: rgba(255, 157, 157, .4);
    background: rgba(255, 157, 157, .1);
}

.kill-victim {
    font-weight: 600;
}

.kill-meta {
    margin-top: 2px;
}

.kill-coords {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.kill-coords code {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .05);
    font-size: .78rem;
    letter-spacing: .02em;
}

@media (max-width: 640px) {
    .kill-map {
        flex-basis: 76px;
        width: 76px;
        height: 76px;
    }
}

/* чат в обозревателе: тот же .chat-log, но с воздухом между строками */
.chat-log > div {
    padding: 3px 0;
    border-bottom: 1px solid var(--border-soft);
    line-height: 1.45;
}

.chat-log > div:last-child {
    border-bottom: none;
}

.chat-log .badge {
    margin: 0 4px;
}

/* ---------- прокрутка живых лент ----------------------------------------- */
/* Чат, торговля и убийства перерисовываются HTMX раз в 15 секунд; позицию
   возвращает static/js/live-scroll.js, а здесь — чтобы колесо листало саму
   ленту, а не страницу под ней, и полоса прокрутки была видна на тёмном. */
.chat-log,
.browser-feed,
.kill-feed {
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .28) rgba(255, 255, 255, .05);
}

.chat-log::-webkit-scrollbar,
.browser-feed::-webkit-scrollbar,
.kill-feed::-webkit-scrollbar {
    width: 8px;
}

.chat-log::-webkit-scrollbar-track,
.browser-feed::-webkit-scrollbar-track,
.kill-feed::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, .05);
    border-radius: 4px;
}

.chat-log::-webkit-scrollbar-thumb,
.browser-feed::-webkit-scrollbar-thumb,
.kill-feed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .28);
    border-radius: 4px;
}

.chat-log::-webkit-scrollbar-thumb:hover,
.browser-feed::-webkit-scrollbar-thumb:hover,
.kill-feed::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .45);
}

/* ---------- адаптив ------------------------------------------------------ */
/* В шапке 7 пунктов меню — до мобильного порога поджимаем отступы,
   чтобы «Обозреватель» не выталкивал кнопки входа за край. */
@media (max-width: 1100px) {
    .header-inner { gap: 14px; }
    .main-nav a { padding: 8px 8px; font-size: 0.9rem; }
}
@media (max-width: 860px) {
    .live-grid { grid-template-columns: 1fr; gap: 12px; }
    .live-updated { margin-left: 0; width: 100%; }
    .hero-fx { display: none; }
    .browser-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    body::after { display: none; }
    .live-status { padding: 14px 14px 12px; }
    .live-value { font-size: 1.45rem; }
}

/* ---------- уважение к настройкам ОС ------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .hero-home,
    .hero-fx::before,
    .hero-fx span,
    .live-dot.is-on,
    .btn-ember::after {
        animation: none !important;
    }
    .hero-fx span { opacity: 0.5; }
}

/* ---------- мобильное кадрирование hero --------------------------------- */
/* От кадра 21:9 на телефоне видно ~27% ширины. По центру в окно попадает
   пустой лес, поэтому смещаем его к лагерю: костёр, выжившие, лачуга. */
@media (max-width: 620px) {
    .hero-art { background-position: 68% center; }
}

