/* «Живой Босх»: своё у игры — тёмное полотно, бумажная мастерская и окна.
   Шапка, кнопки и иконки — из /interactive/ui.css. */

:root {
	--background: #141c1b;
	--foreground: #eee7d4;
	--paper: #f0e7d4;
	--ink: #34362e;
	--accent: #d4a574;
	--viz-bar-max: none;   /* сетка во всю ширину окна — шапка тоже */
}

* { box-sizing: border-box; }

/* overflow-x: clip у body, а не hidden: hidden делает body прокручиваемым
   контейнером, и «Выпустить в картину» перестаёт прилипать к низу окна. */
html, body { max-width: 100%; }
html { overflow-x: hidden; }
body { overflow-x: clip; }

body {
	margin: 0;
	background: var(--background);
	color: var(--foreground);
	font-family: 'Montserrat', sans-serif;
	font-size: 16px;
	line-height: 1.5;
}

body.dialog-open { overflow: hidden; }

button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #bd814b; outline-offset: 4px; }

/* ——— общая сетка ——— */

.workspace {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 370px;
	min-height: calc(100dvh - var(--viz-bar-h));
}
.painting { padding: 34px; display: flex; flex-direction: column; min-width: 0; align-self: start; }
.painting-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 27px; }
.painting h1 {
	font-family: 'Cormorant Garamond', serif;
	font-size: clamp(42px, 4.5vw, 72px);
	font-weight: 400;
	line-height: 1;
	margin: 0;
}
.live-tag {
	white-space: nowrap;
	border: 1px solid #74897855;
	padding: 9px 12px;
	border-radius: 30px;
	font-size: 12px;
	color: #b9c6a9;
	display: flex;
	gap: 8px;
	align-items: center;
}
.live-tag i { width: 6px; height: 6px; background: #b2c095; border-radius: 50%; box-shadow: 0 0 12px #aabb8580; }
.live-tag.offline i { background: #bd8054; }

/* ——— полотно ——— */

.world {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	max-width: 100%;
	background: #35463c url('assets/landscape.webp') center / 100% 100%;
	box-shadow: 0 0 0 1px #b9936245, 0 16px 60px #0005;
	overflow: hidden;
}
.world-canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.realm-labels {
	position: absolute;
	inset: 0 0 auto;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	z-index: 3;
	padding: 14px 8px 22px;
	background: linear-gradient(#142219b0, transparent);
	text-align: center;
	pointer-events: none;
}
.realm-labels span { font: 500 21px/1.2 'Cormorant Garamond', serif; letter-spacing: .02em; color: #f9efd8; text-shadow: 0 1px 5px #000, 0 0 2px #000; }
.world-controls { position: absolute; bottom: 15px; right: 15px; display: flex; gap: 5px; z-index: 4; }
.world-controls button {
	color: #f6eed8;
	background: #18291ec9;
	border: 1px solid #d2c19266;
	width: 38px;
	height: 38px;
	display: grid;
	place-items: center;
	font-size: 18px;
}
.world-controls button:hover { background: #435240; }
.empty-world {
	position: absolute;
	left: 50%;
	bottom: 28%;
	transform: translateX(-50%);
	background: #17251be6;
	padding: 20px 25px;
	text-align: center;
	width: max-content;
	max-width: 85%;
	border: 1px solid #d5c09355;
	z-index: 4;
}
.empty-world span { font: 400 24px 'Cormorant Garamond', serif; display: block; color: #f5e6c4; }
.empty-world small { display: block; color: #c2c2a8; font-size: 14px; margin-top: 9px; }
/* Полотно и карточка выбранного жителя: на компьютере карточка лежит
   поверх картины, на телефоне — под ней (см. адаптив). */
.stage { position: relative; }

.canvas-error { position: absolute; left: 15px; bottom: 20%; background: #392a20; padding: 15px; font-size: 14px; max-width: 90%; z-index: 6; }

/* Кнопка «Создать своего жителя» под картиной — только на телефоне,
   где мастерская начинается далеко внизу. */
.to-workbench { display: none; margin-top: 16px; }

.video-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 18px; }
.video-tools > span { font-size: 12px; color: #a9ae9e; }

.connection-error {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 14px;
	padding: 6px 10px;
	background: #483327;
	margin-top: 10px;
	gap: 10px;
}
.connection-error .viz-btn--quiet { --viz-btn-quiet: #f3dab6; }

/* ——— карточка выбранного жителя ——— */

.resident-card {
	position: absolute;
	bottom: 17px;
	left: 17px;
	right: 110px;
	max-width: 350px;
	padding: 16px 30px 16px 7px;
	display: flex;
	gap: 7px;
	background: #f0e7d4f5;
	color: #383b2e;
	border: 1px solid #b6a37c;
	z-index: 5;
	box-shadow: 0 8px 25px #0004;
}
.resident-card .resident-portrait { width: 70px; height: 80px; align-self: center; }
.resident-card h3 { font: 400 24px/1.1 'Cormorant Garamond', serif; overflow-wrap: anywhere; margin: 5px 0 8px; }
.resident-card p { font-size: 12px; color: #796b50; margin: 0; }
.resident-card div > span { font-size: 14px; line-height: 1.45; display: block; }
.close-card { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; background: none; color: #564d38; font-size: 18px; }

/* ——— список последних жителей ——— */

.residents { margin-top: 26px; min-width: 0; }
.residents-title { font: 500 23px/1.15 'Cormorant Garamond', serif; color: #e4d7b8; margin: 0 0 4px; }
.resident-list {
	display: flex;
	overflow-x: auto;
	gap: 10px;
	padding: 10px 0 3px;
	scrollbar-width: thin;
	scrollbar-color: #73745f transparent;
}
.resident-list > p { font-size: 14px; color: #adb1a1; }
.resident-chip {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
	max-width: 230px;
	border: 1px solid #52604a66;
	background: #1c2720;
	color: #e4ddc4;
	padding: 5px 12px 5px 3px;
	text-align: left;
	font-size: 14px;
}
.resident-chip.active { border-color: #b59a65; }
.resident-chip .creature-art { width: 46px; height: 46px; }
.resident-chip > span:last-child { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resident-chip small { font-size: 12px; display: block; color: #adb099; margin-top: 5px; }

/* ——— мастерская ——— */

.workbench { background: var(--paper); color: var(--ink); padding: 30px 28px; box-shadow: -8px 0 32px #0001; }
.workbench h2 { font: 400 32px/1.1 'Cormorant Garamond', serif; margin: 0 0 13px; color: #344b3c; }
.intro { font-size: 16px; color: #686650; line-height: 1.55; margin: 0 0 16px; }

.specimen {
	height: 180px;
	position: relative;
	background: radial-gradient(ellipse, #fcf8eb, #dfd4bc);
	border: 1px solid #c4b69590;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
.creature-art { display: block; width: 156px; height: 156px; background-repeat: no-repeat; background-position: center; background-size: contain; flex-shrink: 0; }
.specimen-art { width: 150px; height: 150px; }
.random { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; color: #776345; border: 1px solid #b5a27d; background: transparent; border-radius: 50%; font-size: 17px; }
.random:hover { color: #344b3c; border-color: #776345; }

fieldset { border: 0; padding: 0; margin: 24px 0 18px; min-width: 0; }
/* Заголовки шагов мастерской: без номеров, крупно, чтобы выделялись. */
legend, .name-label {
	display: block;
	padding: 0;
	margin-bottom: 12px;
	font: 600 23px/1.15 'Cormorant Garamond', serif;
	color: #344b3c;
}

.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.kind-option {
	display: flex;
	align-items: center;
	gap: 8px;
	border: 1px solid #c7baa1;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	padding: 10px 8px;
	font-size: 14px;
	min-height: 42px;
	text-align: left;
}
.kind-option::before {
	content: '';
	width: 13px;
	height: 13px;
	flex-shrink: 0;
	border: 1px solid #9a8d70;
	border-radius: 50%;
}
.kind-option.chosen { border-color: #7b805a; background: #dbe0c650; }
.kind-option.chosen::before { border-color: #576448; box-shadow: inset 0 0 0 3px #576448; }

.palette-field { margin-bottom: 20px; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.swatch {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 7px;
	padding: 8px 0;
	border: 0;
	background: transparent;
	color: inherit;
}
.swatch .swatch-name { font-size: 12px; }
.swatch small { font-size: 12px; color: #8a7a5c; display: block; margin-top: 2px; }
.swatch::before {
	content: '';
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: 3px solid #efe8d7;
	box-shadow: 0 0 0 1px #b9ad8c;
	background: #bcb088;
}
.swatch.chosen::before { box-shadow: 0 0 0 2px #576448; }
.swatch.color-1::before { background: #aa6540; }
.swatch.color-2::before { background: #5b7869; }
.swatch.color-3::before { background: #6d778d; }
.swatch.color-4::before { background: #a54552; }
.swatch.color-5::before { background: #477695; }
.swatch.unavailable { opacity: .5; }

.name-label { margin-top: 24px; margin-bottom: 10px; }
/* Имя не вводят, оно складывается само — поэтому табличка, а не строка ввода. */
.generated-name {
	display: block;
	font: 400 25px/1.25 'Cormorant Garamond', serif;
	color: #344b3c;
	padding: 10px 14px 11px;
	background: #e7dbbf;
	border-left: 3px solid #a98b54;
	overflow-wrap: anywhere;
}
.name-note { font-size: 13px; line-height: 1.5; color: #73664f; margin: 8px 0 0; }
.nature-story { font-size: 14px; line-height: 1.5; color: #777158; margin: 10px 0 0; }

.realm-picker { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #bcb095; border-radius: 8px; overflow: hidden; }
.realm-picker button {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: center;
	text-align: center;
	font-size: 14px;
	padding: 12px 3px;
	border: 0;
	background: transparent;
	color: inherit;
}
.realm-picker button.chosen { background: #dde0c6; }
.realm-picker button.unavailable { opacity: .55; }
.realm-picker small { font-size: 12px; color: #8a7a5c; }
.slot-hint { font-size: 13px; line-height: 1.5; color: #73664f; margin: 10px 0 0; }

input {
	width: 100%;
	border: 0;
	border-bottom: 1px solid #b6a889;
	background: transparent;
	font-size: 16px;
	padding: 8px 0 12px;
	color: #353a2e;
	border-radius: 0;
}
input::placeholder { color: #7d715d; }
.email-label { margin-top: 28px; margin-bottom: 4px; }
input:disabled { color: #6f6a58; }
.form-error { color: #943b29; font-size: 14px; line-height: 1.5; margin: 18px 0 0; }

/* «Выпустить в картину» прилипает к низу окна, пока видна форма:
   главное действие видно сразу, а не через полторы тысячи пикселей. */
.release-bar {
	position: sticky;
	bottom: 0;
	z-index: 2;
	margin-top: 13px;
	padding: 12px 0 16px;
	background: linear-gradient(rgba(240, 231, 212, 0), var(--paper) 12px);
}
/* Колонка мастерской узкая (314 px): с обычными полями «пилюли» длинные
   подписи переносятся на две строки. */
.workbench .viz-btn--block, .card-side .viz-btn--block { padding-left: 14px; padding-right: 14px; }
.workbench-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.workbench-actions #events-link { margin-top: 6px; }
.workbench-actions .viz-btn--quiet { align-self: center; text-align: center; }

/* Плашки на бумаге мастерской. */
.workbench .viz-chips { margin: 0 0 22px; --viz-chip-ink: #4a3a2c; --viz-chip-line: rgba(74, 58, 44, .3); --viz-chip-bg: rgba(255, 255, 255, .3); }

/* Житель выпущен: выбор застыл, видно только то, из чего он сложен. */
.workbench-form.locked .kind-option:not(.chosen),
.workbench-form.locked .swatch:not(.chosen),
.workbench-form.locked .realm-picker button:not(.chosen) { opacity: .4; }
.workbench-form.locked .kind-option.chosen,
.workbench-form.locked .swatch.chosen,
.workbench-form.locked .realm-picker button.chosen { opacity: 1; }
.workbench-form.locked .random { display: none; }

/* Приём жителей закрыт из админки. */
.closed-note {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 20px 0 6px;
	padding: 16px 18px;
	border: 1px solid #b6a37c;
	background: #e7dbbf;
}
.closed-note strong { font: 600 23px/1.15 'Cormorant Garamond', serif; color: #344b3c; }
.closed-note span { font-size: 14px; line-height: 1.5; color: #5f5a45; }

/* ——— карточка персонажа в окне ——— */

.card-dialog {
	position: fixed;
	inset: 0;
	background: #0b100dcc;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	z-index: 100;
}
/* Картинка слева, действия справа: на ноутбуке кнопка «Отправить на почту»
   видна сразу, без прокрутки окна. На узком экране — в столбик. */
.card-dialog-inner {
	position: relative;
	background: #f1e7ce;
	color: #344b3c;
	padding: 24px;
	width: 100%;
	max-width: 880px;
	max-height: 92dvh;
	overflow-y: auto;
	border: 1px solid #c4b18b;
	display: grid;
	grid-template-columns: auto minmax(240px, 1fr);
	gap: 24px;
	align-items: start;
}
.card-figure { min-width: 0; }
.card-figure img {
	display: block;
	height: min(calc(92dvh - 50px), 640px);
	width: auto;
	max-width: 100%;
	border: 1px solid #c4b18b;
}
.card-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-top: 4px; }
.card-dialog-inner h3 { font: 400 27px/1.15 'Cormorant Garamond', serif; margin: 0 30px 0 0; }
.card-dialog-note { color: #73664f; font-size: 14px; line-height: 1.5; margin: 0; }
.card-mail { display: flex; flex-direction: column; gap: 8px; }
.card-mail-status { margin: 0; font-size: 14px; line-height: 1.5; color: #5f5a45; overflow-wrap: anywhere; }
.card-mail-status.error { color: #943b29; }
.card-mail-status.done { color: #2f5b3a; }

@media (max-width: 860px) {
	.card-dialog-inner { grid-template-columns: minmax(0, 1fr); gap: 16px; }
	.card-figure img { width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
}

/* ——— заставка с QR-кодом (режим ноутбука, ?kiosk=1) ——— */

.attract {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4vh 5vw;
	background: rgba(11, 16, 13, .9);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: var(--foreground);
	cursor: pointer;
	animation: attract-in .6s ease-out;
}
@keyframes attract-in { from { opacity: 0; } to { opacity: 1; } }
body.attract-open { overflow: hidden; }
.attract-inner {
	display: grid;
	grid-template-columns: auto minmax(0, 560px);
	align-items: center;
	gap: 5vw;
}
.attract-qr {
	width: min(78vh, 46vw);
	aspect-ratio: 1 / 1;
	background: #fff;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 24px 90px #000a, 0 0 0 1px #d4a57455;
}
.attract-qr svg { display: block; width: 100%; height: 100%; }
.attract-qr:empty { display: none; }
.attract-text { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.attract-logo { display: block; width: 64px; height: 64px; }
.attract h2 {
	margin: 0;
	font: 400 clamp(48px, 6.4vw, 104px)/1 'Cormorant Garamond', serif;
}
.attract-lead { margin: 0; font-size: clamp(18px, 1.8vw, 28px); line-height: 1.4; color: #e8dfc6; }
.attract-count { margin: 0; font-size: clamp(15px, 1.2vw, 18px); color: #b9c6a9; }
.attract-count:empty { display: none; }
.attract-url { margin: 0; font-size: clamp(14px, 1.1vw, 17px); color: #a9ae9e; letter-spacing: .3px; overflow-wrap: anywhere; }

@media (max-aspect-ratio: 1/1), (max-width: 760px) {
	.attract-inner { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; gap: 24px; }
	.attract-qr { width: min(80vw, 50vh); }
	.attract-text { align-items: center; gap: 12px; }
}

/* ——— уведомление ——— */

.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translate(-50%, 20px);
	background: #e8e2ca;
	color: #30422e;
	padding: 15px 22px;
	box-shadow: 0 10px 40px #0005;
	z-index: 90;
	opacity: 0;
	pointer-events: none;
	display: flex;
	gap: 10px;
	align-items: center;
	transition: .3s;
	max-width: 90vw;
	font-size: 14px;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ——— режим проекции ——— */

/* Шапка сайта в проекции не нужна: из-за неё полотно не помещалось
   в экран по высоте. Вернуться в мастерскую — кнопкой со стрелкой у полотна. */
.projection-mode .viz-bar { display: none; }

.projection { height: 100dvh; overflow: hidden; }
.projection .workspace { display: block; height: 100%; }
.projection .painting {
	padding: 0;
	height: 100%;
	min-height: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #0b100d;
}
.projection .world {
	flex: none;
	width: min(100vw, 177.778dvh);
	height: auto;
	aspect-ratio: 16 / 9;
	box-shadow: none;
}
.projection .workbench,
.projection .to-workbench,
.projection .painting-head,
.projection .video-tools,
.projection .residents { display: none; }
.projection .realm-labels { padding: 18px 0 26px; }
.projection .realm-labels span { font-size: 28px; }
.projection .resident-card { bottom: 75px; max-width: 460px; }
.projection .stage { flex: none; }
.projection .world-controls { opacity: .25; transition: opacity .2s; }
.projection .world-controls:hover, .projection .world-controls:focus-within { opacity: 1; }
/* На сенсорном экране наведения нет — кнопки видны всегда. */
@media (hover: none) {
	.projection .world-controls { opacity: 1; }
}

/* Подпись — внутри картины, в её левом нижнем углу, на любом соотношении
   сторон экрана: поля сверху-снизу (16:10) или по бокам (21:9) вычитаем. */
.projection-caption {
	position: fixed;
	bottom: calc(max(0px, (100dvh - 56.25vw) / 2) + 18px);
	left: calc(max(0px, (100vw - 177.778dvh) / 2) + 24px);
	display: flex;
	align-items: baseline;
	gap: 24px;
	text-shadow: 0 2px 8px black;
	pointer-events: none;
	font-size: 14px;
	z-index: 10;
}
.projection-title { font: 400 28px 'Cormorant Garamond', serif; }
.projection-logo { width: 32px; height: 32px; align-self: center; filter: drop-shadow(0 2px 6px #000); }
.projection-count { font-size: 14px; color: #d8d7b9; }

/* ——— режим ноутбука (?kiosk=1) ———
   Гость не должен одним нажатием уйти со страницы или переключить режим:
   стрелки, логотипа-ссылки, «Большого экрана» и «Перейти к мероприятиям» нет. */
.viz-kiosk .viz-bar,
.viz-kiosk #events-link { display: none; }
.viz-kiosk .workspace { min-height: 100dvh; }

/* ——— адаптив ——— */

@media (min-width: 1550px) {
	.workspace { grid-template-columns: minmax(0, 1fr) 410px; }
	.workbench { padding: 38px; }
	.painting { padding: 40px; }
	.specimen { height: 210px; }
}

@media (max-width: 1000px) {
	.workspace { grid-template-columns: minmax(0, 1fr) 330px; }
	.painting { padding: 24px; }
	.workbench { padding: 24px 20px; }
	.painting-head { display: block; }
	.live-tag { display: inline-flex; margin-top: 18px; }
}

@media (max-width: 740px) {
	.workspace { display: flex; flex-direction: column; }
	/* align-self: stretch обязателен: со start из общих правил колонка
	   растягивалась по ширине ленты жителей, и на телефоне картина
	   уезжала за край экрана, как только жителей становилось больше трёх. */
	.painting { padding: 20px 16px; align-self: stretch; width: 100%; }
	.painting-head { display: block; margin-bottom: 18px; }
	.painting h1 { font-size: 40px; }
	.painting-head .live-tag { margin-top: 15px; }
	legend, .name-label { font-size: 22px; }
	.workbench { padding: 24px 16px 32px; }
	.specimen { height: 200px; }
	.kind-option { font-size: 14px; padding: 12px 8px; }
	.realm-labels { padding: 6px 0 12px; }
	.realm-labels span { font-size: 15px; letter-spacing: 0; }
	/* Карточка выбранного жителя — под картиной, чтобы не закрывать её. */
	.resident-card { position: relative; left: auto; right: auto; bottom: auto; max-width: none; margin-top: 10px; padding: 10px 36px 10px 4px; box-shadow: none; }
	.projection .resident-card { position: absolute; left: 8px; right: 44px; bottom: 5px; margin: 0; max-height: 75%; overflow: auto; }
	.to-workbench { display: flex; }
	/* «Большой экран» — для проектора, на телефоне он не нужен. */
	.viz-bar__extra { display: none; }
	.viz-bar__extra + .viz-bar__logo { margin-left: auto; }
	.resident-card h3 { font-size: 21px; }
	.resident-card .resident-portrait { width: 50px; height: 65px; }
	.resident-card div > span { font-size: 12px; }
	.world-controls { right: 8px; bottom: 8px; flex-direction: column; }
	.empty-world { padding: 12px; bottom: 15%; max-width: 90%; }
	.empty-world span { font-size: 18px; }
	.empty-world small { font-size: 12px; }
	.residents { margin-top: 18px; }
	.residents-title { font-size: 22px; }
	.card-dialog-inner { padding: 16px; }
	.projection-caption > .projection-logo,
	.projection-caption > .projection-count { display: none; }
	.projection-caption { bottom: calc(max(0px, (100dvh - 56.25vw) / 2) + 10px); left: 16px; }
	.projection-title { font-size: 20px; }
	.projection .realm-labels { padding: 6px 0 12px; }
	.projection .realm-labels span { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Сокращение font: сбрасывает прописные цифры из ui.css — возвращаем их. */
.realm-labels span,.empty-world span,.resident-card h3,.residents-title,.workbench h2,legend,.name-label,.generated-name,.closed-note strong,.card-dialog-inner h3,.attract h2,.projection-title{font-feature-settings:'lnum' 1}
