@font-face {
  font-family: "SpanB";
  src: url("../fonts/Span-Bold.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Helvetica";
  src: url("../fonts/HelveticaNowDisplay-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  /* Родитель (корневой index.html) выставляет при скролле; до загрузки главной = 0. */
  --welcome-seam: 0;
}

body {
  overflow: hidden;
  font-family: sans-serif;
}

/* Переход фона к секции ниже (только под текстом: z-index между canvas и .hero-copy). */
.welcome-seam-fade {
  display: none;
  /* --- настройка перехода (высота / где начинается белый внутри полосы) --- */
  --welcome-fade-height: min(48vh, 58%);
  /* Позиции стопов градиента по высоте полосы: 0% = верх полосы, 100% = низ экрана. */
  --welcome-fade-stop-transparent: 0%;
  --welcome-fade-stop-mid: 42%;
  --welcome-fade-stop-solid: 100%;
  /* Базовая сила градиента и добавка при скролле (--welcome-seam 0…1 с главной). */
  --welcome-fade-opacity-base: 0.01;
  --welcome-fade-opacity-seam: 0.99;
  /* --- */

  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  pointer-events: none;
  height: var(--welcome-fade-height);
  opacity: var(--welcome-fade-opacity-base);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: opacity;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background-color: #ffffff;
  background-image: -webkit-linear-gradient(
    top,
    rgba(255, 255, 255, 0) var(--welcome-fade-stop-transparent),
    rgba(255, 255, 255, 0.55) var(--welcome-fade-stop-mid),
    #ffffff var(--welcome-fade-stop-solid)
  );
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) var(--welcome-fade-stop-transparent),
    rgba(255, 255, 255, 0.55) var(--welcome-fade-stop-mid),
    #ffffff var(--welcome-fade-stop-solid)
  );
}

/* Только в iframe с главной (класс вешает корневой index.html): иначе на открытом dist/index.html
   лишняя белая полоса снизу. */
html.welcome-from-parent .welcome-seam-fade {
  display: block;
  opacity: calc(
    var(--welcome-fade-opacity-base) + var(--welcome-seam, 0) * var(--welcome-fade-opacity-seam)
  );
}
#webGLApp {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.hero-copy {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: max(5vh, 32px) 20px max(5vh, 28px);
  text-align: center;
  pointer-events: none;
  z-index: 10;
  color: #000;
}

.quote-container {
  max-width: 90%;
  overflow: visible;
  /* Расстояние между большим текстом (h1.quote) и строкой WHISPERS… */
  --quote-to-author-gap: 3vh;
}

.quote {
  /* Межстрочник букв (между базовыми линиями строк) */
  --quote-leading: 0.75;
  /* Доп. подтяжка 2–3-й строки к 1-й в ASCII: +em сильнее вверх, −em ниже (к авто-overlap подложек) */
  --quote-line-stack-tweak: 0em;

  font-family: "SpanB", system-ui, sans-serif;
  font-size: 9vw;
  line-height: var(--quote-leading);
  letter-spacing: -0.015em;
  transform: scaleY(1.18);
  transform-origin: center center;
  font-weight: 400;
  margin: 0 0 var(--quote-to-author-gap);
  text-transform: uppercase;
  position: relative;
  z-index: 4;
  color: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.18em 0 0.12em;
}

.quote-line {
  display: inline-block;
  white-space: nowrap;
  line-height: var(--quote-leading);
  position: relative;
}

.quote-line-bg {
  display: none;
}

.quote-line-text {
  position: relative;
  z-index: 10;
}

.quote-line + .quote-line {
  margin-top: 0.05em;
}

body.ascii-mode .quote .quote-line + .quote-line {
  margin-top: calc(
    -2 * var(--substrate-quote-pad-y) - var(--substrate-quote-overlap-extra) +
      var(--quote-line-stack-tweak)
  );
}

.welcome-caption {
  display: block;
  position: relative;
  z-index: 100;
  margin: 0;
  padding: 0;
  font-family: "Helvetica", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.15;
  letter-spacing: 0.18em;
  transform: scaleY(1.12);
  transform-origin: center center;
  text-transform: uppercase;
  color: #000;
}

