/* =========================================================
   Общий каркас всех страниц: «техбаза UAC».
   Цвета автокарты взяты из am_map.c (REDS, YELLOWS, BROWNS).
   ========================================================= */
:root {
    --steel-950: #12161b;
    --steel-900: #1b2128;
    --steel-800: #262e37;
    --steel-700: #36414d;
    --steel-600: #4a5664;
    --steel-500: #63717f;
    --steel-300: #a4b0bb;
    --bg: #4b5764;
    --plate: #ece7da;
    --plate-2: #f6f2e8;
    --ink: #1f252c;
    --ink-soft: #4a525c;
    --accent: #d9481f;
    --accent-dark: #a8330f;
    --hazard: #f0b72f;
    --am-red: #fc2a2a;
    --am-yellow: #fcfc3a;
    --am-brown: #bf7b4b;
    --am-green: #3fe04a;
    --link: #a8330f;
    --radius: 3px;
    --font-body: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-head: "Arial Black", "Segoe UI Black", Impact, "Helvetica Neue", Arial, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    /* Сетка 128 px — как ячейки BLOCKMAP. */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    background-size: 128px 128px, 128px 128px, 32px 32px, 32px 32px;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
}

a {
    color: var(--link);
}

a:hover {
    color: var(--accent);
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--hazard);
    outline-offset: 2px;
}

img {
    max-width: 100%;
}

