/* ===================================================================
   Меморіал Полеглих — темне кіно-фентезі
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=IM+Fell+English+SC&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  --ink: #0a0d14;
  --parchment: #e8dcc0;
  --parchment-dark: #c9b896;
  --gold: #b8893a;
  --gold-bright: #d4a854;
  --blood: #6b1f1f;
  --frost: #8fa9c4;
  --panel-bg: rgba(12, 15, 22, 0.94);
  --panel-border: rgba(143, 169, 196, 0.25);

  --font-display: 'IM Fell English SC', 'Cormorant Garamond', serif;
  --font-body: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
}

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

html,
body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--parchment);
  background: #060810;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  cursor: default;
}

/* ===================================================================
   Сцена
   =================================================================== */
.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* Фон-кадр. Трохи більший за екран щоб був простір для паралакс-зсуву. */
.scene-bg {
  position: absolute;
  inset: -4%;
  background-image: url('../assets/city-bg.png');
  background-size: cover;
  background-position: center center;
  /* Початковий стан — буде зсуватись через JS (паралакс). */
  transform: translate3d(0, 0, 0) scale(1.08);
  transition: transform 0.2s ease-out;
  will-change: transform;
}

/* Кольорокорекція — підсилюємо холод і контраст для кінематографічності. */
.scene-grade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, transparent 0%, rgba(6, 8, 16, 0.3) 100%),
    linear-gradient(to bottom, rgba(20, 30, 50, 0.25) 0%, transparent 30%, transparent 60%, rgba(6, 8, 16, 0.5) 100%);
  mix-blend-mode: multiply;
}

/* Віньєтка — темні краї фокусують увагу на обеліску. */
.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 200px 60px rgba(6, 8, 16, 0.9);
  background: radial-gradient(ellipse 70% 80% at 50% 50%, transparent 30%, rgba(6, 8, 16, 0.4) 100%);
}

/* ===================================================================
   Мерехтіння смолоскипів
   Накладається на місця де у кадрі стоять чаші з вогнем.
   =================================================================== */
.torch {
  position: absolute;
  width: 180px;
  height: 220px;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 160, 60, 0.35) 0%, rgba(232, 120, 40, 0.12) 40%, transparent 70%);
  mix-blend-mode: screen;
  filter: blur(8px);
  animation: torch-flicker 3s ease-in-out infinite;
}

/* Позиції підібрані під цей конкретний кадр — дві чаші з вогнем біля обеліску. */
.torch-left {
  left: 18%;
  bottom: 14%;
  animation-delay: 0s;
}

.torch-right {
  right: 22%;
  bottom: 16%;
  animation-delay: 0.7s;
}

@keyframes torch-flicker {

  0%,
  100% {
    opacity: 0.75;
    transform: scale(1);
  }

  25% {
    opacity: 1;
    transform: scale(1.08);
  }

  50% {
    opacity: 0.65;
    transform: scale(0.96);
  }

  75% {
    opacity: 0.9;
    transform: scale(1.04);
  }
}

/* ===================================================================
   Погода (сніг) — canvas
   =================================================================== */
.weather-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* ===================================================================
   Імена вигравіювані на грані обеліску
   Контейнер нахилений під перспективу каменю через transform.
   Текст має ефект "втиснутого в камінь" через подвійну тінь.
   =================================================================== */
.obelisk-names {
  position: absolute;
  /* Позиція і розмір підібрані під грань обеліску в кадрі.
     Підкручуй ці значення якщо текст не лягає на камінь точно. */
  left: 50%;
  top: 48%;
  /* translate(-50%,-50%) центрує, а паралакс-змінні зсувають разом з фоном,
     щоб імена були приклеєні до каменю. За замовчуванням зсув 0. */
  --parallax-x: 0px;
  --parallax-y: 0px;
  transform: translate(calc(-50% + var(--parallax-x)), calc(-50% + var(--parallax-y)));
  width: 15%;
  height: 46%;
  z-index: 10;
  /* Перспектива для дочірнього елемента — створює 3D-простір. */
  perspective: 600px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.obelisk-names-inner {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  /* Кадр фронтальний — нахил не потрібен, текст рівний.
     Якщо колись фон зміниться на кадр під кутом — поверни сюди
     щось типу rotateY(-6deg) для нахилу під грань каменю. */
  transform: none;
  transform-origin: center top;
  padding: 4% 8%;
  /* Ховаємо смугу скролу, але лишаємо можливість гортати. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.obelisk-names-inner::-webkit-scrollbar {
  display: none;
}

.engraved-title {
  font-family: var(--font-display);
  font-size: clamp(0.55rem, 1.1vw, 0.95rem);
  letter-spacing: 0.25em;
  text-align: center;
  color: rgba(180, 165, 140, 0.55);
  margin-bottom: 0.8em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid rgba(180, 165, 140, 0.15);
  /* Ефект гравіювання: світла лінія знизу + темна зверху = втиснуто. */
  text-shadow:
    0 -1px 1px rgba(0, 0, 0, 0.7),
    0 1px 1px rgba(220, 210, 190, 0.18);
  user-select: none;
}

.engraved-list {
  list-style: none;
}

.engraved-list li {
  font-family: var(--font-display);
  font-size: clamp(0.6rem, 1.25vw, 1.05rem);
  letter-spacing: 0.08em;
  text-align: center;
  /* Колір каменю — приглушений, наче вирізьблено в сірому граніті. */
  color: rgba(195, 180, 155, 0.6);
  padding: 0.4em 0.2em;
  cursor: pointer;
  /* Гравіювання */
  text-shadow:
    0 -1px 1px rgba(0, 0, 0, 0.8),
    0 1px 1px rgba(220, 210, 190, 0.2);
  transition: all 0.3s ease;
  user-select: none;
  line-height: 1.3;
}

/* Наведення — наче промінь смолоскипа впав на ім'я. */
.engraved-list li:hover {
  color: var(--gold-bright);
  text-shadow:
    0 -1px 1px rgba(0, 0, 0, 0.8),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 0 14px rgba(212, 168, 84, 0.6);
}

/* ===================================================================
   Заголовок
   =================================================================== */
.memorial-header {
  position: fixed;
  top: 2.5rem;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}

.memorial-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: 0.25em;
  color: var(--parchment);
  text-shadow:
    0 2px 20px rgba(0, 0, 0, 0.95),
    0 0 40px rgba(143, 169, 196, 0.3);
}