@media (min-width: 1025px) {
  .hero-copy > .welcome-caption {
    margin-top: var(--quote-to-author-gap, 3vh);
  }

  .quote {
    margin-bottom: 0;
  }
}

.color-controls {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 10;
  display: flex;
  gap: 1rem;
  pointer-events: auto;
}
.color-btn {
  min-width: 48px;
  height: 48px;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px;
  color: white;
  font-family: "Syne", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.color-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}
.color-btn.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.6);
}

/* Color Adjuster Panel */
.color-adjuster-panel {
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 100;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 1.5rem;
  min-width: 320px;
  max-width: 400px;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  display: none;
}

.color-adjuster-panel.open {
  display: block;
}

.color-adjuster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.color-adjuster-title {
  color: white;
  font-family: "Syne", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.color-adjuster-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.color-adjuster-close:hover {
  opacity: 0.7;
}

.color-picker-group {
  margin-bottom: 1.25rem;
}

.color-picker-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: white;
  font-family: "Inter", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
}

.color-picker-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-picker-input {
  width: 60px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  background: none;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}

.color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.color-value-display {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: white;
  font-family: "Inter", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: text;
  user-select: all;
  transition: all 0.3s ease;
}

.color-value-display:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
}

.color-value-display:focus {
  outline: none;
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.5);
}

.copy-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: white;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.copy-btn.copied {
  background: rgba(76, 175, 80, 0.3);
  border-color: rgba(76, 175, 80, 0.5);
}

.color-adjuster-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 0.75rem;
}

.export-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  color: white;
  font-family: "Syne", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.export-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.toggle-adjuster-btn {
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 100;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-family: "Syne", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  border-radius: 8px;
  pointer-events: auto;
}

.toggle-adjuster-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

body.ascii-mode {
  background: #ffffff;
  letter-spacing: -0.03em;
  /* Размер белой подложки за текстом (= padding вокруг букв) */
  --substrate-quote-pad-y: 0.07em;
  --substrate-quote-pad-x: 0.07em;
  --substrate-quote-pad-top-first: 0.1em;
  --substrate-quote-pad-bottom-last: 0.1em;
  --substrate-quote-radius: 0.06em;
  /* Насколько сильнее смыкать соседние белые блоки (0 = только -2*pad-y) */
  --substrate-quote-overlap-extra: 0em;
  /* Подложка у «WHISPERS THROUGH MEMORY» (высота/ширина = padding вокруг текста) */
  --substrate-author-pad-y: 0.2em;
  --substrate-author-pad-x: 0.4em;
  --substrate-author-radius: 0.06em;
}

body.ascii-mode #ascii-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
}

body.ascii-mode .quote-line {
  padding: var(--substrate-quote-pad-y) var(--substrate-quote-pad-x);
}

body.ascii-mode .quote-line:first-child {
  padding-top: var(--substrate-quote-pad-top-first);
}

body.ascii-mode .quote .quote-line:last-child {
  padding-bottom: var(--substrate-quote-pad-bottom-last);
}

body.ascii-mode .quote-line-bg {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #ffffff;
  border-radius: var(--substrate-quote-radius);
  pointer-events: none;
}

body.ascii-mode .quote-line-text {
  color: #000;
}

body.ascii-mode .hero-copy > .welcome-caption {
  padding: var(--substrate-author-pad-y) var(--substrate-author-pad-x);
  color: #000;
}

body.ascii-mode .hero-copy > .welcome-caption::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #ffffff;
  border-radius: var(--substrate-author-radius);
  pointer-events: none;
}

body.ascii-mode .color-controls,
body.ascii-mode .toggle-adjuster-btn,
body.ascii-mode .color-adjuster-panel {
  display: none !important;
}

/*
 * Welcome tablet — Figma ref 1025×834.
 * 1025–1920: centered (default). 701–1024: углы, фикс. размеры.
 * 510–699: мобильный макет Figma, фикс. размеры (см. блок max-width: 699px).
 * Подпись: tuning в конце файла.
 */
