/* Примерочная MARO: одно кресло, AR и смена материалов.
   Палитра и шрифты — из сайта MARO (~/mirmaro/tokens): тёмный орех, слоновая кость, бронза. */
@font-face { font-family: "Cormorant"; src: url("../fonts/cormorant.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Geologica"; src: url("../fonts/geologica.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  /* примитивы */
  --walnut-950: #0E0B08; --walnut-900: #15110D; --walnut-850: #1B1611; --walnut-800: #231C16;
  --walnut-700: #30271F; --walnut-600: #43372C;
  --ivory-50: #F3ECE0; --ivory-200: #D6CAB7; --ivory-300: #BCAE98;
  --bronze-300: #DCBF94; --bronze-400: #C9A273; --bronze-500: #B08A5A;
  --signal-red: #EE9A86;

  /* смысл */
  --bg: var(--walnut-900);
  --surface: var(--walnut-850);
  --surface-raised: var(--walnut-800);
  --line: var(--walnut-600);
  --text: var(--ivory-50);
  --text-muted: var(--ivory-300);
  --accent: var(--bronze-400);
  --accent-hover: var(--bronze-300);
  --on-accent: var(--walnut-950);
  --focus: var(--bronze-300);
  --error: var(--signal-red);
  --stage: #E9E3D8;              /* фон сцены «Студия»: тёплая бумага, как подиум в салоне */

  --font-display: "Cormorant", Georgia, "Times New Roman", serif;
  --font-body: "Geologica", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --size-display: clamp(2.5rem, 7vw, 3.5rem);
  --size-body: 1rem;
  --size-small: 0.875rem;
  --size-label: 0.8125rem;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px;
  --radius-s: 10px; --radius-m: 16px; --radius-l: 24px; --radius-pill: 999px;
  --dur-fast: 140ms; --dur: 240ms; --ease: cubic-bezier(.2, .7, .2, 1);
  --panel-w: 400px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 var(--size-body)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- раскладка ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; }
@media (min-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr) var(--panel-w); grid-template-rows: 100dvh; }
}

/* ---------- сцена ---------- */
.stage { position: relative; min-height: 52dvh; background: var(--stage); overflow: hidden; }
model-viewer { width: 100%; height: 100%; display: block; --poster-color: transparent; background: transparent; }
.brand {
  position: absolute; top: var(--space-4); left: var(--space-4); z-index: 2;
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  background: var(--walnut-900); color: var(--accent); border-radius: var(--radius-pill);
  font: 600 0.9375rem/1 var(--font-body); letter-spacing: 0.24em; text-decoration: none;
}
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.hint {
  position: absolute; left: 50%; bottom: calc(var(--radius-l) + var(--space-3)); transform: translateX(-50%); z-index: 2;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill);
  background: var(--walnut-900); color: var(--ivory-50); font-size: var(--size-small);
  white-space: nowrap; pointer-events: none; transition: opacity var(--dur) var(--ease);
}
.hint[hidden] { display: block; opacity: 0; }
@media (min-width: 900px) { .hint { bottom: var(--space-6); } }

/* загрузка модели */
.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: transparent; z-index: 3; }
.progress span { display: block; height: 100%; width: 0; background: var(--bronze-500); transition: width var(--dur) linear; }
.progress.done { opacity: 0; transition: opacity var(--dur) var(--ease) 200ms; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 1;
  color: var(--walnut-700); font-size: var(--size-small); pointer-events: none;
}
.loading[hidden] { display: none; }

/* ---------- панель ---------- */
.panel {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: var(--space-5) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--space-4);
  border-radius: var(--radius-l) var(--radius-l) 0 0; margin-top: calc(-1 * var(--radius-l)); position: relative; z-index: 4;
}
@media (min-width: 900px) {
  .panel { border-top: 0; border-left: 1px solid var(--line); border-radius: 0; margin: 0; padding: var(--space-8) var(--space-6); overflow-y: auto; }
}
.title { margin: 0; font: 500 var(--size-display)/1 var(--font-display); letter-spacing: -0.01em; }
.meta { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--size-small); }

/* вкладки */
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1);
  padding: var(--space-1); background: var(--walnut-950); border-radius: var(--radius-pill); }
.tab {
  min-height: 44px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--text-muted); font-size: var(--size-label); font-weight: 500;
  cursor: pointer; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab:hover { color: var(--text); background: var(--walnut-800); }
.tab:active { background: var(--walnut-700); }
.tab[aria-selected="true"] { background: var(--ivory-50); color: var(--walnut-950); }

/* образцы */
.swatches { display: flex; gap: var(--space-3); overflow-x: auto; padding: var(--space-1) var(--space-1) var(--space-2);
  margin: 0 calc(-1 * var(--space-1)); scrollbar-width: none; scroll-snap-type: x proximity; }
.swatches::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .swatches { flex-wrap: wrap; overflow: visible; } }
.swatch {
  flex: 0 0 auto; width: 76px; display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: 0; border: 0; background: none; cursor: pointer; scroll-snap-align: start; text-align: center;
}
.swatch .chip {
  width: 60px; height: 60px; border-radius: 50%; background: var(--walnut-700) center/cover no-repeat;
  box-shadow: 0 0 0 1px var(--line); transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  position: relative;
}
.swatch .name { font-size: var(--size-label); line-height: 1.25; color: var(--text-muted); }
.swatch:hover .chip { box-shadow: 0 0 0 2px var(--ivory-300); }
.swatch:hover .name { color: var(--text); }
.swatch:active .chip { transform: scale(0.96); }
.swatch:focus-visible { outline: none; }
.swatch:focus-visible .chip { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus); }
.swatch[aria-checked="true"] .chip { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch[aria-checked="true"] .name { color: var(--text); font-weight: 500; }
.swatch[aria-busy="true"] .chip::after {
  content: ""; position: absolute; inset: 18px; border-radius: 50%;
  border: 2px solid var(--ivory-50); border-right-color: transparent; animation: spin 700ms linear infinite;
}
.swatch:disabled { cursor: default; opacity: 0.5; }
@keyframes spin { to { transform: rotate(360deg); } }
.picked { margin: 0; font-size: var(--size-small); color: var(--text-muted); min-height: 1.5em; }
.picked b { color: var(--text); font-weight: 500; }

/* кнопки */
.actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); margin-top: auto; }
.btn {
  min-height: 52px; padding: 0 var(--space-5); border-radius: var(--radius-pill); border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-weight: 500; font-size: 1rem; text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--walnut-700); color: var(--text-muted); cursor: not-allowed; }
.btn-primary[aria-busy="true"] { cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover { background: var(--walnut-800); }
.btn-ghost:disabled { color: var(--text-muted); cursor: not-allowed; }
.note { margin: 0; font-size: var(--size-small); color: var(--text-muted); }
.note.error { color: var(--error); }

/* QR для компьютера */
.qr { display: none !important; gap: var(--space-4); align-items: center; padding: var(--space-4); border-radius: var(--radius-m); background: var(--surface-raised); }
.qr img { width: 112px; height: 112px; border-radius: var(--radius-s); background: #fff; padding: 6px; }
.qr p { margin: 0; font-size: var(--size-small); color: var(--text-muted); }
.qr p b { display: block; color: var(--text); font-weight: 500; margin-bottom: var(--space-1); font-size: var(--size-body); }
@media (min-width: 900px) { .no-ar .qr { display: flex !important; } }
.btn[hidden] { display: none; }
.actions:has(.btn[hidden]) { grid-template-columns: minmax(0, 1fr); }

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