/* Минимальная подгонка поверх Pico */
article { margin-bottom: 1.5rem; }
code { font-size: 1.05em; }
mark { padding: 0 0.3em; }

/* === Topbar (глубокий синий navbar) ===================================== */
.topbar {
  background: #1d2735;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
}
.topbar-brand {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.topbar-brand strong { color: #fff; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-btn {
  background: transparent;
  color: #cfd6e0;
  border: 0;
  margin: 0;                         /* Pico ставит button { margin-bottom } — гасим */
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1;                    /* у <button> и <a> разный baseline без этого */
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  height: 34px;                      /* единая высота для button и a в navbar */
  letter-spacing: 0.01em;
}
.topbar-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* --- Таймер обратного отсчёта в navbar --- */
.topbar-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 7px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: #cfd6e0;
  font-size: 12.5px;
  font-feature-settings: "tnum";
}
.topbar-timer-label { color: #8a96a6; }
.topbar-timer-value { color: #fff; font-weight: 600; font-size: 14px; min-width: 44px; text-align: right; }
.topbar-timer.state-open { background: rgba(31,157,85,0.16); border-color: rgba(31,157,85,0.30); }
.topbar-timer.state-open .topbar-timer-value { color: #6cd58a; }
.topbar-timer.warning { background: rgba(224,134,61,0.18); border-color: rgba(224,134,61,0.35); }
.topbar-timer.warning .topbar-timer-value { color: #f5a85a; }
.topbar-timer.expired { background: rgba(220,70,70,0.18); border-color: rgba(220,70,70,0.35); }
.topbar-timer.expired .topbar-timer-value { color: #ff7676; }
.topbar-timer.state-input_closed,
.topbar-timer.state-closed,
.topbar-timer.state-calculated,
.topbar-timer.state-none {
  background: rgba(255,255,255,0.03);
  color: #8a96a6;
}

/* Pico по умолчанию ставит body padding-top — после введения topbar он мешает.
   Container сам про себя позаботится. */
body > main.container { padding-top: 1.2rem; }

/* --- Модальные уведомления (старт таймера, последняя минута года) ---
   Центрированный overlay + карточка с иконкой и анимацией bounce-in.
   Управление в base.html: window.__showToast(text, level) или __showToast(level, title, body).
*/
.warn-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  background: rgba(29, 39, 53, 0);
  transition: opacity 220ms ease, background-color 220ms ease;
}
.warn-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
  background: rgba(29, 39, 53, 0.55);
}
/* info-уровень не должен блокировать клики по странице, только привлекать
   внимание. У warning — блокирующий, нужен осознанный клик «Понятно». */
.warn-modal-overlay.level-info {
  pointer-events: none;
  background: transparent;
}
.warn-modal-overlay.level-info.show { background: rgba(29, 39, 53, 0.15); }
.warn-modal-overlay.level-info .warn-modal { pointer-events: auto; }

.warn-modal {
  background: #ffffff;
  border-radius: 18px;
  padding: 36px 44px 28px;
  min-width: 320px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(0, 0, 0, 0.06);
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 200ms ease;
  border-top: 6px solid #3a6dc7;
}
.warn-modal-overlay.show .warn-modal { transform: scale(1) translateY(0); opacity: 1; }
.warn-modal.level-warning { border-top-color: #e0863d; }
.warn-modal.level-warning .warn-modal-icon {
  background: linear-gradient(135deg, #fff6ec, #ffd9b3);
  color: #e0863d;
  animation: warn-pulse 1.6s ease-in-out infinite;
}
.warn-modal.level-info .warn-modal-icon {
  background: linear-gradient(135deg, #e6edf9, #c8d6f0);
  color: #3a6dc7;
}
.warn-modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 700;
}
.warn-modal-title {
  font-size: 22px;
  font-weight: 700;
  color: #1d2735;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.warn-modal-body {
  font-size: 14.5px;
  color: #7b8696;
  margin: 0 0 20px;
  line-height: 1.45;
}
.warn-modal-btn {
  padding: 10px 28px;
  border-radius: 8px;
  border: none;
  background: #1d2735;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease;
}
.warn-modal-btn:hover { background: #2a3a52; }
.warn-modal.level-warning .warn-modal-btn { background: #e0863d; }
.warn-modal.level-warning .warn-modal-btn:hover { background: #c4732e; }

@keyframes warn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 134, 61, 0.55); }
  50% { box-shadow: 0 0 0 14px rgba(224, 134, 61, 0); }
}

.rules-btn { margin: 0; padding: 0.4rem 0.8rem; }

dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog { border: none; padding: 0; max-width: min(720px, 92vw); }
dialog > article { margin: 0; }

.rules-modal { width: min(720px, 92vw); }
.rules-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}
.rules-body h4 { margin-top: 1.2rem; }
.rules-body h4:first-child { margin-top: 0; }

/* Карточка задачи года: компактнее, чтобы не перегружать страницу */
.year-brief summary { cursor: pointer; font-weight: 600; }
.year-brief[open] summary { margin-bottom: 0.5rem; }

/* Причинно-следственная цепочка */
.causal-chain { list-style: none; padding-left: 0; margin: 0; }
.causal-chain li {
  padding: 0.4rem 0;
  border-left: 3px solid #2a7;
  padding-left: 0.8rem;
  margin-bottom: 0.4rem;
}
.causal-chain li.neg { border-left-color: #c33; }
.causal-chain li.flat { border-left-color: #999; }

/* Скип-линк для клавиатурной навигации: прячется, пока не получает focus. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: 0.6rem 1rem;
  background: #1f5d8c;
  color: #fff;
  border-radius: 0 0 0.4rem 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Тонкая верхняя полоска во время HTMX-запроса (поллинг, сабмиты). */
#top-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: #1f5d8c;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease-out, opacity 0.3s ease-out;
  opacity: 0;
  z-index: 10000;
  pointer-events: none;
}
body.htmx-busy #top-progress {
  transform: scaleX(1);
  opacity: 1;
  transition: transform 1.2s ease-out, opacity 0.1s;
}

/* Мобильная вёрстка: на телефоне таблица команд у админа выходит за экран —
   разрешаем горизонтальный скролл и поджимаем паддинги, чтобы не ломать остальное. */
@media (max-width: 600px) {
  main.container { padding: 0.5rem; }
  article { padding: 0.8rem; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  nav ul { padding: 0; }
  .rules-btn { padding: 0.35rem 0.6rem; font-size: 0.9rem; }
}

/* Публичная главная (overview). */
.overview-hero {
  text-align: center;
  padding: 2rem 0 1rem;
}
.overview-hero hgroup h1 { margin-bottom: 0.4rem; }
.overview-hero hgroup p {
  max-width: 46rem;
  margin: 0 auto;
  color: var(--pico-muted-color, #64748b);
}
.overview-cta {
  max-width: 40rem;
  margin: 1.8rem auto 0;
}
.overview-cta-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  height: 100%;
}
.overview-cta-btn small {
  font-weight: 400;
  opacity: 0.85;
}
.overview-how { margin-top: 2.5rem; }
.overview-how h2 { text-align: center; }
.overview-how article h3 { margin-bottom: 0.4rem; font-size: 1.05rem; }
