/* diarecipes — public site.

   Hand-written, no framework and no build step (see the project CLAUDE.md: the public
   pages deliberately don't inherit the admin panel's CoreUI theme). Everything is a
   token on :root, redefined once under prefers-color-scheme: dark, so a colour is never
   written twice — if you add one, add its dark counterpart in the same place. */

/* ---------- tokens ---------- */

:root {
  color-scheme: light dark;

  --brand: #0f8a5f;
  --brand-strong: #0b6a49;
  --brand-deep: #08533a;
  --brand-soft: #e7f4ee;
  --brand-softer: #f2f9f5;
  --brand-line: #bfded0;
  --on-brand: #ffffff;

  --ink: #0f2019;
  --body-text: #23372e;
  --muted: #5f7369;
  --faint: #8a9a92;

  --bg: #f4f8f6;
  --surface: #ffffff;
  --surface-sunken: #f6faf8;
  --line: #e3ece8;
  --line-strong: #d2e1da;

  --shadow-sm: 0 1px 2px rgba(15, 40, 31, 0.05);
  --shadow-md: 0 6px 18px -8px rgba(15, 40, 31, 0.18);
  --shadow-lg: 0 18px 40px -20px rgba(15, 40, 31, 0.32);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --header-h: 52px;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  --hero-glow: rgba(15, 138, 95, 0.16);
  --hero-top: #eaf4ef;
  --hero-bottom: var(--bg);
  --hero-mark: rgba(15, 138, 95, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3cc891;
    --brand-strong: #63d8a9;
    --brand-deep: #8ce6c4;
    --brand-soft: rgba(60, 200, 145, 0.14);
    --brand-softer: rgba(60, 200, 145, 0.07);
    --brand-line: rgba(60, 200, 145, 0.32);
    --on-brand: #04241a;

    --ink: #ecf5f1;
    --body-text: #d5e3dd;
    --muted: #9bafa7;
    --faint: #7d918a;

    --bg: #0c1411;
    --surface: #141f1a;
    --surface-sunken: #18251f;
    --line: #243229;
    --line-strong: #2e3f36;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 18px 40px -20px rgba(0, 0, 0, 0.8);

    --hero-glow: rgba(60, 200, 145, 0.14);
    --hero-top: #122019;
    --hero-bottom: var(--bg);
    --hero-mark: rgba(60, 200, 145, 0.08);
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body-text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: 0.1px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

a { color: var(--brand); }
a:hover { color: var(--brand-strong); }

img { max-width: 100%; }

::selection { background: var(--brand); color: var(--on-brand); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

.icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  vertical-align: -0.125em;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus { top: 12px; color: var(--on-brand); }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover { color: var(--brand); }
.brand:hover .logo-mark { transform: rotate(-6deg) scale(1.05); }

.logo-mark {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 24px;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease;
}

.brand-divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
}

.brand-tagline {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* on a narrow phone the wordmark alone has to carry the header */
@media (max-width: 460px) {
  .brand-divider, .brand-tagline { display: none; }
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 34px 0 30px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(760px 300px at 8% -50%, var(--hero-glow), transparent 68%),
    linear-gradient(180deg, var(--hero-top), var(--hero-bottom));
}

.hero-inner { position: relative; z-index: 1; max-width: 760px; }

.hero-eyebrow {
  margin: 0 0 10px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--brand-strong);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 1.25rem + 1.9vw, 2.45rem);
}

.hero-lead {
  margin: 0;
  max-width: 580px;
  font-size: 0.98rem;
  color: var(--muted);
}

.hero-count {
  margin: 16px 0 0;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

/* the outlined apple bleeding off the right edge — decoration only, so it goes under
   the copy and disappears on narrow screens rather than competing with it */
.hero-mark {
  position: absolute;
  right: -46px;
  top: 50%;
  transform: translateY(-50%) rotate(8deg);
  width: 230px;
  height: 230px;
  color: var(--hero-mark);
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 900px) { .hero-mark { display: none; } }

/* ---------- tags ---------- */

.tag-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.tag-filter::-webkit-scrollbar { display: none; }

@media (min-width: 760px) { .tag-filter { flex-wrap: wrap; overflow: visible; } }

.tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

a.tag:hover { color: var(--brand-strong); border-color: var(--brand-line); background: var(--brand-softer); }

.tag-active,
a.tag-active:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.tag-sm { padding: 3px 10px; font-size: 0.75rem; }

/* ---------- empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  color: var(--muted);
  text-align: center;
}

.empty p { margin: 0; }
.empty-mark { width: 52px; height: 52px; color: var(--brand-line); }

.empty-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- feed ---------- */

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.recipe-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-line);
}

.card-image {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--brand-softer);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.recipe-card:hover .card-image img { transform: scale(1.045); }

.photo-placeholder { width: 58px; height: 58px; color: var(--brand-line); }

.card-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  color: var(--brand-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.card-body h2 { font-size: 1.3rem; margin: 0; line-height: 1.25; }

.card-body h2 a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--brand), var(--brand));
  background-size: 0% 1.5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease, color 0.2s ease;
}

.card-body h2 a:hover { color: var(--brand-strong); background-size: 100% 1.5px; }

.card-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  align-items: center;
}

.card-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  font-weight: 600;
}

.card-meta .icon { color: var(--brand); }

.card-note { margin: 0; color: var(--faint); font-size: 0.75rem; }

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

/* ---------- КБЖУ strip ---------- */

.kbzhu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0;
  padding: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.kbzhu-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 11px;
  background: var(--surface-sunken);
}

