/* === Magic Ball 8 — точная стилистика qveep.ru === */

:root {
  --bg: #0e0f12;
  --bg-elev: #181a1f;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f5f7;
  --text-dim: rgba(244, 245, 247, 0.6);
  --text-mute: rgba(244, 245, 247, 0.4);

  --accent: #00bfff;
  --accent-dim: rgba(0, 191, 255, 0.15);
  --accent-glow: rgba(0, 191, 255, 0.5);
  --accent-2: #a855f7;
  --accent-2-dim: rgba(168, 85, 247, 0.15);
  --accent-3: #f59e0b;
  --accent-3-dim: rgba(245, 158, 11, 0.15);

  --danger: #ef4444;
  --success: #22c55e;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --font-sans: "Inter", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", sans-serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 0.15s;
  --t-med: 0.3s;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(0, 191, 255, 0.15);

  --safe-top: 0px;
  --safe-bottom: 0px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-rendering: optimizeLegibility;
}

/* ---------- Aurora-фон + зерно (1:1 из site.css) ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(168, 85, 247, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 5%, rgba(0, 191, 255, 0.09), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245, 158, 11, 0.05), transparent 60%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Каркас ---------- */
.container {
  text-align: center;
  padding: var(--safe-top) 1.5rem calc(var(--safe-bottom) + 2.5rem);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  position: relative;
  z-index: 1;
}

/* ---------- Заголовок (просто текст, без навбара) ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-mute);
  letter-spacing: -0.02em;
}

.title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 60%, #fd79a8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: clamp(0.8rem, 3vw, 0.95rem);
  color: var(--text-mute);
  font-weight: 500;
}

/* ---------- 3D-сцена ---------- */
.scene {
  perspective: 800px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  flex: 1;
}

.ball-wrapper {
  position: relative;
  width: clamp(240px, 62vw, 320px);
  height: clamp(240px, 62vw, 320px);
}

/* === Шар — чёрный глянцевый (как оригинал) === */
.ball {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  /* Глянцевый чёрный: глубокий чёрный + лёгкий фиолетовый блик снизу */
  background:
    radial-gradient(circle at 30% 22%,
      rgba(80, 80, 95, 0.6) 0%,
      rgba(35, 35, 45, 0.2) 20%,
      transparent 45%),
    radial-gradient(circle at 50% 50%,
      #1c1c22 0%,
      #0e0e12 35%,
      #050508 75%,
      #000000 100%);
  box-shadow:
    inset -8px -10px 30px rgba(0, 0, 0, 0.9),
    inset 4px 6px 20px rgba(255, 255, 255, 0.04),
    inset 0 0 50px rgba(0, 0, 0, 0.5),
    0 25px 70px rgba(0, 0, 0, 0.85),
    0 0 80px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  will-change: transform;
  transition: transform 0.08s var(--ease-out-expo);
}

/* Основной блик — яркий, белый (глянец) */
.ball-highlight {
  position: absolute;
  top: 8%;
  left: 20%;
  width: 35%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse,
    rgba(255, 255, 255, 0.3) 0%,
    rgba(255, 255, 255, 0.08) 40%,
    transparent 70%);
  filter: blur(4px);
  pointer-events: none;
}

/* Малый блик — резкий белый (глянцевое отражение) */
.ball-highlight-small {
  position: absolute;
  top: 14%;
  left: 28%;
  width: 10%;
  height: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0%, transparent 70%);
  filter: blur(1px);
  pointer-events: none;
}

/* Лёгкое отражение снизу */
.ball-rim {
  position: absolute;
  bottom: 12%;
  left: 30%;
  width: 40%;
  height: 6%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(60, 60, 75, 0.15) 0%, transparent 70%);
  filter: blur(6px);
  pointer-events: none;
}

/* === КРУГЛЫЙ ЭКРАН (как в оригинальном Magic 8 Ball) === */
.ball-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2a2a38 0%, #15151f 60%, #08080d 100%);
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.9),
    0 0 0 3px rgba(255, 255, 255, 0.06),
    0 0 0 5px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 4;
  pointer-events: none;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

/* === Треугольник внутри круглого экрана === */
.triangle {
  position: absolute;
  inset: 0;
  transform: rotateY(90deg);
  opacity: 0;
  will-change: transform, opacity;
}

/* SVG: треугольник + текст внутри него */
.triangle-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translateY(8%);
  filter:
    drop-shadow(0 0 6px rgba(60, 120, 180, 0.5))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.triangle-poly {
  stroke: #4a8ac8;
  stroke-width: 2;
  stroke-linejoin: round;
  fill: rgba(15, 35, 60, 0.3);
}

