/*
 * Mobile-first cookbook. One stylesheet, no build step.
 *
 * Clean and minimal: neutral surfaces, one sans typeface, hairline borders,
 * and a single accent color.
 */

:root {
  color-scheme: light;

  /* Surfaces and text */
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #0f0f10;
  --muted: #6b6b70;
  --line: #e7e7ea;
  --line-strong: #d4d4d8;
  --hover: #f4f4f5;

  /* Accent */
  --accent: #1f7a4d;
  --accent-hover: #186340;
  --accent-soft: #e8f4ed;
  --accent-line: #bfe0cd;

  /* Danger */
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fecdca;

  --radius-sm: 0.5rem;
  --radius: 0.625rem;
  --radius-lg: 0.875rem;

  --shadow-sm: 0 1px 2px rgba(15, 15, 16, 0.04);
  --shadow-md: 0 6px 20px rgba(15, 15, 16, 0.07);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --header-height: 3.5rem;
  --tabbar-height: 3.75rem;
  --gutter: 1rem;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Leave room for the fixed bottom tab bar on small screens. */
body.with-tabs {
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.wrap {
  width: min(64rem, 100%);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-height);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.brand-lockup:hover { color: inherit; }

.mark {
  position: relative;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.45rem;
  background: var(--accent);
  flex: none;
}

.mark::after {
  content: "R";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.household {
  margin-left: auto;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Primary navigation: bottom bar on phones, inline links on wider screens. */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tabbar-height);
  padding: 0 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

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

.tabbar a.active { color: var(--accent); }

.tabbar a.active::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 25%;
  right: 25%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
}

main {
  width: min(42rem, 100%);
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 3rem;
}

main.wide { width: min(64rem, 100%); }

main.auth {
  width: min(26rem, 100%);
  padding-top: 2.5rem;
}

main.auth .content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

main.auth h1 { font-size: 1.5rem; }

main.auth .content > :last-child { margin-bottom: 0; }

@media (min-width: 48rem) {
  :root { --gutter: 1.5rem; }

  body.with-tabs { padding-bottom: 0; }

  .top {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(12px);
  }

  .bar { gap: 2rem; }

  .household { order: 3; }

  .tabbar {
    position: static;
    order: 2;
    display: flex;
    gap: 0.25rem;
    margin-right: 0;
    background: transparent;
    border-top: 0;
    padding-bottom: 0;
  }

  .tabbar a {
    min-height: var(--header-height);
    padding: 0 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
  }

  .tabbar a.active { color: var(--ink); }

  .tabbar a.active::before {
    top: auto;
    bottom: -1px;
    left: 0.75rem;
    right: 0.75rem;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  main { padding-top: 2.5rem; padding-bottom: 4rem; }

  main.auth { padding-top: 4rem; }
}

/* ------------------------------------------------------------------ */
/* Typography                                                          */
/* ------------------------------------------------------------------ */

h1, h2, h3 {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}

h1 { font-size: 1.75rem; line-height: 1.15; margin: 0 0 0.75rem; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 2rem 0 0.65rem; }
h3 { font-size: 1rem; margin: 0 0 0.35rem; }

.lede, .hint, .meta, .by { color: var(--muted); }
.lede { margin: 0 0 1.5rem; }
.hint { font-size: 0.9rem; margin: 0.35rem 0 0.9rem; }
.meta, .by { font-size: 0.875rem; }

@media (min-width: 48rem) {
  h1 { font-size: 2rem; }
}

/* ------------------------------------------------------------------ */
/* Flash and errors                                                    */
/* ------------------------------------------------------------------ */

.flash, .errors {
  border: 1px solid transparent;
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.7rem 0.95rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.flash.notice {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  border-left-color: var(--accent);
  color: #14532d;
}

.flash.alert, .errors {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  border-left-color: var(--danger);
  color: var(--danger);
}

.errors ul { margin: 0; padding-left: 1.1rem; }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

.field { margin-bottom: 1.1rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

input, textarea, select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder { color: #9a9aa1; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.18);
}

select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
textarea.short { min-height: 5.5rem; }

.times {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.form-card, .share {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}

.share { margin-bottom: 1rem; }
.share form { margin: 0; }
.share .field:last-of-type { margin-bottom: 1.1rem; }

input, textarea, button, .button, select {
  scroll-margin-bottom: 6.5rem;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

button, .button, input[type="submit"] {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: auto;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 1.05rem;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

button:hover, .button:hover, input[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.button.secondary, button.secondary, input.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.button.secondary:hover, button.secondary:hover, input.secondary:hover {
  background: var(--hover);
  border-color: var(--line-strong);
  color: var(--ink);
}

button.danger, button.text {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  box-shadow: none;
  padding: 0.25rem 0.6rem;
  min-height: 36px;
  font-size: 0.9rem;
}

button.danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

button.text { color: var(--muted); font-weight: 500; }

button.text:hover {
  background: var(--hover);
  border-color: transparent;
  color: var(--ink);
}

form.inline { display: inline; }
.sign-out { margin-top: 2rem; }

.links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  font-size: 0.95rem;
}

.links a { font-weight: 500; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

/* Compact actions inside cards and page headers */
.card .actions, .head-actions {
  gap: 0.4rem;
}

.card .actions { margin-top: 0.75rem; }

.card .actions .button, .card .actions button,
.head-actions .button, .head-actions button {
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  font-size: 0.875rem;
}

.card .actions button.text, .head-actions button.danger {
  padding: 0.25rem 0.6rem;
}

/* Full-width buttons on the sign-in style pages */
main.auth .content input[type="submit"],
main.auth .content button:not(.text) {
  width: 100%;
}

main.auth .links { align-items: center; text-align: center; }
main.auth .sign-out { margin-top: 1rem; }

/* ------------------------------------------------------------------ */
/* Page header, search, filters                                        */
/* ------------------------------------------------------------------ */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.page-head h1 { margin: 0; }
.page-head + .lede { margin-top: 0; }

form.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0.25rem 0.25rem 0.25rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

form.search::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 1.1rem;
  height: 1.1rem;
  transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

form.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.18);
}

form.search input[type="search"] {
  flex: 1;
  min-width: 0;
  width: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  min-height: 40px;
  padding: 0;
}

form.search input[type="search"]:focus { box-shadow: none; }

form.search input[type="submit"] {
  min-height: 36px;
  padding: 0.3rem 0.9rem;
  font-size: 0.875rem;
  background: var(--hover);
  color: var(--ink);
  border-color: transparent;
  box-shadow: none;
}

form.search input[type="submit"]:hover {
  background: var(--line);
  border-color: transparent;
  color: var(--ink);
}

@media (min-width: 48rem) {
  form.search { max-width: 28rem; }
}

.filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin: 0 calc(var(--gutter) * -1) 1.25rem;
  padding: 0.1rem var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar { display: none; }

@media (min-width: 48rem) {
  .filters { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; overflow: visible; }
}

.tag {
  display: inline-block;
  flex: none;
  padding: 0.2rem 0.65rem;
  background: var(--hover);
  border: 1px solid transparent;
  border-radius: 999px;
  color: #3f3f46;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  transition: background-color 0.15s, color 0.15s;
}

.tag:hover { background: var(--accent-soft); color: var(--accent); }

.tag.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

.filters .tag {
  padding: 0.35rem 0.8rem;
  background: var(--surface);
  border-color: var(--line-strong);
}

.filters .tag:hover { background: var(--hover); color: var(--ink); }

.filters .tag.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
}

.badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.1rem 0.55rem;
  background: var(--hover);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------------------------ */
/* Cards and grid                                                      */
/* ------------------------------------------------------------------ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card h2 a { color: inherit; text-decoration: none; }

.card p { margin: 0; overflow-wrap: anywhere; }
.card p.meta { margin-top: 0.1rem; }

.card .tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }

/* Whole recipe card is clickable; tags stay independently clickable. */
.recipe-card h2 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.recipe-card .tag { position: relative; z-index: 1; }

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

.empty p { margin: 0 0 0.75rem; }
.empty p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ */
/* Recipe page                                                         */
/* ------------------------------------------------------------------ */

.recipe-head { margin-bottom: 1.75rem; }
.recipe-head h1 { margin-bottom: 0.4rem; }
.recipe-head .meta { margin: 0.1rem 0; }

.source {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
}

.source:hover { background: var(--hover); color: var(--ink); }

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
}

.recipe-body { display: grid; gap: 1.5rem; }

.recipe-body h2:first-child { margin-top: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.25rem 1.2rem 0.75rem;
}

.panel h2 { margin: 1rem 0 0.4rem; }

@media (min-width: 48rem) {
  .recipe-body.two-col {
    grid-template-columns: 18rem minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
  }

  .recipe-body.two-col .panel {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
  }
}

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

.ingredients li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.ingredients li:last-child { border-bottom: 0; }

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

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.85rem;
  align-items: start;
  margin: 0 0 1.1rem;
}

.steps li::before {
  content: counter(step);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-top: 0.05rem;
}

.notes-section { margin-top: 2.5rem; max-width: 42rem; }
.notes-section h2 { margin-top: 0; }

.note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 0.65rem 0;
}

.note p { margin: 0.15rem 0; white-space: pre-wrap; }
.note .by { margin-top: 0.4rem; }

.note-form { margin-top: 1.25rem; }
.note-form .field { margin-bottom: 0.75rem; }

/* ------------------------------------------------------------------ */
/* Family                                                              */
/* ------------------------------------------------------------------ */

.people {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.people li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.people li:last-child { border-bottom: 0; }

.people li > span:first-child { overflow-wrap: anywhere; font-weight: 500; }

.people li > span:last-child {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.role {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */

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

@media (max-width: 30rem) {
  h1 { font-size: 1.6rem; }
  .page-head .button { min-height: 40px; padding-inline: 0.85rem; }
}
