@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@500;600;700&family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── Design tokens (matches drewklauser.com / Library palette) ──────── */
:root {
  color-scheme: light;

  --c-bg:           #F7F3EC;
  --c-bg-elevated:  #FCFAF5;
  --c-bg-card:      #FFFFFF;
  --c-border:       rgba(33, 29, 24, 0.10);
  --c-border-hov:   rgba(22, 60, 37, 0.30);

  --c-accent:       #163C25;
  --c-accent-lt:    #3F7D5B;
  --c-accent-tint:  rgba(22, 60, 37, 0.07);

  --c-text:         #211D18;
  --c-text-2:       #6B6459;
  --c-text-3:       #9C9488;

  --font:           'Manrope', system-ui, -apple-system, sans-serif;
  --font-serif:     'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  --radius-lg:      20px;
  --radius:         16px;
  --radius-sm:      8px;
  --ease:           cubic-bezier(0.16, 1, 0.3, 1);
  --nav-h:          56px;

  /* Safe-area aware spacing for notched phones */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ── Reset ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); -webkit-text-size-adjust: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
button { font: inherit; }

/* ── Layout ───────────────────────────────────────────────────────── */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
@media (min-width: 768px) { .page-container { padding: 0 2rem; } }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  padding-top: var(--safe-top);
  background: rgba(247, 243, 236, 0.9);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--c-border);
}
.site-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
}
.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text-2);
  text-decoration: none;
}

.hero {
  padding: 2.5rem 1.25rem 1.5rem;
  text-align: center;
}
@media (min-width: 768px) { .hero { padding: 4rem 2rem 2rem; } }
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 7vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.hero-subtitle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--c-accent);
  margin-top: 0.6rem;
  letter-spacing: 0.04em;
}

/* ── Search + filters ─────────────────────────────────────────────── */
.recipes-search-wrap { position: relative; margin-bottom: 1rem; }
.recipes-search-icon {
  position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%);
  color: var(--c-text-3); pointer-events: none;
}
.recipes-search {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.5rem;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem; /* 16px+ prevents iOS auto-zoom on focus */
  color: var(--c-text);
  outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.recipes-search:focus { border-color: var(--c-border-hov); box-shadow: 0 0 0 3px rgba(22,60,37,0.1); }

.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.filter-label {
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-text-2);
  flex-shrink: 0; width: 4.2rem;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.filter-pill {
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--c-border); background: var(--c-bg-card);
  color: var(--c-text-2); cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: 30px;
}
.filter-pill--active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.filter-pill[data-filter-type="cat"].filter-pill--active:not([data-filter-val=""]) {
  background: var(--pill-color); border-color: var(--pill-color);
}

/* ── Recipe grid + card ───────────────────────────────────────────── */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1.25rem 0 3rem;
}
@media (min-width: 640px)  { .recipes-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }
@media (min-width: 1024px) { .recipes-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }

.recipe-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform 0.15s var(--ease);
}
.recipe-card:hover { transform: translateY(-3px); }
.recipe-card:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 3px; border-radius: var(--radius-sm); }

.recipe-cover-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.05);
  position: relative;
}
.recipe-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 14px; text-align: center;
}
.recipe-cover-placeholder span {
  font-family: var(--font-serif); font-size: clamp(1rem, 5vw, 1.4rem); font-weight: 600;
  line-height: 1.3; color: rgba(248,250,252,0.95);
}

.recipe-info { padding: 0.6rem 0.15rem 0; }
.recipe-title {
  font-family: var(--font); font-size: 0.85rem; font-weight: 600;
  line-height: 1.3; color: var(--c-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 3px;
}
.recipe-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.7rem; color: var(--c-text-2); font-family: var(--font-mono);
}

.category-badge {
  display: inline-block;
  font-size: 0.6rem; font-family: var(--font-mono); font-weight: 500;
  letter-spacing: 0.07em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; color: rgba(248,250,252,0.9);
}

/* ── Modal ────────────────────────────────────────────────────────── */
/* Always full-screen, at every breakpoint — no floating card, no backdrop
   visible behind it, no "card with a hard bottom edge" cutoff. */
dialog.recipe-modal {
  background: transparent; border: none; padding: 0;
  position: fixed; margin: 0; max-width: 100vw; max-height: 100vh;
  width: 100%; height: 100%;
  overflow: hidden;
}
dialog.recipe-modal::backdrop { background: rgba(15, 23, 42, 0.55); }

.modal-inner {
  background: var(--c-bg-elevated);
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.25rem calc(1.5rem + var(--safe-bottom));
}
@media (min-width: 640px) {
  .modal-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
  }
}

.modal-close {
  position: absolute; top: 0.9rem; right: 0.9rem;
  background: rgba(255,255,255,0.85); border: none; color: var(--c-text-2);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}

.modal-hero { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1rem; }
.modal-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-hero-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 14px; text-align: center; color: rgba(248,250,252,0.95);
  font-family: var(--font-serif); font-size: clamp(1.3rem, 6vw, 1.9rem); font-weight: 600; line-height: 1.3;
}

.modal-title { font-family: var(--font); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.25rem; line-height: 1.25; }
.modal-subrow { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; font-size: 0.82rem; color: var(--c-text-2); margin: 0.4rem 0 1rem; }

