/* =========================================================================
   Медный трекер — токены дизайна
   Палитра вдохновлена самим материалом: тёмный графит мастерской,
   тёплое сияние необработанной меди и холодная патина как цвет "успеха".
   ========================================================================= */

:root {
  /* фон */
  --bg-0: #120d0a;
  --bg-1: #1c140f;
  --bg-2: #241a13;

  /* стекло */
  --glass-fill: rgba(255, 246, 237, 0.045);
  --glass-fill-strong: rgba(255, 246, 237, 0.075);
  --glass-border: rgba(255, 236, 220, 0.09);
  --glass-border-strong: rgba(255, 236, 220, 0.16);

  /* медь — основной акцент (в процессе) */
  --copper-300: #f0ab72;
  --copper-500: #e08a4c;
  --copper-600: #c26d34;
  --copper-700: #8a4a22;

  /* патина — акцент завершения / успеха */
  --patina-300: #9bd8c1;
  --patina-500: #57ab8d;
  --patina-700: #2f6b56;

  /* ржавчина — предупреждение / минус */
  --rust-500: #b5533d;
  --rust-600: #96412e;

  /* текст */
  --text-0: #f9f2ea;
  --text-1: #cdbfb1;
  --text-2: #92806f;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root { color-scheme: dark; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  color: var(--text-0);
  background:
    radial-gradient(ellipse 900px 600px at 15% -10%, rgba(224, 138, 76, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(87, 171, 141, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* тонкая текстура — едва заметный шум, чтобы плоский фон не выглядел стерильно */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
}

/* ---------------------------------- header ---------------------------------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--copper-500), var(--copper-700));
  color: #1c1108;
  box-shadow: 0 4px 18px rgba(224, 138, 76, 0.35);
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }

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

.brand-eyebrow {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--text-2);
  font-family: var(--font-mono);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
  color: var(--text-1);
  backdrop-filter: blur(16px);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--copper-500);
  box-shadow: 0 0 0 0 rgba(224, 138, 76, 0.6);
  animation: pulse-dot 2.4s ease-out infinite;
}
.status-dot.is-complete { background: var(--patina-500); box-shadow: 0 0 0 0 rgba(87,171,141,.6); animation-name: pulse-dot-patina; }

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(224, 138, 76, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(224, 138, 76, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 138, 76, 0); }
}
@keyframes pulse-dot-patina {
  0% { box-shadow: 0 0 0 0 rgba(87,171,141, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(87,171,141, 0); }
  100% { box-shadow: 0 0 0 0 rgba(87,171,141, 0); }
}

/* ---------------------------------- content ---------------------------------- */

.content { display: flex; flex-direction: column; gap: 22px; }

/* Signature element: круговой манометр */

.gauge-section { display: flex; justify-content: center; padding: 8px 0 2px; }

.gauge-wrap {
  position: relative;
  width: min(78vw, 280px);
  aspect-ratio: 1 / 1;
}

.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }

.gauge-track {
  fill: none;
  stroke: var(--glass-fill-strong);
  stroke-width: 14;
}

.gauge-fill {
  fill: none;
  stroke: url(#gaugeGradient);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 804.25;
  stroke-dashoffset: 804.25;
  transition: stroke-dashoffset 1.1s var(--ease-out), stroke 0.6s ease;
  filter: drop-shadow(0 0 10px rgba(224, 138, 76, 0.45));
}

.gauge-fill.is-complete {
  filter: drop-shadow(0 0 14px rgba(87, 171, 141, 0.6));
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  padding: 0 20px;
}

.gauge-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-2);
}

.gauge-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(26px, 7vw, 32px);
  color: var(--text-0);
  letter-spacing: -0.01em;
}

.gauge-goal { font-size: 12.5px; color: var(--text-2); }

.gauge-percent {
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--copper-300);
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(224, 138, 76, 0.12);
  border: 1px solid rgba(224, 138, 76, 0.25);
  transition: color 0.4s ease, background 0.4s ease, border-color 0.4s ease;
}
.gauge-percent.is-complete {
  color: var(--patina-300);
  background: rgba(87, 171, 141, 0.14);
  border-color: rgba(87, 171, 141, 0.3);
}

/* Сегментная лента мешков (кабельный мотив) */

.cable-section {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 18px 18px;
  backdrop-filter: blur(16px);
}

.cable-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-1);
  margin-bottom: 12px;
}

.cable-count {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-0);
  font-size: 13.5px;
}

.cable-bar {
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  gap: 3px;
}

.cable-tick {
  height: 22px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  transition: background 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out), transform 0.4s var(--ease-out);
}