.kbzhu-cell dt {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.kbzhu-cell dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}

.kbzhu-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--faint);
  margin-left: 2px;
}

/* ХЕ and ГИ — the two numbers this audience actually reads */
.kbzhu-cell-key { background: var(--brand-soft); }
.kbzhu-cell-key dt { color: var(--brand-strong); }
.kbzhu-cell-key dd { color: var(--brand-deep); }

/* ---------- recipe page ---------- */

.recipe { padding-bottom: 8px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 28px 0 22px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease, gap 0.2s ease;
}

.back-link:hover { color: var(--brand); gap: 10px; }

.recipe-header {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-bottom: 32px;
}

.recipe-intro { min-width: 0; }
.recipe-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.recipe-header h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem);
  margin: 0 0 12px;
}

.recipe-summary {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 56ch;
}

.recipe-cover {
  width: 100%;
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  box-shadow: var(--shadow-md);
}

.recipe-description {
  max-width: 68ch;
  margin-bottom: 32px;
  font-size: 1.05rem;
}

.recipe-description p { margin: 0 0 12px; }
.recipe-description p:last-child { margin-bottom: 0; }

.recipe-layout { display: grid; gap: 24px; }

.recipe-main { display: grid; gap: 24px; min-width: 0; }
.recipe-aside { min-width: 0; }
.aside-sticky { display: grid; gap: 24px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: 1.2rem;
  margin: 0 0 14px;
}

/* ---------- variants ---------- */

.variants-hint {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.variant-group { border: none; padding: 0; margin: 0 0 18px; }
.variant-group:last-child { margin-bottom: 0; }

.variant-group legend {
  padding: 0;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-bottom: 9px;
}

.variant-choices { display: flex; flex-wrap: wrap; gap: 8px; }

.variant-choice input { position: absolute; opacity: 0; pointer-events: none; }

.variant-choice span {
  display: inline-block;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunken);
  color: var(--body-text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.variant-choice:hover span { border-color: var(--brand-line); color: var(--brand-strong); }

.variant-choice input:checked + span {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-md);
}

.variant-choice input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- ingredients ---------- */

.ingredients-list { list-style: none; margin: 0; padding: 0; }

.ingredient {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden; /* clips the leader dots below at the panel edge */
}

.ingredient[hidden] { display: none; }

/* The divider goes on every row that *follows a visible one*, rather than on all but
   the last — a variant's rows are hidden with [hidden], and `:last-child` would happily
   put a dangling rule under the last visible row whenever the real last row belongs to
   an unselected choice. The same trick numbers the steps below. */
.ingredient:not([hidden]) ~ .ingredient:not([hidden]) {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

/* the leader dots between an ingredient and its amount — a printed-recipe convention
   that also stops long names from floating away from their numbers */
.ingredient-name { position: relative; }

.ingredient-name:not(:last-child)::after {
  content: '';
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0.32em;
  width: 100vw;
  border-bottom: 1px dotted var(--line-strong);
}

.ingredient-amount {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding-left: 8px;
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
}

/* ---------- steps ---------- */

.steps-list { list-style: none; margin: 0; padding: 0; }

.step {
  display: flex;
  gap: 16px;
}

.step[hidden] { display: none; }

.step:not([hidden]) ~ .step:not([hidden]) {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.step-number {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-deep);
  font-weight: 800;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body { flex: 1; min-width: 0; }
.step-body p { margin: 0 0 12px; }
.step-body p:last-child { margin-bottom: 0; }

.step-photo {
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 72px;
  padding: 36px 0 44px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer-inner { display: grid; gap: 12px; }

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
}

.logo-mark-footer { width: 26px; height: 26px; flex-basis: 26px; border-radius: 7px; }

.site-footer p { margin: 0; }
.disclaimer { max-width: 660px; }
.footer-credits { color: var(--faint); font-size: 0.8rem; }

/* ---------- wide screens ---------- */

@media (min-width: 760px) {
  /* the cover takes the height of the title block next to it instead of keeping a fixed
     ratio, so the header reads as one block rather than a picture with a hole under it;
     object-fit: cover does the cropping, and min-height keeps a short intro honest */
  .recipe-header { flex-direction: row; align-items: stretch; gap: 32px; }
  .recipe-cover { width: 350px; flex: 0 0 350px; aspect-ratio: auto; height: auto; min-height: 250px; }
  .kbzhu { grid-template-columns: repeat(6, 1fr); }
  .card-body .kbzhu { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1000px) {
  .recipe-layout { grid-template-columns: minmax(0, 1fr) 332px; gap: 32px; }
  .recipe-main { grid-column: 1; grid-row: 1; }
  .recipe-aside { grid-column: 2; grid-row: 1; }
  .aside-sticky { position: sticky; top: calc(var(--header-h) + 24px); }
  /* the aside is narrow, so its КБЖУ goes back to two rows of three */
  .recipe-aside .kbzhu { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- print: the recipe, nothing else ---------- */

@media print {
  .site-header, .site-footer, .back-link, .hero-mark, .card-badge, .skip-link { display: none !important; }

  body { background: #fff; color: #000; font-size: 11pt; }

  .panel, .recipe-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .recipe-layout { display: block; }
  .aside-sticky { position: static; }
  .recipe-aside, .recipe-main > .panel { margin-bottom: 16px; }
  .step, .kbzhu-cell { break-inside: avoid; }
  .step-photo, .recipe-cover { max-width: 60mm; }

  /* only the variant actually on screen is worth printing */
  .variant-choice input:not(:checked) + span { display: none; }
}
