/* ── Design tokens ────────────────────────────── */
:root {
  --bg:            #F8F7F5;
  --surface:       #FFFFFF;
  --ink:           #1A1A1A;
  --muted:         #717171;
  --muted-light:   #B0B0B0;
  --border:        #E0E0E0;
  --border-strong: #ADADAD;

  --primary:       #1B4332;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.12);

  --radius:     12px;
  --radius-sm:  8px;
  --sidebar-w:  260px;
}

/* ── Reset ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: 'Lora', Georgia, serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  clip: rect(0 0 0 0); clip-path: inset(50%);
  height: 1px; overflow: hidden;
  position: absolute; white-space: nowrap; width: 1px;
}

/* ── Sidebar ──────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 100vh;
}

.sidebar {
  align-self: start;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 20px;
  position: sticky;
  scrollbar-width: none;
  top: 0;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand { align-items: center; display: flex; gap: 14px; }

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  height: 52px;
  justify-content: center;
  letter-spacing: 0.06em;
  width: 52px;
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}

.sidebar-tagline {
  color: var(--muted-light);
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  margin: 8px 0 0;
  white-space: nowrap;
}

/* Filters */
.sidebar-filters {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
  margin-top: 22px;
  padding-top: 20px;
}

.filter-group { flex: 0 0 auto; }

.filter-group + .filter-group { margin-top: 20px; }

.filter-label {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

/* Dietary checkboxes */
.filter-list { display: flex; flex-direction: column; gap: 0; }

.filter-chip {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 0.875rem;
  font-weight: 400;
  gap: 10px;
  min-height: 36px;
  padding: 4px 8px;
  transition: background 100ms ease;
}
.filter-chip:hover { background: var(--bg); }

.filter-chip input {
  appearance: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  transition: background 100ms ease, border-color 100ms ease;
  width: 16px;
}
.filter-chip input:checked {
  background:
    linear-gradient(135deg, transparent 38%, #fff 38% 50%, transparent 50%) 2px 7px / 6px 6px no-repeat,
    linear-gradient(45deg,  transparent 40%, #fff 40% 52%, transparent 52%) 6px 5px / 8px 8px no-repeat,
    var(--primary);
  border-color: var(--primary);
}
.filter-chip span { min-width: 0; }
.filter-chip:has(input:checked) { color: var(--primary); font-weight: 500; }
.filter-chip.unavailable { display: none; }

/* Reset */
.reset-button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 16px;
  min-height: 32px;
  padding: 5px 14px;
  transition: border-color 100ms ease, color 100ms ease;
  width: fit-content;
}
.reset-button:hover { border-color: var(--ink); color: var(--ink); }

/* ── Main ─────────────────────────────────────── */
main {
  min-height: 0;
  overflow-x: clip;
  overflow-y: visible;
}

body.static-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.static-page main {
  flex: 1 0 auto;
  margin: 0 auto;
  max-width: 980px;
  overflow: visible;
  padding: clamp(24px, 5vw, 56px);
  width: 100%;
}

.static-header {
  margin-bottom: 24px;
}

.static-back {
  color: var(--muted);
  display: inline-flex;
  font-size: 0.85rem;
  margin-bottom: 28px;
}

.static-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0 0 14px;
}

.static-header p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0;
  max-width: 680px;
}

.credits-page main {
  max-width: 860px;
}

.credits-page .static-header {
  margin-bottom: 18px;
}

.credits-page .static-back {
  font-size: 0.8rem;
  margin-bottom: 22px;
}

.credits-page .static-header h1 {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  letter-spacing: -0.01em;
}

.credits-page .static-header p {
  font-size: 0.9rem;
  max-width: 560px;
}

.credits-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.credits-status {
  color: var(--muted);
  margin: 0;
  padding: 22px 24px;
}

.credits-list {
  display: grid;
}

.credit-item {
  border-top: 1px solid var(--border);
  padding: 14px 18px;
}

.credit-item:first-child {
  border-top: 0;
}

.credit-item h2 {
  font-family: 'Inter', sans-serif;
  font-size: 0.86rem;
  letter-spacing: 0;
  margin: 0 0 6px;
}

.credit-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.76rem;
  gap: 6px 12px;
  line-height: 1.5;
  margin: 0;
}

.credit-meta a {
  color: var(--muted);
  font-weight: 600;
}

.credit-meta a:hover {
  color: var(--primary);
}

.credit-id {
  color: var(--muted-light);
}

.about-prose {
  max-width: 760px;
}

.about-prose p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.75;
}

.about-prose p:first-child {
  margin-top: 0;
}

.view { display: none; }
.view.active { display: block; }

.site-footer {
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted-light);
  display: flex;
  font-size: 0.76rem;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: center;
  line-height: 1.5;
  padding: 12px clamp(20px, 3vw, 36px);
  position: relative;
  text-align: center;
  z-index: 2;
}

.site-footer a {
  color: var(--muted);
  font-weight: 600;
}

.site-footer a:hover {
  color: var(--ink);
}