.cable-tick.is-filled {
  background: linear-gradient(180deg, var(--copper-300), var(--copper-600));
  box-shadow: 0 0 8px rgba(224, 138, 76, 0.4);
}

.cable-tick.is-complete-fill {
  background: linear-gradient(180deg, var(--patina-300), var(--patina-500));
  box-shadow: 0 0 8px rgba(87, 171, 141, 0.45);
}

.cable-tick.just-added {
  animation: tick-pop 0.5s var(--ease-out);
}

@keyframes tick-pop {
  0% { transform: scaleY(0.3); }
  60% { transform: scaleY(1.35); }
  100% { transform: scaleY(1); }
}

/* Мотивационный тост */

.toast {
  min-height: 20px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--copper-300);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  padding: 0 12px;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-complete { color: var(--patina-300); font-size: 17px; }

/* Кнопки управления */

.controls {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 62px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15.5px;
  cursor: pointer;
  backdrop-filter: blur(16px);
  transition: transform 0.15s var(--ease-out), box-shadow 0.25s var(--ease-out), background 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn svg { width: 19px; height: 19px; flex-shrink: 0; }

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

.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-minus {
  background: var(--glass-fill);
  color: var(--text-1);
}
.btn-minus:not(:disabled):hover { background: var(--glass-fill-strong); border-color: rgba(181, 83, 61, 0.35); color: #e3b6ac; }

.btn-plus {
  background: linear-gradient(145deg, var(--copper-500), var(--copper-700));
  color: #1c1108;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(224, 138, 76, 0.3);
}
.btn-plus:not(:disabled):hover { box-shadow: 0 10px 30px rgba(224, 138, 76, 0.42); transform: translateY(-1px); }
.btn-plus:not(:disabled):active { transform: scale(0.96); }

.btn-plus.is-complete {
  background: linear-gradient(145deg, var(--patina-300), var(--patina-700));
  box-shadow: 0 8px 24px rgba(87, 171, 141, 0.3);
}

/* Статистика */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  backdrop-filter: blur(16px);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.stat-icon {
  width: 26px;
  height: 26px;
  color: var(--copper-300);
  opacity: 0.9;
}
.stat-icon svg { width: 100%; height: 100%; }

.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16.5px;
  color: var(--text-0);
  letter-spacing: -0.01em;
}

.stat-label {
  font-size: 10.5px;
  color: var(--text-2);
  line-height: 1.3;
}

/* Достижения */

.achievements {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 18px 18px;
  backdrop-filter: blur(16px);
}

.achievements-title {
  display: block;
  font-size: 13px;
  color: var(--text-1);
  margin-bottom: 12px;
}

.achievements-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.achievement {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.achievement-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--glass-border);
  color: var(--text-2);
  transition: all 0.5s var(--ease-out);
}
.achievement-icon svg { width: 18px; height: 18px; }
.achievement-icon .icon-check { display: none; }
.achievement-icon .icon-lock { display: block; }

.achievement.is-unlocked .achievement-icon {
  background: linear-gradient(145deg, var(--copper-300), var(--copper-600));
  border-color: transparent;
  color: #1c1108;
  box-shadow: 0 4px 14px rgba(224, 138, 76, 0.35);
}
.achievement.is-unlocked .achievement-icon .icon-check { display: block; }
.achievement.is-unlocked .achievement-icon .icon-lock { display: none; }

.achievement.just-unlocked .achievement-icon { animation: badge-pop 0.6s var(--ease-out); }

@keyframes badge-pop {
  0% { transform: scale(0.6); }
  55% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.achievement-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
}
.achievement.is-unlocked .achievement-num { color: var(--copper-300); }

/* Footer */

.page-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-2);
  padding-top: 4px;
}

/* ---------------------------------- завершение цели ---------------------------------- */

.page.is-complete .gauge-percent,
.page.is-complete .toast { color: var(--patina-300); }

/* ---------------------------------- responsive ---------------------------------- */

@media (min-width: 560px) {
  .page { padding-top: 32px; }
  .gauge-amount { font-size: 34px; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 6px; }
  .stat-value { font-size: 14.5px; }
  .btn { font-size: 14px; height: 58px; }
  .cable-bar { grid-template-columns: repeat(13, 1fr); grid-auto-rows: 18px; row-gap: 4px; }
  .cable-tick { height: 18px; }
}

/* ---------------------------------- accessibility ---------------------------------- */

.btn:focus-visible,
.status-pill:focus-visible {
  outline: 2px solid var(--copper-300);
  outline-offset: 3px;
}

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