/*
 * Стили портала (T-02-001; ПП-11, НФТ-15).
 *
 * Требования: экраны от 360 px; элементы управления не меньше 44 px (работа в перчатках); одна контрастная тема
 * для улицы — пары «текст/фон» не ниже 7:1, акцент не ниже 4.5:1 (цвета ниже посчитаны, тест их перепроверяет).
 * Работает в iOS 15+ и Android 10+: без :has, :focus-visible, единиц dvh/svh/lvh, @container, @layer,
 * вложенности правил, color-mix и subgrid. JavaScript не нужен.
 * Цвета заданы переменными в :root — тест читает их оттуда.
 */
:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #374151;
  --surface: #f1f5f9;
  --border: #475569;
  --header-bg: #0b2a4a;
  --header-text: #ffffff;
  --accent: #0a4a94;
  --accent-text: #ffffff;
  --accent-hover: #073766;
  --error: #9b1c1c;
  --focus: #7a3e00;
  --focus-on-dark: #ffd166;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* ── Шапка ─────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  color: var(--header-text);
  background: var(--header-bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--header-text);
  text-decoration: none;
}

.logout {
  margin: 0;
}

/* ── Страница ──────────────────────────────────────────────────────────── */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.25;
}

.lead {
  margin: 0 0 1rem;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Элементы управления: не меньше 44 px по высоте ────────────────────── */
a,
button,
input,
select,
textarea {
  min-height: 44px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 1.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--accent-text);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button-primary {
  width: 100%;
}

.button-ghost {
  color: var(--header-text);
  background: transparent;
  border-color: var(--header-text);
}

.button-ghost:hover {
  color: var(--header-text);
  background: var(--accent-hover);
  border-color: var(--header-text);
}

/* Фокус заметен всегда (клавиатура, внешний переключатель); :focus, а не :focus-visible — его нет в iOS 15.0–15.3. */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.site-header a:focus,
.site-header button:focus {
  outline-color: var(--focus-on-dark);
}

/* ── Поля формы ────────────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="search"] {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  -webkit-appearance: none;
  appearance: none;
}

/* Подсказка в поле — тоже контрастная (по умолчанию браузер делает её светло-серой). */
input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.form {
  margin: 0;
}

.field {
  margin: 0 0 1rem;
}

.field label {
  display: block;
  margin: 0 0 0.25rem;
  font-weight: 600;
}

/* «Запомнить устройство»: вся строка нажимается, флажок крупный. */
.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
}

.check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  accent-color: var(--accent);
}

.check label {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  font-weight: 400;
}

.error {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  color: var(--error);
  background: var(--surface);
  border-left: 4px solid var(--error);
}

.card {
  max-width: 24rem;
  margin: 1rem auto 0;
}

/* ── Поиск и список установок ──────────────────────────────────────────── */
.search {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.search input {
  flex: 1 1 auto;
}

.search .button {
  flex: 0 0 auto;
}

.plant-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plant {
  display: flex;
  flex-direction: column;
  min-height: 44px;
  padding: 0.75rem 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.plant-name {
  font-weight: 700;
  word-wrap: break-word; /* запасной вариант для Safari до 15.4, где нет overflow-wrap: anywhere */
  overflow-wrap: anywhere;
}

.plant-designation,
.plant-site {
  color: var(--muted);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.empty {
  padding: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.empty p {
  margin: 0;
}

.empty-title {
  font-weight: 700;
}

/* ── Меню, путь, карточки (T-02-002) ───────────────────────────────────── */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.menu a,
.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-weight: 600;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}

.crumbs li + li::before {
  content: "\203A";
  margin-right: 0.25rem;
}

.crumbs li {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  overflow-wrap: anywhere;
}

h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.25rem;
}

.facts {
  margin: 0 0 1rem;
}

.facts dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.facts dd {
  margin: 0 0 0.5rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.more summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

a.plant-name,
a.plant-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
}

/* ── Широкий экран ─────────────────────────────────────────────────────── */
@media (min-width: 40rem) {
  .page {
    padding: 1.5rem;
  }

  .plant {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
  }
}
