/* =========================================================
   ЦВЕТА
========================================================= */

:root {
  --gradient-start: #0c0c0e;
  --gradient-end: #0f1515;
  --light: #206c62;
  --text-color: #c3c9c8;
  --accent-color: #e8f0ee;
  --accent-shadow: rgba(0, 0, 0, 0);
  --card-bg: rgba(25, 50, 46, 0.4);
  --border-color: #206c62;
  --subcategory-bg: rgba(45, 212, 191, 0.1);
  --coordinate-bg: #0f1515;
  --input-bg: rgba(29, 59, 54, 0.8);
  --table-header-bg: rgba(29, 59, 54, 0.9);
  --table-row-hover: rgba(32, 108, 98, 0.1);
  --footer-color: #206c62;
  --item-image-bg: rgba(32, 108, 98, 0.2);
  --category-bg: rgba(32, 108, 98, 0);
  --category-border: #14b8a6;
  --sidebar-width: 270px;
  --header-height: 82px;
  --transition: 180ms ease;
}

/* =========================================================
   ОБЩИЕ СТИЛИ
========================================================= */

* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: Inter, Arial, sans-serif;
  color: var(--text-color);
  background:
    radial-gradient(circle at top right, rgba(32, 108, 98, 0.15), transparent 35%),
    linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}

/* =========================================================
   ЛЕВАЯ ПАНЕЛЬ
========================================================= */

.sidebar {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(12, 18, 18, 0.96);
  border-right: 1px solid rgba(32, 108, 98, 0.5);
  backdrop-filter: blur(20px);
}
.sidebar-content {
  flex: 1;
  padding: 24px 24px 30px;
  overflow-y: auto;
}
.navigation {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.navigation-title {
  color: var(--category-border);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.navigation ul {
  padding: 0;
  margin: 0;
  list-style: none;
}
.navigation a {
  display: block;
  padding: 11px 14px;
  color: var(--text-color);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

/* =========================================================
   ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКА
========================================================= */

.language-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 5px;
}
.language-button {
  padding: 9px 5px;
  color: var(--text-color);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  transition: var(--transition);
}
.language-button:hover {
  color: var(--accent-color);
  border-color: var(--category-border);
}
.language-button.active {
  color: #071211;
  background: var(--category-border);
  border-color: var(--category-border);
}

/* =========================================================
   ФУТЕР
========================================================= */

.sidebar-footer {
  padding: 20px 24px;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(195, 201, 200, 0.55);
  border-top: 1px solid rgba(32, 108, 98, 0.4);
}
.sidebar-footer p {
  margin: 2px 0;
}
.sidebar-footer a {
  display: inline-block;
  margin-top: 6px;
  color: var(--footer-color);
  text-decoration: none;
}
.sidebar-footer a:hover {
  color: var(--category-border);
}

/* =========================================================
   ОСНОВНОЕ ПРИЛОЖЕНИЕ
========================================================= */

.application {
  height: 100vh;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

/* =========================================================
   ХЕДЕР
========================================================= */

.header {
  position: relative;
  z-index: 20;
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 0 35px;
  background: rgba(12, 18, 18, 0.88);
  border-bottom: 1px solid rgba(32, 108, 98, 0.5);
  backdrop-filter: blur(20px);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 250px;
}
.logo {
  width: 43px;
  height: 43px;
  object-fit: contain;
}
.header h1 {
  margin: 0;
  color: var(--accent-color);
  font-size: 18px;
  font-weight: 700;
}
.header p {
  margin: 3px 0 0;
  color: rgba(195, 201, 200, 0.55);
  font-size: 11px;
}

/* =========================================================
   КНОПКА МОБИЛЬНОГО МЕНЮ
========================================================= */

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}
.menu-button span {
  display: block;
  width: 100%;
  height: 2px;
  margin: 4px 0;
  background: var(--accent-color);
  border-radius: 5px;
}

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

.search-container {
  position: relative;
  width: min(500px, 48vw);
}
.search-container input {
  width: 100%;
  height: 44px;
  padding: 0 44px;
  color: var(--accent-color);
  background: var(--input-bg);
  outline: none;
  border: 1px solid var(--border-color);
  border-radius: 9px;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
.search-container input::placeholder {
  color: rgba(195, 201, 200, 0.45);
}
.search-container input:focus {
  border-color: var(--category-border);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}
.search-icon {
  position: absolute;
  z-index: 2;
  top: 13px;
  left: 15px;
  width: 18px;
  height: 18px;
  fill: var(--text-color);
  pointer-events: none;
}
.clear-search {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: none;
  color: var(--text-color);
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 21px;
}
.clear-search.visible {
  display: block;
}
.clear-search:hover {
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.06);
}

/* =========================================================
   ПРОКРУЧИВАЕМЫЙ КАТАЛОГ
========================================================= */

.catalogue {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 40px;
  scroll-behavior: smooth;
}
.catalogue::-webkit-scrollbar {
  width: 10px;
}
.catalogue::-webkit-scrollbar-track {
  background: var(--gradient-start);
}
.catalogue::-webkit-scrollbar-thumb {
  background: var(--light);
  border: 3px solid var(--gradient-start);
  border-radius: 20px;
}
.catalogue-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto 40px;
}
.section-label {
  color: var(--category-border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.catalogue-header h2 {
  margin: 8px 0 0;
  color: var(--accent-color);
  font-size: clamp(25px, 3vw, 38px);
}
.navigation li,
.item-counter {
  padding: 9px 14px;
  color: var(--text-color);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  font-size: 12px;
}
.navigation li {
  margin: 4px 0;
  font-size: 16px;
  padding: 5px;
}
.navigation li:hover {
  color: var(--accent-color);
  background: var(--subcategory-bg);
  border-color: rgba(20, 184, 166, 0.25);
}

/* =========================================================
   КАТЕГОРИИ
========================================================= */

.categories-container {
  max-width: 1500px;
  margin: auto;
}
.category-section {
  margin-bottom: 55px;
}
.category-title {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 0 0 18px;
  color: var(--accent-color);
  font-size: 20px;
}
.category-title::before {
  content: "";
  width: 4px;
  height: 25px;
  background: var(--category-border);
  border-radius: 10px;
}
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 72px));
  gap: 13px;
  align-items: center;
}

