/* Our Home Pantry
   One stylesheet, no build step. Colours live as variables at the top so
   the whole app can be re-tinted from one place. */

:root {
  --bg: #FBFAF7;
  --ink: #1B1D18;
  --quiet: #5E645A;
  --line: #E6E4DC;
  --line-soft: #F1EFE8;
  --card: #FFFFFF;
  --field: #F4F2EC;

  --green: #2E5E4E;
  --green-soft: #E8F0EC;
  --green-ink: #1F4134;
  --clay: #B04A17;
  --clay-soft: #FAEBE2;
  --clay-ink: #7A3310;

  --tint-1: #DCE7DF;
  --tint-2: #EFE2D2;
  --tint-3: #E3E3EA;
  --tint-4: #F0E2E0;
  --tint-5: #F1EFE8;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 29, 24, 0.04);
  --display: 'Bricolage Grotesque', Inter, ui-sans-serif, system-ui, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #16180F;
    --ink: #F2F0E6;
    --quiet: #AEB4A4;
    --line: #333A2C;
    --line-soft: #262B20;
    --card: #1F2219;
    --field: #262B20;

    --green: #7FB89C;
    --green-soft: #222E27;
    --green-ink: #AEDCC4;
    --clay: #E08A5C;
    --clay-soft: #30241D;
    --clay-ink: #F0B48C;

    --tint-1: #27322B;
    --tint-2: #322A20;
    --tint-3: #262933;
    --tint-4: #322428;
    --tint-5: #242820;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #16180F; --ink: #F2F0E6; --quiet: #AEB4A4; --line: #333A2C;
  --line-soft: #262B20; --card: #1F2219; --field: #262B20;
  --green: #7FB89C; --green-soft: #222E27; --green-ink: #AEDCC4;
  --clay: #E08A5C; --clay-soft: #30241D; --clay-ink: #F0B48C;
  --tint-1: #27322B; --tint-2: #322A20; --tint-3: #262933;
  --tint-4: #322428; --tint-5: #242820;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* --- shell --------------------------------------------------------- */

/* On a phone the navigation sits at the bottom, under the content, even
   though it comes first in the HTML (where it reads as a sidebar). */
.app { display: flex; flex-direction: column; min-height: 100%; }
.shellmain { order: 1; display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bottomnav { order: 2; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
}
.topbar-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 40px;
}
.wordmark {
  font-family: var(--display); font-size: 1.2rem; font-weight: 700;
  letter-spacing: -0.02em; margin: 0;
}
.view-title {
  font-family: var(--display); font-size: 1.45rem; font-weight: 700;
  letter-spacing: -0.025em; margin: 0;
}

.stack { display: flex; }
.stack .avatar + .avatar { margin-left: -8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 999px; flex: 0 0 28px;
  display: grid; place-items: center; color: #fff;
  font-size: 0.72rem; font-weight: 600;
  border: 2px solid var(--card); object-fit: cover;
}
.avatar.lg { width: 36px; height: 36px; flex-basis: 36px; font-size: 0.85rem; }
.avatar.sm {
  width: 22px; height: 22px; flex-basis: 22px; font-size: 0.62rem;
  border-width: 0; background: var(--field); color: var(--quiet);
}

.tabs { display: flex; gap: 6px; padding: 14px 0 0; }
.tab {
  flex: 1; padding: 9px 6px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--quiet);
  font-size: 0.82rem; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tab[aria-selected='true'] { background: var(--green); border-color: var(--green); color: var(--bg); }

.subrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0; font-size: 0.82rem; color: var(--quiet);
}

main { flex: 1; padding: 16px 16px 24px; }
.view { max-width: 60rem; margin: 0 auto; }

/* --- bottom navigation --------------------------------------------- */

.bottomnav {
  position: sticky; bottom: 0; z-index: 20; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.navlink {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 7px 0; color: var(--quiet); font-size: 0.68rem; font-weight: 500;
  border: 0; background: none; text-decoration: none; border-radius: 10px;
}
.navlink:hover { text-decoration: none; }
.navlink[aria-current='page'] { color: var(--green-ink); font-weight: 700; }
.navlink svg { width: 22px; height: 22px; }

/* --- buttons -------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--quiet); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--bg); }
.btn.primary:hover { border-color: var(--green); filter: brightness(1.06); }
.btn.clay { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn.ghost { background: none; border-color: transparent; color: var(--green-ink); }
.btn.danger { color: var(--clay-ink); border-color: var(--clay-soft); background: var(--clay-soft); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 0.82rem; border-radius: 9px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-icon {
  width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  display: grid; place-items: center; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- fields --------------------------------------------------------- */

.field {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 0.95rem; min-height: 44px;
}
.field:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
textarea.field { min-height: 92px; resize: vertical; line-height: 1.5; }
.label {
  display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--quiet); margin-bottom: 7px;
}
.formrow { margin-bottom: 16px; }
.formrow.split { display: flex; gap: 10px; }
.formrow.split > * { flex: 1; min-width: 0; }

