/* =========================================================
   ТОКЕНИ
   ========================================================= */
:root {
  --ink: #14181c;
  --ink-soft: #1d2228;
  --bone: #ede7db;
  --bone-dim: rgba(237, 231, 219, 0.68);
  --brass: #b08d57;
  --brass-soft: rgba(176, 141, 87, 0.35);
  --verdigris: #3e5449;
  --verdigris-soft: rgba(62, 84, 73, 0.9);
  --danger: #a5524a;

  --glass-bg: rgba(20, 24, 28, 0.55);
  --glass-bg-strong: rgba(15, 18, 21, 0.78);
  --glass-border: rgba(237, 231, 219, 0.14);
  --glass-blur: blur(18px);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-tight: 0 4px 16px rgba(0, 0, 0, 0.3);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--font-body);
  color: var(--bone);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

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

/* =========================================================
   ШАР 1 — MATTERPORT ВІТРИНА
   ========================================================= */
.tour-stage {
  position: fixed;
  inset: 0;
  background: var(--ink);
}

.tour-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.tour-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--ink);
  color: var(--bone-dim);
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: opacity 0.5s ease;
}

.tour-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.tour-loading__ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  border-top-color: var(--brass);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   ШАР 2 — ВИБІР МОВИ (одноразовий пікер у модалці)
   ========================================================= */
.lang-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.lang-picker__btn {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(237, 231, 219, 0.05);
  color: var(--bone);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.lang-picker__btn:hover {
  background: var(--brass-soft);
  border-color: var(--brass);
  transform: translateX(2px);
}

.modal--compact {
  max-width: 320px;
  text-align: center;
}

.modal--compact .lang-picker__btn {
  text-align: center;
}

/* =========================================================
   ШАР 3 — ВІДЖЕТ АВАТАРА
   ========================================================= */
.avatar-widget {
  position: fixed;
  right: calc(22px + var(--safe-r));
  bottom: calc(96px + var(--safe-b));
  z-index: 50;
  width: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.avatar-widget[data-collapsed="true"] {
  transform: translateY(24px) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

.avatar-widget__frame {
  position: relative;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.avatar-widget__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-widget__speaking-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--brass);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.avatar-widget[data-state="speaking"] .avatar-widget__speaking-ring {
  opacity: 1;
  transform: scale(1);
  animation: pulse-ring 1.6s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 var(--brass-soft); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.avatar-widget__collapse {
  position: absolute;
  top: -6px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  color: var(--bone-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.avatar-widget__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  max-width: 100%;
}

.avatar-widget__mute {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bone);
}

.avatar-widget__caption {
  font-size: 11.5px;
  color: var(--bone-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-fab {
  position: fixed;
  right: calc(22px + var(--safe-r));
  bottom: calc(96px + var(--safe-b));
  z-index: 50;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-fab__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brass);
}

/* =========================================================
   ШАР 4 — CTA
   ========================================================= */
.cta-pill {
  position: fixed;
  right: calc(22px + var(--safe-r));
  bottom: calc(28px + var(--safe-b));
  z-index: 50;
  padding: 13px 22px;
  border-radius: 999px;
  background: var(--brass);
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(176, 141, 87, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(176, 141, 87, 0.45);
}

/* =========================================================
   ШАР 5 — МОДАЛЬНА ФОРМА
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 12, 14, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-overlay[hidden] { display: none; }

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 30px 26px 26px;
  border-radius: var(--radius-lg);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  animation: modal-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--bone-dim);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover { background: rgba(237, 231, 219, 0.08); }

.modal__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--bone);
}

.modal__subtitle {
  font-size: 13.5px;
  color: var(--bone-dim);
  margin: 0 0 22px;
  line-height: 1.5;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--bone-dim);
}

.field input,
.field select {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(237, 231, 219, 0.05);
  color: var(--bone);
  font-size: 14.5px;
  font-family: inherit;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23EDE7DB' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.field input::placeholder { color: rgba(237, 231, 219, 0.35); }

.field__submit {
  margin-top: 6px;
  padding: 13px;
  border-radius: var(--radius-sm);
  background: var(--brass);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.15s ease;
}

.field__submit:hover { transform: translateY(-1px); }
.field__submit:disabled { opacity: 0.55; pointer-events: none; }

.field__status {
  min-height: 16px;
  font-size: 12.5px;
  margin: 0;
  color: var(--verdigris);
}

.field__status.is-error { color: var(--danger); }

/* =========================================================
   АДАПТИВНІСТЬ
   ========================================================= */
@media (max-width: 640px) {
  .avatar-widget { width: 128px; bottom: calc(84px + var(--safe-b)); }
  .avatar-widget__frame { width: 108px; height: 108px; }
  .avatar-fab { bottom: calc(84px + var(--safe-b)); width: 50px; height: 50px; }

  .cta-pill {
    left: 14px;
    right: 14px;
    bottom: calc(14px + var(--safe-b));
    text-align: center;
  }

  .modal { max-width: 100%; }
}
