/* Ретро-дизайн «Игротека» по макету Pixso «Игротека - Ретро» (547×700).
   Палитра фиксирована макетом: красный, золотой, синий, зелёный, чёрный,
   кремовый фон и фиолетовое свечение теней. */

:root {
    --ink: #000000;
    --paper: #fff8e7;
    --white: #ffffff;
    --red: #e8001c;
    --gold: #ffd700;
    --blue: #0066cc;
    --green: #00a651;
    --green-bright: #00a652;
    --text: #333333;
    --placeholder: #999999;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Страница — вертикальный flex-поток: секции разделяет общий gap,
   внешние margin у секций не нужны. */
body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 978px;
    margin: 0 auto;
    padding: 2rem 0.5rem;
    font-family: Inter, system-ui, sans-serif;
    color: var(--text);
    background-color: var(--paper);
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
    background-attachment: fixed;
}

button {
    /* Кнопки не наследуют шрифт по умолчанию. */
    font: inherit;
}

/* Firefox добавляет внутренний отступ вокруг текста кнопки */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Скроллбар в стилистике проекта: кремовый трек, золотой ползунок,
   чёрные рамки. Firefox умеет только цвета стандартных свойств,
   Chrome/Safari получают полную стилизацию через псевдоэлементы. */
@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-color: var(--gold) var(--paper);
    }
}

::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-track {
    background: var(--paper);
    border: 2px solid var(--ink);
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border: 2px solid var(--ink);
}

/* Ховер — как у кнопок: тот же оттенок, что даёт brightness(1.08). */
::-webkit-scrollbar-thumb:hover {
    background: #ffe800;
}

::-webkit-scrollbar-corner {
    background: var(--paper);
}

/* Шапка: красная панель с золотым брендом и кнопкой навигации */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    min-height: 56px;
    padding: 0 16px;
    background: var(--red);
    border: 1px solid var(--ink);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 2px;
    line-height: 1;
    text-transform: uppercase;
    color: var(--gold);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 1rem;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--gold);
    border: 3px solid var(--ink);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(128, 63, 255, 0.5);
    transition: filter 0.15s ease;
}

.nav-link:hover {
    filter: brightness(1.08);
}

/* В макете у кнопки одно состояние — активный пункт остаётся золотым. */
.nav-link.active {
    background: var(--gold);
    color: var(--ink);
}

/* Заголовок страницы: панель в общей стилистике — белый фон,
   чёрная рамка и фиолетовое свечение, как у остальных секций. */
.page-head {
    padding: 8px 16px;
    background: #ffffff;
    border: 2px solid var(--ink);
    box-shadow: 0 4px 16px rgba(128, 63, 255, 0.1);
}

.page-head h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--red);
}

.page-sub {
    font-size: 12px;
    color: var(--ink);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Форма добавления игры: синяя панель с чёрной рамкой 4px */
.game-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: var(--blue);
    border: 4px solid var(--ink);
    box-shadow: 0 4px 20px rgba(128, 63, 255, 0.12);
}

.game-form h2 {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold);
    /*-webkit-text-stroke: 1px var(--paper);*/
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
}

.required {
    color: var(--gold);
    font-weight: 900;
}

.game-input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #ffffff;
    border: 2px solid var(--ink);
    outline: none;
}

.game-input::placeholder {
    color: var(--placeholder);
}

.game-input:focus {
    box-shadow: 0 0 0 3px rgba(128, 63, 255, 0.3);
}

/* Нативная стрелка select прижата к правому краю и не слушается padding —
   рисуем свою стрелку с контролируемым отступом. */
select.game-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.25rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.75rem;
}

/* Наведение — как фокус, но слабее: поле «отзывается» ещё до клика. */
select.game-input:hover {
    box-shadow: 0 0 0 3px rgba(128, 63, 255, 0.2);
}

/* Раскрытый список — в палитре проекта, а не системно-белый. */
select.game-input option {
    background: var(--white);
    color: var(--text);
    font: inherit;
}