@media (max-width: 1024px) and (min-width: 701px) {
  .hero-copy {
    display: block;
    padding: 0;
    text-align: left;
  }

  .quote-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    --quote-to-author-gap: 0;
  }

  .hero-copy > .welcome-caption {
    position: fixed;
    z-index: 100;
    left: auto;
    bottom: auto;
    width: max-content;
    max-width: calc(100vw - 56px);
    margin: 0;
    text-align: right;
    white-space: nowrap;
    font-size: 14.5px;
    line-height: 1.15;
    letter-spacing: 0.18em;
    pointer-events: none;
  }

  .quote-container {
    z-index: 1;
  }

  .quote {
    position: absolute;
    z-index: 2;
    left: 28px;
    right: auto;
    bottom: 41px;
    top: auto;
    margin: 0;
    width: fit-content;
    max-width: 651px;
    padding: 0;
    font-size: 77px;
    line-height: 0.75;
    letter-spacing: -0.015em;
    transform: scaleY(1.18);
    transform-origin: bottom left;
    align-items: flex-start;
    text-align: left;
    --quote-line-stack-tweak: 0em;
  }

  .quote-line {
    display: block;
    width: fit-content;
  }

  .quote-line + .quote-line {
    margin-top: 6px;
  }

  body.ascii-mode .quote .quote-line + .quote-line {
    margin-top: calc(
      -2 * var(--substrate-quote-pad-y) - var(--substrate-quote-overlap-extra) +
        var(--quote-line-stack-tweak)
    );
  }

  body.ascii-mode .quote-line:first-child {
    padding-top: var(--substrate-quote-pad-top-first);
  }

  body.ascii-mode .hero-copy > .welcome-caption {
    position: fixed;
    padding: var(--substrate-author-pad-y) var(--substrate-author-pad-x);
  }
}

/*
 * Mobile welcome — Figma 699×834 / 510×834 (510–699, фикс. размеры).
 * Все позиции и размеры — в конце файла: «MOBILE WELCOME TUNING».
 */
@media (max-width: 699px) {
  .hero-copy {
    display: block;
    padding: 0;
    text-align: left;
  }

  .quote-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    --quote-to-author-gap: 0;
    z-index: 1;
  }

  .hero-copy > .welcome-caption {
    position: fixed;
    z-index: 100;
    left: 50%;
    right: auto;
    top: auto;
    width: max-content;
    max-width: calc(100vw - 32px);
    margin: 0;
    text-align: center;
    white-space: nowrap;
    line-height: 1.15;
    letter-spacing: 0.18em;
    pointer-events: none;
  }

  .quote {
    position: fixed;
    z-index: 2;
    right: auto;
    bottom: auto;
    margin: 0;
    width: fit-content;
    max-width: calc(100vw - 56px);
    padding: 0;
    letter-spacing: -0.015em;
    align-items: flex-start;
    text-align: left;
    --quote-line-stack-tweak: -0.02em;
  }

  .quote-line {
    display: block;
    width: fit-content;
  }

  body.ascii-mode .quote .quote-line + .quote-line {
    margin-top: calc(
      -2 * var(--substrate-quote-pad-y) - var(--substrate-quote-overlap-extra) +
        var(--quote-line-stack-tweak)
    );
  }

  body.ascii-mode .quote-line:first-child {
    padding-top: var(--substrate-quote-pad-top-first);
  }

  body.ascii-mode .hero-copy > .welcome-caption {
    position: fixed;
    padding: var(--substrate-author-pad-y) var(--substrate-author-pad-x);
  }
}

/* 510–699: большой текст в две строки (первое слово / остальное) */
@media (max-width: 699px) and (min-width: 510px) {
  .quote-line:nth-child(3) {
    display: none;
  }
}

/* =============================================================================
   MOBILE WELCOME TUNING (ширина ≤699; 360–509 см. NARROW ниже)
   Меняй только значения ниже — всё в одном месте.
   ============================================================================= */
