:root {
  /* Inspired by the ocean: sea mist, deep water, teal shallows, and a touch of coral reef. */
  --bg: #eef5f6;
  --surface: #fbfdfd;
  --ink: #0d2633;
  --ink-soft: #34525f;
  --muted: #6c8691;
  --line: #d3e3e6;
  --line-strong: #b5ccd2;
  --accent: #0f6f85;
  --accent-deep: #0b5466;
  --accent-tint: #dbeef1;
  --sage: #2e7d6b;
  --sage-tint: #dcefe9;
  --amber: #b4513e;
  --amber-tint: #fbe8e3;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(13 38 51 / 0.05), 0 8px 24px rgb(13 38 51 / 0.07);
  --shadow-lift: 0 2px 4px rgb(13 38 51 / 0.06), 0 18px 40px rgb(13 38 51 / 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 420px at 50% -160px, #cfe6ea 0%, transparent 70%),
    linear-gradient(180deg, #e7f1f3 0%, var(--bg) 480px);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.muted {
  color: var(--muted);
}

.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 16px 32px;
  flex: 1;
}

/* Masthead ------------------------------------------------------------- */

.masthead {
  text-align: center;
  margin-bottom: 40px;
}

.title {
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  margin: 0 0 18px;
  color: var(--ink);
}

.lede {
  margin: 0 auto;
  max-width: 30rem;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

/* The pantry box --------------------------------------------------------- */

.pantry {
  max-width: 680px;
  margin: 0 auto;
}

.box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px 14px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: text;
}

.box:has(.chip) {
  border-radius: 24px;
}

.box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(15 111 133 / 0.14), var(--shadow);
}

.chips {
  display: contents;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 4px 5px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  background: var(--accent-tint);
  color: var(--accent-deep);
  animation: fade-in 0.25s ease-out both;
}

.chip button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}

.chip button:hover,
.chip button:focus-visible {
  opacity: 1;
  background: rgb(11 84 102 / 0.1);
  outline: none;
}

#ingredient {
  flex: 1 1 12rem;
  min-width: 10rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  padding: 8px 4px;
  color: var(--ink);
  outline: none;
}

#ingredient::placeholder {
  color: var(--muted);
}

.suggestions {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  max-height: 280px;
  overflow-y: auto;
}

.suggestions li {
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.suggestions li[aria-selected="true"],
.suggestions li:hover {
  background: var(--bg);
}

.suggestions mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.try {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin: 18px 0 8px;
}

.try-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 4px;
}

.try button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.try button:hover,
.try button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
  outline: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.basics {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  flex: 1 1 18rem;
}

.basics input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--sage);
}

.basics .muted {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
}

.cook {
  font: inherit;
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 13px 30px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.cook:hover {
  background: var(--accent);
}

.cook:active {
  transform: scale(0.98);
}

.cook:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.cook:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* Results --------------------------------------------------------------- */

.status {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  min-height: 1.6em;
  margin: 56px 0 24px;
}

.dots {
  display: inline-flex;
  gap: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 32px 24px;
}

.card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  animation: fade-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
  background: #dbe8eb;
  box-shadow: var(--shadow);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s;
}

.card:hover img,
.card:focus-visible img {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.card:focus-visible {
  outline: none;
}

.card:focus-visible .card-title {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.card-body {
  padding: 14px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  order: -1;
}

.card-title {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.3rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.badge {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge.uses {
  color: #1f5c4e;
  background: var(--sage-tint);
}

.badge.need {
  color: var(--amber);
  background: var(--amber-tint);
}

.badge.ready {
  color: #fff;
  background: var(--sage);
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Recipe dialog --------------------------------------------------------- */

.recipe {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgb(13 38 51 / 0.3);
}

.recipe::backdrop {
  background: rgb(13 38 51 / 0.5);
  backdrop-filter: blur(3px);
}

.recipe[open] {
  animation: fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.recipe-hero {
  position: relative;
}

.recipe-hero img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  display: block;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgb(255 253 249 / 0.92);
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.recipe-body {
  padding: 28px 36px 36px;
}

.recipe .meta {
  display: block;
  margin: 0 0 8px;
}

.recipe h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}

.recipe h3 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 32px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px 28px;
}

.ingredients li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 0.95rem;
}

.ingredients .mark {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  transform: translateY(3px);
}

.ingredients .have .mark {
  background: var(--sage);
  color: #fff;
}

.ingredients .staple .mark {
  background: var(--line);
  color: var(--ink-soft);
}

.ingredients .need .mark {
  background: var(--amber-tint);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgb(180 81 62 / 0.4);
}

.ingredients .measure {
  color: var(--muted);
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 4px;
  margin-bottom: 16px;
  color: var(--ink-soft);
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--accent);
  line-height: 1.5;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 18px;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 32px 16px 40px;
  border-top: 1px solid var(--line);
  margin-top: 48px;
}

.footer a {
  color: var(--ink-soft);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

@media (max-width: 560px) {
  .page {
    padding-top: 48px;
  }
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  .basics {
    flex: none;
  }
  .cook {
    width: 100%;
  }
  .recipe-body {
    padding: 22px 20px 28px;
  }
}

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

/* Section labels inside a recipe's steps ("Marinating the chicken") aren't numbered. */
.steps li.sub {
  counter-increment: none;
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink);
  margin: 22px 0 10px;
}

.steps li.sub:first-child {
  margin-top: 0;
}

.steps li.sub::before {
  content: none;
}

/* Find ingredients in a photo ----------------------------------------- */

.scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent-deep);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 14px 8px 11px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: auto;
  transition: border-color 0.15s, background 0.15s;
}

