/* Дизайн-система Baby Parking — вариант „Под навесом".
   Источник токенов: docs/spec.md + макет babyparking-vibes.html (вариант A). */

:root {
  --bg: #f8ece7;
  --card: #fffdfc;
  --ink: #452a31;
  --mut: #8d6f75;
  --acc: #d9536f;
  --sage: #a3bfa0;
  --med: #efc15c;
  --shadow-card: 0 6px 20px -12px rgba(69, 42, 49, .35);
  color-scheme: light;
}

/* ---------- Reset ---------- */

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

/* Фон и на html: во время view transition снимки страниц полупрозрачны
   в момент наложения, и без этого сквозь них мигает белая подложка. */
html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100dvh;
}

img, svg { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--acc); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .tabbar a, input, select, textarea, a.card {
    transition: background-color .15s ease, border-color .15s ease,
                box-shadow .15s ease, transform .15s ease, opacity .15s ease;
  }
  .btn:active { transform: scale(.97); }
  a.card:active { transform: scale(.98); }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  a.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px -12px rgba(69, 42, 49, .45);
  }
}

/* ---------- Layout ---------- */

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 18px 110px; /* снизу — место под .tabbar */
}

@media (min-width: 720px) {
  .page { max-width: 560px; }
}

body.no-tabs .page { padding-bottom: 32px; }

.hello {
  font-size: 14px;
  color: var(--mut);
  font-weight: 700;
}

h1.title {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin-top: 4px;
}