@media (max-width: 699px) {
  .hero-copy {
    /* —— Большой текст (510–699: 2 строки; <510: 3 строки) —— */
    --wc-quote-top: 200px; /* ↓ больше = ниже */
    --wc-quote-left: 28px; /* → больше = правее */
    --wc-quote-size: 100px; /* размер шрифта */
    --wc-quote-line-gap: 40px; /* между строками */
    --wc-quote-scale-y: 1.18; /* верт. растяжение */

    /* —— Мелкий текст (ART THROUGH MOTION…) —— */
    --wc-caption-display: none; /* none = скрыт · block = показан (≤699) */
    --wc-caption-bottom: 48px; /* ↑ больше = выше от низа экрана */
    --wc-caption-size: 13px; /* размер шрифта */
    --wc-caption-nudge-x: 0px; /* + вправо, − влево (от центра) */
    --wc-caption-nudge-y: 0px; /* + вниз, − вверх */
    --wc-caption-scale-y: 1.12;
  }

  h1.quote {
    top: var(--wc-quote-top);
    left: var(--wc-quote-left);
    font-size: var(--wc-quote-size);
    line-height: 0.82;
    transform: scaleY(var(--wc-quote-scale-y));
    transform-origin: top left;
  }

  .quote-line + .quote-line {
    margin-top: var(--wc-quote-line-gap);
  }

  /* ascii-mode всегда на welcome — без этого gap из --wc-quote-line-gap не применяется */
  body.ascii-mode .quote .quote-line + .quote-line {
    margin-top: calc(
      -2 * var(--substrate-quote-pad-y) - var(--substrate-quote-overlap-extra) +
        var(--quote-line-stack-tweak) + var(--wc-quote-line-gap)
    );
  }

  .hero-copy > .welcome-caption,
  p.welcome-caption#rotating-text {
    display: var(--wc-caption-display);
  }

  body.ascii-mode .hero-copy > .welcome-caption {
    display: var(--wc-caption-display);
  }

  p.welcome-caption#rotating-text {
    bottom: var(--wc-caption-bottom);
    font-size: var(--wc-caption-size);
    transform: translateX(calc(-50% + var(--wc-caption-nudge-x)))
      translateY(var(--wc-caption-nudge-y)) scaleY(var(--wc-caption-scale-y));
    transform-origin: center bottom;
  }
}

/* =============================================================================
   NARROW WELCOME TUNING (360–509)
   Только этот диапазон. Размеры/отступы — из MOBILE WELCOME TUNING выше.
   Поднять большой текст: уменьши --wc-quote-top (меньше px = выше).
   Поднять мелкий: --wc-caption-nudge-y отрицательный или больше --wc-caption-bottom.
   Вернуть мелкий на ≤699: в MOBILE WELCOME TUNING поставь --wc-caption-display: block.
   ============================================================================= */
@media (max-width: 509px) and (min-width: 360px) {
  .hero-copy {
    --wc-quote-top: 150px;
    /* --wc-caption-nudge-y: -8px; */
  }
}

/* =============================================================================
   TABLET WELCOME TUNING (701–1024)
   ============================================================================= */
@media (max-width: 1024px) and (min-width: 701px) {
  .hero-copy {
    /* —— Мелкий текст, правый верх —— */
    --wc-caption-top: 90px;
    --wc-caption-right: 12px; /* меньше = правее */
    --wc-caption-nudge-x: 0px;
    --wc-caption-scale-y: 1.12;

    /* —— Большой текст, левый низ —— */
    --wc-quote-bottom: 41px;
    --wc-quote-left: 28px;
    --wc-quote-size: 77px;
    --wc-quote-line-gap: 6px;
  }

  h1.quote {
    bottom: var(--wc-quote-bottom);
    left: var(--wc-quote-left);
    font-size: var(--wc-quote-size);
  }

  .quote-line + .quote-line {
    margin-top: var(--wc-quote-line-gap);
  }

  body.ascii-mode .quote .quote-line + .quote-line {
    margin-top: calc(
      -2 * var(--substrate-quote-pad-y) - var(--substrate-quote-overlap-extra) +
        var(--quote-line-stack-tweak) + var(--wc-quote-line-gap)
    );
  }

  p.welcome-caption#rotating-text {
    top: var(--wc-caption-top);
    right: var(--wc-caption-right);
    left: auto;
    bottom: auto;
    transform: scaleY(var(--wc-caption-scale-y))
      translateX(var(--wc-caption-nudge-x));
    transform-origin: top right;
  }
}
