/* Сессия 11: дизайн-система. Тёплый светлый фон, PT Sans/PT Serif, один
   язык — целевой текст крупно и основным цветом, русский — подписью.
   Тёмной темы нет (сознательное решение ТЗ). */

:root {
  --bg:        #faf8f5;
  --surface:   #ffffff;
  --text:      #2a2622;
  --text-dim:  #8a8074;
  --accent:    #2f6f6a;
  --accent-ink: #ffffff;
  --ok:        #3f7d4f;
  --ok-bg:     #eaf3ec;
  --warn:      #8a5a3d;
  --warn-bg:   #f5ece3;
  --border:    #e7e0d6;
  --radius:    .6rem;
  --gap:       1rem;
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; overscroll-behavior: none; touch-action: pan-x pan-y; }

body {
  min-height: 100dvh;
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: "PT Sans", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a, button, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.connection-status { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; max-width: 38rem; margin: auto; padding: 12px 16px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: 0 4px 20px #0002; font-size: 14px; }
.connection-status[hidden] { display: none; }
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); padding-bottom: calc(4rem + env(safe-area-inset-bottom)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
}

.shell {
  max-width: 40rem;
  margin: 0 auto;
}

h1, h2, h3 {
  font-family: "PT Serif", Georgia, serif;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 .5rem;
}
h1 { font-size: 1.5rem; margin-top: 1.2rem; }
h2 { font-size: 1.1rem; margin-top: 1.6rem; color: var(--text); }
h3 { font-size: 1rem; color: var(--text-dim); }

p { margin: .5rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

.dim { color: var(--text-dim); }
.small { font-size: .9rem; }

/* --- навигация верхнего уровня (часть 1) --- */

.topnav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  padding: 1rem 0 .75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  font-size: .95rem;
  flex-wrap: wrap;
}
.topnav .brand {
  font-family: "PT Serif", serif;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
}
.topnav a {
  color: var(--text-dim);
  padding: .3rem 0;
}
.topnav a.active {
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}
.badge {
  display: inline-block;
  min-width: 1.3rem;
  text-align: center;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 1rem;
  font-size: .75rem;
  padding: .05rem .35rem;
  margin-left: .3rem;
  vertical-align: middle;
}

/* --- карточки/поверхности --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: .75rem 0;
}
.card-list { display: flex; flex-direction: column; gap: .75rem; }
.card-list .card { margin: 0; }
.card a.card-link {
  display: block;
  color: inherit;
}
.card-title { font-weight: 700; margin: 0 0 .15rem; }
.card-meta { color: var(--text-dim); font-size: .9rem; }
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- кнопки и формы --- */

button, .btn {
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  padding: .6rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
button:hover, .btn:hover { opacity: .92; }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--accent);
}
button.linklike {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
  min-height: auto;
  font-size: inherit;
}
button:disabled { opacity: .5; cursor: default; }

/* --- подсказка горячей клавиши на кнопке (сессия 15, j/k) --- */
.hint {
  font-size: .75rem;
  opacity: .65;
  border: 1px solid currentColor;
  border-radius: .25rem;
  padding: 0 .3rem;
  line-height: 1.4;
}

input[type=text], input[type=password], textarea, select {
  font: inherit;
  font-size: 1rem;
  padding: .55rem .7rem;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
textarea { min-height: auto; }
label { display: block; margin: .9rem 0 .3rem; font-size: .9rem; color: var(--text-dim); }
label.inline { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); font-size: 1rem; }
.field { margin: .75rem 0; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
/* положительное/«дальше» слева, отрицательное справа (сессия 15) —
   каждая кнопка в своей hx-форме (чтобы `action` не задваивался), формы
   выстроены в ряд как одна группа действий. */
.actions-split { justify-content: space-between; align-items: center; }

/* --- целевой текст vs русский (часть 3, главное требование) --- */

.target {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.ru {
  font-size: .95rem;
  color: var(--text-dim);
  margin-top: .15rem;
}
.ctx { font-size: .85rem; color: var(--text-dim); }

.cell-row {
  display: flex;
  flex-direction: column;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.cell-row:last-child { border-bottom: none; }

/* «так же, как выше» — не должна читаться как ошибка */
.same {
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: .1rem;
}
.same::before { content: "\2190 "; }

/* --- сессия/упражнение --- */

/* Сессия 16: независимая от карточки полоска прогресса — живёт вне #card
   (own out-of-band своп, study.rs), не пересобирается вместе с ним и не
   должна визуально «прыгать» между шагами разной высоты. `sticky` держит
   её на месте, даже если контент шага (показ батареи) выше экрана. */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 1rem 0 0;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
}
.progress-bar[hidden] { display: none; }
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.exercise-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
  font-size: 1.4rem;
  margin: 1rem 0;
}
.exercise-line span { line-height: 44px; }
.exercise-line input[type=text] {
  font-size: 1.4rem;
  font-weight: 700;
  width: auto;
  flex: 1 1 8rem;
  min-height: 44px;
  line-height: 1.4;
  padding: 0 .4rem;
  border: none;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: transparent;
}
.exercise-line input[type=text]:focus { outline: none; }

.result-ok { color: var(--ok); background: var(--ok-bg); border-radius: var(--radius); padding: .75rem 1rem; }
.result-bad { color: var(--warn); background: var(--warn-bg); border-radius: var(--radius); padding: .75rem 1rem; }

/* --- flip / подтверждение (сессия 12): крупные разнесённые кнопки,
   «не знал» не должна читаться как ошибка — обычный secondary, не алый --- */

.flip-target { font-size: 1.6rem; margin: 1.5rem 0; }
.flip-actions { display: flex; gap: .75rem; margin-top: 1rem; }
.flip-btn { flex: 1 1 0; min-height: 56px; font-size: 1.05rem; }

/* --- клавиатура с палочкой (мобильный первым) --- */

.kbd {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
  gap: .4rem;
  margin: .75rem 0;
}
.kbd button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  min-height: 44px;
  padding: 0;
  font-size: 1.1rem;
}
.kbd button:active { background: var(--bg); }

/* --- список уроков / прогресс --- */

.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li {
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}
.lesson-list li:last-child { border-bottom: none; }
.state-open { color: var(--ok); }
.state-todo a { color: var(--accent); }

/* --- пустые состояния --- */

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 2.5rem 1rem;
}
.empty .big { font-size: 1.05rem; color: var(--text); margin-bottom: .3rem; }

/* --- мастер создания сборки --- */

.steps { display: flex; gap: .5rem; color: var(--text-dim); font-size: .85rem; margin-bottom: 1rem; }
.steps .on { color: var(--accent); font-weight: 700; }

/* --- htmx: не даём дёрнуться контенту при подгрузке --- */

.htmx-swapping { opacity: .6; transition: opacity .1s ease; }

/* --- учебная сессия: карточка и поле ввода по центру экрана (сессия 15),
   не прилипшие к верху --- */

.learn-shell {
  min-height: 100vh; /* запасной вариант для браузеров без svh */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0;
}
.learn-exit { text-align: center; margin-top: 1.5rem; }

@media (min-width: 480px) {
  body { font-size: 17px; }
}