.alert {
    margin-top: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    color: #ffffff;
    background: var(--red);
    border: 2px solid var(--ink);
    text-transform: uppercase;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.game-add {
    padding: 8px 1rem;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--gold);
    border: 3px solid var(--ink);
    box-shadow: 0 3px 10px rgba(128, 63, 255, 0.4);
    cursor: pointer;
    transition: filter 0.15s ease;
}

.game-add:hover {
    filter: brightness(1.08);
}

.game-add:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* «Сохранить» в диалоге редактирования: та же форма, что у .game-add,
   но со своим цветом, чтобы не менять общий класс. */
.dialog-save {
    background: var(--red);
}

/* Импорт/экспорт: единая зелёная панель с двумя одинаковыми кнопками —
   «Загрузить список» слева и «Скачать список» справа. */
.transfer-card {
    padding: 8px 16px;
    background: var(--green);
    border: 3px solid var(--ink);
    box-shadow: 0 4px 16px rgba(128, 63, 255, 0.1);
}

.transfer-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
}

/* File-input скрыт: видна только кнопка-лейбл «Загрузить список»,
   имя выбранного файла не показывается. */
.import-file {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Обе кнопки блока — одна форма: золото с чёрной рамкой. Класс общий
   для лейбла импорта и ссылки экспорта. */
.transfer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 8px 0.9rem;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--gold);
    border: 3px solid var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.transfer-btn:hover {
    filter: brightness(1.08);
}

/* Фокус скрытого input подсвечивает кнопку-лейбл. */
.transfer-btn:has(input:focus-visible) {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Список пуст — скачивать нечего: кнопка «гаснет». */
.transfer-btn-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.transfer-btn-disabled:hover {
    filter: none;
}

/* Селект «Выгрузить»: выглядит как кнопка; стрелка — SVG-фоном, как у
   select.game-input, но чёрным штрихом под рамку кнопки. */
.transfer-export {
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    field-sizing: content;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.75rem;
}

/* Раскрытый список — в палитре проекта и обычным регистром:
   uppercase кнопки не должен перекрашивать варианты формата. */
.transfer-export option {
    background: var(--white);
    color: var(--text);
    font: inherit;
    text-transform: none;
}

/* Кнопка «Очистить список» — деструктивное действие: красная в тон
   панели ошибок, белый текст для контраста. */
.transfer-clear {
    color: var(--white);
    background: var(--red);
}

/* Секции списка: экспорт, шапка таблицы и строки — один вертикальный поток. */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Поиск по списку: нейтральная белая панель в общей стилистике секций,
   чтобы не спорить с цветными панелями формы и экспорта. */
.search-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px;
    background: #ffffff;
    border: 2px solid var(--ink);
    box-shadow: 0 4px 16px rgba(128, 63, 255, 0.1);
}

.search-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--red);
}

/* Строка поиска: поле тянется, кнопка «Найти» прижата справа. */
.search-row {
    display: flex;
    gap: 8px;
}

.search-row .game-input {
    flex: 1;
    min-width: 0;
    height: 44px;
}

/* Кнопка «Найти»: золото и чёрная рамка, как у остальных кнопок;
   высота 44px — комфортная цель и для мыши, и для пальца
   (рекомендация Apple HIG / WCAG). */
.search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 44px;
    padding: 0 1rem;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--green-bright);
    border: 3px solid var(--ink);
    box-shadow: 0 3px 10px rgba(128, 63, 255, 0.4);
    cursor: pointer;
    transition: filter 0.15s ease;
}

/* Иконки «Найти» и «Сортировка»: видны только на мобильных. */
.search-btn-icon,
.sort-icon {
    display: none;
}

/* Обёртка селекта сортировки: на мобильных она же — визуальная кнопка,
   внутри которой лежит иконка текущего варианта. */
.sort-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-btn:hover,
.sort-select:hover {
    filter: brightness(1.08);
}

/* Селект «Сортировка»: выглядит как кнопка в ряду поиска; стрелка —
   SVG-фоном (как у select.game-input), цвета — по кнопке «Найти».
   Опции выпадающего списка стилизует UA, поэтому текст тёмный на белом. */
