/* ============================================================
   Master Matkonim — design system (RTL-first)
   Brand: green #afd200 + purple #391054, font Assistant.
   (Blue/Roboto/Google-Sans from the old extraction were AdSense
   iframe artifacts — intentionally excluded.)
   ============================================================ */
:root {
  --green: #afd200;
  --green-600: #9bbb00;
  --purple: #391054;
  --purple-over: rgba(57, 16, 84, 0.81);
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --line: #e4e4e7;
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --white: #ffffff;

  --radius-sm: 5px;
  --radius-md: 10px;
  --radius-xl: 20px;
  --radius-pill: 25px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 16px rgba(57, 16, 84, .10);

  --container: 1280px;
  --gap: 25px;

  --fs-body: 16px;
  --fs-h1: clamp(28px, 4vw, 40px);
  --fs-h2: clamp(22px, 3vw, 32px);
  --fs-h3: clamp(19px, 2vw, 24px);

  --font: 'Assistant', 'Segoe UI', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  direction: rtl;
  text-align: right;
  overflow-x: hidden;           /* no accidental horizontal scroll */
  min-height: 100vh;            /* sticky-footer: fill the viewport */
  display: flex;
  flex-direction: column;
}
#main { flex: 1 0 auto; }       /* content grows, footer stays at bottom */
.site-footer { flex-shrink: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--green-600); }
h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0 0 .5em; color: var(--purple); }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

