:root {
  --bg: #16110d;
  --bg-2: #211913;
  --surface: #2a2019;
  --surface-2: #34281f;
  --line: #45362a;
  --text: #f5ece2;
  --muted: #bda996;
  --accent: #e8a33d;
  --accent-ink: #1d1409;
  --accent-soft: rgba(232, 163, 61, 0.16);
  --rec: #e0533d;
  --danger: #ff9b87;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  --radius: 20px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf5ee;
    --bg-2: #f2e9dd;
    --surface: #ffffff;
    --surface-2: #f6efe5;
    --line: #e4d6c4;
    --text: #2a1f16;
    --muted: #7a6653;
    --accent: #b86e0f;
    --accent-ink: #ffffff;
    --accent-soft: rgba(184, 110, 15, 0.12);
    --rec: #c8412c;
    --danger: #b3261e;
    --shadow: 0 16px 36px -20px rgba(80, 50, 20, 0.45);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.icon {
  width: 24px; height: 24px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

/* --- intro --------------------------------------------------------------- */
.intro { text-align: center; margin: 8px 0 20px; }
.intro h1 {
  margin: 0 0 6px;
  font: 600 clamp(1.7rem, 6vw, 2.4rem)/1.15 Georgia, "Times New Roman", serif;
  letter-spacing: -0.01em;
}
.lede { margin: 0 auto; max-width: 34ch; color: var(--muted); }

/* --- ask ----------------------------------------------------------------- */
.ask {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: 560px; margin: 0 auto;
}

.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.mic {
  position: relative;
  width: 112px; height: 112px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 30px -8px var(--accent), inset 0 -4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}
.mic .icon { width: 44px; height: 44px; position: relative; z-index: 1; }
.mic .icon-mic rect { fill: currentColor; }
.mic .icon-stop { display: none; fill: currentColor; stroke: none; }
.mic:active { transform: scale(0.96); }
.mic:focus-visible { outline: 3px solid var(--text); outline-offset: 4px; }
.mic:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.mic-level {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--rec);
  opacity: 0; transform: scale(1);
  transition: transform 0.08s linear;
  pointer-events: none;
}

.mic[aria-pressed="true"] {
  background: var(--rec); color: #fff;
  box-shadow: 0 10px 30px -8px var(--rec);
  animation: pulse 1.6s ease-out infinite;
}
.mic[aria-pressed="true"] .mic-level { opacity: 0.35; }
.mic[aria-pressed="true"] .icon-mic { display: none; }
.mic[aria-pressed="true"] .icon-stop { display: block; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 55%, transparent); }
  100% { box-shadow: 0 0 0 26px transparent; }
}

.mic-hint { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 0.95rem; text-align: center; }

.or {
  display: flex; align-items: center; gap: 12px; width: 100%;
  color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.query {
  display: flex; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 5px 5px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease;
}
.query:focus-within { border-color: var(--accent); }
.query input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 1rem;
  padding: 10px 8px 10px 0;
}
.query input::placeholder { color: var(--muted); opacity: 0.8; }
.send {
  flex: none; width: 46px; height: 46px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer;
}
.send:disabled { opacity: 0.45; cursor: not-allowed; }
.send:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

/* --- status -------------------------------------------------------------- */
.status { max-width: 560px; margin: 24px auto 0; text-align: center; }
.loading p { margin: 12px 0 0; color: var(--muted); }
.error {
  margin: 0; padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

.shaker { display: inline-flex; gap: 8px; }
.shaker span {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s ease-in-out infinite;
}
.shaker span:nth-child(2) { animation-delay: 0.15s; }
.shaker span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-12px); opacity: 1; }
}

/* --- results ------------------------------------------------------------- */
.results { margin-top: 28px; }
.results-head { text-align: center; margin-bottom: 14px; }
.results-head h2 { margin: 0; font: 600 1.35rem/1.2 Georgia, "Times New Roman", serif; }
.heard { margin: 6px 0 0; color: var(--muted); font-style: italic; }
.tags {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.tags li {
  font-size: 0.8rem; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

.carousel { position: relative; }

.track {
  list-style: none; margin: 0; padding: 6px 16px 18px;
  display: grid; grid-auto-flow: column;
  grid-auto-columns: min(82%, 320px);
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  margin-inline: -16px;
}
.track::-webkit-scrollbar { display: none; }
.track:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }

.card {
  scroll-snap-align: start;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(80% 80% at 30% 20%, var(--accent-soft), transparent),
    var(--surface-2);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.placeholder img { display: none; }
.photo.placeholder::after {
  content: attr(data-initial);
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 4rem/1 Georgia, serif; color: var(--accent); opacity: 0.55;
}
.rank {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  min-width: 34px; height: 34px; padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(20, 14, 10, 0.72); color: #fff;
  font-weight: 700; font-size: 0.95rem;
  backdrop-filter: blur(6px);
}

.body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.name { margin: 0; font: 600 1.25rem/1.2 Georgia, "Times New Roman", serif; }
.meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.notes li {
  font-size: 0.78rem; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.notes li.hit { border-color: var(--accent); color: var(--accent); }
.ingredients { margin: 0; font-size: 0.92rem; }
.cnotes { margin: 0; font-size: 0.82rem; color: var(--muted); }
.cnotes:empty { display: none; }

.recipe {
  margin-top: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none;
}
.recipe .icon { width: 18px; height: 18px; }
.recipe:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.recipe[hidden] { display: none; }

.nav {
  display: none;
  position: absolute; top: 38%; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  place-items: center; cursor: pointer;
  box-shadow: var(--shadow);
}
.nav:disabled { opacity: 0; pointer-events: none; }
.nav.prev { left: -8px; }
.nav.next { right: -8px; }
@media (hover: hover) and (pointer: fine) {
  .nav { display: grid; }
}

.dots { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.dots button {
  width: 9px; height: 9px; padding: 0; border: 0; border-radius: 999px;
  background: var(--line); cursor: pointer;
  transition: width 0.2s ease, background-color 0.2s ease;
}
.dots button[aria-current="true"] { width: 24px; background: var(--accent); }

@media (min-width: 720px) {
  .track { grid-auto-columns: 300px; }
}
/* room beside the 960px column: park the arrows outside the cards */
@media (min-width: 1100px) {
  .nav.prev { left: -64px; }
  .nav.next { right: -64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .track { scroll-behavior: auto; }
}