.sort-select {
    flex-shrink: 0;
    height: 44px;
    padding: 0 2.25rem 0 1rem;
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--paper);
    background-color: var(--green-bright);
    border: 3px solid var(--ink);
    box-shadow: 0 3px 10px rgba(128, 63, 255, 0.4);
    cursor: pointer;
    transition: filter 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23fff8e7' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.75rem;
}

.sort-select option {
    background: var(--white);
    color: var(--text);
    font: inherit;
}

/* Шапка и строки таблицы — один flex-ряд с одинаковыми пропорциями колонок. */
.table-head,
.note-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 16px;
}

.notes-count {
    font-size: 0.875rem;
    color: var(--text);
}

.notes-count::before {
    content: "(";
}

.notes-count::after {
    content: ")";
}

.col-title,
.note-title {
    flex: 1.35;
}

.col-platform,
.note-platform {
    flex: 1.65;
}

.col-video,
.note-video-cell {
    flex-shrink: 0;
    width: 40px;
}

.col-actions,
.note-actions {
    flex-shrink: 0;
    width: 180px;
}

/* Шапка таблицы: чёрная полоса с золотыми заголовками */
.table-head {
    min-height: 36px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--gold);
    background: var(--ink);
}

.table-head .col-title,
.table-head .col-video,
.table-head .col-platform,
.table-head .col-actions {
    font-weight: 900;
    letter-spacing: 1px;
}

.table-head .col-video {
    text-align: center;
}

.table-head .col-actions {
    text-align: right;
}

/* Список игр */
.note-list {
    display: flex;
    flex-direction: column;
    list-style: none;
}

.note-item {
    min-height: 48px;
    background: #ffffff;
    border: 2px solid rgba(0, 0, 0, 0.15);
}

/* Зебра как в макете: белая, кремовая, белая... */
.note-item:nth-child(even) {
    background: var(--paper);
}

/* Разделитель между строками один: нижнюю рамку рисует следующая строка. */
.note-item:not(:last-child) {
    border-bottom: none;
}

.note-title {
    min-width: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    /* Название не сокращается: длинные переносятся на новую строку,
       а строка таблицы растёт вместе с текстом. */
    overflow-wrap: anywhere;
}

.note-platform {
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
}

.note-video-cell {
    display: flex;
    justify-content: center;
}

/* Ссылка на видео: текст «▶» и SVG-иконки центрируются в клетке одинаково. */
.note-video {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    color: var(--green-bright);
    text-decoration: none;
    transition: filter 0.15s ease;
}

.note-video:hover {
    filter: brightness(1.2);
}

/* Брендовые цвета иконок видео: YouTube — красный, Steam — тёмно-синий.
   Иконки красятся через currentColor, цвет задаёт класс ссылки. */
.note-video-youtube {
    color: var(--red);
}

.note-video-steam {
    color: #1b2838;
}

.note-video-none {
    font-size: 18px;
    font-weight: 900;
    color: rgba(0, 0, 0, 0.25);
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.note-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ffffff;
    border: 3px solid var(--ink);
    cursor: pointer;
    transition: filter 0.15s ease;
}

.note-edit {
    background: var(--blue);
}

.note-delete {
    background: var(--red);
}

.note-action:hover {
    filter: brightness(1.15);
}

/* Иконка кнопки действия: видна только на мобильных. */
.note-action-icon {
    display: inline;
    font-size: 12px;
    line-height: 1;
}

