/* =========================================================
   Todo — общие стили проекта
   ========================================================= */

:root {
  --deep: #0e2b2a;        /* основной тёмный */
  --deep-soft: #1a4140;   /* hover / границы */
  --page: #f1f6f4;        /* фон страницы */
  --text: #dcebe8;        /* текст на тёмном */
  --check: #b6f06b;       /* акцент */
  --line: #dfe9e5;        /* светлые границы */
  --muted: #7c9590;       /* второстепенный текст */
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(14, 43, 42, .08);
  --shadow-hover: 0 12px 28px rgba(14, 43, 42, .14);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

body {
  background:
    radial-gradient(circle at 100% 0%, rgba(182, 240, 107, .12), transparent 40%),
    var(--page);
  background-attachment: fixed;
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--deep);
  min-height: 100vh;
}

::selection { background: var(--check); color: var(--deep); }

/* =========================================================
   Анимации
   ========================================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@keyframes growX    { from { transform: scaleX(0); } }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}
@keyframes ring     { from { stroke-dashoffset: var(--ring-len); } }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* Появление блоков страницы по очереди: style="--i: 2" задаёт задержку */
.anim {
  animation: fadeUp .45s ease both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* Элементы списка появляются каскадом */
.stagger > * { animation: fadeUp .45s ease both; animation-delay: 700ms; }
.stagger > :nth-child(1) { animation-delay: 130ms; }
.stagger > :nth-child(2) { animation-delay: 180ms; }
.stagger > :nth-child(3) { animation-delay: 230ms; }
.stagger > :nth-child(4) { animation-delay: 280ms; }
.stagger > :nth-child(5) { animation-delay: 330ms; }
.stagger > :nth-child(6) { animation-delay: 380ms; }
.stagger > :nth-child(7) { animation-delay: 430ms; }
.stagger > :nth-child(8) { animation-delay: 480ms; }
.stagger > :nth-child(9) { animation-delay: 530ms; }
.stagger > :nth-child(10) { animation-delay: 580ms; }
.stagger > :nth-child(11) { animation-delay: 630ms; }
.stagger > :nth-child(12) { animation-delay: 680ms; }

/* Карточка уезжает (удаление / смена статуса) */
.leaving {
  transition: opacity .3s ease, transform .3s ease, max-height .35s ease .1s,
              margin .35s ease .1s, padding .35s ease .1s;
  opacity: 0 !important;
  transform: translateX(30px) scale(.97) !important;
  max-height: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden;
}

/* Уважаем системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}

/* =========================================================
   Навбар
   ========================================================= */
.navbar-todo {
  background: var(--deep);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  box-shadow: 0 8px 24px rgba(14, 43, 42, .2);
  animation: fadeIn .4s ease both;
}
.navbar-todo .navbar-brand {
  font-weight: 800;
  font-size: 1.35rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.navbar-todo .navbar-brand i {
  background: var(--check);
  color: var(--deep);
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  transition: transform .35s var(--ease-spring);
}
.navbar-todo .navbar-brand:hover i { transform: scale(1.15) rotate(-12deg); }

.navbar-todo .nav-link {
  color: var(--text);
  font-weight: 600;
  padding: .5rem .9rem;
  margin-inline: .15rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: .45rem;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.navbar-todo .nav-link:hover,
.navbar-todo .nav-link:focus-visible {
  background: var(--deep-soft);
  color: #fff;
}
.navbar-todo .nav-link:active { transform: scale(.96); }
.navbar-todo .nav-link.active { background: var(--check); color: var(--deep); }

.navbar-todo .nav-link:focus-visible,
.navbar-todo .navbar-brand:focus-visible,
.btn-add:focus-visible {
  outline: 2px solid var(--check);
  outline-offset: 2px;
}

.task-count {
  background: var(--check);
  color: var(--deep);
  font-size: .72rem;
  font-weight: 800;
  padding: .1rem .45rem;
  border-radius: 999px;
  animation: pop .5s var(--ease-spring) .3s both;
}
.nav-link.active .task-count { background: var(--deep); color: var(--check); }

.btn-add {
  background: transparent;
  color: var(--check);
  border: 1.5px solid var(--check);
  border-radius: 999px;
  font-weight: 700;
  padding: .45rem 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: background-color .2s ease, color .2s ease;
}
.btn-add i { transition: transform .3s var(--ease-spring); }
.btn-add:hover { background: var(--check); color: var(--deep); }
.btn-add:hover i { transform: rotate(90deg); }

.btn-logout {
  border: 0;
  background: transparent;
  width: 100%;
}

.navbar-todo .navbar-toggler { border: 1px solid var(--deep-soft); padding: .4rem .6rem; }
.navbar-todo .navbar-toggler:focus { box-shadow: 0 0 0 .2rem rgba(182, 240, 107, .35); }
.navbar-todo .navbar-toggler-icon { filter: invert(1); }

@media (max-width: 991.98px) {
  .navbar-todo .navbar-collapse {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--deep-soft);
  }
  .btn-add { justify-content: center; margin-top: .5rem; }
}

/* =========================================================
   Уведомления (всплывающие сообщения)
   ========================================================= */
.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast-todo {
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--deep);
  color: #fff;
  border-radius: 12px;
  padding: .75rem .9rem;
  box-shadow: 0 12px 30px rgba(14, 43, 42, .3);
  font-weight: 600;
  animation: toastIn .35s var(--ease-spring) both;
  transition: opacity .3s ease, transform .3s ease;
}
.toast-todo.hide { opacity: 0; transform: translateX(20px); }
.toast-todo .t-icon {
  width: 1.8rem; height: 1.8rem;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--check);
  color: var(--deep);
}
.toast-todo.danger .t-icon,
.toast-todo.warning .t-icon { background: #f0786b; color: #fff; }
.toast-todo .t-close {
  margin-left: auto;
  background: none; border: 0;
  color: var(--text);
  opacity: .7;
}
.toast-todo .t-close:hover { opacity: 1; }

/* =========================================================
   Шапка-«герой» с прогрессом
   ========================================================= */
.hero {
  background: linear-gradient(135deg, var(--deep) 0%, var(--deep-soft) 100%);
  color: #fff;
  border-radius: 18px;
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 30px rgba(14, 43, 42, .18);
  position: relative;
  overflow: hidden;
}
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(182, 240, 107, .12);
  pointer-events: none;
}
.hero::after  { right: -60px; top: -60px; width: 200px; height: 200px; animation: float 6s ease-in-out infinite; }
.hero::before { right: 120px; bottom: -50px; width: 110px; height: 110px; background: rgba(182, 240, 107, .07); animation: float 8s ease-in-out infinite reverse; }
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 1.8rem; font-weight: 800; margin: 0 0 .25rem; }
.hero .sub { color: var(--text); font-weight: 500; margin-bottom: 1.1rem; }
.hero .date-chip,
.hero .back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(182, 240, 107, .15);
  color: var(--check);
  font-weight: 700;
  font-size: .85rem;
  padding: .25rem .75rem;
  border-radius: 999px;
  margin-bottom: .6rem;
  text-decoration: none;
}
.hero .date-chip::first-letter { text-transform: uppercase; }
.hero .back-link { transition: background .2s ease; }
.hero .back-link:hover { background: rgba(182, 240, 107, .28); }
.hero .back-link i { transition: transform .2s ease; }
.hero .back-link:hover i { transform: translateX(-3px); }