.scan-btn:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.scan {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.scan[hidden] {
  display: none;
}

.scan img {
  flex: none;
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--line);
}

.scan-body {
  flex: 1;
  min-width: 0;
}

.scan-title {
  margin: 2px 0 2px;
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.3;
}

.scan-note {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* While the photo is being read, the thumbnail breathes. */
.scan.busy img {
  animation: breathe 1.4s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.55;
  }
}

.found {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.found-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.9rem;
  padding: 5px 13px 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: line-through;
  text-decoration-color: rgb(108 134 145 / 0.5);
}

.found-item .tick {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}

.found-item[aria-pressed="true"] {
  color: var(--accent-deep);
  background: var(--accent-tint);
  border-color: transparent;
  text-decoration: none;
}

.found-item[aria-pressed="true"] .tick {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.scan-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.scan-actions[hidden] {
  display: none;
}

.cook.small {
  font-size: 0.92rem;
  padding: 9px 20px;
}

.ghost {
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.ghost:hover {
  color: var(--accent);
}

@media (max-width: 560px) {
  .scan-label {
    display: none;
  }
  .scan-btn {
    padding: 9px;
  }
  .scan {
    flex-direction: column;
  }
  .scan img {
    width: 100%;
    height: 160px;
  }
}

/* The invitation to use a photo, just under the search box. */
.photo-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.photo-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 2px 2px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgb(15 111 133 / 0.35);
  text-underline-offset: 4px;
  vertical-align: baseline;
}

.photo-link svg {
  align-self: center;
}

.photo-link:hover {
  color: var(--accent-deep);
  text-decoration-color: currentColor;
}

/* Get what's missing ----------------------------------------------------- */

.shop {
  margin: 22px 0 4px;
  padding: 16px 18px;
  background: var(--amber-tint);
  border-radius: 16px;
}

.shop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.shop-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
}

.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shop-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 14px;
  padding: 7px 0;
  border-top: 1px solid rgb(180 81 62 / 0.15);
}

.shop-list li:first-child {
  border-top: 0;
}

.shop-item {
  font-weight: 500;
}

.shop-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.85rem;
}

.shop-links a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgb(15 111 133 / 0.3);
  text-underline-offset: 3px;
}

.shop-links a:hover {
  color: var(--accent-deep);
  text-decoration-color: currentColor;
}

.shop-note {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.link-btn.small {
  font-size: 0.82rem;
  padding: 4px 12px;
  background: var(--surface);
}

.print-only {
  display: none;
}

/* Printing a recipe: just the recipe, on white, without buttons or shopping links. */
@media print {
  @page {
    margin: 16mm;
  }
  body {
    background: #fff;
    display: block;
    min-height: 0;
  }
  body > :not(dialog) {
    display: none !important;
  }
  .recipe,
  .recipe[open] {
    position: static;
    inset: auto;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    animation: none;
  }
  .recipe::backdrop {
    background: none;
    backdrop-filter: none;
  }
  .close,
  .shop,
  .links {
    display: none !important;
  }
  .recipe-hero img {
    max-height: 200px;
    border-radius: 12px;
  }
  .recipe-body {
    padding: 18px 0 0;
  }
  .ingredients .mark {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .steps li {
    break-inside: avoid;
  }
  .print-only {
    display: block;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--muted);
  }
}