.container { max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.section { padding-block: 40px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link:focus { width: auto; height: auto; clip: auto; right: 10px; top: 10px; background: #fff; padding: 8px 16px; z-index: 999; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 16px; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s, background .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--green); color: var(--purple); }
.btn-primary:hover { background: var(--green-600); color: var(--purple); }
.btn-outline { background: transparent; border-color: var(--purple); color: var(--purple); }
.btn-outline:hover { background: var(--purple); color: #fff; }

/* ---------- header ---------- */
.site-header {
  background: var(--purple); color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-md);
}
.site-header .container { position: relative; display: flex; align-items: center; gap: 16px; min-height: 64px; }
.site-logo img, .site-logo svg { height: 40px; width: auto; }
.site-logo { display: flex; align-items: center; flex-shrink: 0; }
.main-nav { margin-inline-start: auto; display: flex; align-items: center; gap: 20px; }
.main-nav ul { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; align-items: center; }
.main-nav a { color: #fff; font-weight: 600; }
.main-nav a:hover { color: var(--green); }
.header-search { display: flex; align-items: center; }
.header-search input {
  border: none; border-radius: var(--radius-pill); padding: 8px 16px;
  font-family: inherit; width: 190px; max-width: 100%;
}
.nav-toggle {
  display: none; background: none; border: 0; color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; padding: 6px 8px;
  margin-inline-start: auto; flex-shrink: 0;
}

/* ---------- nav dropdown ("דפים") ---------- */
.main-nav .has-submenu { position: relative; }
.submenu-toggle {
  background: none; border: 0; color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 0;
}
.submenu-toggle:hover { color: var(--green); }
.submenu-toggle .caret { font-size: .8em; }
.main-nav .submenu {
  position: absolute; top: 100%; inset-inline-end: 0; background: #fff;
  min-width: 190px; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 6px 0; margin: 8px 0 0; list-style: none; display: none; z-index: 60;
}
.has-submenu:hover .submenu, .has-submenu:focus-within .submenu { display: block; }
.main-nav .submenu a { color: var(--purple); display: block; padding: 9px 18px; font-weight: 600; }
.main-nav .submenu a:hover { background: var(--bg-soft); color: var(--green-600); }

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--purple), #55208a);
  color: #fff; text-align: center; padding-block: 60px;
}
.hero h1 { color: #fff; max-width: 20ch; margin-inline: auto; }
.hero p { font-size: 20px; opacity: .95; max-width: 44ch; margin: 12px auto 24px; }

/* ---------- recipe grid + card ---------- */
.recipe-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.recipe-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  overflow: hidden; box-shadow: var(--shadow-sm); position: relative;
  display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s;
}
.recipe-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.recipe-card .thumb { aspect-ratio: 4 / 3; background: var(--bg-soft); overflow: hidden; }
.recipe-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .body { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.recipe-card .title { font-size: 1.15rem; font-weight: 700; color: var(--purple); line-height: 1.25; }
.recipe-card .author { font-size: .9rem; color: var(--ink-soft); }
.recipe-card .meta { margin-top: auto; display: flex; gap: 10px; font-size: .85rem; color: var(--ink-soft); }
.recipe-card .feats { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  display: inline-block; background: var(--bg-soft); color: var(--purple);
  border-radius: var(--radius-sm); padding: 2px 8px; font-size: .78rem; font-weight: 600;
}
.fav-btn {
  position: absolute; inset-inline-start: 10px; top: 10px; z-index: 2;
  background: rgba(255,255,255,.92); border: 0; border-radius: 50%;
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  font-size: 18px; color: #c0374f; box-shadow: var(--shadow-sm);
}
.fav-btn.is-fav { background: #c0374f; color: #fff; }

/* ---------- entity tiles ---------- */
.entity-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.entity-tile {
  position: relative; border-radius: var(--radius-md); overflow: hidden;
  aspect-ratio: 1/1; display: grid; place-items: center; color: #fff; text-align: center;
  box-shadow: var(--shadow-sm);
}
.entity-tile img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.entity-tile::after { content: ""; position: absolute; inset: 0; background: var(--purple-over); z-index: 1; }
.entity-tile .label { position: relative; z-index: 2; font-weight: 700; font-size: 1.2rem; padding: 8px; }
.entity-tile .icon { position: relative; z-index: 2; width: 54px; height: 54px; margin-bottom: 8px; }
.entity-tile .label + .count {
  position: relative; z-index: 2; margin-top: -4px; padding: 0 8px;
  font-size: .9rem; font-weight: 600; opacity: .85;
}

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius-pill);
  padding: 6px 14px; font-size: .9rem; user-select: none; background: #fff;
}
.filter-chip input { accent-color: var(--green); }
.filter-chip:has(input:checked) { border-color: var(--green); background: #f6fbe0; }

/* ---------- single recipe ---------- */
.recipe-header { display: grid; gap: 24px; grid-template-columns: 1.1fr 1fr; align-items: start; margin-bottom: 30px; }
.recipe-header .photo img { width: 100%; border-radius: var(--radius-xl); box-shadow: var(--shadow-md); }
.recipe-title { font-size: var(--fs-h1); }
.recipe-authorbox { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.recipe-authorbox img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; }
.recipe-metabar { display: flex; gap: 22px; flex-wrap: wrap; padding: 14px 0; border-block: 1px solid var(--line); }
.recipe-metabar .item { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ingredients-list { list-style: none; padding: 0; margin: 0; }
.ingredients-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ingredients-list li.section { font-weight: 700; color: var(--purple); border-bottom: 2px solid var(--green); margin-top: 12px; }
.ingredients-list .qty { color: var(--ink-soft); white-space: nowrap; }
.recipe-instructions { font-size: 1.05rem; line-height: 1.9; }
.recipe-columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 40px; }
.recipe-columns.no-ingredients { grid-template-columns: 1fr; }
.card-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px 24px; }

/* ---------- ads ---------- */
.ad-slot { margin: 24px auto; text-align: center; overflow: hidden; }
.ad-slot--horizontal { min-height: 90px; }
.ad-slot--box { min-height: 250px; max-width: 336px; }
.ad-slot--vertical { min-height: 600px; width: 160px; }
.ad-slot--infeed { grid-column: 1 / -1; min-height: 120px; }
/* Card ad: lives inside .recipe-grid and fills exactly one recipe-card cell.
   Height is reserved up front so the row never shifts when the ad loads (CLS). */
.ad-slot--card {
  margin: 0; display: flex; flex-direction: column; min-height: 280px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md);
  overflow: hidden;
}
.ad-slot--card .ad-label {
  font-size: 11px; color: #999; padding: 4px 8px; text-align: start; letter-spacing: .04em;
}
.ad-slot--card ins, .ad-slot--card .demoads { flex: 1; width: 100%; }
.demoads { background: repeating-linear-gradient(45deg,#eee,#eee 10px,#f6f6f6 10px,#f6f6f6 20px); color:#999; display:grid; place-items:center; border:1px dashed #ccc; border-radius: var(--radius-sm); }
.fixed-bottom-banner { position: fixed; inset-inline: 0; bottom: 0; z-index: 60; background:#fff; border-top:1px solid var(--line); text-align:center; box-shadow:0 -2px 8px rgba(0,0,0,.08); }
.fixed-bottom-banner .close { position:absolute; inset-inline-end:8px; top:4px; background:none;border:0;font-size:20px;cursor:pointer; }

/* ---------- footer ---------- */
.site-footer { background: var(--purple); color: #e9e2f0; margin-top: 50px; padding-block: 40px 24px; }
.site-footer a { color: var(--green); }
.footer-cols { display: grid; gap: 30px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.footer-bottom { text-align: center; opacity: .8; margin-top: 24px; font-size: .9rem; }

/* ---------- recipe actions (print / share) ---------- */
.recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.recipe-actions .btn { padding: 8px 16px; font-size: .9rem; }

/* ---------- comments ---------- */
.comments-area { margin-top: 10px; }
.comments-area .comment-list { list-style: none; padding: 0; margin: 0 0 24px; }
.comments-area .comment-list li { border-bottom: 1px solid var(--line); padding: 14px 0; }
.comments-area .comment-author { font-weight: 700; color: var(--purple); }
.comments-area .comment-author img { border-radius: 50%; vertical-align: middle; margin-inline-end: 8px; }
.comments-area .comment-meta { font-size: .82rem; color: var(--ink-soft); margin-bottom: 6px; }
.comments-area .comment-respond { background: var(--bg-soft); border-radius: var(--radius-md); padding: 20px 24px; }
.comments-area input[type="text"], .comments-area input[type="email"], .comments-area input[type="url"], .comments-area textarea {
  width: 100%; max-width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; font-family: inherit; margin-top: 6px;
}
.comments-area .form-submit input { background: var(--green); color: var(--purple); border: 0; border-radius: var(--radius-pill); padding: 10px 24px; font-weight: 700; cursor: pointer; }

/* ---------- empty / loading states ---------- */
.mm-empty { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.mm-empty .icon { font-size: 48px; margin-bottom: 8px; }
.mm-empty h2 { color: var(--purple); }
.mm-skeleton { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.mm-skeleton .sk { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--line); }
.mm-skeleton .sk .ph { aspect-ratio: 4/3; background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; }
.mm-skeleton .sk .ln { height: 12px; margin: 10px 12px; background: #eee; border-radius: 4px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- print ---------- */
@media print {
  .site-header, .site-footer, .recipe-actions, .ad-slot, .ad-slot--infeed, .fav-btn, .fav-btn-lg, .cat-nav,
  .recipe-video, .comments-area, .main-nav, .nav-toggle, .header-search, section.section:has(h2) + * { display: none !important; }
  body { color: #000; }
  .recipe-columns { grid-template-columns: 1fr 1.4fr !important; }
  a[href]::after { content: ""; }
  .card-box { border: 1px solid #ccc; }
}

/* ---------- category strip ---------- */
.cat-nav { margin-bottom: 18px; }
.cat-nav__row { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; color: var(--purple);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 8px 15px; font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.cat-btn:hover { border-color: var(--green); background: var(--bg-soft); }
.cat-btn[aria-expanded="true"] { background: var(--purple); color: #fff; border-color: var(--purple); }
.cat-btn__count {
  font-size: 12px; font-weight: 700; opacity: .6;
  font-variant-numeric: tabular-nums;
}
.cat-btn__chev { font-size: 11px; transition: transform .15s; }
.cat-btn[aria-expanded="true"] .cat-btn__chev { transform: rotate(180deg); }

.cat-panel {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px; padding: 14px 16px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.cat-panel[hidden] { display: none; }
.cat-sub {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 6px 13px; font-size: 14px;
}
.cat-sub:hover { border-color: var(--green); color: var(--purple); }
.cat-sub--all { font-weight: 700; color: var(--purple); border-color: var(--green); }
.cat-sub__count { font-size: 11px; opacity: .55; font-variant-numeric: tabular-nums; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 34px; flex-wrap: wrap; }
/* The same pager also sits above the grid, where the big top margin is wrong. */
.pagination--top { margin-top: 0; margin-bottom: 22px; }
.pagination .page-numbers { padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.pagination .current { background: var(--green); color: var(--purple); border-color: var(--green); font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .recipe-header, .recipe-columns { grid-template-columns: 1fr; }
  .ad-slot--vertical { display: none; }
}
/* On phones the grid is a single column, so keep only the first card ad. */
@media (max-width: 600px) {
  .ad-slot--card.ad-card-2 { display: none; }
}
@media (max-width: 820px) {
  .nav-toggle { display: block; }
  /* Dropdown anchored to the header, full width, so it lines up with content. */
  .main-nav {
    position: absolute; top: 100%; inset-inline: 0;
    background: var(--purple); flex-direction: column; align-items: stretch;
    gap: 0; padding: 8px 20px 18px; margin: 0;
    display: none; box-shadow: var(--shadow-md);
    max-height: calc(100vh - 64px); overflow-y: auto;
  }
  .main-nav.open { display: flex; }
  .main-nav ul { flex-direction: column; gap: 0; align-items: stretch; }
  .main-nav li { border-bottom: 1px solid rgba(255,255,255,.12); }
  .main-nav a { display: block; padding: 14px 4px; font-size: 1.05rem; }
  .header-search { margin-top: 14px; }
  .header-search input { width: 100%; }

  /* dropdown becomes an inline accordion inside the mobile menu */
  .main-nav .has-submenu { border-bottom: 1px solid rgba(255,255,255,.12); }
  .submenu-toggle { width: 100%; justify-content: space-between; padding: 14px 4px; font-size: 1.05rem; }
  .main-nav .submenu {
    position: static; display: none; background: transparent; box-shadow: none;
    padding: 0 0 8px; margin: 0; min-width: 0;
  }
  .main-nav .has-submenu.open .submenu { display: block; }
  .main-nav .has-submenu.open .submenu-toggle .caret { transform: rotate(180deg); }
  .main-nav .submenu a { color: #fff; padding: 10px 16px 10px 22px; font-size: 1rem; }
  .main-nav .submenu a:hover { background: rgba(255,255,255,.08); color: var(--green); }
}
