/* ============================================================
   STAS KOROLIOV — заглушка головного домену
   Та сама айдентика, що в EPK: мальована помаранчева текстура,
   яка повільно проходить палітру, вирізаний артист на червоному
   кубі, KyivType Sans у назві. Без колажу — тільки фігура.
   ============================================================ */

:root {
  --orange:    #F08704;
  --ink:       #161311;
  --paper:     #FFFFFF;
  --red:       #E02A22;
  --yellow:    #F5D912;
  --xp-blue:   #0B50D0;
  --xp-blue-2: #3E8DFF;

  --font-display: "KyivType Sans", "Arial Black", sans-serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Menlo", monospace;

  /* Повний цикл зміни кольору мальованого тла */
  --bg-hue-cycle: 120s;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--orange);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: clip;
}

/* Фіксований шар з мальованою текстурою; hue-rotate дуже повільно
   проганяє її по всій палітрі, зберігаючи яскравість і насиченість */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--orange) url("../img/texture-2600.jpg") center / cover no-repeat;
  background-image: image-set(
    url("../img/texture-2600.webp") type("image/webp"),
    url("../img/texture-2600.jpg") type("image/jpeg")
  );
  will-change: filter;
  animation: bg-hue var(--bg-hue-cycle) linear infinite;
}

@media (max-width: 900px) {
  body::before {
    background-image: image-set(
      url("../img/texture-1600.webp") type("image/webp"),
      url("../img/texture-1600.jpg") type("image/jpeg")
    );
  }
}

@keyframes bg-hue {
  to { filter: hue-rotate(360deg); }
}

::selection { background: var(--ink); color: var(--orange); }

img { max-width: 100%; height: auto; display: block; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- Композиція ---------- */

.stub {
  --fig-h: min(78vh, 150vw);   /* висота фігури — від неї рахується все інше */
  --head: .085;                /* рівень голови — частка висоти фігури
                                  (безрозмірна: calc не множить на % ) */

  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.2rem, 4vh, 2.4rem);
  padding: clamp(1rem, 4vh, 2.5rem) 0 clamp(1.5rem, 5vh, 3rem);
}

/* Сцена за розміром фігури — відносно неї позиціонується назва */
.stub__stage {
  position: relative;
  display: grid;
  place-items: center;
}

.stub__cutout {
  perspective: 900px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stub__cutout img {
  height: var(--fig-h);
  width: auto;
  max-width: none; /* інакше глобальний max-width:100% плющить пропорції */
  transform-origin: 50% 65%;
}

/* Назва на рівні голови. Сітка «1fr | проміжок | 1fr»: проміжок фіксований
   і завжди по центру фігури, тож слова тримаються голови, а не країв екрана.
   minmax(0,1fr) — щоб довге KOROLIOV не розсовувало колонки і не зміщувало центр. */
.stub__name {
  --name-gap: calc(var(--fig-h) * .30);

  position: absolute;
  top: calc(var(--fig-h) * var(--head));
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100vw;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--name-gap) minmax(0, 1fr);
  align-items: baseline;
  padding-inline: 3vw;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 6.2vw, 8rem);
  line-height: 1;
  letter-spacing: .01em;
  color: var(--paper);
  pointer-events: none; /* щоб не заважало клікати по фігурі */
}

.stub__word { display: block; white-space: nowrap; }

/* слова притискаються до проміжку — тобто до голови */
.stub__word:first-child { grid-column: 1; justify-self: end; margin-right: 80px; }
.stub__word:last-child  { grid-column: 3; justify-self: start; }

/* ---------- Кнопка ---------- */

.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(.78rem, 1.6vw, .92rem);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  padding: .85em 1.8em;
  border: 2px solid var(--ink);
  border-radius: 3px;
  transition: background .18s ease, transform .12s ease;
}

.btn:hover { background: var(--yellow); }
.btn:active { transform: translate(1px, 1px); }