/* =========================================================
   КАРТОЧКА ПРЕДМЕТА
========================================================= */

.item-card {
  position: relative;
  width: 72px;
  height: 72px;
  place-items: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  overflow: visible;
  transition:
    transform 160ms ease,
    opacity 180ms ease,
    filter 180ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  contain: layout style;
}
.item-card::before {
  content: "";
  position: absolute;
  z-index: 0;
  width: 104px;
  height: 104px;
  background: url("../assets/item-glow.svg") center / contain no-repeat;
  border-radius: 50%;
  opacity: 0.75;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}
.item-card:hover {
  z-index: 5;
  transform: scale(1.16);
}
.item-card:hover::before {
  opacity: 1;
  transform: scale(1.35);
}

.loading.hidden{

    display:none;

}

/* =========================================================
   ИЗОБРАЖЕНИЕ ИЗ АТЛАСА
========================================================= */

.item-image {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  display: block;
  position: relative;
}
.item-image::before,
.item-image::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
}
.item-image::before {
  z-index: 0;
  top: 50%;
  left: 50%;
  width: 104px;
  height: 104px;
  background-image: var(--shadow-atlas-image);
  background-size: var(--shadow-atlas-size);
  background-position: var(--shadow-atlas-position);
  image-rendering: auto;
  opacity: 1;
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease;
}
.item-image::after {
  z-index: 1;
  inset: 0;
  background-image: var(--item-atlas-image);
  background-size: var(--item-atlas-size);
  background-position: var(--item-atlas-position);
  image-rendering: pixelated;
  transition: filter 160ms ease;
}
.item-card:hover .item-image::before {
  opacity: 0;
}
.item-card:hover .item-image::after {
  filter: drop-shadow(0 0 5px rgba(20, 184, 166, 0.75));
}
.catalogue.is-scrolling .item-card:hover {
  z-index: auto;
  transform: none;
}
.catalogue.is-scrolling .item-card:hover::before {
  opacity: 0.75;
  transform: none;
}
.catalogue.is-scrolling .item-card:hover .item-image::before {
  opacity: 1;
  transition: none;
}
.catalogue.is-scrolling .item-card:hover .item-image::after {
  filter: none;
  transition: none;
}
.catalogue.is-scrolling .item-card.match:hover {
  z-index: 3;
  transform: scale(1.1);
}
.catalogue.is-scrolling .item-card.match:hover::before {
  opacity: 1;
}

