/* Losos World — стили карты. Всё, что относится к интерфейсу, живёт здесь,
   а не в css/ol.css: тот файл принадлежит OpenLayers и может быть перезаписан. */

:root {
    --bg: #11140f;
    --card: rgba(14, 17, 12, 0.84);
    --line: rgba(255, 255, 255, 0.10);
    --text: #f1f4ec;
    --muted: #a3ad9b;
    --accent: #86d15c;
    --accent-ink: #0d1507;
    --danger: #e5685d;
    --font-pixel: "Minecraft", ui-monospace, monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
}

body {
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    image-rendering: pixelated;
}

/* ---------- панель ---------- */

.hud {
    position: fixed;
    z-index: 5;
    top: 16px;
    left: 16px;
    width: min(330px, calc(100vw - 32px));
}

.card {
    padding: 18px 20px 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px) saturate(1.1);
    -webkit-backdrop-filter: blur(10px) saturate(1.1);
}

.brand {
    margin: 0 0 8px;
    font-family: var(--font-pixel);
    font-size: 25px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: 0.5px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    font: inherit;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: 0.02em;
    text-align: left;
    background: none;
    border: 0;
    cursor: pointer;
}

.status:hover .status__text { color: var(--text); }

.status:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* треугольничек-подсказка: счётчик раскрывается */
.status__caret {
    width: 0;
    height: 0;
    flex: 0 0 auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.55;
    transition: transform 0.15s ease;
}

.status[aria-expanded="true"] .status__caret { transform: rotate(180deg); }

/* список тех, кто сейчас в игре — раскрывается под счётчиком */
.players {
    margin: -6px 0 14px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 2px solid var(--accent);
}

.players__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.players__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px 2px 5px;
    font-size: 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

/* Голова игрока: пока картинка не пришла (или сервис не ответил),
   на её месте первая буква ника — место не прыгает. */
.players__avatar {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.players__face,
.players__initial {
    width: 16px;
    height: 16px;
}

/* картинка лежит ПОВЕРХ буквы: пока она не загрузилась (или сервис молчит),
   видно букву. Скрывать img нельзя — браузер тогда вообще не станет грузить
   ленивую картинку и она не появится уже никогда. */
.players__face {
    position: relative;
    z-index: 1;
    display: block;
    image-rendering: pixelated;
}

.players__initial {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    font-size: 9px;
    line-height: 1;
    color: var(--text);
    background: rgba(255, 255, 255, 0.14);
}

.players__empty {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

/* hidden должен побеждать display: flex у списка */
.players[hidden],
.players__list[hidden],
.players__empty[hidden] { display: none; }

.status__dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    background: #5d6457;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.status[data-state="online"] .status__dot {
    background: var(--accent);
    box-shadow: 0 0 9px rgba(134, 209, 92, 0.75);
    animation: pulse 2.4s ease-in-out infinite;
}

.status[data-state="offline"] .status__dot { background: var(--danger); }

@keyframes pulse {
    50% { opacity: 0.55; }
}

/* Время и погода — отдельный блок состояния сервера: у него свой маркер,
   серый ромб (а не зелёный квадрат, как у фактов ниже), и общий межстрочный
   интервал с этим списком. */
.clock,
.weather {
    position: relative;
    margin: 0;
    padding-left: 14px;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.clock::before,
.weather::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 6px;
    height: 6px;
    background: currentColor;
    opacity: 0.6;
    transform: rotate(45deg);
}

.clock__value,
.weather__value { color: var(--text); }

.clock__value {
    font-variant-numeric: tabular-nums;
}

/* Погода: пиксельная иконка 16×16 стоит между подписью и значением —
   «Погода на сервере: ⚡ Гроза». Пока демон не прислал состояние, строки нет. */
.weather { margin-bottom: 6px; }

.weather[data-weather="unknown"] { display: none; }

.weather__icon {
    display: inline-flex;
    vertical-align: -3px;
    margin: 0 2px 0 0;
}

.weather__glyph {
    display: none;
    image-rendering: pixelated;
}

.weather[data-weather="clear"] .weather__glyph[data-glyph="clear"],
.weather[data-weather="rain"] .weather__glyph[data-glyph="rain"],
.weather[data-weather="thunder"] .weather__glyph[data-glyph="thunder"] { display: block; }

/* Ночью «ясно» — это луна, а не солнце. Режим дня/ночи лежит на <body>
   (его ставит PHP при загрузке и js/site.js при переключении карты). */
body[data-map-mode="night"] .weather[data-weather="clear"] .weather__glyph[data-glyph="clear"] { display: none; }
body[data-map-mode="night"] .weather[data-weather="clear"] .weather__glyph[data-glyph="moon"] { display: block; }

.facts {
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    font-size: 12.5px;
    line-height: 1.75;
    color: #cfd7c7;
}

.facts li {
    position: relative;
    padding-left: 14px;
}

.facts li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.66em;
    width: 5px;
    height: 5px;
    background: var(--accent);
    opacity: 0.75;
}

