:root {
  --blue-900: #0f3d55;
  --blue-700: #17607f;
  --blue-500: #2f9bc4;
  --blue-300: #8fd3ea;
  --blue-100: #e6f6fc;
  --blue-50: #f4fbfe;
  --shadow: 0 10px 26px rgba(15, 61, 85, 0.16);
  --shadow-soft: 0 4px 14px rgba(15, 61, 85, 0.1);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

img {
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  color: var(--blue-900);
  background:
    radial-gradient(circle at 12% 8%, #ffffff 0%, rgba(255, 255, 255, 0) 45%),
    linear-gradient(160deg, var(--blue-50) 0%, var(--blue-100) 55%, #d3eefa 100%);
  background-attachment: fixed;
}

.site-header {
  padding: clamp(22px, 5vw, 34px) clamp(14px, 4vw, 20px) clamp(18px, 4vw, 26px);
  text-align: center;
  background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-500) 60%, var(--blue-300) 100%);
  box-shadow: var(--shadow);
  border-bottom-left-radius: clamp(20px, 5vw, 32px);
  border-bottom-right-radius: clamp(20px, 5vw, 32px);
}

.site-title {
  margin: 0;
  font-family: "Georgia", "Palatino Linotype", serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(15, 61, 85, 0.35), 0 10px 24px rgba(9, 43, 61, 0.35);
}

.site-title .accent {
  color: #ffe9a8;
  font-style: italic;
}

.site-subtitle {
  margin: clamp(6px, 2vw, 10px) 0 0;
  font-size: clamp(0.88rem, 2.6vw, 1rem);
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.03em;
}

.container {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 28px) clamp(14px, 4vw, 24px) clamp(40px, 8vw, 60px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 2.5vw, 12px);
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(18px, 4vw, 26px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px clamp(18px, 4vw, 22px);
  border: 2px solid transparent;
  border-radius: 999px;
  font-size: clamp(0.92rem, 2.6vw, 1rem);
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
  box-shadow: var(--shadow-soft);
}

.btn-ghost {
  color: var(--blue-700);
  background: #ffffff;
  border-color: var(--blue-300);
}

.btn-danger {
  color: #9c2b2b;
  background: #ffffff;
  border-color: #f0b4b4;
}

@media (hover: hover) {
  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .btn-ghost:hover {
    background: var(--blue-100);
  }

  .btn-danger:hover {
    background: #fdeeee;
  }
}

.hint {
  flex: 1 1 220px;
  font-size: clamp(0.82rem, 2.4vw, 0.92rem);
  line-height: 1.4;
  color: var(--blue-700);
  opacity: 0.85;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: clamp(16px, 3.5vw, 26px);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
  }
}

.card-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  background: var(--blue-100);
}

.card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  padding: clamp(12px, 3vw, 18px);
}

.card-title {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.15rem);
  line-height: 1.35;
  color: var(--blue-900);
  overflow-wrap: anywhere;
}

.recipe-popup {
  margin: 0 clamp(12px, 3vw, 18px) clamp(12px, 3vw, 18px);
  padding: clamp(12px, 3vw, 16px);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(23, 96, 127, 0.97) 0%, rgba(15, 61, 85, 0.97) 100%);
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.recipe-popup h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue-300);
}

.recipe-popup p {
  margin: 0;
  font-size: clamp(0.92rem, 2.6vw, 0.98rem);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* На устройствах с курсором рецепт показывается поверх карточки по наведению. */
@media (hover: hover) and (min-width: 720px) {
  .recipe-popup {
    position: absolute;
    inset: auto 10px 10px;
    max-height: calc(100% - 20px);
    overflow: auto;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 20;
  }

  .card:hover .recipe-popup,
  .card:focus-within .recipe-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
}

.card-actions .btn {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 0.88rem;
}

.empty-state {
  padding: clamp(26px, 6vw, 40px) clamp(16px, 4vw, 24px);
  border: 2px dashed var(--blue-300);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
  color: var(--blue-700);
}

.form-card {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: clamp(16px, 4vw, 28px);
}

.form-grid {
  display: grid;
  gap: clamp(16px, 3.5vw, 20px);
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--blue-700);
}

.field input[type="text"],
.field input[type="file"],
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 2px solid var(--blue-300);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--blue-900);
  background: var(--blue-50);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(47, 155, 196, 0.18);
}

.field textarea {
  min-height: clamp(120px, 30vw, 140px);
  resize: vertical;
  line-height: 1.5;
}

.field-hint {
  margin: 8px 0 0;
  font-size: clamp(0.78rem, 2.3vw, 0.86rem);
  line-height: 1.4;
  color: var(--blue-700);
  opacity: 0.85;
}

.preview {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 18px);
  flex-wrap: wrap;
  padding: clamp(12px, 3vw, 14px);
  border-radius: 12px;
  background: var(--blue-100);
}

.preview img {
  flex: 0 0 auto;
  width: clamp(120px, 40vw, 180px);
  aspect-ratio: 3 / 2;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  background: #ffffff;
  border: 2px solid var(--blue-300);
}

.preview-caption {
  flex: 1 1 180px;
  min-width: 0;
  font-size: clamp(0.86rem, 2.6vw, 0.92rem);
  color: var(--blue-700);
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  gap: clamp(10px, 2.5vw, 12px);
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.form-actions .btn {
  flex: 0 1 auto;
}

.error-message {
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fdeeee;
  border: 2px solid #f0b4b4;
  color: #9c2b2b;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

.site-footer {
  padding: clamp(14px, 3vw, 18px);
  text-align: center;
  font-size: clamp(0.82rem, 2.4vw, 0.88rem);
  color: var(--blue-700);
  opacity: 0.8;
}

/* Узкие экраны: крупные цели нажатия и элементы во всю ширину. */
@media (max-width: 560px) {
  .toolbar .btn,
  .toolbar .hint,
  .form-actions .btn,
  .card-actions .btn {
    flex: 1 1 100%;
  }

  .card-actions {
    justify-content: stretch;
  }
}