.searchbar {
  display: flex; align-items: center; gap: 9px; background: var(--field);
  border-radius: 11px; padding: 10px 13px;
}
.searchbar input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 0.92rem;
}

.composer {
  position: sticky; bottom: 0; padding: 10px 0;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.composer-inner {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 8px 8px 14px; box-shadow: var(--shadow);
}
.composer-inner input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 0.95rem; padding: 6px 0;
}

/* --- shopping list -------------------------------------------------- */

.group { margin-bottom: 20px; }
.group-head {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--quiet); margin: 0 0 8px;
}

.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 12px; border-radius: 12px; margin-bottom: 6px;
  border: 1px solid var(--line-soft); background: var(--card); text-align: left;
}
.item.done { background: none; border-color: transparent; }
.item:hover { border-color: var(--line); }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-label { font-size: 0.95rem; font-weight: 500; }
.item.done .item-label { color: var(--quiet); text-decoration: line-through; }
.item-note { font-size: 0.78rem; color: var(--quiet); }

.check {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 6px;
  border: 1.8px solid var(--quiet); background: var(--card);
  display: grid; place-items: center; padding: 0;
}
.check[aria-pressed='true'] { background: var(--green); border-color: var(--green); }
.check svg { width: 12px; height: 12px; display: none; }
.check[aria-pressed='true'] svg { display: block; }

/* --- cards and grids ------------------------------------------------ */

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.rcard {
  display: flex; flex-direction: column; border-radius: var(--radius);
  border: 1px solid var(--line-soft); background: var(--card);
  overflow: hidden; color: inherit; text-decoration: none;
}
.rcard:hover { text-decoration: none; border-color: var(--line); }
.rcard-photo {
  position: relative; height: 104px; display: grid; place-items: center;
  background: var(--tint-1); overflow: hidden;
}
.rcard-photo img { width: 100%; height: 100%; object-fit: cover; }
.rcard-photo .badge {
  position: absolute; top: 8px; left: 8px; background: var(--card);
  color: var(--clay-ink); font-size: 0.62rem; font-weight: 700;
  padding: 4px 8px; border-radius: 999px;
}
.rcard-body { padding: 11px 12px 13px; display: flex; flex-direction: column; gap: 5px; }
.rcard-title { font-size: 0.92rem; font-weight: 600; line-height: 1.25; }
.rcard-meta { font-size: 0.75rem; color: var(--quiet); }

.panel {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 18px;
}
.panel + .panel { margin-top: 14px; }
.panel h2 {
  margin: 0 0 14px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--quiet);
}

/* --- recipe detail --------------------------------------------------- */

.hero {
  position: relative; height: clamp(170px, 40vw, 260px);
  border-radius: 16px; overflow: hidden; background: var(--tint-1);
  display: grid; place-items: center; margin-bottom: 18px;
}
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero-actions { position: absolute; bottom: 12px; right: 12px; display: flex; gap: 8px; }

