/* ==========================================================================
   СНЕЖНЫЙ ПАРК «БЕРЛОГА» — Полноэкранный 3D-просмотрщик маскота (/modelka)
   Адаптация под любые экраны (Desktop, Tablet, Mobile + Safe Areas)
   ========================================================================== */

:root {
  --m-bg-top: #f1efea;
  --m-bg-mid: #e6e3dc;
  --m-bg-bot: #d5d1c8;
  --m-ink: #17181c;
  --m-ink-muted: #5a5d66;
  --m-surface: rgba(255, 255, 255, 0.78);
  --m-surface-hover: rgba(255, 255, 255, 0.94);
  --m-border: rgba(20, 22, 28, 0.10);
  --m-shadow: 0 12px 32px rgba(15, 17, 24, 0.10), 0 2px 6px rgba(15, 17, 24, 0.06);
  --m-accent: #f15a24;
  --m-accent-ink: #ffffff;
  --m-hint-bg: rgba(23, 24, 28, 0.76);
  --m-hint-ink: #f7f6f3;
}

html.theme-night {
  --m-bg-top: #1d2028;
  --m-bg-mid: #14161c;
  --m-bg-bot: #0b0c10;
  --m-ink: #f5f5f7;
  --m-ink-muted: #a6aab5;
  --m-surface: rgba(26, 28, 35, 0.76);
  --m-surface-hover: rgba(38, 41, 50, 0.92);
  --m-border: rgba(255, 255, 255, 0.12);
  --m-shadow: 0 14px 36px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.28);
  --m-hint-bg: rgba(255, 255, 255, 0.14);
  --m-hint-ink: #ffffff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--m-bg-mid);
  color: var(--m-ink);
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.modelka-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: radial-gradient(
    ellipse 85% 75% at 50% 44%,
    var(--m-bg-top) 0%,
    var(--m-bg-mid) 56%,
    var(--m-bg-bot) 100%
  );
  transition: background 0.35s ease;
}

#modelkaCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  cursor: grab;
}

#modelkaCanvas:active {
  cursor: grabbing;
}

/* Top bar */
.modelka-topbar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.modelka-pill-link,
.modelka-badge-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  box-shadow: var(--m-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--m-ink);
  text-decoration: none;
  transition: transform 0.18s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.modelka-pill-link:hover {
  background: var(--m-surface-hover);
  transform: translateY(-1px);
}

.modelka-pill-link:active {
  transform: scale(0.97);
}

.modelka-back-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(128, 128, 128, 0.12);
  flex-shrink: 0;
}

.modelka-emblem {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.modelka-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.modelka-brand-title {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.modelka-brand-sub {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--m-accent);
  margin-top: 2px;
}

.modelka-badge-chip {
  padding: 8px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--m-ink-muted);
  cursor: default;
}

.modelka-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--m-accent);
  box-shadow: 0 0 0 3px rgba(241, 90, 36, 0.22);
}

/* Bottom controls dock & gesture hint */
.modelka-bottom-hud {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.modelka-hint {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--m-hint-bg);
  color: var(--m-hint-ink);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.modelka-hint.is-hidden {
  opacity: 0;
  transform: translateY(6px);
}

.modelka-dock {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  box-shadow: var(--m-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.modelka-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--m-ink);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.modelka-ctrl-btn:hover {
  background: rgba(128, 128, 128, 0.12);
}

.modelka-ctrl-btn:active {
  transform: scale(0.96);
}

.modelka-ctrl-btn--toggle[aria-pressed='true'] {
  background: var(--m-accent);
  color: var(--m-accent-ink);
}

.modelka-ctrl-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.modelka-ctrl-btn svg[hidden] {
  display: none;
}

/* Loading & fallback overlay */
.modelka-loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(
    ellipse 85% 75% at 50% 44%,
    var(--m-bg-top) 0%,
    var(--m-bg-mid) 56%,
    var(--m-bg-bot) 100%
  );
  transition: opacity 0.38s ease, visibility 0.38s ease;
}

.modelka-loader.is-ready {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modelka-loader-card {
  width: min(320px, 100%);
  padding: 22px 22px 20px;
  border-radius: 24px;
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  box-shadow: var(--m-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.modelka-loader-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.modelka-loader-title {
  font-family: 'Rubik', 'Onest', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--m-ink);
}

.modelka-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.18);
  overflow: hidden;
}

.modelka-progress-fill {
  width: 8%;
  height: 100%;
  border-radius: 999px;
  background: var(--m-accent);
  transition: width 0.16s ease-out;
}

.modelka-loader-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--m-ink-muted);
  font-variant-numeric: tabular-nums;
}

.modelka-retry-btn {
  display: none;
  margin-top: 4px;
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: var(--m-accent);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.modelka-loader.is-error .modelka-progress-track {
  display: none;
}

.modelka-loader.is-error .modelka-retry-btn {
  display: inline-flex;
}

@media (max-width: 560px) {
  .modelka-badge-chip {
    display: none;
  }

  .modelka-ctrl-btn {
    padding: 0 12px;
    font-size: 0.79rem;
    height: 38px;
  }

  .modelka-hint {
    font-size: 0.72rem;
    max-width: 92vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modelka-stage,
  .modelka-hint,
  .modelka-loader,
  .modelka-progress-fill {
    transition: none;
  }
}
