/* v3 «Жива 3D-майстерня»: общее для обеих вёрсток — токены дня и ночи, шапка, кнопки,
 * карточки станций, панель крупного плана, постер. Своё у компьютера — desk.css,
 * у телефона — phone.css (отдельная вёрстка, а не адаптация).
 * Тема: data-theme="auto" — как в системе; "day" / "night" — выбор посетителя.
 */
:root {
  --page: #efe5d8;
  --glass: rgb(255 251 245 / 78%);
  --glass-line: rgb(120 84 52 / 16%);
  --text: #1f1b17;
  --muted: #5f564e;
  --head: #7a5536;
  --accent: #a94f26;
  --accent-text: #fff;
  --accent-soft: #f3dccd;
  --line: #e0d3c3;
  --ok: #2e7d32;
  --danger: #b3261e;
  --shadow: 0 2px 6px rgb(60 40 20 / 10%), 0 24px 48px -20px rgb(60 40 20 / 38%);
  /* постер: те же тона, что у сцены */
  --p-wall-a: #efe4d6; --p-wall-b: #e2d3c1; --p-win: #fbf6ec; --p-frame: #b89a7c;
  --p-beam: #fff3d6; --p-wood-a: #b9875a; --p-wood-b: #8e6240; --p-edge: #6d4a31; --p-item: #e9d6bd;
  --radius: 20px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --page: #110d0b; --glass: rgb(28 22 18 / 74%); --glass-line: rgb(255 210 160 / 12%);
    --text: #f3ece3; --muted: #bcb0a3; --head: #e3b48a; --accent: #e58b55; --accent-text: #1b1714;
    --accent-soft: #3a2a20; --line: #3a322b; --ok: #7bc47f; --danger: #f2877f;
    --shadow: 0 2px 6px rgb(0 0 0 / 40%), 0 24px 48px -20px rgb(0 0 0 / 75%);
    --p-wall-a: #1c1612; --p-wall-b: #120e0b; --p-win: #1b2540; --p-frame: #3b2d22;
    --p-beam: #ffb565; --p-wood-a: #4a311f; --p-wood-b: #2a1b11; --p-edge: #1a110b; --p-item: #5b4634;
    color-scheme: dark;
  }
}
:root[data-theme="night"] {
  --page: #110d0b; --glass: rgb(28 22 18 / 74%); --glass-line: rgb(255 210 160 / 12%);
  --text: #f3ece3; --muted: #bcb0a3; --head: #e3b48a; --accent: #e58b55; --accent-text: #1b1714;
  --accent-soft: #3a2a20; --line: #3a322b; --ok: #7bc47f; --danger: #f2877f;
  --shadow: 0 2px 6px rgb(0 0 0 / 40%), 0 24px 48px -20px rgb(0 0 0 / 75%);
  --p-wall-a: #1c1612; --p-wall-b: #120e0b; --p-win: #1b2540; --p-frame: #3b2d22;
  --p-beam: #ffb565; --p-wood-a: #4a311f; --p-wood-b: #2a1b11; --p-edge: #1a110b; --p-item: #5b4634;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--text); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--sans); background: var(--page); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.12; margin: 0 0 .4em; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
svg { display: block; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ сцена и постер */
#stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--page); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0;
  transition: opacity .9s var(--ease); outline: none; }
.gl-on #gl { opacity: 1; }
#poster { position: absolute; inset: 0; transition: opacity .9s var(--ease); }
#poster svg { width: 100%; height: 100%; }
.gl-on #poster { opacity: 0; pointer-events: none; }
.shot #gl, .shot #poster, .shot .card, .shot #focus { transition: none !important; animation: none !important; }
.p-wall-a { stop-color: var(--p-wall-a); } .p-wall-b { stop-color: var(--p-wall-b); }
.p-beam { stop-color: var(--p-beam); }
.p-wood-a { stop-color: var(--p-wood-a); } .p-wood-b { stop-color: var(--p-wood-b); }
.p-win { fill: var(--p-win); } .p-frame { stroke: var(--p-frame); } .p-edge { fill: var(--p-edge); }
.p-items { fill: var(--p-item); }
#loader { position: absolute; left: 66%; top: 58%; transform: translate(-50%, -50%); display: flex; gap: 12px;
  align-items: center; padding: 12px 18px; border-radius: 999px; background: var(--glass);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--glass-line); font-size: 14px; }
#loader span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent);
  border-right-color: transparent; animation: spin .8s linear infinite; }
#loader[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ шапка */
.bar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 600 20px/1 var(--serif); color: var(--text);
  text-decoration: none; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--glass-line);
  background: var(--glass); color: var(--muted); }