@media (min-width: 768px) and (max-width: 1023px) {
  .stub__name { font-size: 5vw; }
}

/* Мобілка: слова поруч із головою не вміщуються — ставимо назву
   над фігурою у два рядки (h1 стає звичайним елементом сітки сцени) */
@media (max-width: 767px) {
  .stub {
    --fig-h: min(62vh, 120vw);
    gap: 1rem;
  }

  .stub__stage { gap: clamp(.6rem, 2vh, 1.2rem); }

  .stub__name {
    position: static;
    transform: none;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-inline: 0;
    font-size: clamp(2rem, 11vw, 3.6rem);
    line-height: .95;
    text-align: center;
  }

  .stub__word:first-child,
  .stub__word:last-child { grid-column: auto; justify-self: center; margin-right: 0; }
}

/* ---------- Пасхалка: «система падає» шлейфом XP-помилок ----------
   10 швидких кліків по фігурі (десктоп) */

.xp-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
}

html.is-glitching * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.xp-err {
  position: absolute;
  width: 340px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px 6px 0 0;
  overflow: hidden;
}

.xp-err__bar {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .34rem .55rem;
  background: linear-gradient(180deg, var(--xp-blue-2), var(--xp-blue));
  border-bottom: 2px solid var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
}

.xp-err__dot {
  width: 12px;
  height: 12px;
  background: var(--red);
  border-radius: 3px;
  flex: none;
}

.xp-err__bar i {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 19px;
  font: 700 11px/1 var(--font-body);
  font-style: normal;
  color: #fff;
  background: linear-gradient(#F2846C, var(--red));
  border-radius: 3px;
}

.xp-err__body {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem .9rem;
  font-family: var(--font-mono);
  font-size: .88rem;
  text-align: left;
}

.xp-err__body b {
  flex: none;
  width: 32px;
  height: 32px;
  background: var(--red);
  color: #fff;
  font: 800 18px/32px var(--font-display);
  text-align: center;
  border-radius: 5px;
}

.xp-err--final {
  left: auto;
  top: auto;
  right: 22px;
  bottom: 26px;
  width: min(430px, 92vw);
}

.xp-err--final .xp-err__body {
  font-family: var(--font-body);
  font-size: .92rem;
  line-height: 1.5;
  align-items: flex-start;
  padding: .9rem .9rem .3rem;
}

.xp-err__actions {
  display: flex;
  justify-content: center;
  padding: .5rem .9rem .9rem;
}

.xp-err__actions .btn {
  cursor: pointer;
  font-size: .74rem;
  padding: .55em 1.2em;
}

/* Червоний 3D-куб — чистий CSS 3D, без бібліотек */
.xp-cube {
  position: absolute;
  left: 60%;
  top: 22%;
  width: 190px;
  height: 190px;
  perspective: 900px;
  pointer-events: none;
}

.xp-cube__aim,
.xp-cube__spin {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.xp-cube__spin { animation: cube-tumble 18s linear infinite; }

@keyframes cube-tumble {
  from { transform: rotateX(0deg) rotateY(0deg); }
  to   { transform: rotateX(360deg) rotateY(720deg); }
}

.xp-cube__face {
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--ink);
}

/* грані з різною яскравістю червоного — обʼєм читається без освітлення */
.xp-cube__face:nth-child(1) { transform: rotateY(0deg)   translateZ(95px); background: #F0392E; }
.xp-cube__face:nth-child(2) { transform: rotateY(90deg)  translateZ(95px); background: #D62A20; }
.xp-cube__face:nth-child(3) { transform: rotateY(180deg) translateZ(95px); background: #C4231A; }
.xp-cube__face:nth-child(4) { transform: rotateY(270deg) translateZ(95px); background: #D62A20; }
.xp-cube__face:nth-child(5) { transform: rotateX(90deg)  translateZ(95px); background: #FF4A3D; }
.xp-cube__face:nth-child(6) { transform: rotateX(-90deg) translateZ(95px); background: #A81D15; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