.facts__note { color: var(--muted); }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- кнопки ---------- */

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 14px;
    font-family: var(--font-pixel);
    font-size: 13px;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.35), inset 2px 2px 0 rgba(255, 255, 255, 0.07);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn--primary {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: #4f8a33;
}

.btn--primary:hover { background: #96dd6d; }

/* ---------- переключатель языка ---------- */

.langs {
    display: flex;
    gap: 12px;
    margin: 14px 0 0;
    font-size: 11.5px;
    letter-spacing: 0.04em;
}

.langs a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.langs a:hover {
    color: var(--text);
    border-bottom-color: rgba(255, 255, 255, 0.25);
}

.langs a[aria-current="true"] {
    color: var(--accent);
    border-bottom-color: rgba(134, 209, 92, 0.5);
}

.langs a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.copy {
    appearance: none;
    padding: 5px 9px;
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.copy:hover { background: rgba(255, 255, 255, 0.16); }

.copy:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.copy[data-copied="true"] {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: #4f8a33;
}

/* ---------- диалог подключения ---------- */

.join {
    width: min(430px, calc(100vw - 32px));
    padding: 22px;
    color: var(--text);
    background: #14170f;
    border: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}

.join::backdrop {
    background: rgba(6, 9, 5, 0.72);
    backdrop-filter: blur(2px);
}

.join__title {
    margin: 0 0 18px;
    font-family: var(--font-pixel);
    font-size: 20px;
    font-weight: 400;
}

.join__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.join__label {
    flex: 1 1 100%;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.join__value {
    font-family: var(--font-pixel);
    font-size: 15px;
    letter-spacing: 0.05em;
}

.join__port {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--muted);
}

.join__hint {
    margin: 14px 0 18px;
    font-size: 12px;
    color: var(--muted);
}

.join__close { width: 100%; }

/* ---------- контролы OpenLayers ---------- */

.ol-control {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.ol-zoom {
    top: auto;
    left: auto;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ol-control button {
    width: 38px;
    height: 38px;
    margin: 0;
    font-family: var(--font-pixel);
    font-size: 19px;
    line-height: 1;
    color: var(--text);
    background: rgba(14, 17, 12, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.4), 0 6px 16px -8px rgba(0, 0, 0, 0.9);
}

.ol-control button:hover,
.ol-control button:focus {
    color: var(--accent-ink);
    background: var(--accent);
}

.ol-zoom .ol-zoom-in { border-radius: 0; }
.ol-zoom .ol-zoom-out { border-radius: 0; }

.ol-mouse-position {
    top: 16px;
    right: 16px;
    padding: 7px 10px;
    font-family: var(--font-pixel);
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
    background: rgba(14, 17, 12, 0.75) !important;
    border: 1px solid var(--line);
    border-radius: 0;
}

.ol-mouse-position:empty { display: none; }

.ol-attribution { display: none; }

/* ---------- мобильная раскладка ---------- */

@media (max-width: 720px) {
    .hud {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
    }

    .card {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
        box-shadow: 0 -14px 34px -16px rgba(0, 0, 0, 0.8);
    }

    .brand {
        display: inline;
        margin: 0;
        font-size: 19px;
    }

    .status {
        display: inline-flex;
        margin: 0 0 0 10px;
        vertical-align: baseline;
    }

    .clock { display: none; }

    .facts { display: none; }

    .actions { margin-top: 10px; }
    .actions .btn { flex: 1 1 0; }

    .ol-zoom {
        top: 16px;
        right: 12px;
        bottom: auto;
    }

    .ol-mouse-position { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