.tools { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--text); cursor: pointer; text-decoration: none;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.txt { font-size: 13px; font-weight: 600; }
#theme .moon { display: none; }
.is-night #theme .sun { display: none; }
.is-night #theme .moon { display: inline; }
#cart-n { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font: 600 11px/18px var(--sans); font-style: normal; }
#cart-n[hidden] { display: none; }

/* ------------------------------------------------------------ кнопки, карточки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); font-weight: 600;
  text-decoration: none; cursor: pointer; transition: transform .2s var(--ease), background .2s; }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--head); font-weight: 600; margin: 0 0 8px; }
.card { background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }
.card .text { color: var(--muted); }
.card .acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.card .num { font: 600 12px/1 var(--sans); color: var(--muted); margin-left: 6px; letter-spacing: .04em; text-transform: none; }
.card .art { display: none; }
.card .note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* без WebGL: рисунки видов в карточках вместо сцены */
.no-gl .card .art { display: block; border-radius: 14px; overflow: hidden; background: var(--accent-soft); margin-bottom: 12px; }
.no-gl .card .art svg, .no-gl .card .art video { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.art .art-bg { fill: var(--p-win); }
.no-gl .closer, .no-gl .hint-scroll, .no-gl .hint-swipe { display: none !important; }

/* ------------------------------------------------------------ крупный план */
#focus { position: fixed; z-index: 30; background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); }
#focus[hidden] { display: none; }
#focus:focus { outline: none; }
.f-head { position: relative; padding-right: 52px; }
.f-head h2 { font-size: 24px; }
#f-close { position: absolute; right: 0; top: 0; }
.f-hint { font-size: 13px; color: var(--muted); }
.f-knob label { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.f-knob output { color: var(--accent); font-variant-numeric: tabular-nums; }
#f-range { width: 100%; height: 32px; accent-color: var(--accent); margin: 0 0 12px; }
.lbl { font-weight: 600; font-size: 14px; margin: 4px 0 8px; }
#f-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--glass-line); cursor: pointer; padding: 0;
  background: var(--c, #ccc); box-shadow: inset 0 0 0 2px rgb(255 255 255 / 25%); transition: transform .15s var(--ease); }
.sw[aria-checked="true"] { outline: 3px solid var(--accent); outline-offset: 2px; }
.sw:hover { transform: scale(1.08); }
.f-status { min-height: 1.5em; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.f-status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px; }
.f-status.err { color: var(--danger); }
.f-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ жесты по сцене */
#ghint { position: fixed; z-index: 15; display: grid; gap: 8px; padding: 14px 16px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow); pointer-events: none;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 14px; line-height: 1.3;
  opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .3s var(--ease), transform .3s var(--ease); }
#ghint.on { opacity: 1; transform: none; }
#ghint[hidden] { display: none; }
#ghint p { display: flex; align-items: center; gap: 10px; margin: 0; }
.gi { flex: none; position: relative; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); }
.gi::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%;
  background: var(--accent); }
.gi-swipe::after { animation: g-swipe 1.6s var(--ease) infinite; }
.gi-tap::after { animation: g-tap 1.6s var(--ease) infinite; }
.gi-turn::after { animation: g-turn 1.6s var(--ease) infinite; }
@keyframes g-swipe { 0%, 100% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }
@keyframes g-tap { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(.55); box-shadow: 0 0 0 6px rgb(169 79 38 / 25%); } }
@keyframes g-turn { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(6px); } }
#toast { position: fixed; z-index: 25; left: 50%; top: 72px; transform: translate(-50%, -8px); padding: 8px 14px;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 14px; font-weight: 600; opacity: 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease); pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast[hidden] { display: none; }
.f-act { width: 100%; margin: 0 0 12px; border-color: var(--accent); color: var(--accent); }
.f-act[hidden] { display: none; }
.btn.nudge { animation: nudge-btn .5s var(--ease); }
@keyframes nudge-btn { 30% { transform: scale(1.06); } 60% { transform: scale(.98); } }
#gl { cursor: grab; }
#gl:active { cursor: grabbing; }

#hud { position: fixed; z-index: 40; left: 8px; bottom: 8px; padding: 6px 8px; border-radius: 8px; background: rgb(0 0 0 / 65%);
  color: #9f9; font: 11px/1.35 ui-monospace, Consolas, monospace; white-space: pre; pointer-events: none; }
#hud[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important;
    transition-duration: .001s !important; scroll-behavior: auto !important; }
}
