/* Recipeskipops — shared styles.
   No framework, no build step. Sized for a phone held one-handed in a kitchen. */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --border: #e5e1da;
  --text: #1c1a17;
  --muted: #6b6559;
  --accent: #a0522d;
  --accent-soft: #f4ece5;
  --done: #8a8578;
  --radius: 14px;
  --pad: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #201e1b;
    --border: #35322c;
    --text: #f0ede8;
    --muted: #a09a8e;
    --accent: #d98b5f;
    --accent-soft: #2b2622;
    --done: #6b675e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Both pages set viewport-fit=cover, so the layout extends into the display
   cutouts. Every edge that touches the viewport must pay the safe-area inset
   back, or content sits under the home indicator and — in landscape — under
   the Dynamic Island. Target devices are Pro Max phones, where those insets
   are largest. */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--pad);
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */

header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem var(--pad);
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}

header.site h1 {
  margin: 0 0 0.6rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

/* ── Search + filters ───────────────────────────────────────────────────── */

input[type="search"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-appearance: none;
}

input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* Expanded shows every tag in the catalogue — 97 of them at 63 recipes. Bound it
   and let it scroll, otherwise "+87 more" pushes the recipes off the screen and
   the filter has to be undone before anything can be browsed. 40vh leaves more
   than half the phone showing recipes at all times. */
.tags.expanded {
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tag {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

.tag[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

/* ── Recipe cards ───────────────────────────────────────────────────────── */

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

.card {
  display: block;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.card:active { background: var(--accent-soft); }

.card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  line-height: 1.3;
}

.card .meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.card .card-tags {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.empty {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
}

/* ── Cook view ──────────────────────────────────────────────────────────── */

.back {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  text-decoration: none;
}

.recipe-title {
  margin: 0 0 0.3rem;
  font-size: 1.9rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.recipe-meta {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

h2.section {
  margin: 1.8rem 0 0.6rem;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

h3.subsection {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* Checkable lists — tap anywhere on the row */

ul.checkable, ol.checkable {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

ul.checkable li, ol.checkable li {
  padding: 0.7rem 0.5rem 0.7rem 2.4rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

ul.checkable li::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.95rem;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 5px;
}

ol.checkable li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0.35rem;
  top: 0.7rem;
  width: 1.6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.checkable li[data-done="true"] {
  color: var(--done);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.checkable li[data-done="true"]::before {
  background: var(--done);
  border-color: var(--done);
  color: var(--bg);
}

ol.checkable li { font-size: 1.08rem; line-height: 1.55; }

.qty { font-variant-numeric: tabular-nums; font-weight: 600; }
.note { color: var(--muted); }
.pantry-flag {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  margin-left: 0.35rem;
  white-space: nowrap;
}

ul.notes { padding-left: 1.1rem; color: var(--muted); }
ul.notes li { margin-bottom: 0.5rem; }

/* ── Footer / controls ──────────────────────────────────────────────────── */

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

button.ghost {
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

button.ghost[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.source {
  margin: 2rem 0 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Selection & plan ───────────────────────────────────────────────────── */

.cards li { position: relative; }

/* 44px minimum — Apple's touch target floor. The card is the read action; this
   is the select action, and on a phone they must not be confusable. */
.pick {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.pick::before {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
}

.pick[aria-pressed="true"]::before {
  border-color: var(--accent);
  background: var(--accent);
  /* Checkmark drawn with a background image so there is no icon dependency. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13l5 5L20 6'/%3E%3C/svg%3E");
  background-size: 14px 14px;
  background-position: center;
  background-repeat: no-repeat;
}

.cards li.picked .card {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Leave room for the checkmark so long titles don't run under it. */
.cards li .card h2 { padding-right: 2.5rem; }

/* display:flex would otherwise beat the `hidden` attribute's display:none. */
.selbar[hidden] { display: none; }

.selbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem var(--pad);
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.selbar-count { flex: 1; font-size: 0.95rem; color: var(--muted); }

.selbar-clear {
  min-height: 44px;
  padding: 0 0.5rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.selbar-go {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

/* The fixed bar would otherwise cover the last row of cards. */
.cards { padding-bottom: 4.5rem; }

.plan-meals { list-style: none; margin: 0 0 1.5rem; padding: 0; }

.plan-meals li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.plan-meals li a { flex: 1; font-weight: 600; text-decoration: none; }

.plan-drop {
  min-height: 44px;
  padding: 0 0.6rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.shopping { list-style: none; margin: 0 0 1.5rem; padding: 0; }

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

h2.sub { font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ── Ask (chat) ─────────────────────────────────────────────────────────── */

.chat-hint { color: var(--muted); font-size: 0.95rem; margin-top: 0; }

.thread { display: flex; flex-direction: column; gap: 0.6rem; padding-bottom: 5rem; }

.bubble {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
}

.bubble.you {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.bubble.claude {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}

.bubble.pending { color: var(--muted); font-style: italic; }

.bubble.error {
  align-self: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--text);
}

.bubble.added {
  align-self: stretch;
  max-width: none;
  text-align: center;
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Bottom-anchored so the input is thumb-reachable on a Pro Max. */
.askbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem var(--pad);
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.askbar input {
  flex: 1;
  min-height: 44px;
  padding: 0 0.9rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  -webkit-appearance: none;
}

.askbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.askbar button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.askbar button:disabled { opacity: 0.5; cursor: default; }

.ask-link {
  float: right;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.shuffle {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 0.6rem;
  padding: 0 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
}

.shuffle:active { opacity: 0.7; }

.ask-link + .ask-link { margin-right: 0.9rem; }

/* A device waiting for approval. This is the second factor asking to be let in,
   so it gets the one loud treatment in the header — if it reads as just another
   nav link it will be walked past, and the person waiting stays locked out. */
.ask-link.urgent {
  background: var(--accent);
  /* Not white: --accent is a light orange in dark mode, where white text on it
     lands around 2:1 and is genuinely hard to read. Taking the page background
     as the foreground keeps the badge legible in both themes, because --bg and
     --accent always sit at opposite ends of the same palette. */
  color: var(--bg);
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
}

.importform { display: flex; gap: 0.5rem; margin: 1rem 0; }

.importform input {
  flex: 1;
  min-height: 44px;
  padding: 0 0.9rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-appearance: none;
}

.importform input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.importform button {
  min-height: 44px;
  padding: 0 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.importform button:disabled { opacity: 0.5; cursor: default; }

.preview-steps { padding-left: 1.4rem; }
.preview-steps li { margin-bottom: 0.6rem; line-height: 1.55; }

/* ── Favourites, cook history, timers ───────────────────────────────────── */

.fav {
  margin-left: 0.5rem;
  padding: 0 0.3rem;
  border: 0;
  background: none;
  color: var(--border);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.fav[aria-pressed="true"] { color: var(--accent); }

.card-fav { color: var(--accent); font-size: 0.9rem; margin-right: 0.3rem; }

.tag.fav-filter[aria-pressed="true"] { color: var(--accent); }

.cooked-note { margin-top: -0.1rem; font-size: 0.9rem; }

/* Timers live inside a checkable step row, so they need their own hit area —
   tapping the timer must not also tick the step off. */
.timer {
  display: inline-block;
  margin-left: 0.5rem;
  min-height: 32px;
  padding: 0 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  vertical-align: middle;
}

.timer[data-state="running"] { background: var(--accent); color: #fff; }

.timer[data-state="done"] {
  background: var(--accent);
  color: #fff;
  animation: timer-flash 1s ease-in-out infinite;
}

@keyframes timer-flash { 50% { opacity: 0.45; } }

/* A struck-through step shouldn't strike through its timer. */
.checkable li[data-done="true"] .timer { text-decoration: none; }

.importform { flex-wrap: wrap; }
.importform textarea {
  flex: 1 1 100%;
  min-height: 12rem;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  -webkit-appearance: none;
}
.importform textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ── Rating, notes, current step, ingredients peek ──────────────────────── */

.rating-note[hidden] { display: none; }
.rating-note {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}
.rating-note[data-rating="yes"] { color: var(--accent); }
.rating-note[data-rating="no"] { text-decoration: line-through; }

.verdict {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.verdict-q { margin: 0 0 0.6rem; font-weight: 600; }
.verdict .controls { margin: 0 0 0.7rem; }
.verdict .importform { margin: 0; }

.note-text { flex: 1; }

/* The step you're on. A left bar rather than a fill, so it reads at a glance
   from arm's length without competing with the struck-through done steps. */
ol.checkable li[data-current="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.peek-toggle {
  position: fixed;
  right: max(var(--pad), env(safe-area-inset-right));
  bottom: max(var(--pad), env(safe-area-inset-bottom));
  z-index: 30;
  min-height: 48px;
  padding: 0 1.2rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.peek-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 29;
  max-height: 55vh;
  overflow-y: auto;
  padding: var(--pad);
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.peek-sheet[hidden] { display: none; }
.peek-sheet .shopping li { padding: 0.5rem 0; }

.day-pick {
  min-height: 44px;
  padding: 0 0.4rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
}

.plan-meals li[data-day=""] .day-pick { color: var(--muted); background: none; }

/* ── Review ─────────────────────────────────────────────────────────────── */

.review-title {
  width: 100%;
  margin: 0.5rem 0 0.3rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  -webkit-appearance: none;
}

.review-title:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* The evidence. Horizontal so a 5-screenshot cluster is scannable without
   scrolling the page past the extraction it is meant to be checked against. */
.shots {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin: 0.9rem 0;
  padding-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch;
}

.shots img {
  height: 320px;
  width: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.review-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.5rem;
  padding: 0.7rem 0;
  padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.review-actions .selbar-go { flex: 1; justify-content: center; border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.review-actions button:disabled { opacity: 0.5; cursor: default; }

.tag.tag-more { font-style: italic; }

.flag {
  margin: 0.3rem 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.88rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.flag-high { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.flag-medium { color: var(--muted); }
.flag-low, .flag-ok { color: var(--muted); border-style: dashed; }

.servings {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.2rem 0 1.2rem;
}

.servings-label { font-weight: 600; min-width: 5.5rem; }
.servings-note { font-size: 0.85rem; }

.servings-step {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

/* ── Copy the shopping list ─────────────────────────────────────────────── */

.copy-bar { margin: 0.6rem 0 1rem; }
.copy-button { width: auto; flex: 1; }
.copy-note { flex: 1 1 100%; margin: 0.2rem 0 0; font-size: 0.85rem; }

.copy-fallback textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  -webkit-appearance: none;
}

/* Import: chosen photos, shown before sending. The point is confirming the right
   screenshots were picked — on a phone the picker's own preview is long gone by
   the time you are back on this page. */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
}

#photos {
  display: block;
  width: 100%;
  padding: 0.75rem 0;
}