.section-t {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  padding: 22px 0 10px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

/* Инлайновый снапшот для view transition не строится — карточки-ссылки блочные. */
a.card { display: block; }

.arch-hero {
  background: linear-gradient(160deg, #f7d9d2, #f2b8b3);
  border-radius: 170px 170px 24px 24px;
  padding: 34px 24px 22px;
  text-align: center;
  position: relative;
}

.arch-hero p {
  font-weight: 700;
  font-size: 14.5px;
  color: #6c4048;
  max-width: 26ch;
  margin: 0 auto;
}

.empty {
  text-align: center;
  border: 2px dashed #dfa9a0;
  border-radius: 170px 170px 24px 24px;
  padding: 34px 20px 26px;
  color: var(--mut);
  font-size: 13px;
  font-weight: 700;
}

.empty b { color: var(--acc); }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 13px 24px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
}

.btn-primary {
  background: var(--acc);
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(217, 83, 111, .65);
}

.btn-primary:hover { background: #cb4762; }

.btn-secondary {
  background: transparent;
  color: var(--acc);
  border: 2px solid var(--acc);
  padding: 11px 22px;
}

.btn-secondary:hover { background: rgba(217, 83, 111, .08); }

.btn-ghost {
  background: transparent;
  color: var(--mut);
  padding: 11px 16px;
}

.btn-ghost:hover { color: var(--ink); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Пилюли-статусы ---------- */

.pill {
  display: inline-block;
  background: #fbe9c9;
  color: #8a6320;
  font-size: 11.5px;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.pill-green { background: #e4eee2; color: #4c6a49; }
.pill-red   { background: #f9dde3; color: #a83a52; }
.pill-gray  { background: #efe4e0; color: var(--mut); }

/* ---------- Аватар-арка ---------- */

.ava {
  width: 52px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 26px 26px 10px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  /* градиентный фон задаётся inline per-персона */
}

.ava-lg {
  width: 58px;
  height: 66px;
  font-size: 17px;
}

/* ---------- Чипы ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffffb8;
  border: 1.5px solid #eccfc6;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.chip-add {
  color: var(--acc);
  border-style: dashed;
  background: transparent;
  cursor: pointer;
}

/* Чип с чекбоксом/радио внутри подсвечивается при выборе. */
.chip:has(input:checked) {
  border-color: var(--acc);
  color: var(--acc);
  background: rgba(217, 83, 111, .08);
}

/* Радио-чипы (причина отказа): кружок не рисуем, состояние показывает чип. */
.chip input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Формы ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.field label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--mut);
}

input, select, textarea {
  width: 100%;
  background: var(--card);
  border: 1.5px solid #eccfc6;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
}

input::placeholder, textarea::placeholder {
  color: var(--mut);
  font-weight: 600;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
}

textarea { resize: vertical; min-height: 84px; }

/* Чекбоксы не наследуют width:100% — иначе label.chip разъезжается. */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  accent-color: var(--acc);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238d6f75' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Ошибка валидации формы: значения сохранены, ошибка — в самой форме. */
.form-error {
  background: #fbe3e3;
  border: 1.5px solid #e89b9b;
  border-radius: 14px;
  padding: 11px 14px;
  color: #8c2f39;
  font-weight: 700;
  font-size: 14px;
}

.hint-error { color: #b03a48; font-weight: 700; }

/* Флеш-баннер результата действия (?ok= после редиректа). */
.flash {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #e4eee2;
  border: 1.5px solid #b9cdb6;
  border-radius: 14px;
  padding: 11px 14px;
  color: #4c6a49;
  font-weight: 700;
  font-size: 14px;
}

.flash svg { flex: 0 0 auto; margin-top: 2px; }

/* Карточка, которую только что изменили (?new= после редиректа). */
.card-fresh { box-shadow: var(--shadow-card), 0 0 0 2px var(--sage); }

.form-row {
  display: flex;
  gap: 10px;
}

.form-row > .field { flex: 1; min-width: 0; }

/* ---------- Таймлайн статусов заказа ---------- */

.tl { display: flex; flex-direction: column; }

.tl-step { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.tl-step:last-child { padding-bottom: 0; }

.tl-step::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 24px;
  bottom: 2px;
  width: 2px;
  border-radius: 2px;
  background: #eccfc6;
}
.tl-step:last-child::before { display: none; }

.tl-dot {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.tl-done .tl-dot { background: var(--sage); color: #fff; }
.tl-now .tl-dot  { background: var(--acc); box-shadow: 0 0 0 4px rgba(217, 83, 111, .16); }
.tl-next .tl-dot { border: 2px dashed #dfa9a0; }

.tl-t { font-weight: 800; font-size: 13.5px; line-height: 1.35; padding-top: 1px; }
.tl-step .muted { font-size: 12px; font-weight: 700; }
.tl-now .tl-t { color: var(--acc); }
.tl-next .tl-t { color: var(--mut); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Свёрнутые действия админа ---------- */

.act { border-top: 1.5px solid #f6e7e1; }
.act:first-of-type { border-top: 0; }

.act summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 0;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}

.act summary::-webkit-details-marker { display: none; }

.act .cur { color: var(--mut); font-weight: 700; font-size: 13px; text-align: right; }

.act-body { padding: 2px 0 14px; }

.btn-sm { padding: 9px 16px; font-size: 13.5px; }
.btn-secondary.btn-sm { padding: 7px 14px; }

/* ---------- Неделя няни ---------- */

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.week-nav strong { font-family: 'Comfortaa', sans-serif; font-size: 13.5px; }
.wk-arrow {
  width: 30px; height: 30px;
  border-radius: 999px;
  border: 1.5px solid #eccfc6;
  background: #ffffffb8;
  display: flex; align-items: center; justify-content: center;
  color: var(--mut); font-weight: 800; font-size: 14px;
  text-decoration: none;
}

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }

.day {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 122px;
  background: var(--bg);
  border-radius: 12px;
  padding: 6px 3px;
  cursor: pointer;
}

.day-today { box-shadow: inset 0 0 0 2px var(--acc); }

.day-h { text-align: center; font-size: 10px; font-weight: 800; color: var(--mut); line-height: 1.2; }
.day-h b { display: block; font-size: 13px; color: var(--ink); font-family: 'Comfortaa', sans-serif; }

.slot {
  border-radius: 8px;
  padding: 3px 2px;
  font-size: 9.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.3;
}
.slot-free { background: #e4eee2; color: #4c6a49; }
.slot-busy { background: #f9dde3; color: #a83a52; }

.day-add {
  margin-top: auto;
  align-self: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  border: 1.5px dashed #dfa9a0;
  color: var(--acc);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; line-height: 1;
}

.legend { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.legend .chip { font-size: 11px; padding: 4px 10px; }
.dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }

/* ---------- Таббар ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 14px 10px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px -18px rgba(69, 42, 49, .5);
}

@media (min-width: 720px) {
  .tabbar { max-width: 560px; }
}

.tabbar a {
  font-size: 12px;
  font-weight: 800;
  color: var(--mut);
  text-decoration: none;
  text-align: center;
}

.tabbar a.on { color: var(--acc); }

body.no-tabs .tabbar { display: none; }

/* ---------- Страница ошибки ---------- */

.error-page {
  max-width: 480px;
  margin: 15vh auto 0;
  padding: 0 18px;
  text-align: center;
}

.error-page .card {
  padding: 34px 24px 28px;
  border-radius: 170px 170px 24px 24px;
}

.error-page .emoji {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 12px;
}

.error-page h1 {
  font-family: 'Comfortaa', sans-serif;
  font-weight: 700;
  font-size: 19px;
  margin-bottom: 8px;
}

.error-page p {
  color: var(--mut);
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 18px;
}

/* ---------- Анимации переходов ----------
   htmx оборачивает boosted-навигации в document.startViewTransition()
   (meta htmx-config в base.html); прямые переходы покрывает @view-transition.
   Браузеры без View Transition API просто игнорируют всё это. */

@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  /* Старый снимок не гаснет — новый наплывает поверх. Так суммарная
     непрозрачность никогда не падает и подложка не мигает, даже если
     рендер тормозит и анимация растягивается. mix-blend-mode: normal
     отключает дефолтный plus-lighter кроссфейда (иначе пересвет). */
  ::view-transition-old(root) { animation: none; }
  ::view-transition-new(root) { animation: vt-enter .25s ease both; }
  ::view-transition-image-pair(root) { isolation: auto; }
  ::view-transition-old(root),
  ::view-transition-new(root) { mix-blend-mode: normal; }

  /* Заголовок морфится между страницами, таббар стоит на месте. */
  h1.title { view-transition-name: page-title; }
  .tabbar  { view-transition-name: tabbar; }

  /* Списки карточек мягко «всплывают» с лёгким каскадом. */
  .list > * { animation: rise .3s ease backwards; }
  .list > *:nth-child(2) { animation-delay: .05s; }
  .list > *:nth-child(3) { animation-delay: .1s; }
  .list > *:nth-child(4) { animation-delay: .15s; }
  .list > *:nth-child(n+5) { animation-delay: .2s; }

  /* Карточка с морф-именем перелетает между страницами сама —
     каскадное «всплытие» поверх морфа выглядит как мигание. */
  .list > [style*="view-transition-name"] { animation: none; }

  .arch-hero, .empty { animation: rise .35s ease backwards; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@keyframes vt-enter {
  from { opacity: 0; transform: translateY(10px); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

/* ---------- Утилиты ---------- */

.muted { color: var(--mut); }
.center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.mt-3 { margin-top: 24px; }