/* ── Stage tabs ───────────────────────────────── */
.stage-tabs-row {
  display: grid;
  gap: 4px;
}

.stage-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 8px 10px;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  width: 100%;
}
.stage-tab:hover {
  background: var(--bg);
  color: var(--ink);
}
.stage-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.stage-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.stage-tab.active .tab-day { color: #fff; }
.tab-day { font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 600; line-height: 1.2; }
.tab-sub { color: var(--muted-light); font-size: 0.7rem; font-weight: 400; transition: color 120ms ease; }
.stage-tab.active .tab-sub { color: rgba(255, 255, 255, 0.7); }

/* ── Finder content ───────────────────────────── */
.finder-content {
  padding: clamp(16px, 2.4vw, 28px) clamp(20px, 3vw, 36px) clamp(20px, 3vw, 36px);
}

/* Search */
.main-search-wrap {
  margin-bottom: 18px;
  position: relative;
}
.search-icon {
  left: 14px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.main-search-wrap input {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 0.925rem;
  min-height: 46px;
  outline: none;
  padding: 0 16px 0 42px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
.main-search-wrap input::placeholder { color: var(--muted-light); }
.main-search-wrap input:focus {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(26, 26, 26, 0.06);
}

/* Results meta */
.results-meta {
  align-items: baseline;
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
#resultTitle {
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 0.925rem;
  font-weight: 600;
  margin: 0;
}
.result-count {
  color: var(--muted);
  font-size: 0.825rem;
  margin: 0;
}

/* Cuisine chips */
.cuisine-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}
.cuisine-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
  white-space: nowrap;
}
.cuisine-chip:hover { border-color: var(--border-strong); }
.cuisine-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.cuisine-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Food Cards ───────────────────────────────── */
.results-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.food-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  text-align: left;
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease;
  width: 100%;
}
.food-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.food-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.card-img {
  background-color: var(--border);
  height: 166px;
  overflow: hidden;
  position: relative;
}
.food-photo {
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 350ms ease;
  width: 100%;
}
.food-card:hover .food-photo { transform: scale(1.04); }

.card-cuisine {
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
  bottom: 10px;
  color: #fff;
  font-size: 0.59rem;
  font-weight: 600;
  left: 10px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  position: absolute;
  text-transform: uppercase;
}

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

.card-body h3 {
  font-family: 'Inter', sans-serif;
  font-size: 0.925rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.card-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 7px;
}

/* Empty state */
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 48px;
  text-align: center;
}
.empty-state strong {
  color: var(--ink);
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  margin-bottom: 6px;
}

.eyebrow {
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

/* ── Recipe dialog ────────────────────────────── */
dialog {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: min(860px, calc(100vw - 24px));
  padding: 0;
  width: 860px;
}
dialog::backdrop {
  background: rgba(26, 26, 26, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.dialog-body {
  max-height: min(88vh, 860px);
  overflow: auto;
  position: relative;
}
.icon-button {
  align-items: center;
  background: rgba(26, 26, 26, 0.8);
  border: 0;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 0.875rem;
  height: 34px;
  justify-content: center;
  position: absolute;
  right: 14px;
  top: 14px;
  transition: background 120ms ease;
  width: 34px;
  z-index: 2;
}
.icon-button:hover { background: var(--ink); }
.icon-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.recipe-img {
  background-color: var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  height: 220px;
  overflow: hidden;
}
.recipe-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 24px 22px;
}
.recipe-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.recipe-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}
.recipe-summary {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 0 0 14px;
  max-width: 560px;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.recipe-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.recipe-action {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 11px;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.recipe-action:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}
.recipe-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.recipe-action.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.recipe-action.primary:hover { background: #000; }
.recipe-body {
  display: grid;
  gap: 0;
  grid-template-columns: 1fr 1fr;
}
.recipe-body section {
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.recipe-body section:nth-child(odd) {
  border-right: 1px solid var(--border);
}
.recipe-body h3 {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin: 0 0 12px;
  text-transform: uppercase;
}
.recipe-body ul, .recipe-body ol {
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 0;
  padding-left: 18px;
}
.recipe-notes {
  background: var(--bg);
  border-right: 0 !important;
  grid-column: 1 / -1;
}
.recipe-notes h3 { color: var(--muted); }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1200px) {
  .results-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  :root { --sidebar-w: 238px; }
  .card-img { height: 150px; }
  .food-card { grid-template-rows: 150px 1fr; }
}

@media (max-width: 580px) {
  body { height: auto; overflow: visible; }

  .app-shell {
    display: block;
    height: auto;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    height: auto;
    position: static;
  }

  main { height: auto; overflow: visible; }

  .stage-tabs-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-tab {
    min-width: 0;
    padding: 8px 10px;
  }

  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recipe-body { grid-template-columns: 1fr; }
  .recipe-body section:nth-child(odd) { border-right: 0; }
  .recipe-header h2 { font-size: 1.25rem; }
  .recipe-img { height: 160px; }
}
