/* THE AI CULT · дверь ложи
   Матовая темнота, костяная белая, кровь и воск.
   Ничего внешнего: только системные шрифты и свои пиксели. */

:root {
  --ink:    #0a0a0b;
  --bone:   #e9e5dd;
  --blood:  #c8202b;
  --wax:    #e0a24e;
  --green:  #2e7d4f;

  --ash:    rgba(233, 229, 221, .56);
  --dust:   rgba(233, 229, 221, .34);
  --hair:   rgba(233, 229, 221, .12);
  --hair-2: rgba(233, 229, 221, .22);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", "Noto Serif", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --pad: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* высоту окна и высоту алтаря ведёт app.js */
  --app-h: 100dvh;
  --altar-h: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------ сцена */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--app-h);
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r)) calc(var(--safe-b)) calc(var(--safe-l));
  overflow: hidden;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 80% at 50% 34%, rgba(255, 255, 255, .028) 0%, rgba(0, 0, 0, 0) 58%),
    radial-gradient(100% 70% at 50% 100%, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 60%);
}

.grain {
  position: absolute;
  inset: -60px;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  background-repeat: repeat;
  background-size: 128px 128px;
  transition: opacity .8s ease;
  will-change: transform;
}

.grain.on { opacity: .055; }

@media (prefers-reduced-motion: no-preference) {
  .grain.on { animation: grainshift 1.1s steps(6, end) infinite; }
}

@keyframes grainshift {
  0%   { transform: translate3d(0, 0, 0); }
  16%  { transform: translate3d(-12px, 6px, 0); }
  33%  { transform: translate3d(9px, -11px, 0); }
  50%  { transform: translate3d(-7px, 13px, 0); }
  66%  { transform: translate3d(14px, 4px, 0); }
  83%  { transform: translate3d(-4px, -9px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(60% 40% at 50% 30%, rgba(255, 244, 222, .92) 0%, rgba(224, 162, 78, .32) 34%, rgba(0, 0, 0, 0) 72%);
}

.flash.fire { animation: burst 900ms ease-out 1; }

@keyframes burst {
  0%   { opacity: 0; }
  12%  { opacity: .85; }
  100% { opacity: 0; }
}

/* ---------------------------------------------------------------- шапка */

.brand {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--pad) 4px;
  flex: 0 0 auto;
}

.wordmark {
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--blood);
  text-shadow: 0 0 14px rgba(200, 32, 43, .35);
}

.steplabel {
  font-size: 9.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--dust);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- алтарь */

.altar {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  height: var(--altar-h);
  transition: height .35s cubic-bezier(.2, .7, .2, 1);
}

.altar canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- панель */

.panel {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px var(--pad) 34px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), rgba(0, 0, 0, 0) 100%);
}

.panel::-webkit-scrollbar { width: 0; height: 0; }

.scene {
  animation: rise .42s cubic-bezier(.2, .7, .2, 1) both;
}

.scene.center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  text-align: center;
}

/* Скрытая сцена скрыта всегда, кто бы что ни объявил выше. */
.panel .scene[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ типографика */

.kicker {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--blood);
}

.kicker.warm { color: var(--wax); text-shadow: 0 0 18px rgba(224, 162, 78, .45); }

h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(27px, 8.2vw, 34px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -.01em;
  color: var(--bone);
}

h1.big {
  font-size: clamp(32px, 10vw, 42px);
  text-shadow: 0 0 42px rgba(224, 162, 78, .3);
}

.lead {
  margin: 0 0 20px;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ash);
}

.tiny {
  margin: 20px 0 10px;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: .02em;
  color: var(--dust);
}

.tiny.mono { font-family: var(--mono); font-size: 11px; word-break: break-word; }

.sign {
  margin: 26px 0 0;
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .46em;
  text-transform: uppercase;
  color: var(--blood);
}

.echo {
  margin: 0 0 20px;
  padding: 12px 0 12px 16px;
  border-left: 1px solid var(--hair-2);
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  line-height: 1.45;
  color: var(--bone);
}

.echo[hidden] { display: none; }

/* ---------------------------------------------------------------- выбор */

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choices.tight { gap: 8px; }

.choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  margin: 0;
  padding: 15px 16px;
  border: 1px solid var(--hair);
  border-radius: 2px;
  background: rgba(233, 229, 221, .015);
  color: var(--bone);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, box-shadow .25s ease, transform .12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.choice .mark {
  flex: 0 0 auto;
  width: 11px;
  height: 10px;
  margin-top: 5px;
  background: currentColor;
  color: var(--hair-2);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: color .22s ease, filter .22s ease;
}

.choice .body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice .t { font-size: 16px; line-height: 1.25; letter-spacing: .005em; }
.choice .h { font-size: 12.5px; line-height: 1.4; color: var(--dust); }