.memorial-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(0.85rem, 1.6vw, 1.1rem);
  color: var(--frost);
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
  opacity: 0.85;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}

/* ===================================================================
   Посилання назад
   =================================================================== */
.back-link {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 30;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--frost);
  text-decoration: none;
  padding: 0.5rem 1rem;
  background: rgba(12, 15, 22, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.back-link:hover {
  color: var(--parchment);
  border-color: rgba(143, 169, 196, 0.5);
  background: rgba(12, 15, 22, 0.85);
}

/* ===================================================================
   Перемикач сезону
   =================================================================== */
.season-switch {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 30;
  display: flex;
  gap: 0.3rem;
  background: rgba(12, 15, 22, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 2px;
  padding: 0.3rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.season-switch button {
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: var(--frost);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s ease;
  opacity: 0.5;
}

.season-switch button:hover {
  opacity: 0.85;
  background: rgba(143, 169, 196, 0.1);
}

.season-switch button.active {
  opacity: 1;
  background: rgba(143, 169, 196, 0.18);
  color: var(--parchment);
}

/* ===================================================================
   Картка персонажа
   =================================================================== */
.character-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(6, 8, 16, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.character-card-overlay.open {
  display: flex;
}

.character-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 40px 100px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(143, 169, 196, 0.15);
  border-radius: 2px;
  overflow: hidden;
  /* Поява */
  animation: card-appear 0.4s ease;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-portrait {
  width: 100%;
  height: 280px;
  background-size: cover;
  background-position: center top;
  background-color: #11151f;
  position: relative;
}

/* Якщо портрета нема — показуємо стилізовану заглушку. */
.card-portrait.empty::after {
  content: '⚔';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: rgba(143, 169, 196, 0.2);
}

/* Градієнт знизу портрета для плавного переходу в текст. */
.card-portrait::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, var(--panel-bg) 100%);
  pointer-events: none;
}

.card-body {
  padding: 1.5rem 2rem 2rem;
  text-align: center;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
  margin-bottom: 0.3rem;
}

.card-title {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--frost);
  margin-bottom: 0.8rem;
}

.card-date {
  font-size: 0.85rem;
  color: var(--parchment-dark);
  opacity: 0.7;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.card-date:empty {
  display: none;
}

.card-epitaph {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--parchment);
  padding-top: 1rem;
  border-top: 1px solid var(--panel-border);
}

/* ===================================================================
   Кнопки закриття
   =================================================================== */
.card-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  color: var(--frost);
  font-size: 1.7rem;
  cursor: pointer;
  z-index: 5;
  line-height: 1;
  transition: color 0.2s ease;
}

.card-close:hover {
  color: var(--parchment);
}

/* ===================================================================
   Адаптив
   =================================================================== */
@media (max-width: 768px) {
  .memorial-header {
    top: 4.5rem;
  }

  .memorial-header h1 {
    font-size: 2rem;
  }

  /* На мобілці грань обеліску вужча в кадрі — підлаштовуємо область імен. */
  .obelisk-names {
    width: 30%;
    top: 50%;
    height: 42%;
  }

  .engraved-list li {
    font-size: 0.7rem;
  }

  .engraved-title {
    font-size: 0.55rem;
  }

  .torch {
    width: 120px;
    height: 150px;
  }

  .back-link {
    top: 1rem;
    left: 1rem;
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
  }

  .season-switch {
    top: 1rem;
    right: 1rem;
  }

  .season-switch button {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }

  .card-portrait {
    height: 220px;
  }
}

@media (max-width: 380px) {
  .character-card {
    max-width: 100%;
  }
}
