@font-face {
  font-family: 'Playfair Display';
  src: url('fonts/PlayfairDisplay-Static800.ttf') format('truetype');
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --maroon: #6B1626;
  --maroon-2: #8C2038;
  --maroon-deep: #4A0F1C;
  --gold: #E8C77A;
  --gold-deep: #C9A227;
  --cream: #FBF3EA;
  --cream-2: #F5EBDC;
  --ink: #3A1414;
  --muted: #9A7C64;
  --ui-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

/* ---------- Access gate ---------- */
#gate {
  position: fixed; inset: 0; z-index: 60;
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-2) 55%, var(--maroon-deep) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate-card {
  width: 100%; max-width: 340px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(232,199,122,0.35);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
}
.gate-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: var(--gold); text-transform: uppercase; }
.gate-title { font-family: 'Playfair Display', serif; font-size: 28px; color: #fff; margin: 6px 0 10px; }
.gate-title .accent { color: var(--gold); }
.gate-sub { font-size: 13px; color: rgba(255,255,255,0.78); line-height: 1.4; margin-bottom: 20px; }
.gate-input {
  width: 100%; height: 48px; border-radius: 10px; border: none;
  padding: 0 14px; font-size: 15px; text-align: center;
  background: #fff; color: var(--ink); margin-bottom: 12px;
  font-family: var(--ui-font);
}
.gate-input:focus { outline: 2px solid var(--gold); }
.gate-btn {
  width: 100%; height: 48px; border-radius: 10px; border: none;
  background: var(--gold-deep); color: #fff; font-weight: 700; font-size: 14.5px;
}
.gate-btn:active { background: var(--gold); }
.gate-error { margin-top: 12px; font-size: 12.5px; color: #ffb4b4; }

html, body {
  margin: 0; height: 100%;
  background: var(--cream);
  font-family: var(--ui-font);
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#listScreen, #detailScreen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  transition: transform 0.3s cubic-bezier(.22,.68,0,1);
  background: var(--cream);
}
#detailScreen.offscreen { transform: translateX(100%); }
#listScreen.pushed { transform: translateX(-18%); }

/* ---------- Hero header ---------- */
#hero {
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-2) 55%, var(--maroon-deep) 100%);
  padding: calc(18px + var(--safe-top)) 20px 22px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
#hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.05) 0 2px, transparent 2px 14px);
  pointer-events: none;
}
#hero::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--gold-deep));
}
.hero-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--gold); text-transform: uppercase; position: relative;
}
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: 30px; color: #fff; margin: 4px 0 2px; position: relative;
}
.hero-title .accent { color: var(--gold); }
.hero-sub { font-size: 13px; color: rgba(255,255,255,0.82); position: relative; }
.count-badge {
  display: inline-block; margin-top: 12px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; position: relative;
}

/* ---------- Search ---------- */
.search-wrap {
  position: relative; margin: -16px 16px 0;
  display: flex; align-items: center;
  background: #fff; border-radius: 12px;
  padding: 0 12px; height: 48px;
  box-shadow: 0 4px 16px rgba(74,15,28,0.14);
  z-index: 2;
}
.search-icon { width: 18px; height: 18px; color: var(--maroon); flex-shrink: 0; }
#searchInput {
  flex: 1; border: none; outline: none; background: none;
  font-size: 14.5px; color: var(--ink); padding: 0 10px;
  font-family: var(--ui-font);
}
#searchInput::placeholder { color: #c2ab99; }
.clear-btn { background: none; border: none; color: #c2ab99; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.clear-btn svg { width: 16px; height: 16px; }

/* ---------- Chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 16px 16px 4px; flex-shrink: 0;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; white-space: nowrap;
  padding: 9px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--maroon);
  color: var(--maroon); background: transparent;
  cursor: pointer;
}
.chip.active { background: var(--maroon); color: #fff; }

/* ---------- Recipe list ---------- */
.recipe-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(20px + var(--safe-bottom)); }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; padding-bottom: 60px; }

.recipe-card {
  display: flex; align-items: center; gap: 13px;
  background: #fff; border-radius: 14px;
  padding: 13px 14px; margin-bottom: 11px;
  box-shadow: 0 2px 8px rgba(74,15,28,0.07);
  cursor: pointer;
}
.recipe-card:active { background: #fdf6ee; }

.rc-icon {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #E7B18A 0%, #D98E63 100%);
  display: flex; align-items: center; justify-content: center;
}
.rc-icon svg { width: 22px; height: 22px; color: #fff; }

.rc-body { flex: 1; min-width: 0; }
.rc-num {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--gold-deep); text-transform: uppercase;
}
.rc-title {
  font-family: 'Playfair Display', serif;
  font-size: 15.5px; color: var(--ink); font-weight: 700;
  line-height: 1.25; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.rc-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.rc-tag {
  font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  background: #FBEAEE; color: var(--maroon);
}
.rc-fav { color: var(--gold-deep); flex-shrink: 0; }
.rc-fav svg { width: 18px; height: 18px; }
.rc-chevron { color: var(--muted); flex-shrink: 0; }
.rc-chevron svg { width: 18px; height: 18px; }

/* ---------- Detail screen ---------- */
#detailBar {
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-deep) 100%);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 6px; padding-right: 6px;
  flex-shrink: 0;
}
.detail-title {
  flex: 1; text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 15px; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 8px;
}
.icon-btn {
  background: none; border: none; color: var(--gold);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; flex-shrink: 0;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.favorited { color: #fff; }
.icon-btn.favorited svg path { fill: var(--gold); }

#detailViewer {
  flex: 1; min-height: 0;
  position: relative;
  background: var(--maroon-deep);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
}
#detailImg {
  max-width: 94vw; max-height: 86vh;
  width: auto; height: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border-radius: 3px;
  transition: transform 0.28s ease;
  user-select: none; -webkit-user-drag: none;
}
#detailImg.zoomed { transform: scale(1.9); }