.progress-wrap { display: flex; align-items: center; gap: 1rem; }
.progress-track {
  flex-grow: 1;
  height: .6rem;
  background: rgba(255, 255, 255, .12);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8fdc3f, var(--check));
  border-radius: 999px;
  transform-origin: left;
  animation: growX .9s cubic-bezier(.22, 1, .36, 1) .2s both;
}
.progress-label { font-weight: 800; color: var(--check); min-width: 3rem; text-align: right; }

/* =========================================================
   Быстрое добавление
   ========================================================= */
.quick-add {
  display: flex;
  gap: .6rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem .5rem .5rem 1rem;
  margin-bottom: 1.75rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.quick-add:focus-within {
  border-color: var(--check);
  box-shadow: 0 0 0 .25rem rgba(182, 240, 107, .25);
}
.quick-add .qa-name {
  flex-grow: 1;
  border: 0;
  outline: 0;
  font-weight: 600;
  color: var(--deep);
  background: transparent;
  min-width: 0;
}
.quick-add .qa-date {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .35rem .6rem;
  color: var(--deep-soft);
  font-weight: 600;
}
.quick-add .qa-btn {
  background: var(--deep);
  color: var(--check);
  border: 0;
  border-radius: 10px;
  width: 2.6rem;
  font-size: 1.2rem;
  transition: transform .25s var(--ease-spring);
}
.quick-add .qa-btn:hover  { transform: scale(1.08) rotate(90deg); }
.quick-add .qa-btn:active { transform: scale(.92); }

/* =========================================================
   Секции и карточки задач
   ========================================================= */
.section-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--deep-soft);
  margin: 0 0 .75rem .25rem;
}
.section-title .badge-n {
  background: var(--line);
  color: var(--deep);
  border-radius: 999px;
  padding: .05rem .5rem;
  font-size: .75rem;
}
.section-title.danger { color: var(--danger); }
.section-title.danger .badge-n { background: var(--danger-bg); color: var(--danger); }