.choice:active { transform: scale(.988); }

.choice[aria-checked="true"] {
  border-color: rgba(233, 229, 221, .5);
  background: rgba(233, 229, 221, .05);
  box-shadow: inset 0 0 26px rgba(233, 229, 221, .05), 0 0 22px rgba(233, 229, 221, .05);
}

.choice[aria-checked="true"] .mark {
  color: var(--bone);
  filter: drop-shadow(0 0 6px rgba(233, 229, 221, .8));
}

.choice[aria-checked="true"] .h { color: var(--ash); }

/* ---------------------------------------------------------------- поле */

.field { margin-bottom: 4px; }

textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 148px;
  padding: 14px 14px;
  border: 1px solid var(--hair-2);
  border-radius: 2px;
  background: rgba(233, 229, 221, .025);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color .2s ease, box-shadow .25s ease;
  -webkit-appearance: none;
  appearance: none;
}

textarea::placeholder { color: rgba(233, 229, 221, .26); }

textarea:focus {
  border-color: rgba(233, 229, 221, .46);
  box-shadow: 0 0 24px rgba(233, 229, 221, .06);
}

.under {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.hint { font-size: 12px; line-height: 1.4; color: var(--dust); }
.hint.warn { color: var(--blood); }
.count { font-family: var(--mono); font-size: 11px; color: rgba(233, 229, 221, .24); white-space: nowrap; }

.chips { display: flex; flex-direction: column; gap: 8px; }

.chip {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px dashed var(--hair);
  border-radius: 2px;
  background: none;
  color: var(--ash);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, transform .12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.chip:active { transform: scale(.988); }
.chip.taken { color: var(--bone); border-color: var(--hair-2); border-style: solid; }

/* ------------------------------------------------------------ реликварий */

.relics {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  border-top: 1px solid var(--hair);
}

.relics li {
  display: flex;
  gap: 14px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--hair);
}

.relics .no {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--blood);
  letter-spacing: .05em;
}

.relics .what { min-width: 0; }
.relics .title { display: block; font-size: 15px; line-height: 1.35; color: var(--bone); }
.relics .broke { display: block; margin-top: 5px; font-size: 12.5px; line-height: 1.4; color: var(--dust); }
.relics .who { display: block; margin-top: 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: rgba(233, 229, 221, .28); }

.ghost {
  width: 100%;
  min-height: 52px;
  padding: 15px 16px;
  border: 1px solid var(--hair-2);
  border-radius: 2px;
  background: none;
  color: var(--bone);
  font: inherit;
  font-size: 14.5px;
  letter-spacing: .02em;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.ghost:active { transform: scale(.99); background: rgba(233, 229, 221, .04); }

/* ------------------------------------------------- запасная главная кнопка */

.dock {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  /* Нижний вырез уже отбит на .stage. Отбить его тут второй раз значит
     положить под кнопку пустую полосу в палец высотой. */
  padding: 10px var(--pad) 12px;
  background: linear-gradient(to top, var(--ink) 62%, rgba(10, 10, 11, 0));
}

.dock[hidden] { display: none; }

.mainbtn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 16px;
  border: 0;
  border-radius: 3px;
  background: var(--blood);
  color: #fff;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity .2s ease, transform .12s ease, background .25s ease;
  -webkit-appearance: none;
  appearance: none;
}

.mainbtn:active { transform: scale(.99); }
.mainbtn[disabled] { opacity: .32; cursor: default; }
.mainbtn.accept { background: var(--green); }
.mainbtn.door { background: var(--wax); color: var(--ink); }

/* ------------------------------------------------------------ мелочи UX */

:focus-visible {
  outline: 1px solid rgba(233, 229, 221, .7);
  outline-offset: 2px;
}

body.typing .altar { height: 0; }
body.typing .brand { opacity: .4; }

@media (max-height: 640px) {
  :root { --pad: 18px; }
  h1 { font-size: clamp(24px, 7vw, 28px); margin-bottom: 8px; }
  .lead { font-size: 14px; line-height: 1.45; margin-bottom: 14px; }
  .kicker { margin-bottom: 7px; }
  .choice { min-height: 54px; padding: 12px 14px; }
  .choice .t { font-size: 15px; }
  .choice .h { font-size: 12px; }
  .choices { gap: 8px; }
}

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

/* Знак культа в шапке. Тот же самый path, что уезжает в сплеш телеграма,
   поэтому иконка загрузки и шапка апки показывают одну и ту же фигуру. */
.brandmark {
  width: 18px;
  height: 18px;
  flex: none;
  fill: var(--blood, #c8202b);
  opacity: .95;
}
