/* ==========================================================================
   Страница-заглушка «Сервер перегружен»
   Токены дизайна, типографика, анимации и адаптивная вёрстка (mobile-first)
   ========================================================================== */

:root {
  /* Цвета */
  --bg-base: #0b0d13;
  --bg-mid: #12141c;
  --bg-elevated: #14161f;
  --surface-border: rgba(255, 255, 255, 0.07);
  --text-primary: #edeef2;
  --text-secondary: #8b90a3;
  --accent-amber: #ff8a3d;
  --accent-red: #e5484d;

  /* Типографика */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono",
    "Courier New", monospace;

  /* Форма */
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

/* Сброс базовых отступов и учёт border-box везде */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  min-height: 100dvh; /* корректная высота на мобильных браузерах */
  min-height: 100vh; /* запасной вариант для старых браузеров */
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
      circle at 50% 0%,
      rgba(255, 138, 61, 0.07),
      transparent 60%
    ),
    linear-gradient(165deg, var(--bg-base) 0%, var(--bg-mid) 55%, #171a24 100%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  padding: 20px;
  overflow-x: hidden;
}

/* Едва заметная техническая сетка на фоне — деталь для «серверной» темы */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 75%);
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Карточка со всем контентом */
.card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Мягкие многослойные тени вместо резкой обводки */
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.65),
    0 8px 24px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 138, 61, 0.03);
}

.logo {
  display: block;
  margin-bottom: 18px;
  border-radius: 11px;
}

/* ---------- Иллюстрация: датчик нагрузки ---------- */

.gauge-wrap {
  position: relative;
  margin-bottom: 8px;
}

.gauge {
  width: 176px;
  height: auto;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.09);
  stroke-width: 10;
  stroke-linecap: round;
}

.gauge-danger-zone {
  fill: none;
  stroke: var(--accent-red);
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.9;
}

.gauge-ticks line {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 2;
  stroke-linecap: round;
}

.gauge-bolt {
  fill: var(--accent-amber);
  opacity: 0.85;
}

.gauge-needle line {
  stroke: var(--text-primary);
  stroke-width: 3;
  stroke-linecap: round;
}

.gauge-needle-tip {
  fill: var(--accent-red);
}

.gauge-pivot {
  fill: var(--bg-elevated);
  stroke: var(--text-secondary);
  stroke-width: 2;
}

/* Стрелка «дрожит», застряв в красной зоне — источник вращения в центре шкалы */
.gauge-needle {
  transform-origin: 100px 100px;
  animation: needle-jitter 2.4s ease-in-out infinite;
}

@keyframes needle-jitter {
  0%,
  100% {
    transform: rotate(-1.4deg);
  }
  50% {
    transform: rotate(1.6deg);
  }
}

.gauge-caption {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

/* ---------- Текстовые блоки ---------- */

.eyebrow {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-amber);
}

.title {
  margin-top: 10px;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.subtitle {
  margin-top: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 34ch;
}

/* ---------- Таймер и прогресс-бар ---------- */

.timer-block {
  margin-top: 26px;
  width: 100%;
}

.timer-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.timer {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: clamp(2.4rem, 11vw, 3rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; /* цифры не «прыгают» по ширине */
  color: var(--text-primary);
  transition: color 0.4s ease;
}

/* Состояние тревоги в последнюю минуту отсчёта */
.timer.timer--danger {
  color: var(--accent-red);
  animation: pulse-danger 1.2s ease-in-out infinite;
}

@keyframes pulse-danger {
  0%,
  100% {
    text-shadow: 0 0 0 rgba(229, 72, 77, 0);
  }
  50% {
    text-shadow: 0 0 22px rgba(229, 72, 77, 0.55);
  }
}

.progress-track {
  margin-top: 16px;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%; /* стартует со 100% и уменьшается скриптом */
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-amber), #ffb168);
  transition: width 1s linear, background 0.4s ease, box-shadow 0.4s ease;
}

.progress-fill.progress-fill--danger {
  background: linear-gradient(90deg, var(--accent-red), #ff6b6b);
  box-shadow: 0 0 14px rgba(229, 72, 77, 0.55);
}

.progress-percent {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---------- Кнопка ручного обновления ---------- */

.btn-refresh {
  margin-top: 26px;
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-amber);
  background: transparent;
  border: 1.5px solid var(--accent-amber);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.15s ease;
}

.btn-refresh:hover {
  background: var(--accent-amber);
  color: var(--bg-base);
}

.btn-refresh:active {
  transform: scale(0.98);
}

/* Видимый фокус для клавиатурной навигации */
.btn-refresh:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 3px;
}

.noscript-msg {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.noscript-msg a {
  color: var(--accent-amber);
}

/* ---------- Анимация появления элементов (fade-in) ---------- */

.fade-in {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Адаптивная вёрстка ---------- */

@media (min-width: 480px) {
  .card {
    padding: 40px 36px 34px;
  }

  .gauge {
    width: 196px;
  }
}

@media (min-width: 768px) {
  .card {
    max-width: 480px;
    padding: 46px 44px 38px;
  }
}

/* ---------- Уважение к настройке «уменьшить анимацию» ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-in {
    opacity: 1;
    transform: none;
  }
}
