/* ЛР4. Оформление страницы «Лента фотографий».
   Стили самостоятельные (без Bootstrap), чтобы страница не зависела
   от сторонних библиотек: только CSS Grid и переменные. */

:root {
  --ink: #1d2a33;
  --muted: #6b7a85;
  --line: #e1e6ea;
  --brand: #1f5068;
  --brand-2: #2c6b8a;
  --bg: #f4f6f7;
  --card: #ffffff;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
}

a {
  color: inherit;
}

.wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

/* Шапка */
.site-header {
  background-color: var(--brand);
  color: #fff;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  min-height: 64px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}

.brand span {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.72;
}

.nav {
  display: flex;
  gap: 22px;
}

.nav a {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.nav a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Вводная часть */
.hero {
  padding: 34px 0 30px;
  background-color: #fff;
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.2;
}

.hero p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.chip {
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  background-color: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Панели */
main {
  display: grid;
  gap: 22px;
  padding: 28px 0 40px;
}

.panel {
  min-width: 0; /* иначе длинная строка запроса в <pre> растягивает сетку */
  padding: 22px 24px 24px;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 21px;
}

.panel .muted {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

code {
  padding: 2px 6px;
  font-family: "DejaVu Sans Mono", Consolas, monospace;
  font-size: 12.5px;
  background-color: #eef2f5;
  border-radius: 5px;
}

/* Форма запроса */
.controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select {
  min-width: 260px;
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  background-color: #fff;
  border: 1px solid #cfd8de;
  border-radius: 8px;
}

.field-count select {
  min-width: 110px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(44, 107, 138, 0.35);
  outline-offset: 1px;
}

.btn {
  padding: 10px 20px;
  font: inherit;
  color: #fff;
  background-color: var(--brand);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover {
  background-color: var(--brand-2);
}

.btn-ghost {
  color: var(--brand);
  background-color: #fff;
  border: 1px solid #c3d2db;
}

.btn-ghost:hover {
  background-color: #f2f7f9;
}

/* Строка состояния */
.status {
  min-height: 20px;
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}

.status.is-ok {
  color: #1d6b45;
}

.status.is-error {
  color: #b03a2e;
}

/* Сетка карточек */
.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: opacity 0.2s;
}

.feed.is-loading {
  opacity: 0.45;
  pointer-events: none;
}

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.card-image {
  display: block;
  overflow: hidden;
  background-color: #e9eef1;
}

/* Соотношение сторон задано самому изображению: иначе портретные
   фотографии растягивали бы карточку по своей натуральной высоте. */
.card-image img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.card-image.is-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-title:hover {
  color: var(--brand-2);
  text-decoration: underline;
}

.card-meta {
  margin: auto 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.license {
  white-space: nowrap;
}

.more {
  margin-top: 16px;
}

/* Пояснение с последним запросом */
.note pre {
  margin: 10px 0 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12.5px;
  color: #c9d1d9;
  background-color: #0d1117;
  border-radius: 8px;
}

.note pre code {
  padding: 0;
  color: inherit;
  background-color: transparent;
}

/* Подвал */
.site-footer {
  padding: 16px 0;
  font-size: 13px;
  color: var(--muted);
  background-color: #fff;
  border-top: 1px solid var(--line);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Узкие экраны */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 24px;
  }

  .panel {
    padding: 18px 16px 20px;
  }

  .controls,
  .field {
    flex: 1 1 100%;
  }

  .field input,
  .field select,
  .btn {
    width: 100%;
    min-width: 0;
  }

  .feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .card-body {
    padding: 10px 12px 12px;
  }

  .card-title {
    font-size: 14px;
  }

  .card-meta {
    font-size: 12px;
  }
}