.recipe-head { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.recipe-head h1 {
  margin: 0; font-family: var(--display); font-size: 1.5rem;
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.15;
}
.recipe-meta { font-size: 0.8rem; color: var(--quiet); }

.two-col { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.two-col > .col-narrow { flex: 1 1 15rem; min-width: 13rem; }
.two-col > .col-wide { flex: 999 1 20rem; min-width: 0; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: s;
  display: flex; flex-direction: column; gap: 16px; }
.steps li { counter-increment: s; display: flex; gap: 12px; line-height: 1.5; font-size: 0.95rem; }
.steps li::before {
  content: counter(s); flex: 0 0 24px; width: 24px; height: 24px;
  border-radius: 999px; background: var(--green-soft); color: var(--green-ink);
  font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; margin-top: 1px;
}

.note { display: flex; gap: 12px; padding: 10px 0; }
.note-body { flex: 1; min-width: 0; }
.note-body p { margin: 0 0 3px; font-size: 0.92rem; line-height: 1.5; }
.note-who { font-size: 0.75rem; color: var(--quiet); }

.sourcebox {
  background: var(--clay-soft); border-radius: var(--radius);
  padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 18px;
}
.sourcebox .text { flex: 999 1 14rem; min-width: 0; font-size: 0.88rem; color: var(--clay-ink); }
.sourcebox strong { display: block; margin-bottom: 3px; }

.photostrip { display: flex; gap: 10px; flex-wrap: wrap; }
.photostrip figure { margin: 0; position: relative; }
.photostrip img {
  width: 96px; height: 96px; object-fit: cover;
  border-radius: 11px; background: var(--tint-5); display: block;
}
.photostrip .remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 999px; border: 0; background: rgba(0,0,0,0.55); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem; line-height: 1;
}

/* --- calendar -------------------------------------------------------- */

.day {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 2px;
  border-radius: var(--radius); border: 1px solid transparent; margin-bottom: 6px;
}
.day.today { background: var(--card); border-color: var(--green-soft); }
.daymark {
  width: 44px; flex: 0 0 44px; display: flex; flex-direction: column;
  align-items: center; gap: 1px;
}
.daymark .dow { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; color: var(--quiet); }
.daymark .num { font-size: 1.05rem; font-weight: 700; }
.day.today .daymark .dow, .day.today .daymark .num { color: var(--green-ink); }
.daybody {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px;
  text-align: left; border: 0; background: none; padding: 0; color: inherit;
}
.daythumb {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 11px;
  background: var(--tint-5); display: grid; place-items: center; overflow: hidden;
}
.daythumb img { width: 100%; height: 100%; object-fit: cover; }
.daytext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.daytext .what { font-size: 0.93rem; font-weight: 600; line-height: 1.25; }
.daytext .who { font-size: 0.76rem; color: var(--quiet); }
.dayempty {
  flex: 1; display: flex; align-items: center; gap: 9px; padding: 13px 14px;
  border: 1.5px dashed var(--line); border-radius: 12px;
  color: var(--quiet); font-size: 0.86rem; font-weight: 500;
  background: none; text-align: left;
}

/* --- ideas ----------------------------------------------------------- */

.idea {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px 13px; margin-bottom: 10px;
}
.idea.leading { border-color: var(--clay); }
.idea-thumb {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 11px;
  background: var(--tint-3); display: grid; place-items: center; overflow: hidden;
}
.idea-thumb img { width: 100%; height: 100%; object-fit: cover; }
.idea-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.idea-title { font-size: 0.95rem; font-weight: 600; line-height: 1.25;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.idea-meta { font-size: 0.78rem; color: var(--quiet); }
.pill {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 999px;
  background: var(--clay-soft); color: var(--clay-ink);
}
.vote {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
}
.vote[aria-pressed='true'] { background: var(--green); border-color: var(--green); }
.vote[aria-pressed='true'] .count, .vote[aria-pressed='true'] svg { color: var(--bg); }
.vote svg { width: 14px; height: 14px; }
.vote .count { font-size: 0.78rem; font-weight: 700; }

.dashed {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; border: 1.5px dashed var(--line); background: none;
  border-radius: var(--radius); padding: 15px; color: var(--green-ink);
  font-size: 0.9rem; font-weight: 600;
}

/* --- dialogs --------------------------------------------------------- */

dialog {
  border: 0; border-radius: 18px; padding: 0; background: var(--card);
  color: var(--ink); max-width: min(32rem, calc(100vw - 24px)); width: 100%;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
}
dialog::backdrop { background: rgba(20, 22, 17, 0.45); backdrop-filter: blur(2px); }
.dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 20px 20px 0;
}
.dialog-head h2 {
  margin: 0; font-family: var(--display); font-size: 1.15rem;
  font-weight: 700; letter-spacing: -0.02em;
}
.dialog-body { padding: 16px 20px; max-height: min(66vh, 34rem); overflow-y: auto; }
.dialog-foot {
  display: flex; gap: 9px; justify-content: flex-end;
  padding: 0 20px 20px; flex-wrap: wrap;
}

/* --- odds and ends ---------------------------------------------------- */

.empty { text-align: center; padding: 40px 20px; color: var(--quiet); }
.empty h2 { font-family: var(--display); font-size: 1.1rem; color: var(--ink); margin: 0 0 8px; }
.empty p { margin: 0 auto 18px; max-width: 28ch; font-size: 0.9rem; }

.quiet { color: var(--quiet); }
.small { font-size: 0.82rem; }
.spacer { height: 10px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 11px 18px;
  border-radius: 999px; font-size: 0.86rem; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2); max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--clay); color: #fff; }

.banner {
  background: var(--clay-soft); color: var(--clay-ink); border-radius: var(--radius);
  padding: 14px; display: flex; gap: 12px; align-items: center;
  margin-bottom: 14px; font-size: 0.88rem;
}
.banner .grow { flex: 1; min-width: 0; }

.linkbox {
  display: flex; gap: 8px; align-items: center; background: var(--field);
  border-radius: 10px; padding: 9px 12px; font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

.spinner {
  width: 18px; height: 18px; border-radius: 999px;
  border: 2px solid var(--line); border-top-color: var(--green);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  * { scroll-behavior: auto !important; }
}

/* --- wider screens ---------------------------------------------------- */

@media (min-width: 62rem) {
  .app { flex-direction: row; }
  .bottomnav {
    position: sticky; top: 0; align-self: flex-start;
    flex-direction: column; width: 15rem; height: 100vh;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 22px 12px; gap: 3px; justify-content: flex-start;
  }
  .bottomnav { order: 1; }
  .shellmain { order: 2; }
  .bottomnav .wordmark { padding: 0 10px 20px; }
  .navlink {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 11px; padding: 11px 12px; font-size: 0.9rem;
  }
  .navlink[aria-current='page'] { background: var(--green-soft); }
  .topbar { padding-top: 20px; }
  main { padding: 22px 28px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .toast { bottom: 28px; left: auto; right: 28px; transform: none; }
}

@media (max-width: 61.99rem) {
  .bottomnav .wordmark { display: none; }
}