/* На мобильных в кнопках действий остаются только иконки. */
@media (max-width: 480px) {
    .transfer-row {
        justify-content: space-evenly;
    }
    .transfer-title {
        display: none;
    }
    .table-head,
    .note-item {
        gap: 0.5rem;
    }

    .col-title,
    .note-title {
        flex: 1.2;
    }

    .col-platform,
    .note-platform {
        flex: 1.4;
    }

    .col-video,
    .note-video-cell {
        width: 32px;
    }

    .col-actions,
    .note-actions {
        width: 70px;
    }

    /* Заголовок колонки скрыт, но место под кнопки сохраняется. */
    .table-head .col-actions {
        visibility: hidden;
    }

    /* Подпись скрыта визуально, но остаётся доступной скринридерам. */
    .note-action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* «Найти» и «Сортировка»: вместо надписей — иконки. Свой брейкпоинт
   (600px) — переключается уже на планшетах, а не только на телефонах. */
@media (max-width: 600px) {
    /* Кнопка сжимается до квадрата 44×44 — та же цель для пальца. */
    .search-btn {
        width: 44px;
        padding: 0;
    }

    .search-btn-icon {
        display: inline;
        font-size: 18px;
        line-height: 1;
    }

    /* Подпись кнопки скрыта визуально, но остаётся скринридерам. */
    .search-btn-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    /* «Сортировка»: вместо надписи — иконка выбранного варианта.
       Селект остаётся нативным, но прозрачным поверх обёртки-кнопки:
       тап по иконке попадает в селект и открывает системный список. */
    .sort-wrap {
        width: 44px;
        height: 44px;
        background: var(--green-bright);
        border: 3px solid var(--ink);
        box-shadow: 0 3px 10px rgba(128, 63, 255, 0.4);
    }

    .sort-select {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
    }

    .sort-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        line-height: 1;
        color: var(--paper);
    }

    /* Бинд `:hidden` ставит атрибут, но display: inline-flex его перебивает. */
    .sort-icon[hidden] {
        display: none;
    }

    /* Ховер и фокус — по обёртке: сам селект невидим. */
    .sort-wrap:hover {
        filter: brightness(1.08);
    }

    .sort-wrap:focus-within {
        outline: 2px solid var(--gold);
        outline-offset: 2px;
    }
}

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--paper);
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    backdrop-filter: blur(10px);
}

/* Фон модальных окон: диалоги — его соседи (не вложены), чтобы клик
   внутри них не всплывал до фона и не закрывал окно. */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

/* `:hidden` ставит атрибут, но display: flex перебивает UA-правило — скрываем явно */
.dialog-backdrop[hidden] {
    display: none;
}

/* Общий каркас модальных окон: синяя панель, центрированная поверх фона */
.edit-dialog,
.video-dialog,
.clear-dialog {
    /* UA-стили dialog позиционируют его абсолютно у верха и красят текст
       в CanvasText — перекрываем полностью. */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 21;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    width: calc(100% - 2rem);
    color: inherit;
    background: var(--ink);
    border: 4px solid var(--red);
    box-shadow: 0 4px 20px rgba(128, 63, 255, 0.25);
}

.edit-dialog {
    max-width: 36rem;
}

.video-dialog {
    max-width: 64rem;
}

.clear-dialog {
    max-width: 26rem;
}

/* Атрибут hidden не прячет элемент с собственным display: flex — скрываем
   явно (UA-правило dialog:not([open]) тоже проигрывает авторскому flex). */
.edit-dialog[hidden],
.video-dialog[hidden],
.clear-dialog[hidden] {
    display: none;
}

.edit-dialog h2,
.video-dialog-header h2,
.clear-dialog h2 {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--paper);
}

/* Текст предупреждения об очистке — читаемый на тёмной панели диалога. */
.clear-dialog-text {
    font-size: 14px;
    color: var(--paper);
}

.video-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Длинное название не должно раздвигать заголовок или выталкивать кнопку. */
.video-dialog-header h2 {
    min-width: 0;
    flex: 1;
    overflow-wrap: anywhere;
}

.video-close {
    flex-shrink: 0;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Кадр 16:9, чёрная подложка под полосами леттербокса. */
.video-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--ink);
    border-radius: 4px;
    overflow: hidden;
}

.video-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Строка действий: кнопки прижаты к правому краю. */
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.dialog-cancel,
.video-close {
    padding: 8px 1rem;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    background: var(--gold);
    border: 3px solid var(--ink);
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-transform: uppercase;
}

.dialog-cancel {
    background: var(--paper);
}

.dialog-cancel:hover,
.video-close:hover {
    background: #f5ead2;
}

/* Видимый фокус с клавиатуры */
.game-add:focus-visible,
.dialog-cancel:focus-visible,
.video-close:focus-visible,
.note-action:focus-visible,
.transfer-btn:focus-visible,
.nav-link:focus-visible,
.brand:focus-visible,
.note-video:focus-visible,
.search-btn:focus-visible,
.sort-select:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
