:root {
  --bg: #f8f6f0;
  --surface: #fffdf8;
  --surface-2: #f1ece0;
  --ink: #221f1a;
  --ink-soft: #5f574c;
  --accent: #7a4a20;
  --accent-soft: #a9743f;
  --divider: #e3dac8;
  --tan: #ccbbaa;
  --shadow: 0 1px 2px rgba(60, 45, 25, .06), 0 8px 24px rgba(60, 45, 25, .08);
  --radius: 14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-soft); }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.1) blur(2px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent);
}
.brand-mark { font-size: 1.5rem; }
.site-nav { display: flex; gap: .35rem; flex-wrap: wrap; }
.site-nav a {
  padding: .45rem .8rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .95rem;
}
.site-nav a:hover { background: var(--surface-2); color: var(--accent); }
.site-nav a.active { background: var(--accent); color: #fff; }

/* ---------- Hero / home ---------- */
.hero {
  text-align: center;
  padding: 3.5rem 0 2rem;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 .5rem;
  color: var(--accent);
}
.hero-sub {
  max-width: 38rem;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  padding: 1rem 0 4rem;
}
.home-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
  text-align: center;
}
.home-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(60,45,25,.14); }
.home-card-emoji { font-size: 2.6rem; display: block; margin-bottom: .5rem; }
.home-card h2 { font-family: var(--serif); margin: .25rem 0; color: var(--accent); }
.home-card p { color: var(--ink-soft); margin: .25rem 0 1rem; }
.home-card-cta { font-weight: 600; color: var(--accent-soft); }

.home-card--portrait {
  position: relative;
  min-height: 280px;
  padding: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: center;
}
.home-card--portrait::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(34, 31, 26, 0.88) 0%,
    rgba(34, 31, 26, 0.45) 50%,
    rgba(34, 31, 26, 0.12) 100%
  );
  transition: background .15s ease;
}
.home-card--portrait:hover::before {
  background: linear-gradient(
    to top,
    rgba(34, 31, 26, 0.92) 0%,
    rgba(34, 31, 26, 0.55) 55%,
    rgba(34, 31, 26, 0.18) 100%
  );
}
.home-card--portrait .home-card-inner {
  position: relative;
  z-index: 1;
  padding: 1.75rem;
  width: 100%;
}
.home-card--portrait h2 { color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35); }
.home-card--portrait p { color: rgba(255, 255, 255, 0.88); margin-bottom: 1rem; }
.home-card--portrait .home-card-cta { color: #f1ece0; }

.home-card--gladys {
  background-image: url("/static/images/gladys-portrait.jpeg");
}
.home-card--talya {
  background-image: url("/static/images/talya-portrait.jpeg");
}

/* ---------- Page heads ---------- */
.page-head { padding: 2.25rem 0 1rem; }
.page-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0;
  color: var(--accent);
}
.page-sub { color: var(--ink-soft); margin: .35rem 0 0; }

/* ---------- Toolbar (filter + sort) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 1.5rem;
}
.filter-input {
  flex: 1 1 260px;
  padding: .7rem 1rem;
  border: 1px solid var(--divider);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1rem;
  color: var(--ink);
}
.filter-input:focus { outline: 2px solid var(--accent-soft); outline-offset: 1px; }
.toolbar--categories { margin-bottom: 1rem; }
.toolbar--categories .filter-input { flex: 1 1 100%; }
.sort-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}
.sort-toggle a {
  padding: .45rem .9rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .9rem;
}
.sort-toggle a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- Recipe grid ---------- */
.recipe-grid {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(60,45,25,.16); }
.recipe-card a { color: var(--ink); display: block; height: 100%; }
.thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.thumb-placeholder { font-size: 2.4rem; opacity: .5; }
.recipe-card-body { padding: .85rem 1rem 1rem; }
.recipe-card-body h3 {
  font-family: var(--serif);
  font-size: 1.08rem;
  margin: 0 0 .5rem;
  line-height: 1.3;
}
.recipe-card-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.badge {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--surface-2);
  padding: .2rem .55rem;
  border-radius: 999px;
}
.badge-collection { color: #fff; background: var(--accent-soft); }
.no-results { text-align: center; color: var(--ink-soft); padding: 2rem 0; }

/* ---------- Categories page ---------- */
.category-jump {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1rem 0 2rem;
}
.category-jump a {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: .4rem .8rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.category-jump a span { color: var(--tan); }
.category-jump a:hover { border-color: var(--accent-soft); color: var(--accent); }
.category-section { scroll-margin-top: 80px; margin-bottom: 2.5rem; }
.category-title {
  font-family: var(--serif);
  color: var(--accent);
  border-bottom: 2px solid var(--divider);
  padding-bottom: .4rem;
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
.category-count {
  font-family: var(--sans);
  font-size: .8rem;
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .15rem .55rem;
}

/* ---------- Recipe detail ---------- */
.breadcrumb { padding: 1.5rem 0 .5rem; color: var(--ink-soft); font-size: .9rem; }
.breadcrumb a { font-weight: 600; }
.breadcrumb span { margin: 0 .35rem; color: var(--tan); }

.recipe-pager {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  margin: 0 0 1.25rem;
}
.recipe-pager:last-of-type {
  margin: 1.5rem 0 0;
}
.recipe-pager-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex: 1 1 0;
  max-width: 48%;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.recipe-pager-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(60, 45, 25, .12);
  border-color: var(--tan);
  color: var(--accent);
}
.recipe-pager-prev { text-align: left; }
.recipe-pager-next {
  text-align: right;
  margin-left: auto;
  flex-direction: row;
  justify-content: flex-end;
}
.recipe-pager-arrow {
  flex-shrink: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--accent);
  font-weight: 700;
}
.recipe-pager-text {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}
.recipe-pager-hint {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.recipe-pager-title {
  font-family: var(--serif);
  font-size: .95rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recipe-pager-spacer {
  flex: 1 1 0;
  max-width: 48%;
}

.recipe-detail { padding-bottom: 4rem; }
.recipe-detail-head { margin-bottom: 1.25rem; }
.recipe-detail-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--accent);
  margin: 0 0 .6rem;
}
.recipe-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--ink-soft); font-size: .9rem; }
.recipe-detail-meta .note { font-style: italic; }
.recipe-detail-meta .source { color: var(--tan); }

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.recipe-scans { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 1rem; }
.scan-link {
  display: block;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.scan-link img { width: 100%; display: block; }
.scan-missing {
  border: 1px dashed var(--tan);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
}

.recipe-text {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  font-family: var(--serif);
  font-size: 1.05rem;
}
.recipe-text h2, .recipe-text h3 {
  font-family: var(--serif);
  color: var(--accent);
  margin: 1.2rem 0 .5rem;
}
.recipe-text h3:first-child, .recipe-text p:first-child { margin-top: 0; }
.recipe-text ul, .recipe-text ol { padding-left: 1.4rem; }
.recipe-text li { margin: .2rem 0; }
.recipe-text strong { color: var(--ink); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: .7rem 1.4rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--accent-soft); color: #fff; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--divider);
  background: var(--surface);
  color: var(--ink-soft);
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
  font-size: .9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .recipe-columns { grid-template-columns: 1fr; }
  .recipe-scans { position: static; }
  .recipe-pager { flex-direction: column; }
  .recipe-pager-link,
  .recipe-pager-spacer { max-width: none; }
  .recipe-pager-next { margin-left: 0; justify-content: flex-start; text-align: left; }
}