.servings-stepper { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0; }
.servings-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--c-border); background: var(--c-bg-card);
  font-size: 1.15rem; color: var(--c-text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.servings-btn:active { background: var(--c-accent-tint); }
.servings-display { font-family: var(--font-mono); font-size: 0.9rem; color: var(--c-text); min-width: 6rem; text-align: center; }

.ingredients-list { list-style: none; margin: 0.5rem 0 1.25rem; }
.ingredients-list li {
  padding: 0.5rem 0; font-size: 0.9rem; color: var(--c-text);
  border-bottom: 1px solid var(--c-border);
}

.btn-start-cooking {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; padding: 0.9rem; margin-top: 0.5rem;
  background: var(--c-accent); color: #fff; border: none;
  border-radius: var(--radius-sm); font-family: var(--font); font-weight: 600;
  font-size: 1rem; cursor: pointer;
}

/* ══ Cook mode ═══════════════════════════════════════════════════════
   Mobile-first: this is meant to be used one-handed on a phone propped
   up on a counter, so everything below defaults to phone sizing first. */

body.cook-body { overscroll-behavior-y: contain; }

.cook-top-sticky {
  position: sticky; top: 0; z-index: 20;
  background: rgba(247, 243, 236, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.cook-header {
  padding: calc(0.6rem + var(--safe-top)) 1rem 0.6rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.cook-back {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--c-bg-card); border: 1px solid var(--c-border);
  color: var(--c-text); text-decoration: none;
}
.cook-title { flex: 1; min-width: 0; font-family: var(--font); font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cook-progress {
  display: flex; gap: 5px; padding: 0 1rem 0.6rem;
  overflow-x: auto; scrollbar-width: none;
}
.cook-progress::-webkit-scrollbar { display: none; }
.cook-dot {
  flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-border-hov); border: none; cursor: pointer; padding: 0;
  transition: background 0.15s, transform 0.15s;
}
.cook-dot--active { background: var(--c-accent); transform: scale(1.4); }
.cook-dot--done { background: var(--c-accent-lt); }

.cook-stage {
  position: relative;
  min-height: calc(100vh - 210px);
  display: flex; flex-direction: column;
  padding: 0.5rem 1.25rem 1rem;
  touch-action: pan-y;
}

.cook-step-image { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.cook-step-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cook-step-label {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--c-accent); margin-bottom: 0.5rem;
}
.cook-step-text {
  font-family: var(--font-serif); font-size: clamp(1.25rem, 5vw, 1.75rem);
  font-weight: 500; line-height: 1.4; color: var(--c-text);
}

.cook-step-ingredients {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 1.1rem;
}
.cook-step-ingredient-chip {
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
  color: var(--c-accent); background: var(--c-accent-tint);
  border: 1px solid rgba(22,60,37,0.18);
  padding: 0.4rem 0.75rem; border-radius: 999px;
}

.cook-timer {
  margin-top: 1.5rem; padding: 1rem 1.25rem;
  background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  display: flex; align-items: center; gap: 1rem;
}
.cook-timer-display { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 700; color: var(--c-text); font-variant-numeric: tabular-nums; min-width: 4.5ch; }
.cook-timer-btn {
  padding: 0.6rem 1rem; border-radius: 999px; border: none;
  background: var(--c-accent); color: #fff; font-weight: 600; font-size: 0.8rem; cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}
.cook-timer-btn--secondary { background: transparent; border: 1px solid var(--c-border); color: var(--c-text); }
.cook-timer--done { animation: cook-flash 0.6s ease 3; }
@keyframes cook-flash { 0%, 100% { background: var(--c-bg-card); } 50% { background: rgba(22,60,37,0.25); } }

/* Bottom nav — thumb-reachable, fixed */
.cook-nav {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; gap: 0.75rem;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: rgba(247, 243, 236, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--c-border);
}
.cook-nav-btn {
  flex: 1; min-height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: var(--radius-sm); border: 1px solid var(--c-border);
  background: var(--c-bg-card); color: var(--c-text);
  font-family: var(--font); font-weight: 600; font-size: 0.95rem; cursor: pointer;
}
.cook-nav-btn--primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.cook-nav-btn:disabled { opacity: 0.35; cursor: default; }

/* Active-timers tray — lives in the sticky header, so a timer started on
   an earlier step stays visible (and tappable) after swiping forward. */
.timer-tray {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  padding: 0 1rem;
}
.timer-tray-chip {
  border: none;
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--c-accent); color: #fff;
  padding: 0.4rem 0.8rem; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  cursor: pointer;
}

/* Ingredient checklist toggle — lives in the header, opens a bottom sheet */
.ingredients-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--c-accent); color: #fff; font-family: var(--font-mono);
  font-size: 0.6rem; font-weight: 700; border-radius: 999px;
  padding: 1px 5px; min-width: 1.2rem; text-align: center;
  box-shadow: 0 0 0 2px var(--c-bg-card);
}

dialog.ingredients-sheet {
  background: var(--c-bg-elevated); border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  position: fixed; margin: 0; left: 0; right: 0; bottom: 0; top: auto;
  width: 100%; max-width: 100%; max-height: 75vh;
  padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom));
}
dialog.ingredients-sheet::backdrop { background: rgba(15, 23, 42, 0.45); }
@media (min-width: 640px) {
  dialog.ingredients-sheet {
    left: auto; right: 1.5rem; bottom: 1.5rem; border-radius: var(--radius);
    width: min(360px, 90vw);
  }
}

.check-list { list-style: none; margin-top: 0.75rem; }
.check-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0; font-size: 0.9rem; border-bottom: 1px solid var(--c-border);
}
.check-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--c-accent); flex-shrink: 0; }
.check-item.checked span { color: var(--c-text-3); text-decoration: line-through; }

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--c-bg); }
::-webkit-scrollbar-thumb { background: rgba(22,60,37,0.35); border-radius: 3px; }