.task-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--check);
  border-radius: 12px;
  padding: .85rem 1rem;
  margin-bottom: .6rem;
  max-height: 200px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.task-card.overdue { border-left-color: #f0786b; }
.task-card.is-done { border-left-color: #c5d8d2; background: #f8fbfa; }

.toggle-form { margin: 0; }
.task-check {
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  border: 2px solid var(--deep-soft);
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  color: transparent;
  padding: 0;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.task-check:hover { color: var(--deep-soft); transform: scale(1.1); }
.task-check.checking,
.is-done .task-check {
  background: var(--deep);
  border-color: var(--deep);
  color: var(--check);
}
.task-check.checking { animation: pop .4s var(--ease-spring); }

.task-body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.task-text {
  font-weight: 600;
  color: var(--deep);
  overflow-wrap: anywhere;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 0 2px;
  transition: background-size .3s ease, opacity .3s ease;
}
.is-done .task-text,
.checking ~ .task-body .task-text,
.task-card.striking .task-text { background-size: 100% 2px; opacity: .5; }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .2rem;
  font-size: .78rem;
  color: var(--muted);
}
.task-meta .proj {
  display: inline-flex; align-items: center; gap: .25rem;
  color: var(--deep-soft);
  font-weight: 700;
  text-decoration: none;
}
.task-meta .proj:hover { text-decoration: underline; }

.due {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-weight: 700;
  padding: .05rem .5rem;
  border-radius: 999px;
  background: #eef4f2;
  color: var(--deep-soft);
}
.due.today { background: #f2fbe4; color: #4c7a12; }
.due.late  { background: var(--danger-bg); color: var(--danger); }

.btn-delete {
  border: 0;
  background: transparent;
  color: #a9bdb8;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease, transform .2s ease;
}
.task-card:hover .btn-delete,
.project-card:hover .btn-delete,
.btn-delete:focus-visible { opacity: 1; }
.btn-delete:hover { background: var(--danger-bg); color: var(--danger); }
.btn-delete:hover i { animation: shake .4s ease; display: inline-block; }
@media (hover: none) { .btn-delete { opacity: 1; } }

.done-toggle { background: none; border: 0; padding: 0; cursor: pointer; }
.done-toggle .bi-chevron-down { transition: transform .25s ease; }
.done-toggle.collapsed .bi-chevron-down { transform: rotate(-90deg); }

/* =========================================================
   Пустое состояние
   ========================================================= */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: #fff;
  border: 2px dashed #c5d8d2;
  border-radius: var(--radius);
  color: var(--deep-soft);
}
.empty-state > i {
  font-size: 2rem;
  color: var(--check);
  background: var(--deep);
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  margin-bottom: .75rem;
  animation: float 3s ease-in-out infinite;
}
.empty-state h2 { font-size: 1.2rem; font-weight: 800; color: var(--deep); }

/* =========================================================
   Проекты
   ========================================================= */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.project-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--check);
}
.project-card .p-head { display: flex; align-items: center; gap: .75rem; }
.project-card .p-icon {
  width: 2.6rem; height: 2.6rem;
  border-radius: 12px;
  background: var(--deep);
  color: var(--check);
  display: grid; place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: transform .35s var(--ease-spring);
}
.project-card:hover .p-icon { transform: rotate(-8deg) scale(1.08); }
.project-card .p-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--deep);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.project-card .p-name::after { content: ""; position: absolute; inset: 0; } /* вся карточка — ссылка */
.project-card .p-stats { font-size: .82rem; color: var(--muted); font-weight: 600; }
.project-card .p-track {
  height: .4rem;
  background: #eef4f2;
  border-radius: 999px;
  overflow: hidden;
}
.project-card .p-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--deep-soft), #8fdc3f);
  border-radius: 999px;
  transform-origin: left;
  animation: growX .9s cubic-bezier(.22, 1, .36, 1) .3s both;
}
.project-card .p-del { position: absolute; top: .6rem; right: .6rem; z-index: 2; margin: 0; }