/* =========================================================
   ПРЕДМЕТ, ОТСУТСТВУЮЩИЙ В АТЛАСЕ
========================================================= */

.item-card.atlas-missing {
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255, 80, 80, 0.5);
}
.item-card.dimmed {
  opacity: 0.12;
  filter: grayscale(1);
  transform: scale(0.82);
  pointer-events: none;
}
.item-card.match {
  z-index: 3;
  transform: scale(1.1);
}
.item-image {
  z-index: 1;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 6px;
}
.item-card.match::before {
  width: 144px;
  height: 144px;
  opacity: 1;
  background-image: url("../assets/item-glow-match.svg");
}
.item-image img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 160ms ease;
}
.item-name {
  display: none;
}

/* =========================================================
   ЗАГРУЗКА
========================================================= */

.loading {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
}
.loader {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(32, 108, 98, 0.3);
  border-top-color: var(--category-border);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}
@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   МОДАЛЬНОЕ ОКНО
========================================================= */

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open {
  display: flex;
}
.modal-background {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(7px);
}
.modal-content {
  position: relative;
  z-index: 2;
  width: min(480px, 100%);
  overflow: hidden;
  background: #101918;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: modalAppear 180ms ease;
}
@keyframes modalAppear {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-close {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  color: var(--accent-color);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 23px;
}
.modal-image-container {
  height: 230px;
  display: grid;
  place-items: center;
  padding: 35px;
  background: radial-gradient(circle, rgba(32, 108, 98, 0.3), transparent 70%);
}
.modal-image-container img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  image-rendering: pixelated;
}
.modal-information {
  padding: 25px;
}
.modal-category {
  display: inline-block;
  padding: 5px 9px;
  color: var(--category-border);
  background: var(--subcategory-bg);
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.modal-information h2 {
  margin: 14px 0 22px;
  color: var(--accent-color);
  font-size: 25px;
}
.information-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-top: 1px solid rgba(32, 108, 98, 0.3);
  font-size: 13px;
}
.information-row span {
  color: rgba(195, 201, 200, 0.55);
}
.information-row code {
  color: var(--category-border);
  background: transparent;
}
.wiki-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 13px 15px;
  color: #071211;
  background: var(--category-border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

/* =========================================================
   МОБИЛЬНАЯ ВЕРСИЯ
========================================================= */

.mobile-overlay {
  display: none;
}
@media (max-width: 850px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-overlay {
    position: fixed;
    z-index: 40;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
  }
  .mobile-overlay.visible {
    display: block;
  }
  .application {
    margin-left: 0;
  }
  .menu-button {
    display: block;
  }
  .header {
    padding: 0 18px;
    gap: 15px;
  }
  .header-brand {
    min-width: auto;
  }
  .header-brand p {
    display: none;
  }
  .header h1 {
    display: none;
  }
  .search-container {
    width: min(500px, 75vw);
  }
  .catalogue {
    padding: 25px 18px;
  }
  .catalogue-header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 28px;
  }
  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
    gap: 9px;
  }
}
@media (max-width: 430px) {
  .logo {
    width: 35px;
    height: 35px;
  }
  .menu-button {
    width: 38px;
    height: 38px;
  }
  .search-container input {
    height: 40px;
  }
  .items-grid {
    grid-template-columns: repeat(3, 1fr);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
  }
  .modal {
    padding: 10px;
  }
  .modal-image-container {
    height: 180px;
  }
  .modal-image-container img {
    width: 120px;
    height: 120px;
  }
}