/* HTML текст внутри SVG foreignObject — ВНУТРИ треугольника */
.triangle-text {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 5.5px;
  font-weight: 700;
  color: #d8e8ff;
  text-align: center;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3px;
  line-height: 1.15;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 3px rgba(74, 138, 200, 0.5);
}
  letter-spacing: 0.01em;
}

/* ---------- Свечение (мягкое, тёмно-синее) ---------- */
.glow {
  position: absolute;
  bottom: -8%;
  left: 50%;
  transform: translateX(-50%);
  width: 75%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(42, 90, 138, 0.2) 0%, rgba(20, 40, 72, 0.1) 50%, transparent 70%);
  filter: blur(25px);
  opacity: 0.3;
  pointer-events: none;
}

/* ---------- Частицы ---------- */
.particles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 10;
}

.particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  will-change: transform, opacity;
}

/* ---------- Подсказка + кнопка ---------- */
.hint {
  font-size: clamp(0.8rem, 3vw, 0.92rem);
  color: var(--text-mute);
  min-height: 1.2em;
  font-weight: 500;
  transition: opacity var(--t-med) var(--ease-smooth);
}

.ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #001824;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out-expo),
              transform var(--t-fast) var(--ease-out-expo),
              box-shadow var(--t-fast) var(--ease-out-expo);
  box-shadow: var(--shadow-md);
}

.ask-btn:hover, .ask-btn:active {
  background: #33ccff;
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(0, 191, 255, 0.15);
}

.ask-btn:active { transform: translateY(0); }
.ask-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Футер ---------- */
.footer { margin-top: 0.5rem; padding-bottom: var(--safe-bottom); }

.footer-link {
  font-size: 0.78rem;
  color: var(--text-mute);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast) var(--ease-smooth);
}

.footer-link:hover, .footer-link:active { color: var(--accent-2); }

/* ---------- Анимации ---------- */
.ball.is-animating { pointer-events: none; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.ball-wrapper.idle { animation: float 5s ease-in-out infinite; }

/* ---------- Адаптивность ---------- */

/* Планшеты и большие телефоны (портрет) */
@media (max-width: 480px) {
  .container { gap: 1rem; padding-left: 1rem; padding-right: 1rem; }
  .ball-wrapper { width: clamp(220px, 70vw, 300px); height: clamp(220px, 70vw, 300px); }
  .triangle-text { font-size: clamp(0.58rem, 3.2vw, 0.75rem); }
  .ask-btn { padding: 12px 28px; font-size: 1rem; }
  /* iPhone: уменьшаем заголовок чтобы не занимал место */
  .title { font-size: 1.3rem; }
  .subtitle { font-size: 0.82rem; }
}

/* iPhone (особенности Safari iOS) */
@supports (-webkit-touch-callout: none) {
  .triangle-text {
    -webkit-text-size-adjust: 100%;
    /* Safari рендерит шрифты жирнее — чуть уменьшаем weight */
    font-weight: 600;
  }
  /* iPhone notch / safe area */
  .container {
    padding-top: max(var(--safe-top), env(safe-area-inset-top));
    padding-bottom: max(calc(var(--safe-bottom) + 2.5rem), env(safe-area-inset-bottom));
  }
}

/* Маленькие телефоны + Telegram Mini App (короткий viewport) */
@media (max-height: 700px) {
  .brand { display: none; }
  .footer { display: none; }
  .container { gap: 0.8rem; }
  .ball-wrapper { width: clamp(200px, 58vw, 260px); height: clamp(200px, 58vw, 260px); }
}

@media (max-height: 580px) {
  .subtitle { display: none; }
  .ball-wrapper { width: 190px; height: 190px; }
  .hint { display: none; }
}

/* Telegram Mini App: ландшафтный режим */
@media (orientation: landscape) and (max-height: 500px) {
  .container { flex-direction: row; gap: 1rem; }
  .title { font-size: 1.2rem; }
  .subtitle, .brand, .footer { display: none; }
  .ball-wrapper { width: 180px; height: 180px; }
}

/* Очень старые телефоны: уменьшаем частицы */
@media (max-width: 360px) {
  .particle { width: 4px; height: 4px; }
  .triangle-text { font-size: 0.55rem; }
}

/* prefers-reduced-motion: отключаем idle и уменьшаем частицы */
@media (prefers-reduced-motion: reduce) {
  .ball-wrapper.idle { animation: none; }
  .particle { display: none; }
}