/* =========================================================
   Формы (новая задача / проект, вход, регистрация, профиль)
   ========================================================= */
.form-card {
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.form-card.narrow { max-width: 440px; }
.form-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--deep);
  margin-bottom: 1.25rem;
}
.form-card .form-icon {
  width: 3.4rem; height: 3.4rem;
  border-radius: 50%;
  background: var(--deep);
  color: var(--check);
  display: grid; place-items: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
  animation: pop .6s var(--ease-spring) .2s both;
}
.form-card label { font-weight: 600; color: var(--deep); margin-bottom: .35rem; display: block; }

.form-card input:not([type="checkbox"]):not([type="hidden"]),
.form-card textarea,
.form-card select {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid #cfe0da;
  border-radius: 10px;
  background: var(--page);
  color: var(--deep);
  font-weight: 600;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.form-card input:focus,
.form-card textarea:focus,
.form-card select:focus {
  outline: none;
  border-color: var(--deep);
  background: #fff;
  box-shadow: 0 0 0 .2rem rgba(182, 240, 107, .45);
}
.form-card .has-error input { border-color: #f0786b; animation: shake .4s ease; }
.form-card .form-text { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.form-card .form-text ul { padding-left: 1.1rem; margin: .2rem 0 0; }

.field-error { color: #b42318; font-size: .85rem; margin-top: .3rem; }
.alert-form {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 10px;
  padding: .7rem .9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  animation: shake .4s ease;
}
.alert-form ul { margin: 0; padding-left: 1.1rem; }

.btn-save {
  background: var(--deep);
  color: var(--check);
  border: none;
  border-radius: 999px;
  font-weight: 700;
  padding: .65rem 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background-color .2s ease, transform .15s ease, box-shadow .2s ease;
}
.btn-save:hover  { background: var(--deep-soft); box-shadow: 0 6px 16px rgba(14, 43, 42, .2); }
.btn-save:active { transform: scale(.97); }
.btn-save.w-100 { width: 100%; }

.btn-cancel {
  color: var(--deep-soft);
  font-weight: 600;
  text-decoration: none;
  padding: .6rem 1rem;
  border-radius: 999px;
  transition: background .2s ease;
}
.btn-cancel:hover { background: #e3eeea; color: var(--deep); }

.form-foot { text-align: center; margin-top: 1.25rem; color: var(--muted); font-weight: 500; }
.form-foot a { color: var(--deep); font-weight: 700; }

/* Страницы входа/регистрации — по центру экрана */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: 1rem 0 3rem; }
.auth-wrap .form-card { width: 100%; }

/* =========================================================
   Профиль
   ========================================================= */
.profile-head { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.avatar {
  width: 4.5rem; height: 4.5rem;
  border-radius: 50%;
  background: var(--check);
  color: var(--deep);
  display: grid; place-items: center;
  font-size: 1.9rem;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 0 0 4px rgba(182, 240, 107, .25);
  animation: pop .6s var(--ease-spring) .2s both;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex; align-items: center; gap: .9rem;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.stat .s-icon {
  width: 2.6rem; height: 2.6rem;
  border-radius: 12px;
  background: #eef4f2;
  color: var(--deep-soft);
  display: grid; place-items: center;
  font-size: 1.2rem;
}
.stat .s-val { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.stat .s-lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }

.ring { width: 2.6rem; height: 2.6rem; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .r-bg { stroke: #eef4f2; }
.ring .r-fg {
  stroke: #8fdc3f;
  stroke-linecap: round;
  --ring-len: 100;
  stroke-dasharray: 100;
  animation: ring 1.1s cubic-bezier(.22, 1, .36, 1) .3s both;
}

.profile-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .profile-grid { grid-template-columns: 1fr 1fr; } }
.profile-grid .form-card { max-width: none; margin: 0; }
.profile-grid h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 1rem; display: flex; gap: .5rem; align-items: center; }