code,
kbd {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

code {
    padding: 0 4px;
    background: rgba(31, 37, 44, 0.08);
    border-radius: 2px;
}

kbd {
    padding: 1px 6px;
    border: 1px solid var(--steel-500);
    border-bottom-width: 3px;
    border-radius: 3px;
    background: var(--plate-2);
}

/* ---------- Шапка ---------- */
.site-header {
    position: relative;
    z-index: 50;
    color: #fff;
    background:
        radial-gradient(circle at 10px 10px, #8995a1 0 2px, #202830 2.5px 3.5px, transparent 4px) 0 0 / 40px 100% repeat-x,
        linear-gradient(180deg, #56636f 0%, #3a4551 45%, #2b343e 100%);
    border-bottom: 3px solid #12161b;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

/* Полоса «опасность» под шапкой. */
.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -11px;
    height: 8px;
    background: repeating-linear-gradient(-45deg, var(--hazard) 0 12px, #1b1b1b 12px 24px);
    border-bottom: 1px solid #000;
}

.header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.site-name {
    font-family: var(--font-head);
    font-size: 24px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fff6d6 0%, #f0b72f 45%, #c2621b 55%, #ffd27a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(2px 2px 0 #12161b);
}

.site-sub {
    margin-top: 3px;
    color: #c9d3dc;
    font-size: 14px;
    letter-spacing: 0.3px;
}

/* ---------- Логотип: стрелка игрока с автокарты ----------
   Геометрия повторяет player_arrow из am_map.c: R = 8/16 размера,
   7 отрезков — древко, наконечник и двойное оперение. */
.logo {
    --s: 48px;
    position: relative;
    flex: none;
    width: var(--s);
    height: var(--s);
    overflow: hidden;
    background:
        radial-gradient(circle, rgba(63, 224, 74, 0.18), transparent 70%),
        #0b0e10;
    border: 2px solid #12161b;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px #5d6b7a, 0 2px 0 rgba(0, 0, 0, 0.4);
}

/* Стены автокарты внутри логотипа. */
.logo .wall {
    position: absolute;
    display: block;
}

.logo .wall-red {
    left: 4px;
    top: 4px;
    width: 18px;
    height: 12px;
    border-left: 2px solid var(--am-red);
    border-top: 2px solid var(--am-red);
}

.logo .wall-red2 {
    right: 4px;
    bottom: 4px;
    width: 16px;
    height: 14px;
    border-right: 2px solid var(--am-red);
    border-bottom: 2px solid var(--am-red);
}

.logo .wall-yellow {
    right: 4px;
    top: 4px;
    width: 12px;
    height: 0;
    border-top: 2px solid var(--am-yellow);
}

.logo .wall-brown {
    left: 4px;
    bottom: 4px;
    width: 0;
    height: 12px;
    border-left: 2px solid var(--am-brown);
}

.logo .arrow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    transform: rotate(-30deg);
    transition: transform 0.6s cubic-bezier(0.5, -0.4, 0.4, 1.4);
}

.logo .arrow i {
    position: absolute;
    left: 50%;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: var(--am-green);
    border-radius: 1px;
    box-shadow: 0 0 4px rgba(63, 224, 74, 0.8);
    transform-origin: 0 50%;
}

/* R = 16 px. Координаты концов отрезков — как в исходнике. */
.logo .arrow .shaft {
    left: calc(50% - 14px);
    width: 30px;
}

.logo .arrow .head-1,
.logo .arrow .head-2 {
    left: calc(50% + 16px);
    width: 9px;
    transform: rotate(153deg);
}

.logo .arrow .head-2 {
    transform: rotate(207deg);
}

.logo .arrow .tail-1,
.logo .arrow .tail-2 {
    left: calc(50% - 14px);
    width: 6px;
    transform: rotate(135deg);
}

.logo .arrow .tail-2 {
    transform: rotate(225deg);
}

.logo .arrow .tail-3,
.logo .arrow .tail-4 {
    left: calc(50% - 10px);
    width: 6px;
    transform: rotate(135deg);
}

.logo .arrow .tail-4 {
    transform: rotate(225deg);
}

.brand:hover .logo .arrow,
.brand:focus-visible .logo .arrow {
    transform: rotate(330deg);
}

/* ---------- Навигация и меню «Работы» ---------- */
.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.main-nav > a,
.works-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 6px 14px;
    color: #fff;
    font: 700 15px/1 var(--font-body);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    text-decoration: none;
    background: linear-gradient(180deg, #4d5966, #2a323b);
    border: 1px solid #12161b;
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    cursor: pointer;
}

.main-nav > a:hover,
.works-btn:hover,
.main-nav > a[aria-current="page"] {
    color: #fff;
    background: linear-gradient(180deg, #e0612f, #a8330f);
}

.works {
    position: relative;
}

.works-btn .caret {
    display: inline-block;
    transition: transform 0.2s;
}

.works-btn[aria-expanded="true"] .caret {
    transform: rotate(180deg);
}

.works-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    min-width: 260px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--steel-900);
    border: 2px solid #0b0e10;
    border-top: 3px solid var(--hazard);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.works-menu[hidden] {
    display: none;
}

.works-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: #e8edf2;
    text-decoration: none;
    border-radius: 2px;
}

.works-menu a:hover,
.works-menu a:focus-visible,
.works-menu a[aria-current="page"] {
    color: #fff;
    background: var(--steel-700);
}

.works-menu b {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    color: #12161b;
    background: var(--hazard);
    font-family: var(--font-head);
    font-size: 14px;
    border-radius: 2px;
}

.works-menu small {
    display: block;
    color: var(--steel-300);
    font-size: 12px;
    line-height: 1.2;
}

/* ---------- Основная часть страниц заданий ---------- */
main {
    flex-grow: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 40px 20px 48px;
}

.content {
    padding: 28px 32px;
    background: var(--plate);
    border: 2px solid var(--steel-900);
    border-radius: var(--radius);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 16px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px dashed rgba(31, 37, 44, 0.25);
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    color: #12161b;
    background: var(--hazard);
    font: 700 13px/1.4 var(--font-mono);
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 2px;
}

h1,
h2,
h3 {
    font-family: var(--font-head);
    line-height: 1.2;
    letter-spacing: 0.2px;
}

h1 {
    margin: 0;
    font-size: 30px;
}

h2 {
    margin: 30px 0 12px;
    font-size: 22px;
}

h3 {
    margin: 22px 0 8px;
    font-size: 18px;
}

p {
    margin: 0 0 14px;
}

.lead {
    font-size: 19px;
    color: var(--ink-soft);
}

/* Картинка внутри текста: обтекание. */
.figure {
    margin: 6px 0 16px;
    padding: 8px;
    background: var(--steel-900);
    border: 2px solid #0b0e10;
    border-radius: var(--radius);
    color: #d6dde4;
}

.figure img {
    display: block;
    width: 100%;
    height: auto;
    background: #000;
    image-rendering: pixelated;
}

.figure img.smooth {
    image-rendering: auto;
}

.figure figcaption {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.4;
}

.figure.right {
    float: right;
    width: min(44%, 420px);
    margin-left: 22px;
}

.figure.left {
    float: left;
    width: min(44%, 420px);
    margin-right: 22px;
}

.clear {
    clear: both;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.gallery .figure {
    margin: 0;
}

.note {
    margin: 16px 0;
    padding: 12px 16px;
    background: rgba(240, 183, 47, 0.18);
    border-left: 5px solid var(--hazard);
}

/* Сцена с работой на странице задания. */
.work-stage {
    display: flex;
    justify-content: center;
    margin: 8px 0 28px;
    padding: 24px;
    overflow-x: auto;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(240, 183, 47, 0.12), transparent 70%),
        var(--steel-900);
    border: 2px solid #0b0e10;
    border-radius: var(--radius);
}

.file-tree {
    margin: 0 0 16px;
    padding: 14px 16px;
    overflow-x: auto;
    color: #d6e2d0;
    background: #0e1216;
    border-left: 4px solid var(--hazard);
    font: 14px/1.5 var(--font-mono);
}

.palette {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

.palette span {
    padding: 22px 10px 10px;
    color: #fff;
    border: 2px solid #0b0e10;
    font: 13px/1.3 var(--font-mono);
}

/* ---------- Статус-бар (footer) ---------- */
.statusbar {
    position: relative;
    z-index: 40;
    color: #e9e2cf;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
        repeating-linear-gradient(90deg, #4f4f4f 0 2px, #5a5a5a 2px 4px),
        #555;
    border-top: 3px solid #1a1a1a;
    box-shadow: inset 0 2px 0 #8a8a8a;
}

.statusbar.sticky {
    position: sticky;
    bottom: 0;
}

.sb-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 6px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 6px;
}

.sb-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 4px 10px;
    background: #3d3d3d;
    border: 2px solid;
    border-color: #262626 #7a7a7a #7a7a7a #262626;
}

.sb-label {
    margin-top: 2px;
    color: #d8cfb6;
    font: 700 11px/1 var(--font-mono);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Цифры статус-бара — шрифт STTNUM из WAD, 12 ячеек по 13×16. */
.sb-num {
    display: inline-flex;
    height: 32px;
}

.sb-num .d {
    display: inline-block;
    width: 26px;
    height: 32px;
    background: url("../images/freedoom/sttnum.png") 0 0 / 312px 32px no-repeat;
    image-rendering: pixelated;
}

.sb-arms {
    min-width: 130px;
}

.sb-arms .arms {
    display: grid;
    grid-template-columns: repeat(4, 22px);
    gap: 2px 6px;
}

.sb-arms a {
    display: block;
    color: #8d8d8d;
    font: 700 16px/20px var(--font-mono);
    text-align: center;
    text-decoration: none;
}

.sb-arms a.owned,
.sb-arms a:hover {
    color: var(--hazard);
}

.sb-arms a[aria-current="page"] {
    color: #fff;
    background: #262626;
}

.sb-face {
    display: grid;
    place-items: center;
    width: 76px;
    background: #262626;
    border: 2px solid;
    border-color: #1a1a1a #6a6a6a #6a6a6a #1a1a1a;
}

.sb-face img {
    display: block;
    width: 48px;
    height: 58px;
    image-rendering: pixelated;
}

.sb-author {
    flex: 1 1 200px;
    align-items: flex-start;
    color: #e9e2cf;
    font-size: 14px;
    line-height: 1.35;
}

.sb-author p {
    margin: 0;
}

.sb-author a {
    color: var(--hazard);
}

/* ---------- Переход «melt» ---------- */
.melt-canvas {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

/* ---------- Адаптив ---------- */
@media (max-width: 760px) {
    body {
        font-size: 16px;
    }

    .header-inner {
        padding: 12px 16px;
    }

    .site-name {
        font-size: 20px;
    }

    main {
        padding: 28px 16px 36px;
    }

    .content {
        padding: 20px 16px;
    }

    .figure.right,
    .figure.left {
        float: none;
        width: 100%;
        margin: 8px 0 16px;
    }

    .works-menu {
        left: 0;
        right: auto;
    }

    .statusbar.sticky {
        position: relative;
    }

    .sb-cell {
        min-width: 80px;
    }

    .sb-face {
        width: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
